review comments
This commit is contained in:
parent
109d5c189f
commit
d51f2bd9d7
2 changed files with 9 additions and 12 deletions
|
@ -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));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<dyn 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 | 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue