Closed
Description
Code
trait Trait<A> {}
impl<T, A, O> Trait<A> for T where for<'a> T: Fn(&'a A) -> O + 'a {}
fn function2(value: &u32) -> &u32 {
value
}
fn receive<T, A>(_: T)
where
T: Trait<A>,
{
}
fn main() {
receive(function2);
}
Current output
error[E0308]: mismatched types
--> src/main.rs:16:5
|
16 | receive(function2);
| ^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`
found trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`
note: the lifetime requirement is introduced here
--> src/main.rs:11:8
|
11 | T: Trait<A>,
| ^^^^^^^^
Desired output
The expected trait and found trait lines are identical, which is incredibly confusing when it comes to finding out what's wrong here. I would have expected the output to actually show what the difference is.
Rationale and extra context
No response
Other cases
No response
Anything else?
Feel free to update the title to something more precise if you know what underlying issues is going on.