Skip to content

Commit 272dc5a

Browse files
committed
fix(parse): return unpected when current token is EOF
1 parent 077fc26 commit 272dc5a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/rustc_parse/src/parser/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ impl<'a> Parser<'a> {
536536
} else if inedible.contains(&self.token.kind) {
537537
// leave it in the input
538538
Ok(false)
539-
} else if self.last_unexpected_token_span == Some(self.token.span) {
539+
} else if self.token.kind != token::Eof
540+
&& self.last_unexpected_token_span == Some(self.token.span)
541+
{
540542
FatalError.raise();
541543
} else {
542544
self.expected_one_of_not_found(edible, inedible)
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fn a<<i<Y<w<>#
2+
//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `<`
2+
--> $DIR/issue-111148.rs:1:6
3+
|
4+
LL | fn a<<i<Y<w<>#
5+
| ^ expected one of `#`, `>`, `const`, identifier, or lifetime
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)