diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-10 13:40:56 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-11-16 09:41:28 +1100 |
| commit | 358a603f110b0489d22f3929d3f232e684fd9ffb (patch) | |
| tree | e409967cbf3698809be84c84dbf25285dc154bdb /compiler/rustc_parse/src/parser/stmt.rs | |
| parent | 01760265cbdc985af50e7046e7635d124b24e335 (diff) | |
| download | rust-358a603f110b0489d22f3929d3f232e684fd9ffb.tar.gz rust-358a603f110b0489d22f3929d3f232e684fd9ffb.zip | |
Use `token::Lit` in `ast::ExprKind::Lit`.
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
Diffstat (limited to 'compiler/rustc_parse/src/parser/stmt.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 18b661034e0..7820bbc1789 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -359,7 +359,7 @@ impl<'a> Parser<'a> { /// report error for `let 1x = 123` pub fn report_invalid_identifier_error(&mut self) -> PResult<'a, ()> { if let token::Literal(lit) = self.token.uninterpolate().kind && - let Err(_) = rustc_ast::Lit::from_token(&self.token) && + rustc_ast::Lit::from_token(&self.token).is_none() && (lit.kind == token::LitKind::Integer || lit.kind == token::LitKind::Float) && self.look_ahead(1, |t| matches!(t.kind, token::Eq) || matches!(t.kind, token::Colon ) ) { return Err(self.sess.create_err(InvalidIdentiferStartsWithNumber { span: self.token.span })); |
