]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-header-lifetime-elision/path-underscore.rs
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
[rust.git] / src / test / ui / impl-header-lifetime-elision / path-underscore.rs
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.
4 //
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.
10
11 // Test that `impl MyTrait for Foo<'_>` works.
12
13 // run-pass
14
15 #![allow(warnings)]
16
17 #![feature(impl_header_lifetime_elision)]
18
19 trait MyTrait { }
20
21 struct Foo<'a> { x: &'a u32 }
22
23 impl MyTrait for Foo<'_> {
24 }
25
26 fn impls_my_trait<T: MyTrait>() { }
27
28 fn impls_my_trait_val<T: MyTrait>(_: T) {
29     impls_my_trait::<T>();
30 }
31
32 fn random_where_clause()
33 where for<'a> Foo<'a>: MyTrait { }
34
35 fn main() {
36     let x = 22;
37     let f = Foo { x: &x };
38
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);
42
43     impls_my_trait::<Foo<'static>>();
44
45     random_where_clause();
46 }