diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index c431c048ca0..2b580452a60 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -161,7 +161,15 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { if let Some(must_use_op) = must_use_op { cx.struct_span_lint(UNUSED_MUST_USE, expr.span, |lint| { - lint.build(&format!("unused {} that must be used", must_use_op)).emit() + let mut lint = lint.build(&format!("unused {} that must be used", must_use_op)); + lint.span_label(expr.span, &format!("the {} produces a value", must_use_op)); + lint.span_suggestion_verbose( + expr.span.shrink_to_lo(), + "use `let _ = ...` to ignore the resulting value", + "let _ = ".to_string(), + Applicability::MachineApplicable, + ); + lint.emit(); }); op_warned = true; } |
