est31 / cargo-udeps

Find unused dependencies in Cargo.toml
Other
1.76k stars 46 forks source link

`cargo-udeps` 1.0.36 crashes when given a `manifest-path` #154

Closed ithinuel closed 1 year ago

ithinuel commented 1 year ago

When called through cargo-hack some arguments are passed to cargo-udeps that lead to a crash/backtrace as visible in: https://github.com/rp-rs/rp-hal/actions/runs/4855558306/jobs/8654546918

replicating the pipeline locally with RUST_BACKTRACE=1 generates this message:

$ RUST_BACKTRACE=1 cargo hack udeps --optional-deps --each-feature
info: running `cargo udeps --no-default-features` on rp2040-hal (1/13)
thread 'main' panicked at 'Mismatch between definition and access: Could not downcast to TypeId { t: 6525541059101503405 }, need to downcast to TypeId { t: 8455232766977344124 }
', /home/ithinuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-0.70.1/src/cargo/util/command_prelude.rs:747:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/core/src/panicking.rs:67:14
   2: <clap_builder::parser::matches::arg_matches::ArgMatches as cargo::util::command_prelude::ArgMatchesExt>::_value_of
   3: cargo::util::command_prelude::ArgMatchesExt::workspace
   4: cargo_udeps::run
   5: cargo_udeps::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `/home/ithinuel/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo udeps --manifest-path rp2040-hal/Cargo.toml --no-default-features` (exit status: 101)

cargo udeps --manifest-path rp2040-hal/Cargo.toml --no-default-features does indeed generates the same crash report.

ithinuel commented 1 year ago

Running from a local clone of cargo-udeps shows more accurate backtrace:

RUST_BACKTRACE=1 cargo run -- udeps --manifest-path ../wilskeeb/vendor/rp-hal/rp2040-hal/Cargo.toml
    Finished dev [unoptimized] target(s) in 0.07s
     Running `target/debug/cargo-udeps udeps --manifest-path ../wilskeeb/vendor/rp-hal/rp2040-hal/Cargo.toml`
thread 'main' panicked at 'Mismatch between definition and access: Could not downcast to alloc::string::String, need to downcast to std::path::PathBuf
', /home/ithinuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-0.70.1/src/cargo/util/command_prelude.rs:747:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9ecda8de85ce893cc3fc748ab06be0b8250147a7/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/9ecda8de85ce893cc3fc748ab06be0b8250147a7/library/core/src/panicking.rs:67:14
   2: cargo::util::command_prelude::ignore_unknown
   3: <clap_builder::parser::matches::arg_matches::ArgMatches as cargo::util::command_prelude::ArgMatchesExt>::_value_of
   4: cargo::util::command_prelude::ArgMatchesExt::value_of_path
   5: cargo::util::command_prelude::ArgMatchesExt::root_manifest
   6: cargo::util::command_prelude::ArgMatchesExt::workspace
   7: cargo_udeps::OptUdeps::run
   8: cargo_udeps::run
   9: cargo_udeps::main
  10: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrac