diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index cbc4ebe90fd09..e8de6c36ba18d 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -182,7 +182,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } if !(ty_warned || fn_warned) { - cx.span_lint(UNUSED_RESULTS, s.span, "unused result"); + match t.sty { + // Historically, booleans have not been considered unused + // results. (See Issue #44119.) + ty::TyBool => return, + _ => { + cx.span_lint(UNUSED_RESULTS, s.span, "unused result"); + } + } } fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool { diff --git a/src/test/compile-fail/unused-result.rs b/src/test/compile-fail/unused-result.rs index 0c6c7fc5a0d75..c0417e6e997ca 100644 --- a/src/test/compile-fail/unused-result.rs +++ b/src/test/compile-fail/unused-result.rs @@ -42,6 +42,9 @@ fn main() { foo::(); //~ ERROR: unused `MustUse` which must be used foo::(); //~ ERROR: unused `MustUseMsg` which must be used: some message + // as an exceptional case, booleans are not considered unused + foo::(); + let _ = foo::(); let _ = foo::(); let _ = foo::();