rust-lang / rust-lang/rust-clippy

clippy::cargo lint is applied to sibling crates

Open
#13,745 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the workspace using a/src/main.rs and b/src/main.rs, with #[warn(clippy::cargo)] only in crate a, then trace how cargo lint warnings are applied across workspace crates. Done means cargo clippy reports the cargo-lint warnings for a without emitting them for sibling crate b.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.