Skip to content

Commit 2ef1552

Browse files
Don't fatal when calling expect_one_of when recovering arg in parse_seq
1 parent c5de414 commit 2ef1552

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

compiler/rustc_parse/src/parser/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ impl<'a> Parser<'a> {
898898
}
899899

900900
// Attempt to keep parsing if it was an omitted separator.
901+
self.last_unexpected_token_span = None;
901902
match f(self) {
902903
Ok(t) => {
903904
// Parsed successfully, therefore most probably the code only
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// We used to fatal error without any useful diagnostic when we had an unexpected
2+
// token due to a strange interaction between the sequence parsing code and the
3+
// param/lifetime parsing code.
4+
5+
fn hello() -> impl use<'a {}> Sized {}
6+
//~^ ERROR expected one of `,` or `>`, found `{`
7+
//~| ERROR expected item, found `>`
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: expected one of `,` or `>`, found `{`
2+
--> $DIR/unexpected-token.rs:5:27
3+
|
4+
LL | fn hello() -> impl use<'a {}> Sized {}
5+
| ^ expected one of `,` or `>`
6+
7+
error: expected item, found `>`
8+
--> $DIR/unexpected-token.rs:5:29
9+
|
10+
LL | fn hello() -> impl use<'a {}> Sized {}
11+
| ^ expected item
12+
|
13+
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
14+
15+
error: aborting due to 2 previous errors
16+

0 commit comments

Comments
 (0)