dependencies foo?/bar
that are disabled should not need to be available during dependency resolution
#11698
Labels
Uh oh!
There was an error while loading. Please reload this page.
Problem
I'm trying to adapt the tooling that is used in Fedora Linux (and some other related distributions) to work with
dep:foo
andfoo?/bar
feature dependency syntax, but I have now hit a rather annoying roadblock:It appears that conditionally enabled dependency features (accidentally?) are still required to be available during dependency resolution, even if they end up being completely unused (because they are not enabled). This might be an oversight from when this feature was implemented (for Rust 1.60.0), since other optional dependencies that are disabled aren't required to be available during dependency resolution either.
Needing to pull in additional dependencies (that end up being completely unused during the build) would be a real pain for Rust builds in Linux distributions, since it will increase the "breadth" of the dependency tree greatly for any crate that uses weak dependency features like this.
Steps
For example, in
time v0.3.17
, the "default" feature pulls in the following features as dependencies:{"default", "std", "alloc", "serde?/alloc"}
. In this case, thedep:serde
dependency isn't even included, and so the theserde?/alloc
feature should be ignored. However, cargo still fails to build the crate ifserde
is not available:error: no matching package named
serdefound
Possible Solution(s)
Cargo should ignore optional dependencies that are only mentioned in disabled "weak dependency features" during dependency resolution (they are already ignored when building the crate), similar to other disabled optional dependencies.
Notes
Version
I have tested this with the
cargo
binary provided by Fedora Linux (because that's the onlycargo
that is available for our package builds):However, no downstream patches are applied to cargo in Fedora Linux as far as I can tell, so this should be very close to cargo from an official Rust toolchain installed with rustup.
The text was updated successfully, but these errors were encountered: