rust/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
361 B
Rust
Raw Normal View History

2022-05-22 06:05:15 +00:00
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
struct Ref<'a, T: 'a> {
data: &'a T
}
fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
let z = Ref { data: y.data };
2022-05-22 06:05:15 +00:00
x.push(z);
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() { }