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
|
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 covariance<'a, 'b, 'upper>(v: bool)
where
'upper: 'a,
'upper: 'b,
{
let _: &'upper () = match v {
//~^ ERROR lifetime may not live long enough
//~| ERROR lifetime may not live long enough
true => lt::<'a>(),
false => lt::<'b>(),
};
}
fn contra_fn<'a, 'b, 'lower>(v: bool)
where
'a: 'lower,
'b: 'lower,
{
let _: fn(&'lower ()) = match v {
//~^ ERROR lifetime may not live long enough
true => lt_in_fn::<'a>(),
false => lt_in_fn::<'b>(),
};
}
fn contra_struct<'a, 'b, 'lower>(v: bool)
where
'a: 'lower,
'b: 'lower,
{
let _: Contra<'lower> = match v {
//~^ ERROR lifetime may not live long enough
true => lt_in_contra::<'a>(),
false => lt_in_contra::<'b>(),
};
}
fn main() {}
|