2015-01-08 10:54:35 +00:00
|
|
|
fn a<'a>() -> &'a isize {
|
2016-10-29 21:54:04 +00:00
|
|
|
let vec = vec![1, 2, 3, 4];
|
2019-04-22 07:40:08 +00:00
|
|
|
let vec: &[isize] = &vec;
|
2013-03-15 19:24:24 +00:00
|
|
|
let tail = match vec {
|
2019-07-07 23:47:46 +00:00
|
|
|
&[_a, ref tail @ ..] => &tail[0],
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("foo")
|
2012-12-15 23:13:55 +00:00
|
|
|
};
|
2019-04-22 07:40:08 +00: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-25 05:16:43 +00:00
|
|
|
println!("{}", *fifth);
|
2012-12-15 23:13:55 +00:00
|
|
|
}
|