-
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.
Rollup merge of #86010 - FabianWolff:ICE-parser, r=varkor
Fix two ICEs in the parser This pull request fixes #84104 and fixes #84148. The latter is caused by an invalid `assert_ne!()` in the parser, which I have simply removed because the error is then caught in another part of the parser. #84104 is somewhat more subtle and has to do with a suggestion to remove extraneous `<` characters; for instance: ```rust fn main() { foo::<Ty<<<i32>(); } ``` currently leads to ``` error: unmatched angle brackets --> unmatched-langle.rs:2:10 | 2 | foo::<Ty<<<i32>(); | ^^^ help: remove extra angle brackets ``` which is obviously wrong and stems from the fact that the code for issuing the above suggestion does not consider the possibility that there might be other tokens in between the opening angle brackets. In #84104, this has led to a span being generated that ends in the middle of a multi-byte character (because the code issuing the suggestion thought that it was only skipping over `<`, which are single-byte), causing an ICE.
- Loading branch information
Showing
12 changed files
with
182 additions
and
38 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,3 @@ | ||
// error-pattern: this file contains an unclosed delimiter | ||
// error-pattern: expected one of | ||
#[i=i::<ښܖ< |
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,16 @@ | ||
error: this file contains an unclosed delimiter | ||
--> $DIR/issue-84104.rs:3:13 | ||
| | ||
LL | #[i=i::<ښܖ< | ||
| - ^ | ||
| | | ||
| unclosed delimiter | ||
|
||
error: expected one of `>`, a const expression, lifetime, or type, found `]` | ||
--> $DIR/issue-84104.rs:3:13 | ||
| | ||
LL | #[i=i::<ښܖ< | ||
| ^ expected one of `>`, a const expression, lifetime, or type | ||
|
||
error: aborting due to 2 previous errors | ||
|
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,4 @@ | ||
fn f(t:for<>t?) | ||
//~^ ERROR: expected parameter name | ||
//~| ERROR: expected one of | ||
//~| ERROR: expected one of |
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,23 @@ | ||
error: expected parameter name, found `?` | ||
--> $DIR/issue-84148-1.rs:1:14 | ||
| | ||
LL | fn f(t:for<>t?) | ||
| ^ expected parameter name | ||
|
||
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?` | ||
--> $DIR/issue-84148-1.rs:1:14 | ||
| | ||
LL | fn f(t:for<>t?) | ||
| ^ | ||
| | | ||
| expected one of `(`, `)`, `+`, `,`, `::`, or `<` | ||
| help: missing `,` | ||
|
||
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>` | ||
--> $DIR/issue-84148-1.rs:1:15 | ||
| | ||
LL | fn f(t:for<>t?) | ||
| ^ expected one of `->`, `;`, `where`, or `{` | ||
|
||
error: aborting due to 3 previous errors | ||
|
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,4 @@ | ||
// error-pattern: this file contains an unclosed delimiter | ||
// error-pattern: expected parameter name | ||
// error-pattern: expected one of | ||
fn f(t:for<>t? |
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,31 @@ | ||
error: this file contains an unclosed delimiter | ||
--> $DIR/issue-84148-2.rs:4:16 | ||
| | ||
LL | fn f(t:for<>t? | ||
| - ^ | ||
| | | ||
| unclosed delimiter | ||
|
||
error: expected parameter name, found `?` | ||
--> $DIR/issue-84148-2.rs:4:14 | ||
| | ||
LL | fn f(t:for<>t? | ||
| ^ expected parameter name | ||
|
||
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?` | ||
--> $DIR/issue-84148-2.rs:4:14 | ||
| | ||
LL | fn f(t:for<>t? | ||
| ^ | ||
| | | ||
| expected one of `(`, `)`, `+`, `,`, `::`, or `<` | ||
| help: missing `,` | ||
|
||
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>` | ||
--> $DIR/issue-84148-2.rs:4:16 | ||
| | ||
LL | fn f(t:for<>t? | ||
| ^ expected one of `->`, `;`, `where`, or `{` | ||
|
||
error: aborting due to 4 previous errors | ||
|
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,9 @@ | ||
// Check that a suggestion is issued if there are too many `<`s in a | ||
// generic argument list, and that the parser recovers properly. | ||
|
||
fn main() { | ||
foo::<<<<Ty<i32>>(); | ||
//~^ ERROR: unmatched angle brackets | ||
//~| ERROR: cannot find function `foo` in this scope [E0425] | ||
//~| ERROR: cannot find type `Ty` in this scope [E0412] | ||
} |
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 @@ | ||
error: unmatched angle brackets | ||
--> $DIR/unmatched-langle-1.rs:5:10 | ||
| | ||
LL | foo::<<<<Ty<i32>>(); | ||
| ^^^ help: remove extra angle brackets | ||
|
||
error[E0425]: cannot find function `foo` in this scope | ||
--> $DIR/unmatched-langle-1.rs:5:5 | ||
| | ||
LL | foo::<<<<Ty<i32>>(); | ||
| ^^^ not found in this scope | ||
|
||
error[E0412]: cannot find type `Ty` in this scope | ||
--> $DIR/unmatched-langle-1.rs:5:14 | ||
| | ||
LL | foo::<<<<Ty<i32>>(); | ||
| ^^ not found in this scope | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0425. | ||
For more information about an error, try `rustc --explain E0412`. |
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,15 @@ | ||
// When there are too many opening `<`s, the compiler would previously | ||
// suggest nonsense if the `<`s were interspersed with other tokens: | ||
// | ||
// error: unmatched angle brackets | ||
// --> unmatched-langle.rs:2:10 | ||
// | | ||
// 2 | foo::<Ty<<<i32>(); | ||
// | ^^^ help: remove extra angle brackets | ||
// | ||
// This test makes sure that this is no longer happening. | ||
|
||
fn main() { | ||
foo::<Ty<<<i32>(); | ||
//~^ ERROR: expected `::`, found `(` | ||
} |
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 @@ | ||
error: expected `::`, found `(` | ||
--> $DIR/unmatched-langle-2.rs:13:20 | ||
| | ||
LL | foo::<Ty<<<i32>(); | ||
| ^ expected `::` | ||
|
||
error: aborting due to previous error | ||
|