1
Fork 0

Improve warning

This commit is contained in:
Ryan Levick 2021-01-08 11:37:52 +01:00 committed by Ryan Levick
parent c5ff54cbdb
commit 217c88655b
3 changed files with 18 additions and 16 deletions

View file

@ -70,11 +70,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
.iter()
.any(|s| cx.tcx.is_diagnostic_item(*s, i.def_id()))
{
let span = expr.span;
let expr_span = expr.span;
cx.struct_span_lint(NOOP_METHOD_CALL, span, |lint| {
let message = "call to noop method";
lint.build(&message).emit()
cx.struct_span_lint(NOOP_METHOD_CALL, expr_span, |lint| {
let message = "call to method that does nothing";
lint.build(&message)
.span_label(expr_span, "unnecessary method call")
.emit()
});
}
}