]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / ui / nll / ty-outlives / projection-where-clause-env-wrong-bound.rs
1 // Test that we are able to establish that `<T as
2 // MyTrait<'a>>::Output` outlives `'b` here. We need to prove however
3 // that `<T as MyTrait<'a>>::Output` outlives `'a`, so we also have to
4 // prove that `'b: 'a`.
5
6 trait MyTrait<'a> {
7     type Output;
8 }
9
10 fn foo1<'a, 'b, T>() -> &'a ()
11 where
12     T: MyTrait<'a>,
13     <T as MyTrait<'a>>::Output: 'b,
14 {
15     bar::<T::Output>() //~ ERROR may not live long enough
16 }
17
18 fn foo2<'a, 'b, T>() -> &'a ()
19 where
20     T: MyTrait<'a>,
21     <T as MyTrait<'a>>::Output: 'b,
22     'b: 'a,
23 {
24     bar::<T::Output>() // OK
25 }
26
27 fn bar<'a, T>() -> &'a ()
28 where
29     T: 'a,
30 {
31     &()
32 }
33
34 fn main() {}