From b64ddecae8112ca41d9a37ed8a3ebfd388b7e453 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Thu, 7 Dec 2017 20:48:12 +0200 Subject: use `places_conflict` to handle reassignment This fixes the handling of reassignment of struct fields. --- src/test/compile-fail/immut-function-arguments.rs | 9 ++++++--- src/test/compile-fail/mutable-class-fields.rs | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs index 949c1c0d9c4..b32056fcb91 100644 --- a/src/test/compile-fail/immut-function-arguments.rs +++ b/src/test/compile-fail/immut-function-arguments.rs @@ -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) { - *y = 5; //~ ERROR cannot assign + *y = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign twice } fn g() { - let _frob = |q: Box| { *q = 2; }; //~ ERROR cannot assign - + let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign twice } fn main() {} diff --git a/src/test/compile-fail/mutable-class-fields.rs b/src/test/compile-fail/mutable-class-fields.rs index c163dc2b4d2..f138ae93f71 100644 --- a/src/test/compile-fail/mutable-class-fields.rs +++ b/src/test/compile-fail/mutable-class-fields.rs @@ -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 } -- cgit 1.4.1-3-g733a5