unused_import
is a valid lint to be changed on use
statements
This commit is contained in:
parent
2d57902a27
commit
14d2cd0b0a
1 changed files with 11 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue