-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect Python-like slicing and suggest how to fix
Fix #108215
- Loading branch information
1 parent
b29a1e0
commit e65c060
Showing
4 changed files
with
47 additions
and
0 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,8 @@ | ||
// edition:2021 | ||
|
||
fn main() { | ||
&[1, 2, 3][1:2]; | ||
//~^ ERROR: expected one of | ||
//~| HELP: you might have meant to make a slice with range index | ||
//~| HELP: maybe write a path separator here | ||
} |
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,18 @@ | ||
error: expected one of `.`, `?`, `]`, or an operator, found `:` | ||
--> $DIR/range-index-instead-of-colon.rs:4:17 | ||
| | ||
LL | &[1, 2, 3][1:2]; | ||
| ^ expected one of `.`, `?`, `]`, or an operator | ||
| | ||
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> | ||
help: you might have meant to make a slice with range index | ||
| | ||
LL | &[1, 2, 3][1..2]; | ||
| ~~ | ||
help: maybe write a path separator here | ||
| | ||
LL | &[1, 2, 3][1::2]; | ||
| ~~ | ||
|
||
error: aborting due to previous error | ||
|