]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-move-out-from-array-no-overlap.rs
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
[rust.git] / tests / ui / borrowck / borrowck-move-out-from-array-no-overlap.rs
1 // check-pass
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_one_from_end() {
10     let a = array();
11     let [_, _, _x] = a;
12     let [.., _y, _] = a;
13 }
14
15 fn move_out_from_begin_field_and_end_field() {
16     let a = array();
17     let [_, _, (_x, _)] = a;
18     let [.., (_, _y)] = a;
19 }
20
21 // Const Index + Slice
22
23 fn move_out_by_const_index_and_subslice() {
24     let a = array();
25     let [_x, _, _] = a;
26     let [_, _y @ ..] = a;
27 }
28
29 fn move_out_by_const_index_end_and_subslice() {
30     let a = array();
31     let [.., _x] = a;
32     let [_y @ .., _] = a;
33 }
34
35 fn move_out_by_const_index_field_and_subslice() {
36     let a = array();
37     let [(_x, _), _, _] = a;
38     let [_, _y @ ..] = a;
39 }
40
41 fn move_out_by_const_index_end_field_and_subslice() {
42     let a = array();
43     let [.., (_x, _)] = a;
44     let [_y @ .., _] = a;
45 }
46
47 fn move_out_by_const_subslice_and_index_field() {
48     let a = array();
49     let [_, _y @ ..] = a;
50     let [(_x, _), _, _] = a;
51 }
52
53 fn move_out_by_const_subslice_and_end_index_field() {
54     let a = array();
55     let [_y @ .., _] = a;
56     let [.., (_x, _)] = a;
57 }
58
59 // Slice + Slice
60
61 fn move_out_by_subslice_and_subslice() {
62     let a = array();
63     let [x @ .., _, _] = a;
64     let [_, _y @ ..] = a;
65 }
66
67 fn main() {}