Skip to content

iter_without_into_iter fires on code generated by macros from other crates #12037

Closed
@jyn514

Description

@jyn514

Summary

iter_without_into_iter fires on external macros.

Lint Name

iter_without_into_iter

Reproducer

I tried this code with bitflags version 2.3.2 (note that later versions may not reproduce the lint):

#![warn(clippy::pedantic)]

bitflags::bitflags! {
    pub struct HttpComponents: u16 {
        const REQUEST_RESPONSE = 1 << 0;
    }
}

I saw this happen:

warning: `iter` method without an `IntoIterator` impl for `&$BitFlags`
  --> src/main.rs:4:1
   |
4  | / bitflags! {
5  | |     ///  Configuration for HTTP metadata fields.
6  | |     #[derive(Copy, Clone)]
7  | |     pub struct HttpComponents: u16 {
...  |
18 | |     }
19 | | }
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_without_into_iter
   = note: this warning originates in the macro `__impl_public_bitflags_iter` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen: No warning, because this is not code I can change.

Version

clippy 0.1.75 (82e1608d 2023-12-21)
rustc 1.75.0 (82e1608df 2023-12-21)

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-macrosType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions