1
Fork 0

Factor out suggest_ref_mut; use it in rustc_borrowck

Also teach rustc_borrowck not to show useless help messages like
"use a mutable reference instead: `x`".
This commit is contained in:
ashtneoi 2018-07-12 15:39:36 -07:00
parent 323df7b504
commit 531a68cea7
5 changed files with 27 additions and 39 deletions

View file

@ -1,24 +1,18 @@
error[E0594]: cannot assign to immutable borrowed content `*x`
--> $DIR/enum.rs:19:5
|
LL | let Wrap(x) = &Wrap(3);
| - help: use a mutable reference instead: `x`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to immutable borrowed content `*x`
--> $DIR/enum.rs:23:9
|
LL | if let Some(x) = &Some(3) {
| - help: use a mutable reference instead: `x`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to immutable borrowed content `*x`
--> $DIR/enum.rs:29:9
|
LL | while let Some(x) = &Some(3) {
| - help: use a mutable reference instead: `x`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable

View file

@ -1,24 +1,18 @@
error[E0594]: cannot assign to immutable borrowed content `*n`
--> $DIR/explicit-mut.rs:17:13
|
LL | Some(n) => {
| - help: use a mutable reference instead: `n`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to immutable borrowed content `*n`
--> $DIR/explicit-mut.rs:25:13
|
LL | Some(n) => {
| - help: use a mutable reference instead: `n`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to immutable borrowed content `*n`
--> $DIR/explicit-mut.rs:33:13
|
LL | Some(n) => {
| - help: use a mutable reference instead: `n`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^ cannot borrow as mutable