-
Notifications
You must be signed in to change notification settings - Fork 1.7k
same_item_push lint can trigger when the pushed value is not constant. #5902
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
Labels
C-bug
Category: Clippy is not doing the correct thing
Comments
I will prepare a fix. |
We just ran into this as well with rustc 1.47.0-nightly (81dc88f 2020-08-13) repro:
causes:
|
This was referenced Sep 2, 2020
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Oct 1, 2020
[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`
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Simple example:
I expected to see this happen:
No clippy warning, because the value being pushed is not constant (despite the otherwise unidiomatic code, as this is a contrived example).
Instead, this happened:
The
same_item_push
lint throws a warning with an incorrect description of a fix.The docs at https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push say that this lint should only fire when "a for loop is used to push a constant value", but in this case the value being pushed is not constant.
Meta
cargo clippy -V
: clippy 0.0.212 (576d27c 2020-08-12)rustc -Vv
:rustc 1.47.0-nightly (576d27c 2020-08-12)
binary: rustc
commit-hash: 576d27c
commit-date: 2020-08-12
host: x86_64-pc-windows-msvc
release: 1.47.0-nightly
LLVM version: 10.0
The text was updated successfully, but these errors were encountered: