1 // Test that `impl MyTrait for Foo<'_>` works.
2 
3 // run-pass
4 
5 #![allow(warnings)]
6 
7 trait MyTrait { }
8 
9 struct Foo<'a> { x: &'a u32 }
10 
11 impl MyTrait for Foo<'_> {
12 }
13 
impls_my_trait<T: MyTrait>()14 fn impls_my_trait<T: MyTrait>() { }
15 
impls_my_trait_val<T: MyTrait>(_: T)16 fn impls_my_trait_val<T: MyTrait>(_: T) {
17     impls_my_trait::<T>();
18 }
19 
random_where_clause() where for<'a> Foo<'a>: MyTrait20 fn random_where_clause()
21 where for<'a> Foo<'a>: MyTrait { }
22 
main()23 fn main() {
24     let x = 22;
25     let f = Foo { x: &x };
26 
27     // This type is `Foo<'x>` for a local lifetime `'x`; so the impl
28     // must apply to any lifetime to apply to this.
29     impls_my_trait_val(f);
30 
31     impls_my_trait::<Foo<'static>>();
32 
33     random_where_clause();
34 }
35