Better suggestion for closure that needs to capture bindings, but not all #80139
Labels
A-closures
Area: closures (`|args| { .. }`)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given
we currently emit
if we apply the suggestion we get the following
because we're moving
numbers
into the closure and consuming it.Ideally, we would suggest to introduce a new binding that borrows
numbers
to avoid moving it.Example taken from https://stackoverflow.com/questions/65258521/how-do-i-write-a-lazily-evaluated-double-for-loop-in-a-functional-style
The text was updated successfully, but these errors were encountered: