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`".
This commit is contained in:
Esteban Küber 2017-03-12 13:49:28 -07:00
parent 6ba494b68b
commit 38b5b29c57
2 changed files with 4 additions and 2 deletions

View File

@ -748,7 +748,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
db.span_label(span, &msg);
}
if let Some(span) = local_def {
db.span_label(span, &"this should be `mut`");
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
db.span_label(span, &format!("consider changing this to `mut {}`", snippet));
}
}
db
}

View File

@ -2,7 +2,7 @@ error: cannot borrow immutable field `z.x` as mutable
--> $DIR/issue-39544.rs:21:18
|
20 | let z = Z { x: X::Y };
| - this should be `mut`
| - consider changing this to `mut z`
21 | let _ = &mut z.x;
| ^^^