Skip to content

Commit

Permalink
fix(parse): return unpected when current token is EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanjoi committed May 12, 2023
1 parent 077fc26 commit 272dc5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ impl<'a> Parser<'a> {
} 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)
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/parser/issues/issue-111148.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fn a<<i<Y<w<>#
//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<`
8 changes: 8 additions & 0 deletions tests/ui/parser/issues/issue-111148.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 272dc5a

Please sign in to comment.