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:
|
2020-01-18 19:47:01 -06:00
|
|
|
fn u() -> U {
|
|
|
|
U
|
|
|
|
}
|
2019-12-14 17:50:44 -06:00
|
|
|
|
2020-01-18 19:47:01 -06:00
|
|
|
let a @ b = U; //~ ERROR use of moved value
|
2019-11-11 04:39:52 -06:00
|
|
|
|
2020-11-01 12:35:55 -06:00
|
|
|
let a @ (b, c) = (U, U); //~ ERROR use of partially moved value
|
2019-11-11 04:39:52 -06:00
|
|
|
|
2020-11-01 12:35:55 -06:00
|
|
|
let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value
|
2019-12-14 17:50:44 -06:00
|
|
|
|
2019-11-11 04:39:52 -06:00
|
|
|
match Ok(U) {
|
2020-11-01 12:35:55 -06:00
|
|
|
a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value
|
|
|
|
//~^ ERROR use of partially moved value
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|
2019-12-14 20:50:55 -06:00
|
|
|
|
2020-01-18 19:47:01 -06:00
|
|
|
fn fun(a @ b: U) {} //~ ERROR use of moved value
|
2019-12-14 20:50:55 -06:00
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
2020-11-01 12:35:55 -06:00
|
|
|
xs @ [a, .., b] => {} //~ ERROR use of partially moved value
|
2019-12-14 20:50:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
2020-11-01 12:35:55 -06:00
|
|
|
xs @ [_, ys @ .., _] => {} //~ ERROR use of partially moved value
|
2019-12-14 20:50:55 -06:00
|
|
|
}
|
2019-11-11 04:39:52 -06:00
|
|
|
}
|