1 // Check that closure captures for slice patterns are inferred correctly
3 fn arr_by_ref(mut x: [String; 3]) {
5 let [ref y, ref z @ ..] = x;
8 //~^ ERROR cannot borrow
12 fn arr_by_mut(mut x: [String; 3]) {
14 let [ref mut y, ref mut z @ ..] = x;
17 //~^ ERROR cannot borrow
21 fn arr_by_move(x: [String; 3]) {
26 //~^ ERROR borrow of moved value
29 fn arr_ref_by_ref(x: &mut [String; 3]) {
31 let [ref y, ref z @ ..] = *x;
34 //~^ ERROR cannot borrow
38 fn arr_ref_by_uniq(x: &mut [String; 3]) {
40 let [ref mut y, ref mut z @ ..] = *x;
43 //~^ ERROR cannot borrow
47 fn arr_box_by_move(x: Box<[String; 3]>) {
52 //~^ ERROR borrow of moved value
55 fn slice_by_ref(x: &mut [String]) {
57 if let [ref y, ref z @ ..] = *x {}
60 //~^ ERROR cannot borrow
64 fn slice_by_uniq(x: &mut [String]) {
66 if let [ref mut y, ref mut z @ ..] = *x {}
69 //~^ ERROR cannot borrow
74 arr_by_ref(Default::default());
75 arr_by_mut(Default::default());
76 arr_by_move(Default::default());
77 arr_ref_by_ref(&mut Default::default());
78 arr_ref_by_uniq(&mut Default::default());
79 arr_box_by_move(Default::default());
80 slice_by_ref(&mut <[_; 3]>::default());
81 slice_by_uniq(&mut <[_; 3]>::default());