Skip to content

Commit d51f2bd

Browse files
committed
review comments
1 parent 109d5c1 commit d51f2bd

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
447447

448448
/// Targetted error when encountering an `FnMut` closure where an `Fn` closure was expected.
449449
fn expected_fn_found_fn_mut_call(&self, err: &mut DiagnosticBuilder<'_>, sp: Span, act: &str) {
450-
err.span_label(sp, format!("cannot {ACT}", ACT = act));
450+
err.span_label(sp, format!("cannot {}", act));
451451

452452
let hir = self.infcx.tcx.hir();
453453
let closure_id = hir.as_local_hir_id(self.mir_def_id).unwrap();
@@ -528,13 +528,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
528528
kind: hir::ImplItemKind::Method(sig, _),
529529
..
530530
}) => {
531-
err.span_label(ident.span, "you might have to change this...");
532-
err.span_label(sig.decl.output.span(), "...to return `FnMut` instead of `Fn`");
531+
err.span_label(ident.span, "");
532+
err.span_label(
533+
sig.decl.output.span(),
534+
"change this to return `FnMut` instead of `Fn`",
535+
);
533536
err.span_label(self.body.span, "in this closure");
534537
}
535-
parent => {
536-
err.note(&format!("parent {:?}", parent));
537-
}
538+
_ => {}
538539
}
539540
}
540541
}

src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closu
6868
--> $DIR/borrow-immutable-upvar-mutation.rs:43:9
6969
|
7070
LL | fn foo() -> Box<dyn Fn() -> usize> {
71-
| --- ---------------------- ...to return `FnMut` instead of `Fn`
72-
| |
73-
| you might have to change this...
71+
| --- ---------------------- change this to return `FnMut` instead of `Fn`
7472
LL | let mut x = 0;
7573
LL | Box::new(move || {
7674
| ______________-
@@ -84,9 +82,7 @@ error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closu
8482
--> $DIR/borrow-immutable-upvar-mutation.rs:51:9
8583
|
8684
LL | fn bar() -> impl Fn() -> usize {
87-
| --- ------------------ ...to return `FnMut` instead of `Fn`
88-
| |
89-
| you might have to change this...
85+
| --- ------------------ change this to return `FnMut` instead of `Fn`
9086
LL | let mut x = 0;
9187
LL | / move || {
9288
LL | | x += 1;

0 commit comments

Comments
 (0)