Don't fatal when calling expect_one_of when recovering arg in parse_seq

This commit is contained in:
Michael Goulet 2024-04-19 13:12:12 -04:00
parent c5de414865
commit 2ef15523c1
3 changed files with 26 additions and 0 deletions

View File

@ -898,6 +898,7 @@ fn parse_seq_to_before_tokens<T>(
}
// Attempt to keep parsing if it was an omitted separator.
self.last_unexpected_token_span = None;
match f(self) {
Ok(t) => {
// Parsed successfully, therefore most probably the code only

View File

@ -0,0 +1,9 @@
// We used to fatal error without any useful diagnostic when we had an unexpected
// token due to a strange interaction between the sequence parsing code and the
// param/lifetime parsing code.
fn hello() -> impl use<'a {}> Sized {}
//~^ ERROR expected one of `,` or `>`, found `{`
//~| ERROR expected item, found `>`
fn main() {}

View File

@ -0,0 +1,16 @@
error: expected one of `,` or `>`, found `{`
--> $DIR/unexpected-token.rs:5:27
|
LL | fn hello() -> impl use<'a {}> Sized {}
| ^ expected one of `,` or `>`
error: expected item, found `>`
--> $DIR/unexpected-token.rs:5:29
|
LL | fn hello() -> impl use<'a {}> Sized {}
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
error: aborting due to 2 previous errors