-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
rustc_lint: Allow scoped non_ascii_idents lint levels
#157497
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
Open
joshlf
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
joshlf:non-ascii-idents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
31 changes: 31 additions & 0 deletions
31
tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents-nested.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Nested lint levels should control `non_ascii_idents` at the annotated scope. | ||
|
|
||
| #![allow(dead_code, unused_macros)] | ||
| #![deny(non_ascii_idents, unused_attributes)] | ||
|
|
||
| #[allow(non_ascii_idents)] | ||
| fn föö() {} | ||
|
|
||
| mod allowed { | ||
| #![allow(non_ascii_idents)] | ||
|
|
||
| fn bår() {} | ||
|
|
||
| macro_rules! allowed_macro_tokens { | ||
| () => { | ||
| let quúx = 0; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| fn bår() {} | ||
| //~^ ERROR identifier contains non-ASCII characters | ||
|
|
||
| macro_rules! denied_macro_tokens { | ||
| () => { | ||
| let bazé = 0; | ||
| //~^ ERROR identifier contains non-ASCII characters | ||
| }; | ||
| } | ||
|
|
||
| fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents-nested.stderr
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| error: identifier contains non-ASCII characters | ||
| --> $DIR/lint-non-ascii-idents-nested.rs:21:4 | ||
| | | ||
| LL | fn bår() {} | ||
| | ^^^ | ||
| | | ||
| note: the lint level is defined here | ||
| --> $DIR/lint-non-ascii-idents-nested.rs:4:9 | ||
| | | ||
| LL | #![deny(non_ascii_idents, unused_attributes)] | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: identifier contains non-ASCII characters | ||
| --> $DIR/lint-non-ascii-idents-nested.rs:26:13 | ||
| | | ||
| LL | let bazé = 0; | ||
| | ^^^^ | ||
|
|
||
| error: aborting due to 2 previous errors | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| extern crate proc_macro; | ||
|
|
||
| use proc_macro::TokenStream; | ||
|
|
||
| #[proc_macro_derive(NonAsciiIdent)] | ||
| pub fn derive_non_ascii_ident(_: TokenStream) -> TokenStream { | ||
| "#[allow(non_ascii_idents)] const föö: () = ();".parse().unwrap() | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Regression test for #151025: derive-generated `#[allow(non_ascii_idents)]` | ||
| // should not be rejected as an unused attribute. | ||
|
|
||
| //@ check-pass | ||
| //@ proc-macro: non-ascii-idents-derive.rs | ||
|
|
||
| #![allow(dead_code)] | ||
| #![deny(non_ascii_idents, unused_attributes)] | ||
|
|
||
| extern crate non_ascii_idents_derive; | ||
|
|
||
| use non_ascii_idents_derive::NonAsciiIdent; | ||
|
|
||
| #[derive(NonAsciiIdent)] | ||
| struct S; | ||
|
|
||
| fn main() {} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Is there a standard or blessed way of stacking PRs in this repo? Or should I just remember to push a new PR once this one has merged?