about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-05-04 16:30:02 +0800
committerbohan <bohan-zhang@foxmail.com>2023-05-13 00:33:27 +0800
commit272dc5a6d5967c0816564894b4fd86835a860d97 (patch)
tree7bd36ac85162f9b1bdf496e912ce382afbde9dee /compiler/rustc_parse/src/parser
parent077fc26f0acfa54e9c580534616c17ffc279a9d4 (diff)
downloadrust-272dc5a6d5967c0816564894b4fd86835a860d97.tar.gz
rust-272dc5a6d5967c0816564894b4fd86835a860d97.zip
fix(parse): return unpected when current token is EOF
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs4
1 files changed, 3 insertions, 1 deletions
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)