Open
Description
When I compile the following code:
use std::future::Future;
pub async fn async_magic<F, R>(f: F) -> Vec<u8>
where
F: FnOnce(&mut Vec<u8>) -> R,
R: Future,
{
todo!()
}
async fn push_zero(v: &mut Vec<u8>) {
todo!()
}
pub async fn test_async_magic() {
async_magic(push_zero).await;
}
async fn sleep() {}
I get the error message:
error[E0308]: mismatched types
--> src/lib.rs:16:5
|
16 | async_magic(push_zero).await;
| ^^^^^^^^^^^ lifetime mismatch
|
= note: expected associated type `<for<'_> fn(&mut Vec<u8>) -> impl for<'_> Future {push_zero} as FnOnce<(&mut Vec<u8>,)>>::Output`
found associated type `<for<'_> fn(&mut Vec<u8>) -> impl for<'_> Future {push_zero} as FnOnce<(&mut Vec<u8>,)>>::Output`
= note: the required lifetime does not necessarily outlive the empty lifetime
note: the lifetime requirement is introduced here
--> src/lib.rs:5:32
|
5 | F: FnOnce(&mut Vec<u8>) -> R,
| ^
I'm sure the 'expected' and 'found' types are indeed different somehow, but there's nothing in the output that would allow us to distinguish them.
EDIT: Output from rustc -vV
:
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1