]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-move-out-from-array-use-no-overlap-match.rs
CommitLineData
dfeec247
XL
1// Due to #53114, which causes a "read" of the `_` patterns,
2// the borrow-checker refuses this code, while it should probably be allowed.
3// Once the bug is fixed, the test, which is derived from a
4// passing test for `let` statements, should become check-pass.
5
6fn array() -> [(String, String); 3] {
7 Default::default()
8}
9
10// Const Index + Const Index
11
12fn move_out_from_begin_and_one_from_end() {
13 let a = array();
14 match a {
15 [_, _, _x] => {}
16 }
17 match a {
1b1a35ee 18 //~^ ERROR use of partially moved value
dfeec247
XL
19 [.., ref _y, _] => {}
20 }
21}
22
23fn move_out_from_begin_field_and_end_field() {
24 let a = array();
25 match a {
26 [_, _, (_x, _)] => {}
27 }
28 match a {
1b1a35ee 29 //~^ ERROR use of partially moved value
dfeec247
XL
30 [.., (_, ref _y)] => {}
31 }
32}
33
34// Const Index + Slice
35
36fn move_out_by_const_index_and_subslice() {
37 let a = array();
38 match a {
39 [_x, _, _] => {}
40 }
41 match a {
1b1a35ee 42 //~^ ERROR use of partially moved value
dfeec247
XL
43 [_, ref _y @ ..] => {}
44 }
45}
46
47fn move_out_by_const_index_end_and_subslice() {
48 let a = array();
49 match a {
50 [.., _x] => {}
51 }
52 match a {
1b1a35ee 53 //~^ ERROR use of partially moved value
dfeec247
XL
54 [ref _y @ .., _] => {}
55 }
56}
57
58fn move_out_by_const_index_field_and_subslice() {
59 let a = array();
60 match a {
61 [(_x, _), _, _] => {}
62 }
63 match a {
1b1a35ee 64 //~^ ERROR use of partially moved value
dfeec247
XL
65 [_, ref _y @ ..] => {}
66 }
67}
68
69fn move_out_by_const_index_end_field_and_subslice() {
70 let a = array();
71 match a {
72 [.., (_x, _)] => {}
73 }
74 match a {
1b1a35ee 75 //~^ ERROR use of partially moved value
dfeec247
XL
76 [ref _y @ .., _] => {}
77 }
78}
79
80fn move_out_by_const_subslice_and_index_field() {
81 let a = array();
82 match a {
83 [_, _y @ ..] => {}
84 }
85 match a {
1b1a35ee 86 //~^ ERROR use of partially moved value
dfeec247
XL
87 [(ref _x, _), _, _] => {}
88 }
89}
90
91fn move_out_by_const_subslice_and_end_index_field() {
92 let a = array();
93 match a {
94 [_y @ .., _] => {}
95 }
96 match a {
1b1a35ee 97 //~^ ERROR use of partially moved value
dfeec247
XL
98 [.., (ref _x, _)] => {}
99 }
100}
101
102// Slice + Slice
103
104fn move_out_by_subslice_and_subslice() {
105 let a = array();
106 match a {
107 [x @ .., _, _] => {}
108 }
109 match a {
1b1a35ee 110 //~^ ERROR use of partially moved value
dfeec247
XL
111 [_, ref _y @ ..] => {}
112 }
113}
114
115fn main() {}