]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
test: Make manual changes to deal with the fallout from removal of
[rust.git] / src / test / compile-fail / borrowck-move-out-of-vec-tail.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.
4 //
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.
10
11 // Test that we do not permit moves from &[] matched by a vec pattern.
12
13 #[deriving(Clone)]
14 struct Foo {
15     string: ~str
16 }
17
18 pub fn main() {
19     let x = vec!(
20         Foo { string: ~"foo" },
21         Foo { string: ~"bar" },
22         Foo { string: ~"baz" }
23     );
24     let x: &[Foo] = x.as_slice();
25     match x {
26         [_, ..tail] => {
27             match tail {
28                 [Foo { string: a }, Foo { string: b }] => {
29                     //~^ ERROR cannot move out of dereference of `&`-pointer
30                     //~^^ ERROR cannot move out of dereference of `&`-pointer
31                 }
32                 _ => {
33                     unreachable!();
34                 }
35             }
36             let z = tail[0].clone();
37             println!("{:?}", z);
38         }
39         _ => {
40             unreachable!();
41         }
42     }
43 }