don't lint if snippet is shortert than 1 character
This happens with various combinations of cfg attributes and macros expansion. Not linting here is the safe route, as everything else might produce false positives.
This commit is contained in:
parent
663d8497aa
commit
2d57902a27
@ -109,14 +109,16 @@ impl LateLintPass for AttrPass {
|
||||
if let MetaItemKind::List(ref name, _) = attr.node.value.node {
|
||||
match &**name {
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
span_lint_and_then(cx, USELESS_ATTRIBUTE, attr.span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
||||
sugg.insert(1, '!');
|
||||
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
||||
if sugg.len() > 1 {
|
||||
span_lint_and_then(cx, USELESS_ATTRIBUTE, attr.span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
sugg.insert(1, '!');
|
||||
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user