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
|
|
|
&[_, ref tail @ ..] => tail,
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("a")
|
2012-12-08 20:22:43 +00:00
|
|
|
};
|
2019-04-22 08:40:08 +01:00
|
|
|
tail //~ ERROR cannot return value referencing local variable `vec`
|
2012-12-08 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn b<'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 init = match vec {
|
2019-07-08 01:47:46 +02:00
|
|
|
&[ref init @ .., _] => init,
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("b")
|
2013-02-27 03:58:46 +09:00
|
|
|
};
|
2019-04-22 08:40:08 +01:00
|
|
|
init //~ ERROR cannot return value referencing local variable `vec`
|
2012-12-08 20:22:43 +00:00
|
|
|
}
|
2013-02-27 03:58:46 +09:00
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn c<'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 slice = match vec {
|
2019-07-08 01:47:46 +02:00
|
|
|
&[_, ref slice @ .., _] => slice,
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("c")
|
2013-02-27 03:58:46 +09:00
|
|
|
};
|
2019-04-22 08:40:08 +01:00
|
|
|
slice //~ ERROR cannot return value referencing local variable `vec`
|
2013-02-27 03:58:46 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|