diff --git a/src/test/compile-fail/E0594.rs b/src/test/compile-fail/E0594.rs index 50f115306c8f..f3fbc3b8b54d 100644 --- a/src/test/compile-fail/E0594.rs +++ b/src/test/compile-fail/E0594.rs @@ -15,5 +15,5 @@ static NUM: i32 = 18; fn main() { NUM = 20; //[ast]~ ERROR E0594 - //[mir]~^ ERROR cannot assign to immutable static item + //[mir]~^ ERROR cannot assign to immutable item `NUM` } diff --git a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs b/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs index 57002dd40fc9..76a670af3531 100644 --- a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs +++ b/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs @@ -16,5 +16,5 @@ static foo: isize = 5; fn main() { // assigning to various global constants foo = 6; //[ast]~ ERROR cannot assign to immutable static item - //[mir]~^ ERROR cannot assign to immutable static item `foo` + //[mir]~^ ERROR cannot assign to immutable item `foo` } diff --git a/src/test/compile-fail/borrowck/borrowck-issue-14498.rs b/src/test/compile-fail/borrowck/borrowck-issue-14498.rs index 8b7ccedd6974..8a09ab3fd06c 100644 --- a/src/test/compile-fail/borrowck/borrowck-issue-14498.rs +++ b/src/test/compile-fail/borrowck/borrowck-issue-14498.rs @@ -14,6 +14,9 @@ // Also includes tests of the errors reported when the Box in question // is immutable (#14270). +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + #![feature(box_syntax)] struct A { a: isize } @@ -23,7 +26,8 @@ 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 a `&` reference + ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference + //[mir]~^ ERROR cannot assign to immutable item `***p` drop(p); } @@ -32,7 +36,8 @@ fn borrow_in_var_from_var() { let mut y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -42,7 +47,8 @@ fn borrow_in_var_from_var_via_imm_box() { let y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -52,7 +58,8 @@ fn borrow_in_var_from_field() { let mut y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -62,7 +69,8 @@ fn borrow_in_var_from_field_via_imm_box() { let y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -72,7 +80,8 @@ fn borrow_in_field_from_var() { let mut y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -82,7 +91,8 @@ fn borrow_in_field_from_var_via_imm_box() { let y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -92,7 +102,8 @@ fn borrow_in_field_from_field() { let mut y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -102,7 +113,8 @@ fn borrow_in_field_from_field_via_imm_box() { let y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs index edffa9a8311a..3a4c22eb1395 100644 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs +++ b/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs @@ -70,5 +70,5 @@ fn main() { }; s[2] = 20; //[ast]~^ ERROR cannot assign to immutable indexed content - // FIXME Error for MIR + //[mir]~^^ ERROR cannot assign to immutable item } diff --git a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs index 5ddde6460b01..8eed61ec8d53 100644 --- a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + #![feature(unboxed_closures)] use std::io::Read; @@ -17,9 +21,11 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let x = 1; to_fn_once(move|| { x = 2; }); - //~^ ERROR: cannot assign to immutable captured outer variable + //[ast]~^ ERROR: cannot assign to immutable captured outer variable + //[mir]~^^ ERROR: cannot assign to immutable item `x` let s = std::io::stdin(); to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - //~^ ERROR: cannot borrow immutable captured outer variable + //[ast]~^ ERROR: cannot borrow immutable captured outer variable + //[mir]~^^ ERROR: cannot borrow immutable item `s` as mutable } diff --git a/src/test/compile-fail/issue-5500-1.rs b/src/test/compile-fail/issue-5500-1.rs index 77f4e0bfd891..75ff0a121014 100644 --- a/src/test/compile-fail/issue-5500-1.rs +++ b/src/test/compile-fail/issue-5500-1.rs @@ -20,6 +20,7 @@ fn main() { let _iter = TrieMapIterator{node: &a}; _iter.node = & //[ast]~ ERROR cannot assign to immutable field `_iter.node` //[mir]~^ ERROR cannot assign to immutable field `_iter.node` (Ast) - // FIXME Error for MIR + // MIR doesn't generate an error because the code isn't reachable. This is OK + // because the test is here to check that the compiler doesn't ICE (cf. #5500). panic!() } diff --git a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs index 432c7fa5d1b2..0dbd61413e05 100644 --- a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs +++ b/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.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 + // Test that a by-ref `FnMut` closure gets an error when it tries to // mutate a value. @@ -19,6 +22,7 @@ fn main() { let mut counter = 0; call(|| { counter += 1; - //~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure + //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure + //[mir]~^^ ERROR cannot assign to immutable item `counter` }); }