-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
From https://www.reddit.com/r/rust/comments/bv90s7/temporary_value_dropped_while_borrowed/
We currently supply the following diagnostic:
let mut words = con.unwrap().split_whitespace().peekable();
^^^^^^^^^^^^ - temporary value is freed at the
| end of this statement
| |
| creates a temporary which is freed while still in use
|
| while words.peek().is_some() {
| ----- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
The note should be a structured suggestion that looks at the current line, figures out the indentation, finds the span for the beginning of the line and suggests adding a line above with a let
binding. This should make it clearer what we're suggesting. Additionally, it'd be nice if we could add either a succinct explanation or a link to the book with an explanation of what might be happening here.
orvly, neelrr1 and ierezell
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`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.