Repository navigation
failed to automatically apply fixes suggested by rustc due to use of moved value #103776
Description
Activity
- changed the title
[-]BUG: `failed to automatically apply fixes suggested by rustc` due to `use of moved value: `conn``[/-][+]BUG: `failed to automatically apply fixes suggested by rustc` due to `use of moved value: `conn`.[/+]on Oct 30, 2022 - changed the title
[-]BUG: `failed to automatically apply fixes suggested by rustc` due to `use of moved value: `conn`.[/-][+]BUG: `failed to automatically apply fixes suggested by rustc` due to `use of moved value: conn`.[/+]on Oct 30, 2022 Do you mind sharing what the suggested fix actually was? It's hard to tell what was applied just from the bug here.
Do you mind sharing what the suggested fix actually was? It's hard to tell what was applied just from the bug here.
Okay,
connhas a typeString. It's suggested to remove a reference and pass a value, but it didn't understand the context that this happens in a loop.
So, an error happens that was used move value.- addedA-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-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-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.
on Oct 31, 2022 FWIW, be aware that diagnostics don't always have enough information available to them to fully provide correct code, but we consider it appropriate if subsequent compilations provide enough guidance that you can eventually end up with correct code. Having said that, we absolutely appreciate reports of cases like these where we can preclude some of those iterations.
Here, the type error suggestion can/should climb up from the current expression until it finds the binding creation and track whether any looping expression is in between them. If so, it should suggest both removing the
&and a.clone()call.FWIW, be aware that diagnostics don't always have enough information available to them to fully provide correct code, but we consider it appropriate if subsequent compilations provide enough guidance that you can eventually end up with correct code. Having said that, we absolutely appreciate reports of cases like these where we can preclude some of those iterations.
Here, the type error suggestion can/should climb up from the current expression until it finds the binding creation and track whether any looping expression is in between them. If so, it should suggest both removing the
&and a.clone()call.I'm happy that my issue is helpful. I'm not a lang dev, but I think that compiler doesn't provide a context that this happens in the loop, just ignored this fact.
Anyway, thanks for the positive feedback, have a good day or evening!#103908 will provide the following error after the first applied change:
error[E0382]: use of moved value: `conn` --> src\cli\sql.rs:43:12 | 22 | let conn = format!("{conn}/sql"); | ---- move occurs because `conn` has type `std::string::String`, which does not implement the `Copy` trait ... 28 | loop { | ---- inside of this loop ... 43 | .post(conn) | ^^^^ value moved here, in previous iteration of loop help: consider cloning the value if the performance cost is acceptable | 43 | .post(conn.clone()) | ++++++++- changed the title
[-]BUG: `failed to automatically apply fixes suggested by rustc` due to `use of moved value: conn`.[/-][+]`failed to automatically apply fixes suggested by rustc` due to `use of moved value`[/+]on Nov 3, 2022 Fixed: #103908.
I close this issue, anyway I can reopen it due to appeared issues after this PR.
I tried this code:
This block of code (43):
I expected to see this happen:
I used
cargo clippy --fix --allow-dirtyand everything fixes correct.Instead, this happened:
Meta
rustc --version --verbose:Backtrace
// NO BACKTRACE IT JUST FALES TO FIX.