-
-
Notifications
You must be signed in to change notification settings - Fork 15k
fix suggestion for E0716 (temporary value dropped while borrowed) #137486
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Description
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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: