Fix useless_attribute to also whitelist unused_extern_crates.

This commit is contained in:
Eduard-Mihai Burtescu 2018-09-15 10:56:03 +03:00
parent 9219fc6c5c
commit 85caaf5905
3 changed files with 16 additions and 10 deletions

View File

@ -180,10 +180,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|| is_word(lint, "deprecated") {
return
},
ItemKind::ExternCrate(..) => if is_word(lint, "unused_imports")
ItemKind::ExternCrate(..) => {
if is_word(lint, "unused_imports")
&& skip_unused_imports {
return
},
}
if is_word(lint, "unused_extern_crates") {
return
}
}
_ => {},
}
}

View File

@ -2,11 +2,12 @@
#![warn(clippy::useless_attribute)]
#[allow(dead_code, unused_extern_crates)]
#[cfg_attr(feature = "cargo-clippy", allow(dead_code, unused_extern_crates))]
#[allow(dead_code)]
#[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
#[cfg_attr(feature = "cargo-clippy",
allow(dead_code, unused_extern_crates))]
allow(dead_code))]
#[allow(unused_imports)]
#[allow(unused_extern_crates)]
#[macro_use]
extern crate clippy_lints;

View File

@ -1,16 +1,16 @@
error: useless lint attribute
--> $DIR/useless_attribute.rs:5:1
|
5 | #[allow(dead_code, unused_extern_crates)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code, unused_extern_crates)]`
5 | #[allow(dead_code)]
| ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]`
|
= note: `-D clippy::useless-attribute` implied by `-D warnings`
error: useless lint attribute
--> $DIR/useless_attribute.rs:6:1
|
6 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code, unused_extern_crates))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code, unused_extern_crates))`
6 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code))`
error: aborting due to 2 previous errors