1 // Test various cases where the defaults should lead to errors being
10 struct SomeStruct<'a> {
11 r: Box<dyn SomeTrait+'a>
14 fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
15 // `Box<SomeTrait>` defaults to a `'static` bound, so this return
19 //~^ ERROR lifetime may not live long enough
20 //~| ERROR cannot move out of
23 fn store(ss: &mut SomeStruct, b: Box<dyn SomeTrait>) {
24 // No error: b is bounded by 'static which outlives the
25 // (anonymous) lifetime on the struct.
30 fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) {
31 // Here we override the lifetimes explicitly, and so naturally we get an error.
33 ss.r = b; //~ ERROR explicit lifetime required in the type of `ss` [E0621]