Open
Description
trait MyFn<'a> {}
impl<'a, F> MyFn<'a> for F where
F: FnOnce(&'a i32) -> &'a i32 {}
fn foo<F>(f: F) where F: for<'a> MyFn<'a> {}
// This works:
// fn foo<F>(f: F) where F: for<'a> FnOnce(&'a i32) -> &'a i32 {}
fn main() {
foo(|x: &i32| -> &i32 { x });
}
produces:
error: implementation of `MyFn` is not general enough
--> src/main.rs:10:5
|
1 | trait MyFn<'a> {}
| ----------------- trait `MyFn` defined here
...
10 | foo(|x: &i32| -> &i32 { x });
| ^^^ implementation of `MyFn` is not general enough
|
= note: `MyFn<'1>` would have to be implemented for the type `[closure@src/main.rs:10:9: 10:32]`, for any lifetime `'1`...
= note: ...but `MyFn<'_>` is actually implemented for the type `[closure@src/main.rs:10:9: 10:32]`, for some specific lifetime `'2`
But clearly it actually is implemented for any lifetime.