-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed as not planned
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fixStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Description
Problem
Cargo.toml
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]
libc = "*"src/lib.rs
#![deny(unused_crate_dependencies)]src/main.rs
#![deny(unused_crate_dependencies)]
use hello as _;
use libc;
fn main() {
let _: libc::size_t = 0;
}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
Metadata
Metadata
Assignees
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fixStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix