1 // Test that the lifetime from the enclosing `&` is "inherited" 2 // through the `MyBox` struct. 3 4 #![allow(dead_code)] 5 #![feature(rustc_error)] 6 7 trait Test { foo(&self)8 fn foo(&self) { } 9 } 10 11 struct SomeStruct<'a> { 12 t: &'a MyBox<dyn Test>, 13 u: &'a MyBox<dyn Test + 'a>, 14 } 15 16 struct MyBox<T:?Sized> { 17 b: Box<T> 18 } 19 c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>)20fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { 21 ss.t = t; //~ ERROR mismatched types 22 } 23 main()24fn main() { 25 } 26