about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@mozilla.com>2014-06-07 02:46:35 -0700
committerCameron Zwarich <zwarich@mozilla.com>2014-06-07 03:03:03 -0700
commit653f57af2085534ced338bd146e2528b81c9fd11 (patch)
tree232edcaaf6bf85cac8c2e906e78090fe89cd0d9c
parent61c81bf00cc8f8a87940fce3ba7be0bfd66cf04f (diff)
downloadrust-653f57af2085534ced338bd146e2528b81c9fd11.tar.gz
rust-653f57af2085534ced338bd146e2528b81c9fd11.zip
Fix bad borrowck tests and move them from run-pass to compile-fail
The move_after_borrow / fu_move_after_borrow tests in
run-pass/borrowck-field-sensitivity.rs are not testing the right thing,
since the scope of the borrow is limited to the call to borrow(). When
fixed, these tests fail and thus should be moved to the corresponding
compile-fail test file.
-rw-r--r--src/test/compile-fail/borrowck-field-sensitivity.rs17
-rw-r--r--src/test/run-pass/borrowck-field-sensitivity.rs14
2 files changed, 17 insertions, 14 deletions
diff --git a/src/test/compile-fail/borrowck-field-sensitivity.rs b/src/test/compile-fail/borrowck-field-sensitivity.rs
index 3d303625182..9a0d81e7332 100644
--- a/src/test/compile-fail/borrowck-field-sensitivity.rs
+++ b/src/test/compile-fail/borrowck-field-sensitivity.rs
@@ -84,6 +84,20 @@ fn fu_move_after_fu_move() {
 
 // The following functions aren't yet accepted, but they should be.
 
+fn move_after_borrow_correct() {
+    let x = A { a: 1, b: box 2 };
+    let p = &x.a;
+    drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed
+    drop(*p);
+}
+
+fn fu_move_after_borrow_correct() {
+    let x = A { a: 1, b: box 2 };
+    let p = &x.a;
+    let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
+    drop(*p);
+}
+
 fn copy_after_field_assign_after_uninit() {
     let mut x: A;
     x.a = 1;
@@ -117,6 +131,9 @@ fn main() {
     fu_move_after_move();
     fu_move_after_fu_move();
 
+    move_after_borrow_correct();
+    fu_move_after_borrow_correct();
+
     copy_after_field_assign_after_uninit();
     borrow_after_field_assign_after_uninit();
     move_after_field_assign_after_uninit();
diff --git a/src/test/run-pass/borrowck-field-sensitivity.rs b/src/test/run-pass/borrowck-field-sensitivity.rs
index 7f9a1427d72..2500ec764eb 100644
--- a/src/test/run-pass/borrowck-field-sensitivity.rs
+++ b/src/test/run-pass/borrowck-field-sensitivity.rs
@@ -73,18 +73,6 @@ fn borrow_after_fu_move() {
     borrow(&x.a);
 }
 
-fn move_after_borrow() {
-    let x = A { a: 1, b: box 2 };
-    borrow(&x.a);
-    drop(x.b);
-}
-
-fn fu_move_after_borrow() {
-    let x = A { a: 1, b: box 2 };
-    borrow(&x.a);
-    let _y = A { a: 3, .. x };
-}
-
 fn mut_borrow_after_mut_borrow() {
     let mut x = A { a: 1, b: box 2 };
     let y = &mut x.a;
@@ -232,8 +220,6 @@ fn main() {
 
     borrow_after_move();
     borrow_after_fu_move();
-    move_after_borrow();
-    fu_move_after_borrow();
     mut_borrow_after_mut_borrow();
 
     move_after_move();