about summary refs log tree commit diff
path: root/src/test/compile-fail
diff options
context:
space:
mode:
authorBasile Desloges <basile.desloges@gmail.com>2017-11-22 18:15:56 +0100
committerBasile Desloges <basile.desloges@gmail.com>2017-11-28 16:19:44 +0100
commit1cd9d74a2d1998c18761369cad3d9dd53916bf9f (patch)
treef417cfcb67e1e043df0482ce0edaf4824379b6da /src/test/compile-fail
parent34f56c44a9a9d027964fe992ce966ad407c1d9f3 (diff)
downloadrust-1cd9d74a2d1998c18761369cad3d9dd53916bf9f.tar.gz
rust-1cd9d74a2d1998c18761369cad3d9dd53916bf9f.zip
mir-borrowck: Update tests
Diffstat (limited to 'src/test/compile-fail')
-rw-r--r--src/test/compile-fail/E0594.rs2
-rw-r--r--src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs2
-rw-r--r--src/test/compile-fail/borrowck/borrowck-issue-14498.rs30
-rw-r--r--src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs2
-rw-r--r--src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs10
-rw-r--r--src/test/compile-fail/issue-5500-1.rs3
-rw-r--r--src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs6
7 files changed, 39 insertions, 16 deletions
diff --git a/src/test/compile-fail/E0594.rs b/src/test/compile-fail/E0594.rs
index 50f115306c8..f3fbc3b8b54 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 57002dd40fc..76a670af353 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 8b7ccedd697..8a09ab3fd06 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 edffa9a8311..3a4c22eb139 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 5ddde6460b0..8eed61ec8d5 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<A,F:FnOnce<A>>(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 77f4e0bfd89..75ff0a12101 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 432c7fa5d1b..0dbd61413e0 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`
     });
 }