rust/src/test/ui/nll/issue-52113.rs

38 lines
813 B
Rust
Raw Normal View History

2018-07-27 21:46:16 +00:00
#![feature(nll)]
2018-12-11 21:49:40 +00:00
trait Bazinga {}
impl<F> Bazinga for F {}
2018-07-27 21:46:16 +00:00
fn produce1<'a>(data: &'a u32) -> impl Bazinga + 'a {
let x = move || {
let _data: &'a u32 = data;
};
x
}
fn produce2<'a>(data: &'a mut Vec<&'a u32>, value: &'a u32) -> impl Bazinga + 'a {
let x = move || {
let value: &'a u32 = value;
data.push(value);
};
x
}
fn produce3<'a, 'b: 'a>(data: &'a mut Vec<&'a u32>, value: &'b u32) -> impl Bazinga + 'a {
let x = move || {
let value: &'a u32 = value;
data.push(value);
};
x
}
fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b {
2018-09-15 17:30:29 +00:00
let x = move || {
2018-07-27 21:46:16 +00:00
let value: &'a u32 = value;
data.push(value);
2018-07-27 21:46:16 +00:00
};
x //~ ERROR lifetime may not live long enough
2018-07-27 21:46:16 +00:00
}
2018-12-11 21:49:40 +00:00
fn main() {}