Fill in Applicability from review comments by @flip1995
This commit is contained in:
parent
3eccccb367
commit
58729346be
29 changed files with 52 additions and 48 deletions
|
|
@ -90,13 +90,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
|
|||
long
|
||||
),
|
||||
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
db.span_suggestion_with_applicability(
|
||||
expr.span,
|
||||
"or",
|
||||
long,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -183,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
|
|||
expr.span,
|
||||
"replace it with",
|
||||
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
|||
line_span,
|
||||
"if you just forgot a `!`, use",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
|
|||
e.span,
|
||||
"try",
|
||||
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,6 +395,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
|
|||
e.span,
|
||||
"it would look like the following",
|
||||
suggest(self.cx, suggestion, &h2q.terminals).0,
|
||||
// nonminimal_bool can produce minimal but
|
||||
// not human readable expressions (#3141)
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
},
|
||||
|
|
@ -423,6 +425,8 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
|
|||
e.span,
|
||||
"try",
|
||||
suggestions,
|
||||
// nonminimal_bool can produce minimal but
|
||||
// not human readable expressions (#3141)
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
|
|||
lhs.and(&rhs),
|
||||
snippet_block(cx, content.span, ".."),
|
||||
),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ impl StaticConst {
|
|||
ty.span,
|
||||
"consider removing `'static`",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, //snippet
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
|
|||
self.span,
|
||||
"consider using",
|
||||
help,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
@ -156,7 +156,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
|
|||
self.span,
|
||||
"consider using",
|
||||
help,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
|||
left.span,
|
||||
"use the left value directly",
|
||||
lsnip,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
})
|
||||
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) {
|
||||
|
|
@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
|||
right.span,
|
||||
"use the right value directly",
|
||||
rsnip,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
},
|
||||
)
|
||||
|
|
@ -150,7 +150,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
|||
left.span,
|
||||
"use the left value directly",
|
||||
lsnip,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
})
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
|||
right.span,
|
||||
"use the right value directly",
|
||||
rsnip,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
|
|||
expr.span,
|
||||
"remove closure as shown",
|
||||
snippet,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
expr.span,
|
||||
"consider using .to_string()",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
span,
|
||||
"consider using .to_string()",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
|
|||
e.span,
|
||||
"consider removing `.into()`",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
|
|||
e.span,
|
||||
"consider removing `.into_iter()`",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
|
|||
e.span,
|
||||
&sugg_msg,
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
span,
|
||||
"try this",
|
||||
format!("if {}.{}", snippet(cx, op.span, "_"), good_method),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
|
|||
attr.span,
|
||||
&format!("use of `#[inline]` on trait method `{}` which has no body", name),
|
||||
|db| {
|
||||
db.suggest_remove_item(cx, attr.span, "remove", Applicability::Unspecified);
|
||||
db.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ impl IntPlusOne {
|
|||
block.span,
|
||||
"change `>= y + 1` to `> y` as shown",
|
||||
recommendation,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
|
|||
"consider boxing the large fields to reduce the total size of the \
|
||||
enum",
|
||||
format!("Box<{}>", snip),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
|
|||
span,
|
||||
"it is more idiomatic to write",
|
||||
sug,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
if !mutability.is_empty() {
|
||||
db.note("you might not need `mut` at all");
|
||||
|
|
|
|||
|
|
@ -1206,7 +1206,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
|
|||
dots = dots,
|
||||
start = start_snippet
|
||||
),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
|
|||
stmt.span,
|
||||
"try this",
|
||||
suggestion,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
} else {
|
||||
let suggestion = format!("if let {0}({1}) = {2} {{ ... }}",
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex
|
|||
expr.span,
|
||||
"consider using an if/else expression",
|
||||
sugg,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect, // not sure
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1132,13 +1132,13 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
|||
expr.span,
|
||||
"try dereferencing it",
|
||||
format!("{}({}{}).clone()", refs, derefs, snip.deref()),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
db.span_suggestion_with_applicability(
|
||||
expr.span,
|
||||
"or try being explicit about what type to clone",
|
||||
explicit,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
@ -1659,7 +1659,7 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr,
|
|||
expr.span,
|
||||
"try using and_then instead",
|
||||
hint,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
tyopt=tyopt,
|
||||
initref=initref,
|
||||
),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
@ -331,7 +331,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
sugg,
|
||||
&snippet(cx, b.span, ".."),
|
||||
),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
expr.span,
|
||||
"consider comparing them within some error",
|
||||
format!("({}).abs() < error", lhs - rhs),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available.");
|
||||
});
|
||||
|
|
@ -553,7 +553,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
|
|||
expr.span,
|
||||
"try",
|
||||
snip.to_string(),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ impl EarlyLintPass for MiscEarly {
|
|||
expr.span,
|
||||
"Try doing something like: ",
|
||||
hint,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
@ -402,13 +402,13 @@ impl MiscEarly {
|
|||
lit.span,
|
||||
"if you mean to use a decimal constant, remove the `0` to remove confusion",
|
||||
src.trim_left_matches(|c| c == '_' || c == '0').to_string(),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
db.span_suggestion_with_applicability(
|
||||
lit.span,
|
||||
"if you mean to use an octal constant, use `0o`",
|
||||
format!("0o{}", src.trim_left_matches(|c| c == '_' || c == '0')),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
|||
e.span,
|
||||
"change this to",
|
||||
snippet,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
|||
pat.span,
|
||||
"change this to",
|
||||
snippet,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
|
|||
pat.span,
|
||||
"try removing the `&ref` part and just keep",
|
||||
hint,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
|||
sp,
|
||||
"try this",
|
||||
"#[derive(Default)]",
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
|
|
@ -150,7 +150,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
|||
item.span,
|
||||
"try this",
|
||||
&create_new_without_default_suggest_msg(self_ty),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl QuestionMarkPass {
|
|||
expr.span,
|
||||
"replace_it_with",
|
||||
format!("{}?;", receiver_str),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -155,14 +155,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
expr.span,
|
||||
"use",
|
||||
format!("({}..={})", start, end),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
db.span_suggestion_with_applicability(
|
||||
expr.span,
|
||||
"use",
|
||||
format!("{}..={}", start, end),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
expr.span,
|
||||
"use",
|
||||
format!("{}..{}", start, end),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable, // snippet
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ impl ReturnPass {
|
|||
ret_span,
|
||||
"remove `return` as shown",
|
||||
snippet,
|
||||
Applicability::Unspecified,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) {
|
|||
lhs,
|
||||
rhs,
|
||||
),
|
||||
Applicability::Unspecified,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
db.note("or maybe you should use `std::mem::replace`?");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue