Skip to content

Commit e40d7e6

Browse files
authored
Rollup merge of #84140 - b-naber:parser_past_eof, r=varkor
Don't call bump in check_mistyped_turbofish_with_multiple_type_params Fixes #84117
2 parents cf67c9b + 4dfaa78 commit e40d7e6

File tree

3 files changed

+75
-15
lines changed

3 files changed

+75
-15
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -666,21 +666,23 @@ impl<'a> Parser<'a> {
666666
);
667667
match x {
668668
Ok((_, _, false)) => {
669-
self.bump(); // `>`
670-
match self.parse_expr() {
671-
Ok(_) => {
672-
e.span_suggestion_verbose(
673-
binop.span.shrink_to_lo(),
674-
TURBOFISH_SUGGESTION_STR,
675-
"::".to_string(),
676-
Applicability::MaybeIncorrect,
677-
);
678-
e.emit();
679-
*expr = self.mk_expr_err(expr.span.to(self.prev_token.span));
680-
return Ok(());
681-
}
682-
Err(mut err) => {
683-
err.cancel();
669+
if self.eat(&token::Gt) {
670+
match self.parse_expr() {
671+
Ok(_) => {
672+
e.span_suggestion_verbose(
673+
binop.span.shrink_to_lo(),
674+
TURBOFISH_SUGGESTION_STR,
675+
"::".to_string(),
676+
Applicability::MaybeIncorrect,
677+
);
678+
e.emit();
679+
*expr =
680+
self.mk_expr_err(expr.span.to(self.prev_token.span));
681+
return Ok(());
682+
}
683+
Err(mut err) => {
684+
err.cancel();
685+
}
684686
}
685687
}
686688
}

src/test/ui/parser/issue-84117.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
3+
//~^ ERROR expected one of `>`, a const expression
4+
//~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}`
5+
//~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
6+
//~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
7+
//~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
8+
}
9+
//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `}`

src/test/ui/parser/issue-84117.stderr

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: expected one of `>`, a const expression, lifetime, or type, found `}`
2+
--> $DIR/issue-84117.rs:2:67
3+
|
4+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
5+
| ------------ ^ expected one of `>`, a const expression, lifetime, or type
6+
| | |
7+
| | help: use `=` if you meant to assign
8+
| while parsing the type for `inner_local`
9+
10+
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
11+
--> $DIR/issue-84117.rs:2:65
12+
|
13+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
14+
| ^ expected one of 7 possible tokens
15+
16+
error: expected one of `,`, `:`, `=`, or `>`, found `}`
17+
--> $DIR/issue-84117.rs:8:1
18+
|
19+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
20+
| ------------ help: use `=` if you meant to assign - expected one of `,`, `:`, `=`, or `>`
21+
| |
22+
| while parsing the type for `outer_local`
23+
...
24+
LL | }
25+
| ^ unexpected token
26+
27+
error: expected one of `>`, a const expression, lifetime, or type, found `}`
28+
--> $DIR/issue-84117.rs:2:67
29+
|
30+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
31+
| ------------ ^ expected one of `>`, a const expression, lifetime, or type
32+
| | |
33+
| | help: use `=` if you meant to assign
34+
| while parsing the type for `inner_local`
35+
36+
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
37+
--> $DIR/issue-84117.rs:2:65
38+
|
39+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
40+
| ^ expected one of 7 possible tokens
41+
42+
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
43+
--> $DIR/issue-84117.rs:2:33
44+
|
45+
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
46+
| ^ expected one of 7 possible tokens
47+
48+
error: aborting due to 6 previous errors
49+

0 commit comments

Comments
 (0)