Skip to content

keyword_idents misses lifetime in several places #133839

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

Closed
ehuss opened this issue Dec 4, 2024 · 2 comments
Closed

keyword_idents misses lifetime in several places #133839

ehuss opened this issue Dec 4, 2024 · 2 comments
Assignees
Labels
A-edition-2024 Area: The 2024 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. L-keyword_idents Lint group: keyword_idents L-keyword_idents_2024 Lint: keyword_idents_2024 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Dec 4, 2024

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
@ehuss ehuss added A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. L-keyword_idents_2024 Lint: keyword_idents_2024 L-keyword_idents Lint group: keyword_idents labels Dec 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2024
@ehuss
Copy link
Contributor Author

ehuss commented Dec 4, 2024

Another example is an APIT:

pub fn inner<'gen>(func: impl FnOnce() + 'gen) {}

It gets the function generic parameter, but not the generic parameter in the APIT.

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 4, 2024
@ehuss ehuss self-assigned this Dec 6, 2024
@ehuss
Copy link
Contributor Author

ehuss commented Dec 8, 2024

Closing as fixed by #133992.

@ehuss ehuss closed this as completed Dec 8, 2024
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. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. L-keyword_idents Lint group: keyword_idents L-keyword_idents_2024 Lint: keyword_idents_2024 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.

3 participants