Skip to content

rustc_lint: Allow scoped non_ascii_idents lint levels#157497

Open
joshlf wants to merge 1 commit into
rust-lang:mainfrom
joshlf:non-ascii-idents
Open

rustc_lint: Allow scoped non_ascii_idents lint levels#157497
joshlf wants to merge 1 commit into
rust-lang:mainfrom
joshlf:non-ascii-idents

Conversation

@joshlf
Copy link
Copy Markdown
Contributor

@joshlf joshlf commented Jun 5, 2026

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.

Fixes #151025

r? @jswrenn

@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 Jun 5, 2026
@rustbot

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.
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('\'') {
Copy link
Copy Markdown
Contributor

@estebank estebank Jun 5, 2026

Choose a reason for hiding this comment

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

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?)

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd be happy to include lifetime names here too if you think that's appropriate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

Allow derives to allow(non_ascii_idents) at the non-crate level

4 participants