about summary refs log tree commit diff
path: root/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs
blob: e542238d035665c2b56f238f167877663d939223 (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 {
        [_a, ..tail] => &tail[0], //~ ERROR borrowed value does not live long enough
        _ => fail!("foo")
    };
    tail
}

fn main() {
    let fifth = a();
    println!("{}", *fifth);
}