]> git.proxmox.com Git - rustc.git/blob - tests/ui/borrowck/borrowck-move-out-from-array.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / borrowck / borrowck-move-out-from-array.rs
1 fn array() -> [(String, String); 3] {
2 Default::default()
3 }
4
5 // Const Index + Const Index
6
7 fn move_out_from_begin_and_end() {
8 let a = array();
9 let [_, _, _x] = a;
10 let [.., _y] = a; //~ ERROR [E0382]
11 }
12
13 fn move_out_from_begin_field_and_end() {
14 let a = array();
15 let [_, _, (_x, _)] = a;
16 let [.., _y] = a; //~ ERROR [E0382]
17 }
18
19 fn move_out_from_begin_field_and_end_field() {
20 let a = array();
21 let [_, _, (_x, _)] = a;
22 let [.., (_y, _)] = a; //~ ERROR [E0382]
23 }
24
25 // Const Index + Slice
26
27 fn move_out_by_const_index_and_subslice() {
28 let a = array();
29 let [_x, _, _] = a;
30 let [_y @ .., _, _] = a; //~ ERROR [E0382]
31 }
32
33 fn move_out_by_const_index_end_and_subslice() {
34 let a = array();
35 let [.., _x] = a;
36 let [_, _, _y @ ..] = a; //~ ERROR [E0382]
37 }
38
39 fn move_out_by_const_index_field_and_subslice() {
40 let a = array();
41 let [(_x, _), _, _] = a;
42 let [_y @ .., _, _] = a; //~ ERROR [E0382]
43 }
44
45 fn move_out_by_const_index_end_field_and_subslice() {
46 let a = array();
47 let [.., (_x, _)] = a;
48 let [_, _, _y @ ..] = a; //~ ERROR [E0382]
49 }
50
51 fn move_out_by_subslice_and_const_index_field() {
52 let a = array();
53 let [_y @ .., _, _] = a;
54 let [(_x, _), _, _] = a; //~ ERROR [E0382]
55 }
56
57 fn move_out_by_subslice_and_const_index_end_field() {
58 let a = array();
59 let [_, _, _y @ ..] = a;
60 let [.., (_x, _)] = a; //~ ERROR [E0382]
61 }
62
63 // Slice + Slice
64
65 fn move_out_by_subslice_and_subslice() {
66 let a = array();
67 let [x @ .., _] = a;
68 let [_, _y @ ..] = a; //~ ERROR [E0382]
69 }
70
71 fn main() {}