Skip to content

Commit 14d2cd0

Browse files
committed
unused_import is a valid lint to be changed on use statements
1 parent 2d57902 commit 14d2cd0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clippy_lints/src/attrs.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,19 @@ impl LateLintPass for AttrPass {
106106
ItemExternCrate(_) |
107107
ItemUse(_) => {
108108
for attr in &item.attrs {
109-
if let MetaItemKind::List(ref name, _) = attr.node.value.node {
109+
if let MetaItemKind::List(ref name, ref lint_list) = attr.node.value.node {
110110
match &**name {
111111
"allow" | "warn" | "deny" | "forbid" => {
112+
// whitelist `unused_imports`
113+
for lint in lint_list {
114+
if let MetaItemKind::Word(ref word) = lint.node {
115+
if word == "unused_imports" {
116+
if let ItemUse(_) = item.node {
117+
return;
118+
}
119+
}
120+
}
121+
}
112122
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
113123
if sugg.len() > 1 {
114124
span_lint_and_then(cx, USELESS_ATTRIBUTE, attr.span,

0 commit comments

Comments
 (0)