-
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.
Fix turbofish recovery with multiple generic args
check_mistyped_turbofish_with_multiple_type_params was previously expecting type arguments between angle brackets, which is not right, as we can also see const expressions. We now use generic argument parser instead of type parser. Test with one, two, and three generic arguments added to check consistentcy between 1. check_no_chained_comparison: Called after parsing a nested binop application like `x < A > ...` where angle brackets are interpreted as binary operators and `A` is an expression. 2. check_mistyped_turbofish_with_multiple_type_params: called by `parse_full_stmt` when we expect to see a semicolon after parsing an expression but don't see it. (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 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,21 @@ | ||
struct T1<const X1: usize>; | ||
struct T2<const X1: usize, const X2: usize>; | ||
struct T3<const X1: usize, const X2: usize, const X3: usize>; | ||
|
||
impl T1<1> { | ||
const C: () = (); | ||
} | ||
|
||
impl T2<1, 2> { | ||
const C: () = (); | ||
} | ||
|
||
impl T3<1, 2, 3> { | ||
const C: () = (); | ||
} | ||
|
||
fn main() { | ||
T1<1>::C; //~ ERROR: comparison operators cannot be chained | ||
T2<1, 2>::C; //~ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` | ||
T3<1, 2, 3>::C; //~ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, 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,35 @@ | ||
error: comparison operators cannot be chained | ||
--> $DIR/issue-82566.rs:18:7 | ||
| | ||
LL | T1<1>::C; | ||
| ^ ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify type or const arguments | ||
| | ||
LL | T1::<1>::C; | ||
| ^^ | ||
|
||
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` | ||
--> $DIR/issue-82566.rs:19:9 | ||
| | ||
LL | T2<1, 2>::C; | ||
| ^ expected one of `.`, `;`, `?`, `}`, or an operator | ||
| | ||
help: use `::<...>` instead of `<...>` to specify type or const arguments | ||
| | ||
LL | T2::<1, 2>::C; | ||
| ^^ | ||
|
||
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` | ||
--> $DIR/issue-82566.rs:20:9 | ||
| | ||
LL | T3<1, 2, 3>::C; | ||
| ^ expected one of `.`, `;`, `?`, `}`, or an operator | ||
| | ||
help: use `::<...>` instead of `<...>` to specify type or const arguments | ||
| | ||
LL | T3::<1, 2, 3>::C; | ||
| ^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|