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
fnmain(){let v1 = vec![Some(1),Some(2),Some(3),None];letmut v1_iter = v1.iter();letmut v2 = Vec::new();for _ in0..3{let a = match v1_iter.next(){Some(a) => a,None => break,};
v2.push(a);}println!("items are not the same: {:#?}", v2);}
I expected to see this happen:
No warnings.
Instead, this happened:
Clippy warns:
warning: it looks like the same item is being pushed into this Vec
--> src/main.rs:10:9
|
10 | v2.push(a);
| ^^
|
= note: `#[warn(clippy::same_item_push)]` on by default
= help: try using vec![a;SIZE] or v2.resize(NEW_SIZE, a)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
warning: 1 warning emitted
I can't reproduce this false positive in the playground.
This was fixed in #6016, and backported to 1.47 in rust-lang/rust#77403. Your Clippy version seems older (2020-08-16), so I think that if you update Clippy you will get rid of that false positive.
Feel free to reopen if the suggested fix does not work for you!
I tried this code:
I expected to see this happen:
No warnings.
Instead, this happened:
Clippy warns:
Meta
cargo clippy -V
: clippy 0.0.212 (7e6d6e5 2020-08-16)rustc -Vv
:Backtrace
The text was updated successfully, but these errors were encountered: