Closed as not planned
Description
I tried this code:
(I'm trying to get some way to port the rustup test suite which uses closures to run test within the context of the framework over to async code)
I got this error:
23 | call_a_callback(make_future);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected trait `for<'a> <for<'a> fn(&'a str) -> impl Future<Output = ()> + 'a {make_future} as FnOnce<(&'a str,)>>`
found trait `for<'a> <for<'a> fn(&'a str) -> impl Future<Output = ()> + 'a {make_future} as FnOnce<(&'a str,)>>`
note: the lifetime requirement is introduced here
--> src/main.rs:5:20
|
5 | F: Fn(&str) -> FR,
| ^^
On
Nightly version: 1.71.0-nightly
(2023-05-25 a2b1646c597329d0a25e
The following error
16 | fn make_future<'a>(s: &'a str) -> impl Future<Output=()>+ 'a {
| --------------------------
| |
| the expected future
| the found future
...
23 | call_a_callback(make_future);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected opaque type `impl for<'a> Future<Output = ()> + '_`
found opaque type `impl Future<Output = ()> + '_`
= help: consider `await`ing on both `Future`s
= note: distinct uses of `impl Trait` result in different opaque types
Meta
rustc --version --verbose
: (from playground, not sure how to get --verbose there)
1.69.0
<version>
I'm not entirely sure what is going on.
What I hoped would happen is that the future returned from make_future would be suitable for awaiting on in call_a_callback - the bigger picture is I'm trying to port rustups test suite to async, and this is a minimal reproduction of the code style there, where async lifetime errors are being a nuisance ;)