From 14d2cd0b0af2490415d776694f10f581bed5a065 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 18 Aug 2016 13:07:47 +0200 Subject: [PATCH] `unused_import` is a valid lint to be changed on `use` statements --- clippy_lints/src/attrs.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 4bb32ec4d327..086716c1f464 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -106,9 +106,19 @@ impl LateLintPass for AttrPass { ItemExternCrate(_) | ItemUse(_) => { for attr in &item.attrs { - if let MetaItemKind::List(ref name, _) = attr.node.value.node { + if let MetaItemKind::List(ref name, ref lint_list) = attr.node.value.node { match &**name { "allow" | "warn" | "deny" | "forbid" => { + // whitelist `unused_imports` + for lint in lint_list { + if let MetaItemKind::Word(ref word) = lint.node { + if word == "unused_imports" { + if let ItemUse(_) = item.node { + return; + } + } + } + } if let Some(mut sugg) = snippet_opt(cx, attr.span) { if sugg.len() > 1 { span_lint_and_then(cx, USELESS_ATTRIBUTE, attr.span,