rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.41k stars 1.54k forks source link

used_underscore_binding is triggered for fields without underscore #13058

Open Bytekeeper opened 3 months ago

Bytekeeper commented 3 months ago

Summary

When running cargo clippy with the linked code (https://github.com/Bytekeeper/bevy_particle_systems/tree/bevy_14 - sorry for referencing the whole branch but this is just part of a PR for a project not owned by me) I get a lot of used_underscore_binding warnings. The error message is quite funny as it prints out the definition, which has no underscores at all.

Lint Name

used_underscore_binding

Reproducer

Sorry - this is from a PR for another project, so here goes. I tried this code: https://github.com/abnormalbrain/bevy_particle_systems/pull/72/files

I expected to see this happen: used_underscore_binding not triggered for fields without underscore.

note: `_texture` is defined here
  --> src/components.rs:58:9
   |
58 |         texture: Handle<Image>,
   |         ^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding

As you can see, there is no _texture here.

Instead, this happened: used_underscore_binding triggered for fields without underscore.

Version

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Bytekeeper commented 3 months ago

I cannot change the labels, but it's not I-false-negative - it's a false positive.

alex-semenyuk commented 3 months ago

@rustbot label +i-false-positive -i-false-negative