Skip to content

Commit 38b5b29

Browse files
committed
Change label to "consider changing this to mut f"
Change the wording of mutable borrow on immutable binding from "this should be `mut`" to "consider changing this to `mut f`".
1 parent 6ba494b commit 38b5b29

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/librustc_borrowck/borrowck/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
748748
db.span_label(span, &msg);
749749
}
750750
if let Some(span) = local_def {
751-
db.span_label(span, &"this should be `mut`");
751+
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
752+
db.span_label(span, &format!("consider changing this to `mut {}`", snippet));
753+
}
752754
}
753755
db
754756
}

src/test/ui/did_you_mean/issue-39544.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: cannot borrow immutable field `z.x` as mutable
22
--> $DIR/issue-39544.rs:21:18
33
|
44
20 | let z = Z { x: X::Y };
5-
| - this should be `mut`
5+
| - consider changing this to `mut z`
66
21 | let _ = &mut z.x;
77
| ^^^
88

0 commit comments

Comments
 (0)