Closed
Description
Code
fn main() {
let x = |a: u8| {};
let x: fn(i32) = x;
}
Current output
error[E0308]: mismatched types
--> src/main.rs:4:22
|
2 | let x = |a: u8| {};
| ------- the found closure
3 |
4 | let x: fn(i32) = x;
| ------- ^ expected fn pointer, found closure
| |
| expected due to this
|
= note: expected fn pointer `fn(i32)`
found closure `{closure@src/main.rs:2:13: 2:20}`
Desired output
error[E0308]: mismatched types
--> src/main.rs:4:22
|
2 | let x = |a: u8| {};
| ------- the found closure
3 |
4 | let x: fn(i32) = x;
| ------- ^ expected fn pointer, found closure
| |
| expected due to this
|
= note: expected fn pointer `fn(i32)`
| found closure `{closure@src/main.rs:2:13: 2:20}`
= note: closure has signature `fn(u8)`
Rationale and extra context
Here it's obvious, but when the error says that it is mismatched with for<'tcx> fn(context::TyCtxt<'tcx>, rustc_span::def_id::LocalDefId) -> &'tcx rustc_data_structures::unord::UnordSet<rustc_span::Symbol>
and that "types differ in mutability" then I have zero chance of figuring what's going on.
Other cases
No response
Anything else?
No response