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