diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index 4fc31b3a41262..d91f6edc9800c 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -447,7 +447,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// Targetted error when encountering an `FnMut` closure where an `Fn` closure was expected. fn expected_fn_found_fn_mut_call(&self, err: &mut DiagnosticBuilder<'_>, sp: Span, act: &str) { - err.span_label(sp, format!("cannot {ACT}", ACT = act)); + err.span_label(sp, format!("cannot {}", act)); let hir = self.infcx.tcx.hir(); let closure_id = hir.as_local_hir_id(self.mir_def_id).unwrap(); @@ -528,13 +528,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { kind: hir::ImplItemKind::Method(sig, _), .. }) => { - err.span_label(ident.span, "you might have to change this..."); - err.span_label(sig.decl.output.span(), "...to return `FnMut` instead of `Fn`"); + err.span_label(ident.span, ""); + err.span_label( + sig.decl.output.span(), + "change this to return `FnMut` instead of `Fn`", + ); err.span_label(self.body.span, "in this closure"); } - parent => { - err.note(&format!("parent {:?}", parent)); - } + _ => {} } } } diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr index a97d694685d76..3046b047d00f6 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -68,9 +68,7 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closu --> $DIR/borrow-immutable-upvar-mutation.rs:43:9 | LL | fn foo() -> Box usize> { - | --- ---------------------- ...to return `FnMut` instead of `Fn` - | | - | you might have to change this... + | --- ---------------------- change this to return `FnMut` instead of `Fn` LL | let mut x = 0; LL | Box::new(move || { | ______________- @@ -84,9 +82,7 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closu --> $DIR/borrow-immutable-upvar-mutation.rs:51:9 | LL | fn bar() -> impl Fn() -> usize { - | --- ------------------ ...to return `FnMut` instead of `Fn` - | | - | you might have to change this... + | --- ------------------ change this to return `FnMut` instead of `Fn` LL | let mut x = 0; LL | / move || { LL | | x += 1;