fix(parse): return unpected when current token is EOF

This commit is contained in:
bohan 2023-05-04 16:30:02 +08:00
parent 077fc26f0a
commit 272dc5a6d5
3 changed files with 13 additions and 1 deletions

View file

@ -536,7 +536,9 @@ pub fn expect_one_of(
} else if inedible.contains(&self.token.kind) {
// leave it in the input
Ok(false)
} else if self.last_unexpected_token_span == Some(self.token.span) {
} else if self.token.kind != token::Eof
&& self.last_unexpected_token_span == Some(self.token.span)
{
FatalError.raise();
} else {
self.expected_one_of_not_found(edible, inedible)

View file

@ -0,0 +1,2 @@
fn a<<i<Y<w<>#
//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<`

View file

@ -0,0 +1,8 @@
error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `<`
--> $DIR/issue-111148.rs:1:6
|
LL | fn a<<i<Y<w<>#
| ^ expected one of `#`, `>`, `const`, identifier, or lifetime
error: aborting due to previous error