Rollup merge of #40841 - arielb1:immutable-blame, r=pnkfelix
borrowck: consolidate `mut` suggestions This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823. Fixes #40859. cc @estebank r? @pnkfelix
This commit is contained in:
commit
a63b1dfa34
23 changed files with 428 additions and 226 deletions
|
|
@ -27,7 +27,7 @@ fn main() {
|
|||
x; //~ value moved here
|
||||
|
||||
let y = Int(2);
|
||||
//~^use `mut y` here to make mutable
|
||||
//~^ consider changing this to `mut y`
|
||||
y //~ error: cannot borrow immutable local variable `y` as mutable
|
||||
//~| cannot borrow
|
||||
+=
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn indirect_write_to_imm_box() {
|
|||
let mut x: isize = 1;
|
||||
let y: Box<_> = box &mut x;
|
||||
let p = &y;
|
||||
***p = 2; //~ ERROR cannot assign to data in an immutable container
|
||||
***p = 2; //~ ERROR cannot assign to data in a `&` reference
|
||||
drop(p);
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,6 @@ fn borrow_in_var_from_var_via_imm_box() {
|
|||
let p = &y;
|
||||
let q = &***p;
|
||||
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -64,7 +63,6 @@ fn borrow_in_var_from_field_via_imm_box() {
|
|||
let p = &y;
|
||||
let q = &***p;
|
||||
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -85,7 +83,6 @@ fn borrow_in_field_from_var_via_imm_box() {
|
|||
let p = &y.a;
|
||||
let q = &***p;
|
||||
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
@ -106,7 +103,6 @@ fn borrow_in_field_from_field_via_imm_box() {
|
|||
let p = &y.a;
|
||||
let q = &***p;
|
||||
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
|
||||
//~^ ERROR cannot assign to data in an immutable container
|
||||
drop(p);
|
||||
drop(q);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ fn main() {
|
|||
match op {
|
||||
Some(ref v) => { let a = &mut v; },
|
||||
//~^ ERROR:cannot borrow immutable
|
||||
//~| use `ref mut v` here to make mutable
|
||||
//~| cannot borrow mutably
|
||||
None => {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ impl S {
|
|||
}
|
||||
|
||||
fn func(arg: S) {
|
||||
//~^ here to make mutable
|
||||
//~^ consider changing this to `mut arg`
|
||||
arg.mutate();
|
||||
//~^ ERROR cannot borrow immutable argument
|
||||
//~| cannot borrow mutably
|
||||
|
|
@ -25,7 +25,7 @@ fn func(arg: S) {
|
|||
|
||||
fn main() {
|
||||
let local = S;
|
||||
//~^ here to make mutable
|
||||
//~^ consider changing this to `mut local`
|
||||
local.mutate();
|
||||
//~^ ERROR cannot borrow immutable local variable
|
||||
//~| cannot borrow mutably
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue