summaryrefslogtreecommitdiffstats
path: root/tests/ui/associated-type-bounds/hrtb.rs
blob: 7ab3836493b01ce546bec90266e0e8080fd223a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// check-pass

#![feature(associated_type_bounds)]

trait A<'a> {}
trait B<'b> {}
fn foo<T>()
where
    for<'a> T: A<'a> + 'a,
{
}
trait C<'c>: for<'a> A<'a> + for<'b> B<'b> {
    type As;
}
struct D<T>
where
    T: for<'c> C<'c, As: A<'c>>,
{
    t: std::marker::PhantomData<T>,
}

trait E<'e> {
    type As;
}
trait F<'f>: for<'a> A<'a> + for<'e> E<'e> {}
struct G<T>
where
    for<'f> T: F<'f, As: E<'f>> + 'f,
{
    t: std::marker::PhantomData<T>,
}

trait I<'a, 'b, 'c> {
    type As;
}
trait H<'d, 'e>: for<'f> I<'d, 'f, 'e> + 'd {}
fn foo2<T>()
where
    T: for<'g> H<'g, 'g, As: for<'h> H<'h, 'g> + 'g>,
{
}

fn foo3<T>()
where
    T: for<'i> H<'i, 'i, As: for<'j> H<'j, 'i, As: for<'k> I<'i, 'k, 'j> + 'j> + 'i>,
{
}
fn foo4<T>()
where
    T: for<'l, 'i> H<'l, 'i, As: for<'j> H<'j, 'i, As: for<'k> I<'l, 'k, 'j> + 'j> + 'i>,
{
}

struct X<'x, 'y> {
    x: std::marker::PhantomData<&'x ()>,
    y: std::marker::PhantomData<&'y ()>,
}

fn foo5<T>()
where
    T: for<'l, 'i> H<'l, 'i, As: for<'j> H<'j, 'i, As: for<'k> H<'j, 'k, As = X<'j, 'k>> + 'j> + 'i>
{
}

fn main() {}