-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit suggestion when trying to write exclusive ranges as
..<
- Loading branch information
Showing
4 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
fn foo() { | ||
let _ = 0..<10; | ||
//~^ ERROR: expected type, found `10` | ||
//~| HELP: remove the `<` to write an exclusive range | ||
} | ||
|
||
fn bar() { | ||
let _ = 0..<foo; | ||
//~^ ERROR: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `;` | ||
//~| HELP: remove the `<` to write an exclusive range | ||
} | ||
|
||
fn baz() { | ||
let _ = <foo>; | ||
//~^ ERROR: expected `::`, found `;` | ||
} | ||
|
||
fn qux() { | ||
let _ = [1, 2, 3][..<1]; | ||
//~^ ERROR: expected type, found `1` | ||
//~| HELP: remove the `<` to write an exclusive range | ||
} | ||
|
||
fn quux() { | ||
let _ = [1, 2, 3][..<foo]; | ||
//~^ ERROR: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `]` | ||
//~| HELP: remove the `<` to write an exclusive range | ||
} | ||
|
||
fn foobar() { | ||
let _ = [1, 2, 3][..<foo>]; | ||
//~^ ERROR: expected `::`, found `]` | ||
} | ||
|
||
fn ok1() { | ||
let _ = [1, 2, 3][..<usize>::default()]; | ||
} | ||
|
||
fn ok2() { | ||
let _ = 0..<i32>::default(); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
error: expected type, found `10` | ||
--> $DIR/range-exclusive-dotdotlt.rs:2:17 | ||
| | ||
LL | let _ = 0..<10; | ||
| -^^ expected type | ||
| | | ||
| help: remove the `<` to write an exclusive range | ||
|
||
error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `;` | ||
--> $DIR/range-exclusive-dotdotlt.rs:8:20 | ||
| | ||
LL | let _ = 0..<foo; | ||
| - ^ expected one of 7 possible tokens | ||
| | | ||
| help: remove the `<` to write an exclusive range | ||
|
||
error: expected `::`, found `;` | ||
--> $DIR/range-exclusive-dotdotlt.rs:14:18 | ||
| | ||
LL | let _ = <foo>; | ||
| ^ expected `::` | ||
|
||
error: expected type, found `1` | ||
--> $DIR/range-exclusive-dotdotlt.rs:19:26 | ||
| | ||
LL | let _ = [1, 2, 3][..<1]; | ||
| -^ expected type | ||
| | | ||
| help: remove the `<` to write an exclusive range | ||
|
||
error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `]` | ||
--> $DIR/range-exclusive-dotdotlt.rs:25:29 | ||
| | ||
LL | let _ = [1, 2, 3][..<foo]; | ||
| - ^ expected one of 7 possible tokens | ||
| | | ||
| help: remove the `<` to write an exclusive range | ||
|
||
error: expected `::`, found `]` | ||
--> $DIR/range-exclusive-dotdotlt.rs:31:30 | ||
| | ||
LL | let _ = [1, 2, 3][..<foo>]; | ||
| ^ expected `::` | ||
|
||
error: aborting due to 6 previous errors | ||
|