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(box_patterns)]
12 #![feature(box_syntax)]
13 #![feature(slice_patterns)]
16 let mut vec = [box 1, box 2, box 3];
18 [box ref _a, _, _] => {
19 //~^ borrow of `vec[..]` occurs here
20 vec[0] = box 4; //~ ERROR cannot assign
21 //~^ assignment to borrowed `vec[..]` occurs here
28 let mut vec = vec![box 1, box 2, box 3];
29 let vec: &mut [Box<isize>] = &mut vec;
32 //~^ borrow of `vec[..]` occurs here
33 vec[0] = box 4; //~ ERROR cannot assign
34 //~^ assignment to borrowed `vec[..]` occurs here
41 let mut vec = vec![box 1, box 2, box 3];
42 let vec: &mut [Box<isize>] = &mut vec;
44 &mut [_a, //~ ERROR cannot move out
49 // Note: `_a` is *moved* here, but `b` is borrowing,
52 // See comment in middle/borrowck/gather_loans/mod.rs
53 // in the case covering these sorts of vectors.
57 let a = vec[0]; //~ ERROR cannot move out
58 //~| cannot move out of here
62 let mut vec = vec![box 1, box 2, box 3];
63 let vec: &mut [Box<isize>] = &mut vec;
65 &mut [ //~ ERROR cannot move out
70 let a = vec[0]; //~ ERROR cannot move out
71 //~| cannot move out of here
75 let mut vec = vec![box 1, box 2, box 3];
76 let vec: &mut [Box<isize>] = &mut vec;
78 &mut [_a, _b, _c] => {} //~ ERROR cannot move out
82 let a = vec[0]; //~ ERROR cannot move out
83 //~| cannot move out of here
88 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
89 impl<T> Fake for T { }