1 // run-pass 2 // Test that the lifetime from the enclosing `&` is "inherited" 3 // through the `MyBox` struct. 4 5 // pretty-expanded FIXME #23616 6 7 #![allow(dead_code)] 8 9 trait Test { foo(&self)10 fn foo(&self) { } 11 } 12 13 struct SomeStruct<'a> { 14 t: &'a MyBox<dyn Test>, 15 u: &'a MyBox<dyn Test+'a>, 16 } 17 18 struct MyBox<T:?Sized> { 19 b: Box<T> 20 } 21 a<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>)22fn a<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) { 23 ss.t = t; 24 } 25 b<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>)26fn b<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) { 27 ss.u = t; 28 } 29 30 // see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs 31 d<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>)32fn d<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { 33 ss.u = t; 34 } 35 main()36fn main() { 37 } 38