2019-11-11 10:39:52 +00:00
|
|
|
// Test that moving on both sides of an `@` pattern is not allowed.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
struct U; // Not copy!
|
|
|
|
|
2019-12-14 23:50:44 +00:00
|
|
|
// Prevent promotion:
|
2020-01-19 01:47:01 +00:00
|
|
|
fn u() -> U {
|
|
|
|
U
|
|
|
|
}
|
2019-12-14 23:50:44 +00:00
|
|
|
|
2020-01-19 01:47:01 +00:00
|
|
|
let a @ b = U; //~ ERROR use of moved value
|
2019-11-11 10:39:52 +00:00
|
|
|
|
2020-11-01 18:35:55 +00:00
|
|
|
let a @ (b, c) = (U, U); //~ ERROR use of partially moved value
|
2019-11-11 10:39:52 +00:00
|
|
|
|
2020-11-01 18:35:55 +00:00
|
|
|
let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value
|
2019-12-14 23:50:44 +00:00
|
|
|
|
2019-11-11 10:39:52 +00:00
|
|
|
match Ok(U) {
|
2024-01-21 22:36:33 +00:00
|
|
|
a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value
|
|
|
|
//~^ ERROR use of partially moved value
|
2019-11-11 10:39:52 +00:00
|
|
|
}
|
2019-12-15 02:50:55 +00:00
|
|
|
|
2020-01-19 01:47:01 +00:00
|
|
|
fn fun(a @ b: U) {} //~ ERROR use of moved value
|
2019-12-15 02:50:55 +00:00
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
2020-11-01 18:35:55 +00:00
|
|
|
xs @ [a, .., b] => {} //~ ERROR use of partially moved value
|
2019-12-15 02:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match [u(), u(), u(), u()] {
|
2020-11-01 18:35:55 +00:00
|
|
|
xs @ [_, ys @ .., _] => {} //~ ERROR use of partially moved value
|
2019-12-15 02:50:55 +00:00
|
|
|
}
|
2019-11-11 10:39:52 +00:00
|
|
|
}
|