diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 0c265d7af0e..c23420661fa 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -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) diff --git a/tests/ui/parser/issues/issue-111148.rs b/tests/ui/parser/issues/issue-111148.rs new file mode 100644 index 00000000000..2502beab443 --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.rs @@ -0,0 +1,2 @@ +fn a<# +//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` diff --git a/tests/ui/parser/issues/issue-111148.stderr b/tests/ui/parser/issues/issue-111148.stderr new file mode 100644 index 00000000000..e6595a5cbcc --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` + --> $DIR/issue-111148.rs:1:6 + | +LL | fn a<# + | ^ expected one of `#`, `>`, `const`, identifier, or lifetime + +error: aborting due to previous error +