Closed
Description
Code
fn bar() {}
fn main() {
let b: fn() -> u32 = bar;
}
Current output
error[E0308]: mismatched types
--> src/main.rs:4:26
|
4 | let b: fn() -> u32 = bar;
| ----------- ^^^ expected fn pointer, found fn item
| |
| expected due to this
|
= note: expected fn pointer `fn() -> u32`
found fn item `fn() {bar}`
Desired output
error[E0308]: mismatched types
--> src/main.rs:4:26
|
4 | let b: fn() -> u32 = bar;
| ----------- ^^^ `fn` return types do not match, expected `fn() -> u32`, found `fn() -> ()`
| |
| expected due to this
Rationale and extra context
The current version is not wrong, but it is a bit confusing when one does not know the way rustc handles fn
stuff.
I think that leading with what is not matching up would make it easier to see one's error. Especially in context for example of RA, where in-line errors only show the 'main' message.
Other cases
No response
Rust Version
Playground, Stable 1.79.0
Anything else?
No response