Skip to content

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

Open
@zjp-CN

Description

@zjp-CN

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions