Possibly confusing error message when deref/deref_mut are used. #58843
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Beginners can be confused when
deref
andderef_mut
are called implicitely:In this given code:
The error message is not the clearest:
The users could not understand that the borrows are done by
deref
andderef_mut
, since the calls are implicit. They could think that, for an unknown reason, the borrow checker does not understand that the fields are disjoint.I think that it would be an improvement if the compiler added that the implicit call to
deref
/deref_mut
is responsible of the borrowing:This could be even better if the compiler gave the solution:
The text was updated successfully, but these errors were encountered: