Misleading compile error message when checking match arm types. #78124
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-type-system
Area: Type system
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I ran into a case where the compiler is complaining that match arms have incompatible types, as seen in this code snippet below.
However, the line it is pointing to is not necessarily incorrect: the real issue is that the outer "shouldwe" Some => match-arm is not returning a u32 as expected. (In other words, this can be made to compile by adding a return after the match shouldwe2 statement).
I eventually realized the actual issue, but this could possibly be clarified by pointing at the outer shouldwe match instead of the inner shouldwe2 match.
(Playground)
Errors:
The text was updated successfully, but these errors were encountered: