rustc_lint: Allow scoped non_ascii_idents lint levels#157497
Open
joshlf wants to merge 1 commit into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
`non_ascii_idents` was marked `crate_level_only`, and its diagnostic was emitted from the crate-wide symbol gallery. Move the lint into the scoped early lint visitor, checking both AST idents and macro token streams. Keep the one-diagnostic-per-ident behavior by deduplicating by ident and effective lint level/expectation, and leave the other Unicode security lints crate-level-only.
This was referenced Jun 5, 2026
estebank
reviewed
Jun 5, 2026
| fn check_ident_token(&mut self, cx: &EarlyContext<'_>, ident: Ident) { | ||
| let symbol = ident.name; | ||
| let symbol_str = symbol.as_str(); | ||
| if symbol_str.is_ascii() || symbol_str.starts_with('\'') { |
Contributor
There was a problem hiding this comment.
Is there a reason we're ignoring lifetime names here? I would have assumed that lifetimes should also be handled by this lint (although a quick check of the current logic it does seem like we don't?)
Contributor
Author
There was a problem hiding this comment.
I'd be happy to include lifetime names here too if you think that's appropriate.
Contributor
There was a problem hiding this comment.
Doing so might cause us to have to delay landing this PR (as we'll have to run crater to make sure we don't suddenly regress a lot of crates). Would you mind doing that as a follow up though?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
non_ascii_identswas markedcrate_level_only, and its diagnostic was emitted from the crate-wide symbol gallery.Move the lint into the scoped early lint visitor, checking both AST idents and macro token streams. Keep the one-diagnostic-per-ident behavior by deduplicating by ident and effective lint level/expectation, and leave the other Unicode security lints crate-level-only.
Fixes #151025
r? @jswrenn