-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10869 - Centri3:allow_attributes, r=Manishearth
[`allow_attributes`, `allow_attributes_without_reason`]: Ignore attributes from procedural macros I use `lint_reasons` and `clap`, which is a bit overzealous when it comes to preventing warnings in its macros; it uses a ton of allow attributes on everything to, as ironic as it is, silence warnings. These two now ignore anything from procedural macros. PS, I think `allow_attributes.rs` should be merged with `attrs.rs` in the future. fixes #10377 changelog: [`allow_attributes`, `allow_attributes_without_reason`]: Ignore attributes from procedural macros
- Loading branch information
Showing
9 changed files
with
166 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,44 @@ | ||
//@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() {} | ||
} | ||
} | ||
|
||
// Make sure this is not triggered on `?` desugaring | ||
|
||
pub fn trigger_fp_option() -> Option<()> { | ||
Some(())?; | ||
None?; | ||
Some(()) | ||
} | ||
|
||
pub fn trigger_fp_result() -> Result<(), &'static str> { | ||
Ok(())?; | ||
Err("asdf")?; | ||
Ok(()) | ||
} |
This file contains 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 | ||
|