Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyword_idents_2024 should not warn on raw lifetimes #130486

Closed
ehuss opened this issue Sep 17, 2024 · 0 comments · Fixed by #130489
Closed

keyword_idents_2024 should not warn on raw lifetimes #130486

ehuss opened this issue Sep 17, 2024 · 0 comments · Fixed by #130489
Assignees
Labels
A-edition-2024 Area: The 2024 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Sep 17, 2024

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
@ehuss ehuss added A-edition-2024 Area: The 2024 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. labels Sep 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 17, 2024
@compiler-errors compiler-errors self-assigned this Sep 17, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 18, 2024
@bors bors closed this as completed in 32c4d41 Sep 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 18, 2024
Rollup merge of rust-lang#130489 - compiler-errors:raw-lt-lint, r=jieyouxu

Ensure that `keyword_ident` lint doesn't trigger on `'r#kw` lifetime

Fixes rust-lang#130486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants