summary refs log tree commit diff
path: root/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs
blob: 714a80def9358de21f52a8d8633c88e079919b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
fn a() -> &int {
    let vec = [1, 2, 3, 4];
    let tail = match vec { //~ ERROR illegal borrow
        [_a, ..tail] => &tail[0],
        _ => fail!(~"foo")
    };
    tail
}

fn main() {
    let fifth = a();
    io::println(fmt!("%d", *fifth));
}