summaryrefslogtreecommitdiffstats
path: root/tests/ui/lub-glb/empty-binders.rs
blob: f9d07e79fdabf6cfae700bc055270fee3cd5bcdc (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
// check-pass
//
// Check that computing the lub works even for empty binders.
fn lt<'a: 'a>() -> &'a () {
    &()
}

fn lt_in_fn<'a: 'a>() -> fn(&'a ()) {
    |_| ()
}

struct Contra<'a>(fn(&'a ()));
fn lt_in_contra<'a: 'a>() -> Contra<'a> {
    Contra(|_| ())
}

fn ok<'a, 'b, 'upper, 'lower>(v: bool)
where
    'upper: 'a,
    'upper: 'b,
    'a: 'lower,
    'b: 'lower,

{
    let _: &'lower () = match v {
        true => lt::<'a>(),
        false => lt::<'b>(),
    };

    // This errored in the past because LUB and GLB always
    // bailed out when encountering binders, even if they were
    // empty.
    let _: fn(&'upper ()) = match v {
        true => lt_in_fn::<'a>(),
        false => lt_in_fn::<'b>(),
    };

    // This was already accepted, as relate didn't encounter any binders.
    let _: Contra<'upper> = match v {
        true => lt_in_contra::<'a>(),
        false => lt_in_contra::<'b>(),
    };
}

fn main() {}