1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that `impl MyTrait for Foo<'_>` works.
17 #![feature(impl_header_lifetime_elision)]
21 struct Foo<'a> { x: &'a u32 }
23 impl MyTrait for Foo<'_> {
26 fn impls_my_trait<T: MyTrait>() { }
28 fn impls_my_trait_val<T: MyTrait>(_: T) {
29 impls_my_trait::<T>();
32 fn random_where_clause()
33 where for<'a> Foo<'a>: MyTrait { }
37 let f = Foo { x: &x };
39 // This type is `Foo<'x>` for a local lifetime `'x`; so the impl
40 // must apply to any lifetime to apply to this.
41 impls_my_trait_val(f);
43 impls_my_trait::<Foo<'static>>();
45 random_where_clause();