1 // run-pass
2 // Test that the lifetime from the enclosing `&` is "inherited"
3 // through the `Box` 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 Box<dyn Test>,
15     u: &'a Box<dyn Test+'a>,
16 }
17 
a<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>)18 fn a<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
19     ss.t = t;
20 }
21 
b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>)22 fn b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
23     ss.u = t;
24 }
25 
26 // see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
27 
d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>)28 fn d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
29     ss.u = t;
30 }
31 
main()32 fn main() {
33 }
34