fix suggestion for E0716 (temporary value dropped while borrowed) #137486
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
I tried this code:
The Rust compiler suggests an incorrect fix:
However, this suggestion leads to another compilation error because binding is immutable:
This forces the user to encounter another error message before arriving at the correct fix.
Expected Fix
The Rust compiler should directly suggest the correct fix:
This avoids an unnecessary additional compilation error, improving the developer experience.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: