Skip to content

keyword_idents misses lifetime in several places #133839

Closed
@ehuss

Description

@ehuss

The keyword_idents lint seems to miss the lifetime in a few places. Example:

#![warn(keyword_idents)]

pub struct S<'gen>(pub &'gen i32);

pub trait Visit {
    fn visit_path(&mut self) {}
}

impl<'gen> Visit for S<'gen> {}

The suggestions applied results in:

@@ -1,9 +1,9 @@
 #![warn(keyword_idents)]
 
-pub struct S<'gen>(pub &'gen i32);
+pub struct S<'r#gen>(pub &'gen i32);
 
 pub trait Visit {
     fn visit_path(&mut self) {}
 }
 
-impl<'gen> Visit for S<'gen> {}
+impl<'r#gen> Visit for S<'gen> {}

Notice that it missed the 'r#gen update in the tuple struct definition, and the for S<'gen> position. I have not audited to see what other scenarios it is missing.

Meta

rustc 1.85.0-nightly (c44b3d50f 2024-12-03)
binary: rustc
commit-hash: c44b3d50fea96a3e0417e8264c16ea21a0a3fca2
commit-date: 2024-12-03
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Metadata

Metadata

Assignees

Labels

A-edition-2024Area: The 2024 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-editionDiagnostics: An error or lint that should account for edition differences.L-keyword_identsLint group: keyword_identsL-keyword_idents_2024Lint: keyword_idents_2024T-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

No branches or pull requests

Issue actions