Closed
Description
I tried this code:
// On edition 2021
#![warn(keyword_idents_2024)]
pub fn lifetime<'r#gen>() {}
I expected to see this happen: No warning
Instead, this happened: Received a warning:
warning: `gen` is a keyword in the 2024 edition
--> src/lib.rs:3:17
|
3 | pub fn lifetime<'r#gen>() {}
| ^^^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
|
= warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
The lint should not warn on raw lifetimes/labels because of the way the edition migration works. cargo fix --edition
will modify the source to have a raw lifetime, and then run the compiler again which will emit another warning which will likely be confusing.
Compare this to keyword_idents_2018:
// On edition 2015
#![warn(keyword_idents_2018)]
pub fn r#async() {}
which does not generate a warning.
Meta
rustc 1.83.0-nightly (c52c23b6f 2024-09-16)
binary: rustc
commit-hash: c52c23b6f44cd19718721a5e3b2eeb169e9c96ff
commit-date: 2024-09-16
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0