Skip to content

keyword_idents_2024 should not warn on raw lifetimes #130486

Closed
@ehuss

Description

@ehuss
Contributor

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.

cc @compiler-errors

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

Activity

added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
C-bugCategory: This is a bug.
on Sep 17, 2024
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 17, 2024
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Sep 18, 2024
added a commit that references this issue on Sep 18, 2024

Rollup merge of rust-lang#130489 - compiler-errors:raw-lt-lint, r=jie…

32c4d41
added a commit that references this issue on Sep 18, 2024
520e93e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-edition-2024Area: The 2024 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @ehuss@compiler-errors@jieyouxu@rustbot

    Issue actions

      keyword_idents_2024 should not warn on raw lifetimes · Issue #130486 · rust-lang/rust