use places_conflict to handle reassignment
This fixes the handling of reassignment of struct fields.
This commit is contained in:
parent
97c58ed66c
commit
b64ddecae8
3 changed files with 55 additions and 51 deletions
|
|
@ -8,14 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
fn f(y: Box<isize>) {
|
||||
*y = 5; //~ ERROR cannot assign
|
||||
*y = 5; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign twice
|
||||
}
|
||||
|
||||
fn g() {
|
||||
let _frob = |q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
|
||||
|
||||
let _frob = |q: Box<isize>| { *q = 2; }; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign twice
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
struct cat {
|
||||
meows : usize,
|
||||
how_hungry : isize,
|
||||
|
|
@ -22,5 +25,6 @@ fn cat(in_x : usize, in_y : isize) -> cat {
|
|||
|
||||
fn main() {
|
||||
let nyan : cat = cat(52, 99);
|
||||
nyan.how_hungry = 0; //~ ERROR cannot assign
|
||||
nyan.how_hungry = 0; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue