-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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 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
fmease and mu001999
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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.