From 653f57af2085534ced338bd146e2528b81c9fd11 Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Sat, 7 Jun 2014 02:46:35 -0700 Subject: [PATCH] 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. --- .../compile-fail/borrowck-field-sensitivity.rs | 17 +++++++++++++++++ src/test/run-pass/borrowck-field-sensitivity.rs | 14 -------------- 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 3d303625182b..9a0d81e73320 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 7f9a1427d725..2500ec764eba 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();