From 919feaaec5c3c07052f607268f110778ead48964 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 1 Dec 2016 22:36:35 +0100 Subject: [PATCH] Allow `allow(deprecated)` attribute on `use` items fixes #1372 --- clippy_lints/src/attrs.rs | 4 ++-- tests/compile-fail/useless_attribute.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index f03dcbc5a9aa..2d9960c7e3d8 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -110,9 +110,9 @@ impl LateLintPass for AttrPass { if let MetaItemKind::List(ref lint_list) = attr.value.node { match &*attr.name().as_str() { "allow" | "warn" | "deny" | "forbid" => { - // whitelist `unused_imports` + // whitelist `unused_imports` and `deprecated` for lint in lint_list { - if is_word(lint, "unused_imports") { + if is_word(lint, "unused_imports") || is_word(lint, "deprecated") { if let ItemUse(_) = item.node { return; } diff --git a/tests/compile-fail/useless_attribute.rs b/tests/compile-fail/useless_attribute.rs index 1826f3a20e9b..de3896f091b4 100644 --- a/tests/compile-fail/useless_attribute.rs +++ b/tests/compile-fail/useless_attribute.rs @@ -11,4 +11,9 @@ extern crate clippy_lints; #[allow(unused_imports)] use std::collections; +// don't lint on deprecated for `use` items +mod foo { #[deprecated] pub struct Bar; } +#[allow(deprecated)] +pub use foo::Bar; + fn main() {}