]> git.lizzy.rs Git - rust.git/blob - tests/ui/higher-rank-trait-bounds/hrtb-type-outlives.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / higher-rank-trait-bounds / hrtb-type-outlives.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 // Test what happens when a HR obligation is applied to an impl with
5 // "outlives" bounds. Currently we're pretty conservative here; this
6 // will probably improve in time.
7
8 trait Foo<X> {
9     fn foo(&self, x: X) { }
10 }
11
12 fn want_foo<T>()
13     where T : for<'a> Foo<&'a isize>
14 {
15 }
16
17 // Expressed as a where clause
18
19 struct SomeStruct<X> {
20     x: X
21 }
22
23 impl<'a,X> Foo<&'a isize> for SomeStruct<X>
24     where X : 'a
25 {
26 }
27
28 fn one() {
29     want_foo::<SomeStruct<usize>>();
30 }
31
32 // Expressed as shorthand
33
34 struct AnotherStruct<X> {
35     x: X
36 }
37
38 impl<'a,X:'a> Foo<&'a isize> for AnotherStruct<X>
39 {
40 }
41
42 fn two() {
43     want_foo::<AnotherStruct<usize>>();
44 }
45
46 fn main() { }