unused_import is a valid lint to be changed on use statements

This commit is contained in:
Oliver Schneider 2016-08-18 13:07:47 +02:00
parent 2d57902a27
commit 14d2cd0b0a
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46

View file

@ -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,