]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
[rust.git] / tests / ui / borrowck / borrowck-vec-pattern-tail-element-loan.rs
1 fn a<'a>() -> &'a isize {
2     let vec = vec![1, 2, 3, 4];
3     let vec: &[isize] = &vec;
4     let tail = match vec {
5         &[_a, ref tail @ ..] => &tail[0],
6         _ => panic!("foo")
7     };
8     tail //~ ERROR cannot return value referencing local variable `vec`
9 }
10
11 fn main() {
12     let fifth = a();
13     println!("{}", *fifth);
14 }