Skip to content

clippy::cargo lint is applied to sibling crates #13745

Open
@purplesyringa

Description

@purplesyringa

Summary

When #[warn(clippy::cargo)] is enabled in one crate in a workspace, warnings are emitted for other crates in the same workspace too.

Reproducer

I tried this code:

.
├── a
│  ├── Cargo.toml
│  └── src
│     └── main.rs
├── b
│  ├── Cargo.toml
│  └── src
│     └── main.rs
├── Cargo.lock
└── Cargo.toml

a/src/main.rs:

#![warn(clippy::cargo)]

fn main() {
    println!("Hello, world!");
}

b/src/main.rs:

fn main() {
    println!("Hello, world!");
}

I expected to see this happen: cargo clippy emits warnings for a but not b

Instead, this happened: cargo clippy emits warnings for both a and b

Version

rustc 1.84.0-nightly (1e4f10ba6 2024-10-29)
binary: rustc
commit-hash: 1e4f10ba6476e48a42a79b9f846a2d9366525b9e
commit-date: 2024-10-29
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions