1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(advanced_slice_patterns)]
12 #![feature(box_syntax)]
15 let mut vec = [box 1, box 2, box 3];
17 [box ref _a, _, _] => {
18 vec[0] = box 4; //~ ERROR cannot assign
24 let mut vec = vec!(box 1, box 2, box 3);
25 let vec: &mut [Box<isize>] = vec.as_mut_slice();
28 vec[0] = box 4; //~ ERROR cannot assign
34 let mut vec = vec!(box 1, box 2, box 3);
35 let vec: &mut [Box<isize>] = vec.as_mut_slice();
37 [_a, //~ ERROR cannot move out
38 _b..] => { //~^ NOTE attempting to move value to here
40 // Note: `_a` is *moved* here, but `b` is borrowing,
43 // See comment in middle/borrowck/gather_loans/mod.rs
44 // in the case covering these sorts of vectors.
48 let a = vec[0]; //~ ERROR cannot move out
52 let mut vec = vec!(box 1, box 2, box 3);
53 let vec: &mut [Box<isize>] = vec.as_mut_slice();
55 [_a.., //~ ERROR cannot move out
56 _b] => {} //~ NOTE attempting to move value to here
59 let a = vec[0]; //~ ERROR cannot move out
63 let mut vec = vec!(box 1, box 2, box 3);
64 let vec: &mut [Box<isize>] = vec.as_mut_slice();
66 [_a, _b, _c] => {} //~ ERROR cannot move out
67 //~^ NOTE attempting to move value to here
72 let a = vec[0]; //~ ERROR cannot move out
73 //~^ NOTE attempting to move value to here