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.
This commit is contained in:
parent
61c81bf00c
commit
653f57af20
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user