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