Skip to content

Commit dbdef68

Browse files
Make sure we consume a generic arg when checking mistyped turbofish
1 parent 6f7e00a commit dbdef68

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Diff for: compiler/rustc_parse/src/parser/diagnostics.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,11 @@ impl<'a> Parser<'a> {
12241224
let x = self.parse_seq_to_before_end(
12251225
&token::Gt,
12261226
SeqSep::trailing_allowed(token::Comma),
1227-
|p| p.parse_generic_arg(None),
1227+
|p| match p.parse_generic_arg(None)? {
1228+
Some(arg) => Ok(arg),
1229+
// If we didn't eat a generic arg, then we should error.
1230+
None => p.unexpected_any(),
1231+
},
12281232
);
12291233
match x {
12301234
Ok((_, _, Recovered::No)) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn foo() {
2+
let x = Tr<A, A:>;
3+
//~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
4+
}
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
2+
--> $DIR/turbofish-arg-with-stray-colon.rs:2:17
3+
|
4+
LL | let x = Tr<A, A:>;
5+
| ^ expected one of 8 possible tokens
6+
|
7+
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
8+
help: maybe write a path separator here
9+
|
10+
LL | let x = Tr<A, A::>;
11+
| ~~
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)