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
Excerpt of original output of cargo clippy --fix in console-rs/indicatif#547, which suggested to create an issue here:
Checking indicatif v0.17.4 (C:\foresterre\indicatif)
warning: failed to automatically apply fixes suggested by rustc to crate `multi_autodrop`
after fixes were automatically applied the compiler reported errors within these files:
* tests\multi-autodrop.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/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
I tried this code (can probably be made more minimal):
use std::sync::{atomic::AtomicU32, atomic::Ordering,Arc,Mutex,RwLock};// Reproduction derived from indicatif::MultiProgress and ProgressBar where this Clippy suggestion was found.// With Clippy 0.1.71 (2023-06-01 d59363a)// With Rust 1.70.0#[derive(Clone)]structMultiProgress{state:Arc<RwLock<State>>,}implDefaultforMultiProgress{fndefault() -> Self{Self{state:Arc::new(RwLock::new(State)),}}}implMultiProgress{fnadd(&self,pb:ProgressBar) -> ProgressBar{let state = self.state.write().unwrap();drop(state);
pb.set_remote(self.state.clone());
pb
}}#[derive(Clone)]structProgressBar{value:Arc<AtomicU32>,remote:Arc<Mutex<Arc<RwLock<State>>>>,}implDefaultforProgressBar{fndefault() -> Self{Self{value:Arc::new(AtomicU32::new(0)),remote:Arc::new(Mutex::new(Arc::new(RwLock::new(State)))),}}}implProgressBar{fnset_remote(&self,state:Arc<RwLock<State>>){*self.remote.lock().unwrap() = state;}fninc(&self,delta:u32){self.value.fetch_add(delta,Ordering::SeqCst);}fnreset(&self){self.value.fetch_add(0,Ordering::SeqCst);}}structState;fnmain(){let pb = {let m = MultiProgress::default();
m.add(ProgressBar::default())// m is dropped here};{// Clippy faults here: it suggests to remove the clone.let pb2 = pb.clone();for _ in0..10{
pb2.inc(1);}}
pb.reset();}
Running cargo clippy:
hecking playground v0.0.1 (/playground)
warning: redundant clone
--> src/main.rs:70:21
|
70 | let pb2 = pb.clone();
| ^^^^^^^^ help: remove this
|
note: cloned value is neither consumed nor mutated
--> src/main.rs:70:19
|
70 | let pb2 = pb.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: `playground` (bin "playground") generated 1 warning (run `cargo clippy --fix --bin "playground"` to apply 1 suggestion)
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
When applying the suggestion:
Checking playground v0.0.1 (/playground)
error[E0382]: borrow of moved value: `pb`
--> src/main.rs:76:5
|
62 | let pb = {
| -- move occurs because `pb` has type `ProgressBar`, which does not implement the `Copy` trait
...
70 | let pb2 = pb;
| -- value moved here
...
76 | pb.reset();
| ^^^^^^^^^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
70 | let pb2 = pb.clone();
| ++++++++
For more information about this error, try `rustc --explain E0382`.
error: could not compile `playground` (bin "playground") due to previous error
Whoops, wrong repo (altough cargo clippy --fix does suggest creating an issue here). Moved to comment on equivalent issue: rust-lang/rust-clippy#10577 (comment)
Excerpt of original output of
cargo clippy --fix
in console-rs/indicatif#547, which suggested to create an issue here:indicatif pipeline
I tried this code (can probably be made more minimal):
Running
cargo clippy
:When applying the suggestion:
Meta
rustc --version --verbose
:cargo clippy --version --verbose
:Extra
Playground
Gist
Clippy lint
The text was updated successfully, but these errors were encountered: