Skip to content
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

False positive in used_underscore_binding on _next in a for-loop #1846

Closed
dtolnay opened this issue Jun 23, 2017 · 5 comments · Fixed by #1855
Closed

False positive in used_underscore_binding on _next in a for-loop #1846

dtolnay opened this issue Jun 23, 2017 · 5 comments · Fixed by #1855
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

@dtolnay
Copy link
Member

dtolnay commented Jun 23, 2017

#![cfg_attr(feature = "cargo-clippy", deny(used_underscore_binding))]

pub fn f(bytes: &[u8]) {
    for b in bytes {
        println!("{}", b);
    }
}
error: used binding `_next` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
 --> src/lib.rs:4:5
  |
4 | /     for b in bytes {
5 | |         println!("{}", b);
6 | |     }
  | |_____^
  |
note: lint level defined here
 --> src/lib.rs:1:44
  |
1 | #![cfg_attr(feature = "cargo-clippy", deny(used_underscore_binding))]
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#used_underscore_binding
@llogiq
Copy link
Contributor

llogiq commented Jun 23, 2017

Interesting. They must've changed how a for loop is represented.

@dtolnay
Copy link
Member Author

dtolnay commented Jun 23, 2017

Ah, looks like rust-lang/rust#42634.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 24, 2017

This would have been fixed by rust-lang/rust#39766, but unfortunately I can't really tell why that PR was bad and thus delayed...

frewsxcv referenced this issue in frewsxcv/rust Jun 27, 2017
…ielb1

change binding name of for loop lowering to appease clippy

With the latest change to for loop lowering (rust-lang#42634), a `_next` binding was introduced.
Unfortunately, this [disturbs](https://github.com/Manishearth/rust-clippy/issues/1846) clippy's `used_underscore_binding` lint. This commit just renames the binding to `__next` so clippy will be happy. It should have no other effect.
@dtolnay
Copy link
Member Author

dtolnay commented Jun 28, 2017

Fixed by rust-lang/rust#42871 in rustc 1.20.0-nightly (f590a44 2017-06-27). Thanks!

@dtolnay dtolnay closed this as completed Jun 28, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2017

I'm fixing the for loop repr problems... All our for lints have stopped doing anything meaningful

@oli-obk oli-obk reopened this Jun 28, 2017
@rustbot rustbot added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Sep 13, 2021
# for free to join this conversation on GitHub. Already have an account? # 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
Development

Successfully merging a pull request may close this issue.

5 participants