Diagnostics for mutating non-DerefMut types are confusing #58864
Labels
A-borrow-checker
Area: The borrow checker
A-diagnostics
Area: Messages for errors, warnings, and lints
NLL-diagnostics
Working towards the "diagnostic parity" goal
emits
which is super confusing. Firstly, I have what appears to be two conflicting error messages. The second one tells me to make things mutable, and if I listen to it I get told that things don't need to be mutable. Secondly, the relevant error message (the second one) talks about
&
references which don't exist.The actual issue here is that
x
is notDerefMut
, of course. Which is obvious in this case, but that's not always true. I've often hit this error in other situations and I've basically learned to pattern match it to mean "something something DerefMut", but people seeing it for the first time typically don't.We should explicitly make the diagnostics say something like "
x
is anRc<T>
which cannot be dereferenced mutably"The text was updated successfully, but these errors were encountered: