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

42 lines
842 B
Rust
Raw Normal View History

2018-07-27 16:46:16 -05:00
//
#![allow(warnings)]
#![feature(nll)]
trait Bazinga { }
impl<F> Bazinga for F { }
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 12:30:29 -05:00
let x = move || {
2018-07-27 16:46:16 -05:00
let value: &'a u32 = value;
data.push(value);
};
2018-09-15 12:30:29 -05:00
x //~ ERROR unsatisfied lifetime constraints
2018-07-27 16:46:16 -05:00
}
fn main() { }