Skip to content

Commit 5d3e3e1

Browse files
committed
Auto merge of #5250 - mlegner:unused_fp, r=flip1995
Whitelist unused attribute for use items. This PR whitelists the `unused` attribute with `use` items and adds a corresponding test case. Fixes: #5229 changelog: none
2 parents a94b2c1 + 8669be5 commit 5d3e3e1

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
248248
if is_word(lint, sym!(unused_imports))
249249
|| is_word(lint, sym!(deprecated))
250250
|| is_word(lint, sym!(unreachable_pub))
251+
|| is_word(lint, sym!(unused))
251252
{
252253
return;
253254
}

tests/ui/useless_attribute.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ extern crate proc_macro_derive;
2020
#[allow(unused_imports)]
2121
use std::collections;
2222

23+
// don't lint on unused for `use` items
24+
#[allow(unused)]
25+
use std::option;
26+
2327
// don't lint on deprecated for `use` items
2428
mod foo {
2529
#[deprecated]

tests/ui/useless_attribute.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ extern crate proc_macro_derive;
2020
#[allow(unused_imports)]
2121
use std::collections;
2222

23+
// don't lint on unused for `use` items
24+
#[allow(unused)]
25+
use std::option;
26+
2327
// don't lint on deprecated for `use` items
2428
mod foo {
2529
#[deprecated]

tests/ui/useless_attribute.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
1414

1515
error: useless lint attribute
16-
--> $DIR/useless_attribute.rs:49:5
16+
--> $DIR/useless_attribute.rs:53:5
1717
|
1818
LL | #[allow(clippy::almost_swapped)]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]`

0 commit comments

Comments
 (0)