rust/tests/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.

26 lines
428 B
Rust
Raw Normal View History

// 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 13:46:13 -05:00
t: &'a MyBox<dyn Test>,
u: &'a MyBox<dyn Test + 'a>,
}
struct MyBox<T:?Sized> {
b: Box<T>
}
2019-05-28 13:46:13 -05:00
fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) {
ss.t = t;
2022-04-01 12:13:25 -05:00
//~^ ERROR lifetime may not live long enough
}
fn main() {
}