Skip to content

v2 resolver: different handling for inactive, optional dependencies based on how they're specified #8316

@sunshowers

Description

@sunshowers

Problem
Looks like the v2 resolver appears to have some small differences to a dependency that's optional, target-specific, and currently inactive, based on how it's specified.

Specifically, if inactive is a target-specific, optional dependency that is inactive on the platform under consideration:

[features]
foo = ["inactive/extra"]

causes the inactive feature to not be activated, while

[features]
foo = ["inactive", "inactive/extra"]

does cause the feature to be activated.

Steps

Test workspace.

git clone https://github.com/sunshowers/cargo-guppy && cd cargo-guppy
git checkout bce9ea7e6150049a8e660b401b7dabf79f8abdef
cd fixtures/workspace/inside-outside/workspace
cargo clean && cargo +nightly build -Zfeatures=all -p internal --all-features --verbose 2>&1 | grep -F -- "--crate-name internal "

causes:

     Running `rustc --crate-name internal --edition=2018 internal/src/lib.rs
--error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="build-feature"' --cfg 'feature="default"' --cfg 'feature="dev-feature"' --cfg 'feature="extra"' [...]

Now if you change to:

[features]
extra = ["x86-active', "x86-active/extra"]

You'll get:

     Running `rustc --crate-name internal --edition=2018 internal/src/lib.rs
--error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="build-feature"' --cfg 'feature="default"' --cfg 'feature="dev-feature"' --cfg 'feature="extra"' --cfg 'feature="x86-active"' [...]

There is no difference between the two for active features, as you can find out by setting --target i686-unknown-linux-gnu.

Possible Solution(s)
A uniform solution for both, I'd prefer the x86-active feature to be present for both I think.

Notes

Output of cargo version:

cargo 1.45.0-nightly (9fcb8c1d2 2020-05-25)

cc @ehuss

Metadata

Metadata

Assignees

Labels

A-documenting-cargo-itselfArea: Cargo's documentationA-features2Area: issues specifically related to the v2 feature resolverC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions