-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[allow_attributes, allow_attributes_without_reason]: Ignore attributes from procedural macros
#10869
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
[allow_attributes, allow_attributes_without_reason]: Ignore attributes from procedural macros
#10869
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0086b6a
don't lint `allow_attributes` on attributes from proc macros
Centri3 ab70553
foiled again (forgot to run cargo test)
Centri3 497f377
Fix `attr_search_pat` for `#[cfg_attr]`
Centri3 05bfcbd
remove tuple
Centri3 7055371
add test for `?` desugaring
Centri3 b469e8c
Update allow_attributes_without_reason.rs
Centri3 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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,14 +1,30 @@ | ||
| //@aux-build:proc_macros.rs | ||
| #![feature(lint_reasons)] | ||
| #![deny(clippy::allow_attributes_without_reason)] | ||
| #![allow(unfulfilled_lint_expectations)] | ||
|
|
||
| extern crate proc_macros; | ||
| use proc_macros::{external, with_span}; | ||
|
|
||
| // These should trigger the lint | ||
| #[allow(dead_code)] | ||
| #[allow(dead_code, deprecated)] | ||
| #[expect(dead_code)] | ||
| // These should be fine | ||
| #[allow(dead_code, reason = "This should be allowed")] | ||
| #[warn(dyn_drop, reason = "Warnings can also have reasons")] | ||
| #[warn(deref_nullptr)] | ||
| #[deny(deref_nullptr)] | ||
| #[forbid(deref_nullptr)] | ||
|
|
||
| fn main() {} | ||
| fn main() { | ||
| external! { | ||
| #[allow(dead_code)] | ||
| fn a() {} | ||
| } | ||
| with_span! { | ||
| span | ||
| #[allow(dead_code)] | ||
| fn b() {} | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -1,23 +1,39 @@ | ||
| error: `allow` attribute without specifying a reason | ||
| --> $DIR/allow_attributes_without_reason.rs:5:1 | ||
| --> $DIR/allow_attributes_without_reason.rs:4:1 | ||
| | | ||
| LL | #[allow(dead_code)] | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
| LL | #![allow(unfulfilled_lint_expectations)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = help: try adding a reason at the end with `, reason = ".."` | ||
| note: the lint level is defined here | ||
| --> $DIR/allow_attributes_without_reason.rs:2:9 | ||
| --> $DIR/allow_attributes_without_reason.rs:3:9 | ||
| | | ||
| LL | #![deny(clippy::allow_attributes_without_reason)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: `allow` attribute without specifying a reason | ||
| --> $DIR/allow_attributes_without_reason.rs:6:1 | ||
| --> $DIR/allow_attributes_without_reason.rs:10:1 | ||
| | | ||
| LL | #[allow(dead_code)] | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = help: try adding a reason at the end with `, reason = ".."` | ||
|
|
||
| error: `allow` attribute without specifying a reason | ||
| --> $DIR/allow_attributes_without_reason.rs:11:1 | ||
| | | ||
| LL | #[allow(dead_code, deprecated)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = help: try adding a reason at the end with `, reason = ".."` | ||
|
|
||
| error: aborting due to 2 previous errors | ||
| error: `expect` attribute without specifying a reason | ||
| --> $DIR/allow_attributes_without_reason.rs:12:1 | ||
| | | ||
| LL | #[expect(dead_code)] | ||
| | ^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = help: try adding a reason at the end with `, reason = ".."` | ||
|
|
||
| error: aborting due to 4 previous errors | ||
|
|
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.