about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/compile-fail/borrowck-field-sensitivity.rs29
-rw-r--r--src/test/run-pass/borrowck-field-sensitivity.rs31
2 files changed, 33 insertions, 27 deletions
diff --git a/src/test/compile-fail/borrowck-field-sensitivity.rs b/src/test/compile-fail/borrowck-field-sensitivity.rs
index 9a0d81e7332..2fa9067af54 100644
--- a/src/test/compile-fail/borrowck-field-sensitivity.rs
+++ b/src/test/compile-fail/borrowck-field-sensitivity.rs
@@ -10,8 +10,6 @@
 
 struct A { a: int, b: Box<int> }
 
-fn borrow<T>(_: &T) { }
-
 fn deref_after_move() {
     let x = A { a: 1, b: box 2 };
     drop(x.b);
@@ -27,35 +25,37 @@ fn deref_after_fu_move() {
 fn borrow_after_move() {
     let x = A { a: 1, b: box 2 };
     drop(x.b);
-    borrow(&x.b); //~ ERROR use of moved value: `x.b`
+    let p = &x.b; //~ ERROR use of moved value: `x.b`
+    drop(**p);
 }
 
 fn borrow_after_fu_move() {
     let x = A { a: 1, b: box 2 };
     let _y = A { a: 3, .. x };
-    borrow(&x.b); //~ ERROR use of moved value: `x.b`
+    let p = &x.b; //~ ERROR use of moved value: `x.b`
+    drop(**p);
 }
 
 fn move_after_borrow() {
     let x = A { a: 1, b: box 2 };
-    let y = &x.b;
+    let p = &x.b;
     drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed
-    borrow(&*y);
+    drop(**p);
 }
 
 fn fu_move_after_borrow() {
     let x = A { a: 1, b: box 2 };
-    let y = &x.b;
-    let _z = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
-    borrow(&*y);
+    let p = &x.b;
+    let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
+    drop(**p);
 }
 
 fn mut_borrow_after_mut_borrow() {
     let mut x = A { a: 1, b: box 2 };
-    let y = &mut x.a;
-    let z = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time
-    drop(*y);
-    drop(*z);
+    let p = &mut x.a;
+    let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time
+    drop(*p);
+    drop(*q);
 }
 
 fn move_after_move() {
@@ -107,7 +107,8 @@ fn copy_after_field_assign_after_uninit() {
 fn borrow_after_field_assign_after_uninit() {
     let mut x: A;
     x.a = 1;
-    borrow(&x.a); //~ ERROR use of possibly uninitialized variable: `x.a`
+    let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a`
+    drop(*p);
 }
 
 fn 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 2500ec764eb..a297300daf1 100644
--- a/src/test/run-pass/borrowck-field-sensitivity.rs
+++ b/src/test/run-pass/borrowck-field-sensitivity.rs
@@ -11,8 +11,6 @@
 struct A { a: int, b: Box<int> }
 struct B { a: Box<int>, b: Box<int> }
 
-fn borrow<T>(_: &T) { }
-
 fn move_after_copy() {
     let x = A { a: 1, b: box 2 };
     drop(x.a);
@@ -64,21 +62,23 @@ fn fu_copy_after_fu_move() {
 fn borrow_after_move() {
     let x = A { a: 1, b: box 2 };
     drop(x.b);
-    borrow(&x.a);
+    let p = &x.a;
+    drop(*p);
 }
 
 fn borrow_after_fu_move() {
     let x = A { a: 1, b: box 2 };
     let _y = A { a: 3, .. x };
-    borrow(&x.a);
+    let p = &x.a;
+    drop(*p);
 }
 
 fn mut_borrow_after_mut_borrow() {
     let mut x = A { a: 1, b: box 2 };
-    let y = &mut x.a;
-    let z = &mut x.b;
-    drop(*y);
-    drop(**z);
+    let p = &mut x.a;
+    let q = &mut x.b;
+    drop(*p);
+    drop(**q);
 }
 
 fn move_after_move() {
@@ -138,28 +138,32 @@ fn borrow_after_assign_after_move() {
     let mut x = A { a: 1, b: box 2 };
     drop(x.b);
     x = A { a: 3, b: box 4 };
-    borrow(&x.b);
+    let p = &x.b;
+    drop(**p);
 }
 
 fn borrow_after_assign_after_fu_move() {
     let mut x = A { a: 1, b: box 2 };
     let _y = A { a: 3, .. x };
     x = A { a: 3, b: box 4 };
-    borrow(&x.b);
+    let p = &x.b;
+    drop(**p);
 }
 
 fn borrow_after_field_assign_after_move() {
     let mut x = A { a: 1, b: box 2 };
     drop(x.b);
     x.b = box 3;
-    borrow(&x.b);
+    let p = &x.b;
+    drop(**p);
 }
 
 fn borrow_after_field_assign_after_fu_move() {
     let mut x = A { a: 1, b: box 2 };
     let _y = A { a: 3, .. x };
     x.b = box 3;
-    borrow(&x.b);
+    let p = &x.b;
+    drop(**p);
 }
 
 fn move_after_assign_after_move() {
@@ -199,7 +203,8 @@ fn copy_after_assign_after_uninit() {
 fn borrow_after_assign_after_uninit() {
     let mut x: A;
     x = A { a: 1, b: box 2 };
-    borrow(&x.a);
+    let p = &x.a;
+    drop(*p);
 }
 
 fn move_after_assign_after_uninit() {