summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/ty-outlives/projection-body.rs
blob: 722d6747102fc7ceb4db33a10e0115b0788f3535 (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
// Test that when we infer the lifetime to a subset of the fn body, it
// works out.
//
// check-pass

#![allow(dropping_references)]

trait MyTrait<'a> {
    type Output;
}

fn foo1<T>()
where
    for<'x> T: MyTrait<'x>,
{
    // Here the region `'c` in `<T as MyTrait<'c>>::Output` will be
    // inferred to a subset of the fn body.
    let x = bar::<T::Output>();
    drop(x);
}

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

fn main() {}