-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Pre lint port cleanups #162813
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
Merged
Merged
Pre lint port cleanups #162813
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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,11 @@ | ||
| #![crate_type = "lib"] | ||
|
|
||
| #[expect] // OK | ||
| #[expect[wut]] // OK | ||
| #[expect(expect)] // OK | ||
| #[expect(expect(expect))] //~ ERROR malformed lint attribute input | ||
| //~| ERROR malformed lint attribute input | ||
| #[deny(({!}))] // OK | ||
| #[expect[helix::<ub>]] // OK | ||
| #[cfg(false)] | ||
| const _: () = (); | ||
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 @@ | ||
| error[E0452]: malformed lint attribute input | ||
| --> $DIR/pre-expansion-parsing.rs:6:10 | ||
| | | ||
| LL | #[expect(expect(expect))] | ||
| | ^^^^^^^^^^^^^^ bad attribute argument | ||
|
|
||
| error[E0452]: malformed lint attribute input | ||
| --> $DIR/pre-expansion-parsing.rs:6:10 | ||
| | | ||
| LL | #[expect(expect(expect))] | ||
| | ^^^^^^^^^^^^^^ bad attribute argument | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: aborting due to 2 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0452`. |
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.
This also should be ok.
Before the
const _item is fully expanded (the item itself, not its nested nodes), all the#[expect]s (and other potential inert attributes) are just tokens without any semantic meaning, and the active attributes can change those tokens in any way or remove them likecfg(false)does, so any semantic checks like "this built-in attribute has unexpected input" should not be performed for them.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.
In this sense
is also equivalent to
#[expect(expect(expect))]incfg(false)code, and also shouldn't report any "malformed" attribute errors, and #160904 is not doing the right thing.Although it would still be nice to conservatively turn it into an error, and then try turning
#[attrs]in#[attrs] mac_call!()into a part of the macro input (#63221 (comment)).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 agree, it's annoyingly inconsistent. I'm just adding the test here to document the current behavior and I don't want to change that behavior before or during #162811 because it'll make porting lint attributes much harder to write and review.
They have meaning for pre-expansion lints, so it's not as simple as "they're just tokens":
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.
Since when the example with
#[warn(keyword_idents_2024)]works, and how?Previously lint attributes were only attached to node ids, and node ids are not created for
cfg(false)code.I don't think it's generally a good idea to support this, if it goes against the core expansion model.
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.
With this I agree.
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.
This equivalent example works in rust 1.30:
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.
Hmm, weird, I need to investigate.