diff options
| author | bors <bors@rust-lang.org> | 2023-03-16 10:18:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-16 10:18:19 +0000 |
| commit | 5afa93bd8ea57faa67f8ea75103971831066f283 (patch) | |
| tree | 12399ed3a004b1ea84a8a559286cd69cadc06868 /tests | |
| parent | c465bf7f67ff12b9d7246a26ea83f66f0de228da (diff) | |
| parent | 1cab0cbaf0dddb4cd403c4a0c391315801a22835 (diff) | |
| download | rust-5afa93bd8ea57faa67f8ea75103971831066f283.tar.gz rust-5afa93bd8ea57faa67f8ea75103971831066f283.zip | |
Auto merge of #10481 - blyxyas:allow_attribute, r=xFrednet
Add `allow_attribute` lint Fixes #10468 changelog: new lint: [`allow_attributes`] [#10481](https://github.com/rust-lang/rust-clippy/pull/10481)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/allow_attributes.fixed | 25 | ||||
| -rw-r--r-- | tests/ui/allow_attributes.rs | 25 | ||||
| -rw-r--r-- | tests/ui/allow_attributes.stderr | 16 |
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/ui/allow_attributes.fixed b/tests/ui/allow_attributes.fixed new file mode 100644 index 00000000000..b8dd0619e6d --- /dev/null +++ b/tests/ui/allow_attributes.fixed @@ -0,0 +1,25 @@ +// run-rustfix +#![allow(unused)] +#![warn(clippy::allow_attributes)] +#![feature(lint_reasons)] + +fn main() {} + +// Using clippy::needless_borrow just as a placeholder, it isn't relevant. + +// Should lint +#[expect(dead_code)] +struct T1; + +struct T2; // Should not lint +#[deny(clippy::needless_borrow)] // Should not lint +struct T3; +#[warn(clippy::needless_borrow)] // Should not lint +struct T4; +// `panic = "unwind"` should always be true +#[cfg_attr(panic = "unwind", expect(dead_code))] +struct CfgT; + +fn ignore_inner_attr() { + #![allow(unused)] // Should not lint +} diff --git a/tests/ui/allow_attributes.rs b/tests/ui/allow_attributes.rs new file mode 100644 index 00000000000..295f560906a --- /dev/null +++ b/tests/ui/allow_attributes.rs @@ -0,0 +1,25 @@ +// run-rustfix +#![allow(unused)] +#![warn(clippy::allow_attributes)] +#![feature(lint_reasons)] + +fn main() {} + +// Using clippy::needless_borrow just as a placeholder, it isn't relevant. + +// Should lint +#[allow(dead_code)] +struct T1; + +struct T2; // Should not lint +#[deny(clippy::needless_borrow)] // Should not lint +struct T3; +#[warn(clippy::needless_borrow)] // Should not lint +struct T4; +// `panic = "unwind"` should always be true +#[cfg_attr(panic = "unwind", allow(dead_code))] +struct CfgT; + +fn ignore_inner_attr() { + #![allow(unused)] // Should not lint +} diff --git a/tests/ui/allow_attributes.stderr b/tests/ui/allow_attributes.stderr new file mode 100644 index 00000000000..681837e9ed7 --- /dev/null +++ b/tests/ui/allow_attributes.stderr @@ -0,0 +1,16 @@ +error: #[allow] attribute found + --> $DIR/allow_attributes.rs:11:3 + | +LL | #[allow(dead_code)] + | ^^^^^ help: replace it with: `expect` + | + = note: `-D clippy::allow-attributes` implied by `-D warnings` + +error: #[allow] attribute found + --> $DIR/allow_attributes.rs:20:30 + | +LL | #[cfg_attr(panic = "unwind", allow(dead_code))] + | ^^^^^ help: replace it with: `expect` + +error: aborting due to 2 previous errors + |
