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 @@ fn next_token(&mut self) -> (Token, bool) { 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() {}