]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / pattern / bindings-after-at / borrowck-move-and-move.rs
1 // Test that moving on both sides of an `@` pattern is not allowed.
2
3 #![feature(bindings_after_at)]
4
5 fn main() {
6     struct U; // Not copy!
7
8     // Prevent promotion:
9     fn u() -> U { U }
10
11     let a @ b = U;
12     //~^ ERROR cannot bind by-move with sub-bindings
13     //~| ERROR use of moved value
14
15     let a @ (b, c) = (U, U);
16     //~^ ERROR cannot bind by-move with sub-bindings
17     //~| ERROR use of moved value
18
19     let a @ (b, c) = (u(), u());
20     //~^ ERROR cannot bind by-move with sub-bindings
21     //~| ERROR use of moved value
22
23     match Ok(U) {
24         a @ Ok(b) | a @ Err(b) => {}
25         //~^ ERROR cannot bind by-move with sub-bindings
26         //~| ERROR use of moved value
27         //~| ERROR cannot bind by-move with sub-bindings
28         //~| ERROR use of moved value
29     }
30
31     fn fun(a @ b: U) {}
32     //~^ ERROR cannot bind by-move with sub-bindings
33     //~| ERROR use of moved value
34
35     match [u(), u(), u(), u()] {
36         xs @ [a, .., b] => {}
37         //~^ ERROR cannot bind by-move with sub-bindings
38         //~| ERROR use of moved value
39     }
40
41     match [u(), u(), u(), u()] {
42         xs @ [_, ys @ .., _] => {}
43         //~^ ERROR cannot bind by-move with sub-bindings
44         //~| ERROR use of moved value
45     }
46 }