summary refs log tree commit diff
path: root/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs
blob: c35be2f6be62c02f48a9569aa9d02a7085346122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![feature(slice_patterns)]

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);
}