Skip to content

Fix keyword_idents_2024 missing lifetimes in various positions #133989

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 2 commits into from

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Dec 7, 2024

This fixes the keyword_idents_2024 lint which was missing 'gen in various positions (it was generally only catching macros and generic arguments). Lifetimes are only treated as an "ident" for the purpose of visit_ident in generic arguments. In other positions, it needs to go through visit_lifetime.

Fixes #133839

ehuss added 2 commits December 6, 2024 16:29
This is intended to fix keyword_idents_2024 which was not checking
for `'gen` in most positions.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 7, 2024
Comment on lines +25 to +31
fn test<'gen>(_: &'gen i32) {}
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| ERROR `gen` is a keyword in the 2024 edition
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: I know this gets eventually deduplicated, but the duplicate error messages are interesting

@compiler-errors
Copy link
Member

Hm, I don't believe this is the right solution.

@compiler-errors
Copy link
Member

This is because the EarlyLint visitor is actually walking into lifetimes always, though it's a bit strange that it is for generic param declarations.

@compiler-errors
Copy link
Member

Alternative: #133992

@jieyouxu
Copy link
Member

jieyouxu commented Dec 7, 2024

@ehuss I'm going to close this in favor of #133992 due to the more systemic nature of that approach (which it turns out exposed that we weren't properly visiting things, oops). Thanks for the PR!

@jieyouxu jieyouxu closed this Dec 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keyword_idents misses lifetime in several places
4 participants