rust/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
Alex Crichton daf5f5a4d1 Drop the '2' suffix from logging macros
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00

33 lines
779 B
Rust

// Test that we do not permit moves from &[] matched by a vec pattern.
#[deriving(Clone)]
struct Foo {
string: ~str
}
pub fn main() {
let x = ~[
Foo { string: ~"foo" },
Foo { string: ~"bar" },
Foo { string: ~"baz" }
];
match x {
[_, ..tail] => {
match tail {
[Foo { string: a }, Foo { string: b }] => {
//~^ ERROR cannot move out of dereference of & pointer
//~^^ ERROR cannot move out of dereference of & pointer
}
_ => {
unreachable!();
}
}
let z = tail[0].clone();
info!("{:?}", z);
}
_ => {
unreachable!();
}
}
}