Compiler-Hint to assign to a mutably borrowed value #136026
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
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
A beginner might add a &-Symbol by themself, because val is a (mutable) reference. The output suggest adding a mut. However, assigning a mutably borrowed value might be desired in this case.
Internals: https://internals.rust-lang.org/t/compiler-hint-to-assign-to-a-mutably-borrowed-value/22209
Other cases
If you follow the current output and add the mut, one receives a Error about a too short lifetime.
I suggest the same hint in that case as well.
and similar, when using a variable instead of a constant:
Rust Version
valon@valon:~/RustroverProjects/future_test$ rustc --version --verbose rustc 1.84.0 (9fc6b4312 2025-01-07) binary: rustc commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869 commit-date: 2025-01-07 host: x86_64-unknown-linux-gnu release: 1.84.0 LLVM version: 19.1.5
Anything else?
No response
The text was updated successfully, but these errors were encountered: