]> git.proxmox.com Git - rustc.git/blob - tests/ui/impl-header-lifetime-elision/path-underscore.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / impl-header-lifetime-elision / path-underscore.rs
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
14 fn impls_my_trait<T: MyTrait>() { }
15
16 fn impls_my_trait_val<T: MyTrait>(_: T) {
17 impls_my_trait::<T>();
18 }
19
20 fn random_where_clause()
21 where for<'a> Foo<'a>: MyTrait { }
22
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 }