summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs
blob: dce88b88c7530bbbddd498e3847d6fbdd2be0f11 (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
// Test that we are able to establish that `<T as
// MyTrait<'a>>::Output` outlives `'b` here. We need to prove however
// that `<T as MyTrait<'a>>::Output` outlives `'a`, so we also have to
// prove that `'b: 'a`.

trait MyTrait<'a> {
    type Output;
}

fn foo1<'a, 'b, T>() -> &'a ()
where
    T: MyTrait<'a>,
    <T as MyTrait<'a>>::Output: 'b,
{
    bar::<T::Output>() //~ ERROR may not live long enough
}

fn foo2<'a, 'b, T>() -> &'a ()
where
    T: MyTrait<'a>,
    <T as MyTrait<'a>>::Output: 'b,
    'b: 'a,
{
    bar::<T::Output>() // OK
}

fn bar<'a, T>() -> &'a ()
where
    T: 'a,
{
    &()
}

fn main() {}