]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs
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_patterns)]
13 #![feature(box_syntax)]
14 #![feature(slice_patterns)]
17 let mut vec
= [box 1, box 2, box 3];
19 [box ref _a
, _
, _
] => {
20 //~^ borrow of `vec[..]` occurs here
21 vec
[0] = box 4; //~ ERROR cannot assign
22 //~^ 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
40 let mut vec
= vec
!(box 1, box 2, box 3);
41 let vec
: &mut [Box
<isize>] = &mut vec
;
43 &mut [_a
, //~ ERROR cannot move out
48 // Note: `_a` is *moved* here, but `b` is borrowing,
51 // See comment in middle/borrowck/gather_loans/mod.rs
52 // in the case covering these sorts of vectors.
56 let a
= vec
[0]; //~ ERROR cannot move out
57 //~^ NOTE to prevent move
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
67 _b
] => {}
//~ NOTE to prevent move
70 let a
= vec
[0]; //~ ERROR cannot move out
71 //~^ NOTE to prevent move
72 //~| cannot move out of here
76 let mut vec
= vec
!(box 1, box 2, box 3);
77 let vec
: &mut [Box
<isize>] = &mut vec
;
79 &mut [_a
, _b
, _c
] => {}
//~ ERROR cannot move out
81 //~| NOTE to prevent move
86 let a
= vec
[0]; //~ ERROR cannot move out
87 //~^ NOTE to prevent move
88 //~| cannot move out of here