diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index da1edcf6fe3b4..ed24b94e2fd3b 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -169,7 +169,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { } if !(type_permits_lack_of_use || fn_warned || op_warned) { - cx.struct_span_lint(UNUSED_RESULTS, s.span, |lint| lint.build("unused result").emit()); + cx.struct_span_lint(UNUSED_RESULTS, s.span, |lint| { + lint.build(&format!("unused result of type `{}`", ty)).emit() + }); } // Returns whether an error has been emitted (and thus another does not need to be later). diff --git a/src/test/ui/lint/unused/unused-result.rs b/src/test/ui/lint/unused/unused-result.rs index a65e98990dceb..e283eaa88dd13 100644 --- a/src/test/ui/lint/unused/unused-result.rs +++ b/src/test/ui/lint/unused/unused-result.rs @@ -31,7 +31,7 @@ fn test2() { } fn main() { - foo::(); //~ ERROR: unused result + foo::(); //~ ERROR: unused result of type `isize` foo::(); //~ ERROR: unused `MustUse` that must be used foo::(); //~ ERROR: unused `MustUseMsg` that must be used //~^ NOTE: some message diff --git a/src/test/ui/lint/unused/unused-result.stderr b/src/test/ui/lint/unused/unused-result.stderr index 1b1dcab3a1bc9..087e06341cdde 100644 --- a/src/test/ui/lint/unused/unused-result.stderr +++ b/src/test/ui/lint/unused/unused-result.stderr @@ -18,7 +18,7 @@ LL | foo::(); | = note: some message -error: unused result +error: unused result of type `isize` --> $DIR/unused-result.rs:34:5 | LL | foo::();