rust/src/test/compile-fail/alt-vec-illegal-tail-loan.rs
2012-12-18 14:35:53 -08:00

18 lines
294 B
Rust

// xfail-test
fn a() -> &[int] {
let vec = [1, 2, 3, 4];
let tail = match vec {
[_a, ..tail] => tail, //~ ERROR illegal borrow
_ => fail ~"foo"
};
move tail
}
fn main() {
let tail = a();
for tail.each |n| {
io::println(fmt!("%d", *n));
}
}