Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive on used_underscore_binding #9131

Closed
hellow554 opened this issue Jul 7, 2022 · 1 comment · Fixed by rust-lang/rust#99026 or rust-lang/rust#99047
Closed

False positive on used_underscore_binding #9131

hellow554 opened this issue Jul 7, 2022 · 1 comment · Fixed by rust-lang/rust#99026 or rust-lang/rust#99047
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@hellow554
Copy link
Contributor

hellow554 commented Jul 7, 2022

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

@hellow554 hellow554 added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jul 7, 2022
@anall
Copy link
Contributor

anall commented Jul 7, 2022

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 8, 2022
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by rust-lang#98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: rust-lang/rust-clippy#9131
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 8, 2022
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by rust-lang#98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: rust-lang/rust-clippy#9131
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 8, 2022
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by rust-lang#98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: rust-lang/rust-clippy#9131
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 8, 2022
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#95635 (sess: stabilize `--terminal-width` as `--diagnostic-width`)
 - rust-lang#98718 (Stabilize `into_future`)
 - rust-lang#98795 (A few cleanups)
 - rust-lang#98798 (Fix caching bug in `download-rustc = true`)
 - rust-lang#99019 (Add doc comments in `rustc_middle::mir`)
 - rust-lang#99026 (Add test for and fix rust-lang/rust-clippy#9131)

Failed merges:

 - rust-lang#98957 ( don't allow ZST in ScalarInt )

r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jul 14, 2022
This lint seems to have been broken by #98446
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jul 14, 2022
Add test for and fix rust-lang#9131

This lint seems to have been broken by #98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: rust-lang#9131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
2 participants