Wrong syntax suggested by "consider changing this to be a mutable reference" with mut parameter in closure when iterating a vector #115259
Labels
A-closures
Area: Closures (`|…| { … }`)
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.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
No response
Rationale and extra context
Initially, my
State.process
function looked like this:This led to a diagnostic that already has an open issue #62387 (it should suggest
iter
->iter_mut
).I didn't notice I was not using
iter_mut
and tried changinglayer
->mut layer
, which led to the compiler somehow adding a secondmut
in the middle of the closure parameter.I don't know what the desired output should be in this case; I don't think
mut
parameter is correct here either way, but it might be worth investigating why the compiler is making a syntactically wrong suggestion.Other cases
No response
Anything else?
Tested on 1.71.0 and 1.72.0 (stable-x86_64-unknown-linux-gnu).
The text was updated successfully, but these errors were encountered: