-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
Description
use std::marker::CovariantLifetime as CLT;
fn does_not_compile<'b>(y: CLT<'b>) -> Box<for<'s:'b> Fn() -> CLT<'s>> {
Box::new(move ||y)
}
fn does_compile<'b, 's:'b>(y: CLT<'b>) -> Box<Fn() -> CLT<'s>> {
Box::new(move ||y)
}
fn main() {}
Error:
<anon>:3:21: 3:22 error: mismatched types:
expected `core::marker::CovariantLifetime<'s>`,
found `core::marker::CovariantLifetime<'b>`
(lifetime mismatch) [E0308]
<anon>:3 Box::new(move ||y)
^
<anon>:3:21: 3:22 note: the lifetime 's as defined on the block at 3:20...
<anon>:3 Box::new(move ||y)
^
<anon>:2:72: 4:2 note: ...does not necessarily outlive the lifetime 'b as defined on the block at 2:71
<anon>:2 fn does_not_compile<'b>(y: CLT<'b>) -> Box<for<'s:'b> Fn() -> CLT<'s>> {
<anon>:3 Box::new(move ||y)
<anon>:4 }
error: aborting due to previous error
playpen: application terminated with error code 101