v2 resolver: different handling for inactive, optional dependencies based on how they're specified
@ehuss is already working on this.
Since Jun 25, 2020.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
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
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.