2015-01-08 04:54:35 -06:00
|
|
|
fn a<'a>() -> &'a isize {
|
2016-10-29 16:54:04 -05:00
|
|
|
let vec = vec![1, 2, 3, 4];
|
2019-04-22 02:40:08 -05:00
|
|
|
let vec: &[isize] = &vec;
|
2013-03-15 14:24:24 -05:00
|
|
|
let tail = match vec {
|
2019-07-07 18:47:46 -05:00
|
|
|
&[_a, ref tail @ ..] => &tail[0],
|
2014-10-09 14:17:22 -05:00
|
|
|
_ => panic!("foo")
|
2012-12-15 17:13:55 -06:00
|
|
|
};
|
2019-04-22 02:40:08 -05:00
|
|
|
tail //~ ERROR cannot return value referencing local variable `vec`
|
2012-12-15 17:13:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let fifth = a();
|
2013-09-25 00:16:43 -05:00
|
|
|
println!("{}", *fifth);
|
2012-12-15 17:13:55 -06:00
|
|
|
}
|