-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
matthiasbeyer and samyak-nz
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.