2 // Test that the lifetime of the enclosing `&` is used for the object
5 // pretty-expanded FIXME #23616
15 struct Ref<'a,T:'a+?Sized> {
19 struct Ref2<'a,'b,T:'a+'b+?Sized> {
24 struct SomeStruct<'a> {
26 u: Ref<'a, dyn Test+'a>,
29 fn a<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) {
33 fn b<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) {
37 fn c<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) {
41 fn d<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) {
45 fn e<'a>(_: Ref<'a, dyn Display+'static>) {}
46 fn g<'a, 'b>(_: Ref2<'a, 'b, dyn Display+'static>) {}
50 // Inside a function body, we can just infer all
51 // lifetimes, to allow Ref<'tmp, Display+'static>
52 // and Ref2<'tmp, 'tmp, Display+'static>.
53 let x = &0 as &(dyn Display+'static);
54 let r: Ref<dyn Display> = Ref { r: x };
55 let r2: Ref2<dyn Display> = Ref2 { a: x, b: x };