]> git.proxmox.com Git - rustc.git/blame - src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs
New upstream version 1.49.0~beta.4+dfsg1
[rustc.git] / src / test / ui / pattern / bindings-after-at / borrowck-move-and-move.rs
CommitLineData
dfeec247
XL
1// Test that moving on both sides of an `@` pattern is not allowed.
2
3#![feature(bindings_after_at)]
4
5fn main() {
6 struct U; // Not copy!
7
8 // Prevent promotion:
74b04a01
XL
9 fn u() -> U {
10 U
11 }
dfeec247 12
74b04a01 13 let a @ b = U; //~ ERROR use of moved value
dfeec247 14
29967ef6 15 let a @ (b, c) = (U, U); //~ ERROR use of partially moved value
dfeec247 16
29967ef6 17 let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value
dfeec247
XL
18
19 match Ok(U) {
74b04a01
XL
20 a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value
21 //~^ ERROR use of moved value
dfeec247
XL
22 }
23
74b04a01 24 fn fun(a @ b: U) {} //~ ERROR use of moved value
dfeec247
XL
25
26 match [u(), u(), u(), u()] {
29967ef6 27 xs @ [a, .., b] => {} //~ ERROR use of partially moved value
dfeec247
XL
28 }
29
30 match [u(), u(), u(), u()] {
29967ef6 31 xs @ [_, ys @ .., _] => {} //~ ERROR use of partially moved value
dfeec247
XL
32 }
33}