2015-07-14 18:36:15 -05:00
|
|
|
// 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>,
|
2015-07-14 18:36:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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>) {
|
2022-05-21 13:45:57 -05:00
|
|
|
ss.t = t;
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-07-14 18:36:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|