unused-crate-dependencies
conflicts in lib and bin crates
#12854
Labels
A-cargo-targets
Area: selection and definition of targets (lib, bins, examples, tests, benches)
C-bug
Category: bug
S-blocked-external
Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Problem
Cargo.toml
src/lib.rs
#![deny(unused_crate_dependencies)]
src/main.rs
In package
hello
,libc
is needed by bin crate, not lib crate.Steps
To reproduce, run
cargo build
. The build fails.Possible Solution(s)
Because
libc
is needed by the bin crate, we have to list it as a package dependency. But then the lib crate complains.One possible solution is to have each crate specify its own dependencies. The package-level dependencies would then be the union of all crate-level dependencies. But crate-level dependencies make more sense because users of a package may not want everything in the package. For example a user merely interested in using the library crate shouldn't be forced to pull dependencies required by binary crates.
Notes
No response
Version
No response
The text was updated successfully, but these errors were encountered: