2020-01-18 19:47:01 -06:00
|
|
|
// Test that `ref mut? @ pat_with_by_move_bindings` is prevented.
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
fn main() {
|
2020-01-18 19:47:01 -06:00
|
|
|
struct U;
|
|
|
|
|
|
|
|
// Prevent promotion.
|
|
|
|
fn u() -> U {
|
|
|
|
U
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f1(ref a @ b: U) {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of moved value
|
|
|
|
//~| ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
fn f3(ref mut a @ [b, mut c]: [U; 2]) {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of partially moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
let ref a @ b = U;
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
let ref a @ (ref b @ mut c, ref d @ e) = (U, U);
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
let ref mut a @ [b, mut c] = [U, U];
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of partially moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
let ref a @ b = u();
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
let ref a @ (ref b @ mut c, ref d @ e) = (u(), u());
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of moved value
|
|
|
|
//~| ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
let ref mut a @ [b, mut c] = [u(), u()];
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of partially moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
match Some(U) {
|
|
|
|
ref a @ Some(b) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
match Some((U, U)) {
|
|
|
|
ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
match Some([U, U]) {
|
|
|
|
ref mut a @ Some([b, mut c]) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
match Some(u()) {
|
|
|
|
ref a @ Some(b) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
match Some((u(), u())) {
|
|
|
|
ref a @ Some((ref b @ mut c, ref d @ e)) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
|
|
|
//~| ERROR cannot move out of value because it is borrowed
|
2020-11-01 12:35:55 -06:00
|
|
|
//~| ERROR borrow of moved value
|
|
|
|
//~| ERROR borrow of moved value
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
match Some([u(), u()]) {
|
|
|
|
ref mut a @ Some([b, mut c]) => {}
|
2020-02-02 10:58:15 -06:00
|
|
|
//~^ ERROR cannot move out of value because it is borrowed
|
2020-01-18 19:47:01 -06:00
|
|
|
None => {}
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|
|
|
|
}
|