summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs
blob: 39872825cd2a461d832bc074782f9b12c41d921f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
fn a<'a>() -> &'a isize {
    let vec = vec![1, 2, 3, 4];
    let vec: &[isize] = &vec;
    let tail = match vec {
        &[_a, ref tail @ ..] => &tail[0],
        _ => panic!("foo")
    };
    tail //~ ERROR cannot return value referencing local variable `vec`
}

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