Help uncover issues with too few features requested that is masked by feature unification #14021
Labels
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
A-features
Area: features — conditional compilation
C-bug
Category: bug
S-triage
Status: This issue is waiting on initial triage.
Problem
Due to the way dependency features get consolidated across the packages that happen to be being built at the same time,
cargo check --all
can mask problems where insufficient features are specified for a dependency by one of the packages in a workspace.For the purposes of demonstration, I use a dependency (
dep
) within the workspace, but I originally observed this issue with a dependency from crates.io.Steps
Run the following command in an empty directory:
This creates the following files:
Cargo.toml
src/lib.rs
user1/Cargo.toml
user2/Cargo.toml
user*/src/main.rs
Run
cargo check --all
and note that it executes successfully. Conclude that all the packages in the workspace compile correctly.Run
cargo check -p user1
and have your expectations subverted –user1
only works becauseuser2
requested theopt
feature fromdep
.Possible Solution(s)
I am honestly unsure whether it's possible to solve this. Ideally
rustc
would track whether the items that are being accessed have actually been requested as features by the crate that's accessing them, or if they're compiled in because of a different consumer. Considering that trait implementations can becfg
'd out, I don't think this is practical.Still, I decided to report this surprising behavior in case someone here has any ideas on this.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: