2019-11-11 04:39:52 -06:00
|
|
|
// Test that moving on both sides of an `@` pattern is not allowed.
|
|
|
|
|
|
|
|
#![feature(bindings_after_at)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
struct U; // Not copy!
|
|
|
|
|
2019-12-14 17:50:44 -06:00
|
|
|
// Prevent promotion:
|
|
|
|
fn u() -> U { U }
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
let a @ b = U;
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
|
|
|
|
let a @ (b, c) = (U, U);
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
|
2019-12-14 17:50:44 -06:00
|
|
|
let a @ (b, c) = (u(), u());
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
match Ok(U) {
|
|
|
|
a @ Ok(b) | a @ Err(b) => {}
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
//~| ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
}
|
2019-12-14 20:50:55 -06:00
|
|
|
|
|
|
|
fn fun(a @ b: U) {}
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
|
|
|
xs @ [a, .., b] => {}
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
}
|
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
|
|
|
xs @ [_, ys @ .., _] => {}
|
|
|
|
//~^ ERROR cannot bind by-move with sub-bindings
|
|
|
|
//~| ERROR use of moved value
|
|
|
|
}
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|