From 9dbf20ef27b56c0bff35366689861ebbe5dfb7e5 Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Fri, 7 Apr 2023 08:54:13 +1200 Subject: [PATCH] fix: fix regression in #109203 --- .../rustc_parse/src/parser/diagnostics.rs | 4 ++-- tests/ui/parser/issues/issue-110014.rs | 3 +++ tests/ui/parser/issues/issue-110014.stderr | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/ui/parser/issues/issue-110014.rs create mode 100644 tests/ui/parser/issues/issue-110014.stderr diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 5210b8fe69d6e..e03ce5d712056 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -423,11 +423,11 @@ impl<'a> Parser<'a> { if let token::Literal(Lit { kind: token::LitKind::Integer | token::LitKind::Float, symbol, - suffix, + suffix: Some(suffix), // no suffix makes it a valid literal }) = self.token.kind && rustc_ast::MetaItemLit::from_token(&self.token).is_none() { - Some((symbol.as_str().len(), suffix.unwrap())) + Some((symbol.as_str().len(), suffix)) } else { None } diff --git a/tests/ui/parser/issues/issue-110014.rs b/tests/ui/parser/issues/issue-110014.rs new file mode 100644 index 0000000000000..69d8f402bb620 --- /dev/null +++ b/tests/ui/parser/issues/issue-110014.rs @@ -0,0 +1,3 @@ +fn`2222222222222222222222222222222222222222() {} +//~^ ERROR unknown start of token: ` +//~^^ ERROR expected identifier, found `2222222222222222222222222222222222222222` diff --git a/tests/ui/parser/issues/issue-110014.stderr b/tests/ui/parser/issues/issue-110014.stderr new file mode 100644 index 0000000000000..7f1dd592e1238 --- /dev/null +++ b/tests/ui/parser/issues/issue-110014.stderr @@ -0,0 +1,19 @@ +error: unknown start of token: ` + --> $DIR/issue-110014.rs:1:3 + | +LL | fn`2222222222222222222222222222222222222222() {} + | ^ + | +help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not + | +LL | fn'2222222222222222222222222222222222222222() {} + | ~ + +error: expected identifier, found `2222222222222222222222222222222222222222` + --> $DIR/issue-110014.rs:1:4 + | +LL | fn`2222222222222222222222222222222222222222() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + +error: aborting due to 2 previous errors +