1 // Ensure that we cannot move out of a reference to a fixed-size array
5 impl Drop for D { fn drop(&mut self) { } }
7 fn move_elem(a: &[D; 4]) -> D {
8 let [_, e, _, _] = *a; //~ ERROR cannot move
12 fn move_subarr(a: &[D; 4]) -> [D; 2] {
13 let [_, s @ .. , _] = *a; //~ ERROR cannot move
17 fn move_elem_mut(a: &mut [D; 4]) -> D {
18 let [_, e, _, _] = *a; //~ ERROR cannot move
22 fn move_subarr_mut(a: &mut [D; 4]) -> [D; 2] {
23 let [_, s @ .. , _] = *a; //~ ERROR cannot move
28 fn d() -> D { D { _x: 0 } }
30 move_elem(&[d(), d(), d(), d()]);
31 move_subarr(&[d(), d(), d(), d()]);
32 move_elem_mut(&mut [d(), d(), d(), d()]);
33 move_subarr_mut(&mut [d(), d(), d(), d()]);