diff options
| author | bors <bors@rust-lang.org> | 2020-03-03 11:16:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-03-03 11:16:55 +0000 |
| commit | 5d3e3e1a9ea9968bdb6474fe8106850dbf645480 (patch) | |
| tree | d1ebf30f156f4195cdff026d9ad5b237cfeac56d | |
| parent | a94b2c1f7df3525317f03a5021369a001b57fe95 (diff) | |
| parent | 8669be56c48a26d730577fb5e77025172cfdfc44 (diff) | |
| download | rust-5d3e3e1a9ea9968bdb6474fe8106850dbf645480.tar.gz rust-5d3e3e1a9ea9968bdb6474fe8106850dbf645480.zip | |
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
| -rw-r--r-- | clippy_lints/src/attrs.rs | 1 | ||||
| -rw-r--r-- | tests/ui/useless_attribute.fixed | 4 | ||||
| -rw-r--r-- | tests/ui/useless_attribute.rs | 4 | ||||
| -rw-r--r-- | tests/ui/useless_attribute.stderr | 2 |
4 files changed, 10 insertions, 1 deletions
diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index f753d3dc1c7..7d5e1d88191 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -248,6 +248,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes { if is_word(lint, sym!(unused_imports)) || is_word(lint, sym!(deprecated)) || is_word(lint, sym!(unreachable_pub)) + || is_word(lint, sym!(unused)) { return; } diff --git a/tests/ui/useless_attribute.fixed b/tests/ui/useless_attribute.fixed index 56811a99872..ff626ab3ddf 100644 --- a/tests/ui/useless_attribute.fixed +++ b/tests/ui/useless_attribute.fixed @@ -20,6 +20,10 @@ extern crate proc_macro_derive; #[allow(unused_imports)] use std::collections; +// don't lint on unused for `use` items +#[allow(unused)] +use std::option; + // don't lint on deprecated for `use` items mod foo { #[deprecated] diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index bbf5e495db4..822c6b6ea06 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -20,6 +20,10 @@ extern crate proc_macro_derive; #[allow(unused_imports)] use std::collections; +// don't lint on unused for `use` items +#[allow(unused)] +use std::option; + // don't lint on deprecated for `use` items mod foo { #[deprecated] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 08a211b41a9..57ba976730c 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -13,7 +13,7 @@ LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` error: useless lint attribute - --> $DIR/useless_attribute.rs:49:5 + --> $DIR/useless_attribute.rs:53:5 | LL | #[allow(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]` |
