Skip to content

multiple_inherent_impl shouldn't trigger for #[cfg(test)] impl #13040

@nickdrozd

Description

@nickdrozd

Summary

I have a struct with impl block, plus an additional impl block for testing:

struct X {}

impl X {}

#[cfg(test)]
impl X {}

The multiple_inherent_impl lint flags this, but it shouldn't. Combining the two impl blocks would cause a change in behavior, namely enabling the test methods outside of the test environment.

Lint Name

multiple_inherent_impl

Reproducer

No response

Version

rustc 1.81.0-nightly (6292b2af6 2024-07-02)
binary: rustc
commit-hash: 6292b2af620dbd771ebb687c3a93c69ba8f97268
commit-date: 2024-07-02
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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 have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions