cannot borrow as mutable suggestion confusing #113886
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I encountered this while discussing a larger code example (also involving
async move
and spawning tokio tasks). When you read the diagnostics top to bottom, something that's common in an IDE (rust-analyzer also shows a similar suggestion) you might be tempted to apply what the compiler says: make the variable mut.More often than not, that's not the desired behaviour I find. Making the parameter mut often locally fixes the problem (the
do_thing
function compiles) but globally the program gets worse, and might cause other errors.Even if the suggestion is right, it might be nice to show both options since they would both fix the error.
Other cases
No response
Anything else?
@estebank @compiler-errors
The text was updated successfully, but these errors were encountered: