From 5de89bb011fdaaf9d300cf63f97a3cf4c86d367a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 17 Sep 2024 16:43:18 -0400 Subject: [PATCH] Store raw ident span for raw lifetime --- compiler/rustc_parse/src/lexer/mod.rs | 3 +++ tests/ui/rust-2024/raw-gen-lt.rs | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/ui/rust-2024/raw-gen-lt.rs diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index b7232ff21ca..898c4779b08 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -299,6 +299,9 @@ impl<'psess, 'src> StringReader<'psess, 'src> { lifetime_name += lifetime_name_without_tick; let sym = Symbol::intern(&lifetime_name); + // Make sure we mark this as a raw identifier. + self.psess.raw_identifier_spans.push(self.mk_sp(start, self.pos)); + token::Lifetime(sym, IdentIsRaw::Yes) } else { // Otherwise, this should be parsed like `'r`. Warn about it though. diff --git a/tests/ui/rust-2024/raw-gen-lt.rs b/tests/ui/rust-2024/raw-gen-lt.rs new file mode 100644 index 00000000000..b2df217d1a1 --- /dev/null +++ b/tests/ui/rust-2024/raw-gen-lt.rs @@ -0,0 +1,8 @@ +//@ edition: 2021 +//@ check-pass + +#![deny(keyword_idents_2024)] + +fn foo<'r#gen>() {} + +fn main() {}