-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend trailing
>
detection for paths.
This commit extends the trailing `>` detection to also work for paths such as `Foo::<Bar>>:Baz`. This involves making the existing check take the token that is expected to follow the path being checked as a parameter. Care is taken to ensure that this only happens on the construction of a whole path segment and not a partial path segment (during recursion). Through this enhancement, it was also observed that the ordering of right shift token and greater than tokens was overfitted to the examples being tested. In practice, given a sequence of `>` characters: `>>>>>>>>>` ..then they will be split into `>>` eagerly: `>> >> >> >> >`. ..but when a `<` is prepended, then the first `>>` is split: `<T> > >> >> >> >` ..and then when another `<` is prepended, a right shift is first again: `Vec<<T>> >> >> >> >` In the previous commits, a example that had two `<<` characters was always used and therefore it was incorrectly assumed that `>>` would always be first - but when there is a single `<`, this is not the case.
- Loading branch information
Showing
4 changed files
with
131 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// run-rustfix | ||
|
||
// This test checks that the following error is emitted and the suggestion works: | ||
// | ||
// ``` | ||
// let _ = Vec::<usize>>>::new(); | ||
// ^^ help: remove extra angle brackets | ||
// ``` | ||
|
||
fn main() { | ||
let _ = Vec::<usize>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
} |
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,22 @@ | ||
// run-rustfix | ||
|
||
// This test checks that the following error is emitted and the suggestion works: | ||
// | ||
// ``` | ||
// let _ = Vec::<usize>>>::new(); | ||
// ^^ help: remove extra angle brackets | ||
// ``` | ||
|
||
fn main() { | ||
let _ = Vec::<usize>>>>>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>>>>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>>>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
|
||
let _ = Vec::<usize>>::new(); | ||
//~^ ERROR unmatched angle bracket | ||
} |
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,26 @@ | ||
error: unmatched angle brackets | ||
--> $DIR/issue-54521-2.rs:11:25 | ||
| | ||
LL | let _ = Vec::<usize>>>>>::new(); | ||
| ^^^^ help: remove extra angle brackets | ||
|
||
error: unmatched angle brackets | ||
--> $DIR/issue-54521-2.rs:14:25 | ||
| | ||
LL | let _ = Vec::<usize>>>>::new(); | ||
| ^^^ help: remove extra angle brackets | ||
|
||
error: unmatched angle brackets | ||
--> $DIR/issue-54521-2.rs:17:25 | ||
| | ||
LL | let _ = Vec::<usize>>>::new(); | ||
| ^^ help: remove extra angle brackets | ||
|
||
error: unmatched angle bracket | ||
--> $DIR/issue-54521-2.rs:20:25 | ||
| | ||
LL | let _ = Vec::<usize>>::new(); | ||
| ^ help: remove extra angle bracket | ||
|
||
error: aborting due to 4 previous errors | ||
|