1
Fork 0
rust/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs

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

31 lines
561 B
Rust
Raw Normal View History

// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// Test that the lifetime from the enclosing `&` is "inherited"
// through the `MyBox` struct.
#![allow(dead_code)]
trait Test {
fn foo(&self) { }
}
struct SomeStruct<'a> {
2019-05-28 14:46:13 -04:00
t: &'a MyBox<dyn Test>,
u: &'a MyBox<dyn Test + 'a>,
}
struct MyBox<T:?Sized> {
b: Box<T>
}
2019-05-28 14:46:13 -04:00
fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) {
ss.t = t;
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() {
}