Skip to content

False positive on used_underscore_binding #9131

Closed
@hellow554

Description

@hellow554

Summary

Maybe that lint should check for the #[automatically_derived] attribute on impls to fix this?

Lint Name

used_underscore_binding

Reproducer

I tried this code:

#[derive(Clone, Debug)]
pub struct TupleCombinations<I> {
    _mi: I,
}

I saw this happen:

warning: used binding `_mi` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
 --> src/main.rs:4:5
  |
1 | #[derive(Clone, Debug)]
  |          ----- in this derive macro expansion
...
4 |     _mi: I,
  |     ^^^^^^
  |
  = note: requested on the command line with `-W clippy::used-underscore-binding`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
  = note: this warning originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: used binding `_mi` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
 --> src/main.rs:4:5
  |
1 | #[derive(Clone, Debug)]
  |                 ----- in this derive macro expansion
...
4 |     _mi: I,
  |     ^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
  = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen:

Nothing

Version

rustc 1.64.0-nightly (27eb6d701 2022-07-04)
binary: rustc
commit-hash: 27eb6d7018e397cf98d51c205e3576951d766323
commit-date: 2022-07-04
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions