1 // Check that closure captures for slice patterns are inferred correctly
3 #![allow(unused_variables)]
7 fn arr_by_ref(x: [String; 3]) {
10 let [ref y, ref z @ ..] = x;
14 // Ensure `x` was borrowed
16 // Ensure that `x` wasn't moved from.
20 fn arr_by_mut(mut x: [String; 3]) {
22 let [ref mut y, ref mut z @ ..] = x;
29 fn arr_by_move(x: [String; 3]) {
36 fn arr_ref_by_ref(x: &[String; 3]) {
39 let [ref y, ref z @ ..] = *x;
52 fn arr_ref_by_mut(x: &mut [String; 3]) {
54 let [ref mut y, ref mut z @ ..] = *x;
60 // Ensure binding mode was chosen correctly:
61 std::mem::swap(y, &mut z[0]);
68 fn arr_box_by_move(x: Box<[String; 3]>) {
75 fn slice_by_ref(x: &[String]) {
78 if let [ref y, ref z @ ..] = *x {}
81 if let [y, z @ ..] = x {}
91 fn slice_by_mut(x: &mut [String]) {
93 if let [ref mut y, ref mut z @ ..] = *x {}
98 if let [y, z @ ..] = x {
99 // Ensure binding mode was chosen correctly:
100 std::mem::swap(y, &mut z[0]);
109 arr_by_ref(Default::default());
110 arr_by_mut(Default::default());
111 arr_by_move(Default::default());
112 arr_ref_by_ref(&Default::default());
113 arr_ref_by_mut(&mut Default::default());
114 arr_box_by_move(Default::default());
115 slice_by_ref(&<[_; 3]>::default());
116 slice_by_mut(&mut <[_; 3]>::default());