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