]> git.proxmox.com Git - rustc.git/blob - tests/ui/nll/ty-outlives/projection-body.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / tests / ui / nll / ty-outlives / projection-body.rs
1 // Test that when we infer the lifetime to a subset of the fn body, it
2 // works out.
3 //
4 // check-pass
5
6 #![allow(dropping_references)]
7
8 trait MyTrait<'a> {
9 type Output;
10 }
11
12 fn foo1<T>()
13 where
14 for<'x> T: MyTrait<'x>,
15 {
16 // Here the region `'c` in `<T as MyTrait<'c>>::Output` will be
17 // inferred to a subset of the fn body.
18 let x = bar::<T::Output>();
19 drop(x);
20 }
21
22 fn bar<'a, T>() -> &'a ()
23 where
24 T: 'a,
25 {
26 &()
27 }
28
29 fn main() {}