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