-
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.
Add lint to detect
allow
attributes without reason
- Loading branch information
Showing
6 changed files
with
99 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![feature(lint_reasons)] | ||
#![deny(clippy::allow_lint_without_reason)] | ||
|
||
// These should trigger the lint | ||
#[allow(dead_code)] | ||
#[allow(dead_code, deprecated)] | ||
// 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() {} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error: `allow` attribute without reason | ||
--> $DIR/allow_lint_without_reason.rs:5:1 | ||
| | ||
LL | #[allow(dead_code)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/allow_lint_without_reason.rs:2:9 | ||
| | ||
LL | #![deny(clippy::allow_lint_without_reason)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: try adding a reason at the end with `, reason = ".."` | ||
|
||
error: `allow` attribute without reason | ||
--> $DIR/allow_lint_without_reason.rs:6:1 | ||
| | ||
LL | #[allow(dead_code, deprecated)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: try adding a reason at the end with `, reason = ".."` | ||
|
||
error: aborting due to 2 previous errors | ||
|