Confusing error message on deref-coercion after partial move out #73268
Labels
A-coercions
Area: implicit and explicit `expr as Type` coercions
A-diagnostics
Area: Messages for errors, warnings, and lints
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-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code:
gives the following error message:
This error occurs because
val.inner
performs a deref-coercion to access the fieldinner
onNotCopy
. However, this is not mentioned in the error message - we instead refer to val being 'borrowed' by what appears to be a normal field access.If
val.second
is uncommented, andval.inner
commented out, the code compiles successfully. This may be very confusing to users who don't realize that only one field involves a deref-coercion, as it looks like either access should be allowed.When a move error occurs, we should explicitly mention any deref-coercions that occur, and explain why they prevent the code from compiling.
The text was updated successfully, but these errors were encountered: