Open
Description
Code
async fn mutate(t: &mut i64) {
*t += 1000;
}
fn use_async_fn<A, U>(_fun: A)
where
A: Fn(&mut i64) -> U,
U: futures::Future<Output = ()>,
{
}
fn main() {
use_async_fn(mutate);
}
Current output
error[E0308]: mismatched types
--> src/main.rs:13:5
|
13 | use_async_fn(mutate);
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected trait `for<'a> <for<'a> fn(&'a mut i64) -> impl futures::Future<Output = ()> {mutate} as FnOnce<(&'a mut i64,)>>`
found trait `for<'a> <for<'a> fn(&'a mut i64) -> impl futures::Future<Output = ()> {mutate} as FnOnce<(&'a mut i64,)>>`
note: the lifetime requirement is introduced here
--> src/main.rs:7:24
|
7 | A: Fn(&mut i64) -> U,
| ^
Desired output
Rather than show the same type twice, rustc should explain what the actual mismatch between the two types is.
If you want to get fancy, it could explain how to pass async mutating functions properly :D
Rationale and extra context
If we find that we'll show the same type twice to the user after stringifying it, we may want to give additional context to help the user better understand what is being shown.
Other cases
No response
Anything else?
No response