Open
Description
trait Yokeable<'a>: 'static {
type Output: 'a;
}
fn project<Y, P, F>(f: F)
where Y: for<'a> Yokeable<'a>,
P: for<'a> Yokeable<'a>,
F: for<'a> FnOnce(<Y as Yokeable<'a>>::Output) -> <P as Yokeable<'a>>::Output {}
fn project_fn<Y, P>(f: for<'a> fn(<Y as Yokeable<'a>>::Output) -> <P as Yokeable<'a>>::Output)
where Y: for<'a> Yokeable<'a>,
P: for<'a> Yokeable<'a> {}
fn main() {}
(playpen, also tested on rustc 1.54.0-nightly (fe72845f7 2021-05-16)
)
produces
Compiling playground v0.0.1 (/playground)
error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
--> src/main.rs:10:59
|
10 | F: for<'a> FnOnce(<Y as Yokeable<'a>>::Output) -> <P as Yokeable<'a>>::Output
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
--> src/main.rs:14:67
|
14 | fn project_fn<Y, P>(f: for<'a> fn(<Y as Yokeable<'a>>::Output) -> <P as Yokeable<'a>>::Output)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
The lifetime is used in the inputs, just behind a trait.