You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fngenerate_for_loop(ident:Variable,expr:Expression,body:Statement) -> String{// Assign expression to variable to access it from within the loopletmut expr_ident = ident.clone();
expr_ident.name = format!("loop_orig_{}", ident.name);letmut out_str = format!("{};\n", generate_declare(&expr_ident,Some(expr)));// Loop signature
out_str += &format!("for (let iter_{I} = 0; iter_{I} < {E}.length; iter_{I}++)",I = ident.name,E = expr_ident.name
);// Block with prepended declaration of the actual variable
out_str += &generate_block(
body,Some(format!("let {I} = {E}[iter_{I}];\n",I = ident.name,E = expr_ident.name,)),);
out_str
}
I expected to see this happen: The code to run successfully and apply fixes suggested by cargo clippy --fix.
Instead, this happened: I encountered the following error:
warning: failed to automatically apply fixes suggested by rustc to crate `sb`
after fixes were automatically applied the compiler reported errors within these files:
* src/generator/js.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0382]: borrow of moved value: `ident`
--> src/generator/js.rs:188:47
|
185 | fn generate_for_loop(ident: Variable, expr: Expression, body: Statement) -> String {
| ----- move occurs because `ident` has type `ast::Variable`, which does not implement the `Copy` trait
186 | // Assign expression to variable to access it from within the loop
187 | let mut expr_ident = ident;
| ----- value moved here
188 | expr_ident.name = format!("loop_orig_{}", ident.name);
| ^^^^^^^^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
187 | let mut expr_ident = ident.clone();
| ++++++++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
Original diagnostics will follow.
warning: redundant clone
--> src/generator/js.rs:187:31
|
187 | let mut expr_ident = ident.clone();
| ^^^^^^^^ help: remove this
|
note: cloned value is neither consumed nor mutated
--> src/generator/js.rs:187:
26
|
187 | let mut expr_ident = ident.clone();
| ^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
= note: `#[warn(clippy::redundant_clone)]` on by default
warning: `antimony-lang` (bin "sb") generated 1 warning (run `cargo clippy --fix --bin "sb"` to apply 1 suggestion)
Uh oh!
There was an error while loading. Please reload this page.
I tried this code:
I expected to see this happen: The code to run successfully and apply fixes suggested by
cargo clippy --fix
.Instead, this happened: I encountered the following error:
Meta
rustc --version --verbose
:(Also present on 1.70.0)
No backtrace is shown.
The text was updated successfully, but these errors were encountered: