]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs
1 // compile-flags:-Zverbose
4 #![feature(rustc_attrs)]
8 fn with_signature
<'a
, T
, F
>(x
: Box
<T
>, op
: F
) -> Box
<dyn Debug
+ 'a
>
9 where F
: FnOnce(Box
<T
>) -> Box
<dyn Debug
+ 'a
>
15 fn no_region
<'a
, T
>(x
: Box
<T
>) -> Box
<dyn Debug
+ 'a
>
19 // Here, the closure winds up being required to prove that `T:
20 // 'a`. In principle, it could know that, except that it is
21 // type-checked in a fully generic way, and hence it winds up with
22 // a propagated requirement that `T: '_#2`, where `'_#2` appears
23 // in the return type. The caller makes the mapping from `'_#2` to
24 // `'a` (and subsequently reports an error).
26 with_signature(x
, |y
| y
)
27 //~^ ERROR the parameter type `T` may not live long enough
30 fn correct_region
<'a
, T
>(x
: Box
<T
>) -> Box
<Debug
+ 'a
>
37 fn wrong_region
<'a
, 'b
, T
>(x
: Box
<T
>) -> Box
<Debug
+ 'a
>
42 //~^ ERROR the parameter type `T` may not live long enough
45 fn outlives_region
<'a
, 'b
, T
>(x
: Box
<T
>) -> Box
<Debug
+ 'a
>