rust-lang / rust-lang/rust-clippy

Clippy with `--no-deps` emits unexpected warnings from deps or should have emitted warnings as expected

Open
#13,983 4 comments 0 reactions 1 assignee View on GitHub

@km274 is already working on this.

Since Aug 30, 2025.

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

Description

Summary

Zulipchat: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/unexpected.20results.20of.20clippy.20with.20.60--no-deps.60/near/459710102

Reproducer

There is a minimum reproducible repo: https://github.com/os-checker/bug-MRE-clippy-no-deps

echo Bug Case 1

cargo clean
echo expected warning
cargo clippy --no-deps --manifest-path ./a-dep/Cargo.toml
echo unexpected warning from a-dep
cargo clippy --no-deps --manifest-path ./b-dep/Cargo.toml

echo Bug Case 2

cargo clean
echo expected no warning from a-dep
cargo clippy --no-deps --manifest-path ./b-dep/Cargo.toml
echo unexpected no warning
cargo clippy --no-deps --manifest-path ./a-dep/Cargo.toml
// a-dep/src/lib.rs
pub struct A {}

impl A {
    pub fn new() -> A {
        A {}
    }
}
/// b-dep/src/lib.rs
$ sh ./reproducible.sh
Bug Case 1
     Removed 23 files, 56.1KiB total
expected warning
    Checking a-dep v0.1.0 (/rust/tmp/clippy-no-deps/a-dep)
warning: you should consider adding a `Default` implementation for `A`
...

warning: `a-dep` (lib) generated 1 warning (run `cargo clippy --fix --lib -p a-dep` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
unexpected warning from a-dep 👈👈👈 only check b-dep, but a-dep's result is included here
warning: you should consider adding a `Default` implementation for `A`
...
warning: `a-dep` (lib) generated 1 warning (run `cargo clippy --fix --lib -p a-dep` to apply 1 suggestion) 
    Checking b-dep v0.1.0 (/rust/tmp/clippy-no-deps/b-dep) 👈👈👈 b-dep is empty without any code!
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
Bug Case 2
     Removed 24 files, 102.4KiB total
expected no warning from a-dep
    Checking a-dep v0.1.0 (/rust/tmp/clippy-no-deps/a-dep)
    Checking b-dep v0.1.0 (/rust/tmp/clippy-no-deps/b-dep)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
unexpected no warning 👈👈👈 only check a-dep, but no result????
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Version
rustc 1.85.0-nightly (7f75bfa1a 2024-12-30)
binary: rustc
commit-hash: 7f75bfa1ad4e9a9d33a179a90603001515e91991
commit-date: 2024-12-30
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.