Skip to content

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

Closed
@dtolnay

Description

@dtolnay
#![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

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