Whitelist unused attribute for use items.

This commit is contained in:
mlegner 2020-03-02 10:22:05 +01:00
parent 0f4a3feccc
commit 8669be56c4
No known key found for this signature in database
GPG key ID: 8373ED3B4CCFA845
4 changed files with 10 additions and 1 deletions

View file

@ -248,6 +248,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
if is_word(lint, sym!(unused_imports)) if is_word(lint, sym!(unused_imports))
|| is_word(lint, sym!(deprecated)) || is_word(lint, sym!(deprecated))
|| is_word(lint, sym!(unreachable_pub)) || is_word(lint, sym!(unreachable_pub))
|| is_word(lint, sym!(unused))
{ {
return; return;
} }

View file

@ -20,6 +20,10 @@ extern crate proc_macro_derive;
#[allow(unused_imports)] #[allow(unused_imports)]
use std::collections; use std::collections;
// don't lint on unused for `use` items
#[allow(unused)]
use std::option;
// don't lint on deprecated for `use` items // don't lint on deprecated for `use` items
mod foo { mod foo {
#[deprecated] #[deprecated]

View file

@ -20,6 +20,10 @@ extern crate proc_macro_derive;
#[allow(unused_imports)] #[allow(unused_imports)]
use std::collections; use std::collections;
// don't lint on unused for `use` items
#[allow(unused)]
use std::option;
// don't lint on deprecated for `use` items // don't lint on deprecated for `use` items
mod foo { mod foo {
#[deprecated] #[deprecated]

View file

@ -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)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
error: useless lint attribute error: useless lint attribute
--> $DIR/useless_attribute.rs:49:5 --> $DIR/useless_attribute.rs:53:5
| |
LL | #[allow(clippy::almost_swapped)] LL | #[allow(clippy::almost_swapped)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]`