-
Notifications
You must be signed in to change notification settings - Fork 1.7k
same_item_push is incorrect in several cases #5985
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Can confirm, self-contained version of the first example: Playground |
Hmm, it might be better not to emit a lint when the pushed item is the variable that introduced in loop, but what about? Of cource, while I think the above FP can be avoided FN will occur in the following cases. rust-clippy/tests/ui/same_item_push.rs Lines 25 to 29 in f98ffa2
|
Maybe an even simpler example using fn main() {
let start = std::time::Instant::now();
let mut vec = Vec::new();
for _ in 0..1000 {
let elapsed = std::time::Instant::now() - start;
vec.push(elapsed.as_millis());
}
} |
[beta][clippy] backport multiple FP fixes for a warn-by-default lint This backports the PR rust-lang/rust-clippy#6016 fixing multiple FPs: rust-lang/rust-clippy#5902 rust-lang/rust-clippy#5979 rust-lang/rust-clippy#5985 We didn't have any complaints about this lint, since me merged this PR. cc `@ebroto` (sorry I forgot about this, since we talked about the backport 3 weeks ago 😐) r? `@pietroalbini`
Code: the
pdf
crate on this commit https://github.com/Ploppz/pdf/tree/535429d8543434fbd5f46b4589c013bf96be9d10/pdf .cargo clippy
says:Which seems incorrect.
Pasting the code in question here:
Meta
cargo clippy -V
: clippy 0.0.212 (de521cb 2020-08-21)rustc -Vv
:The text was updated successfully, but these errors were encountered: