v2 resolver: proc macros specified in initials participate in feature resolution for both target and host
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Problem
I'm writing some tests with cargo-guppy + the v2 resolver, and it appears that currently, proc macros specified in the initial set participate in feature resolution for the host, not just the target platform.
Steps
git clone https://github.com/facebookincubator/cargo-guppy && cd cargo-guppy
git checkout d5781f069ea57b2d0ec80fddb410978eb1b0f2d5
cd fixtures/workspace/inside-outside/workspace
cargo +nightly build -p internal-macro -p internal -Zfeatures=all --verbose
Note these two lines from the output:
Running `rustc --crate-name external --edition=2018 /Users/rain1/local/cargo-guppy/fixtures/workspace/inside-outside/external/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="internal-build-feature"' --cfg 'feature="macro-build-feature"' --cfg 'feature="macro-normal-feature"' [...]
--error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="macro-normal-feature"' [...]
Note that external is built twice:
- The first line is for the host, which looks correct: normal + build + macro-normal
- The second line is for the target, in which case
macro-normal-featureis included. This shouldn't be because proc macros are built on the host only, not the target.
Notes
Output of cargo version:
cargo 1.45.0-nightly (9fcb8c1d2 2020-05-25)
Also reproduces with 15bb455d12ca42b48b659e7c7c831ba621e95ec4, which is the pinned version here.
This can also be reproduced with the cargo-compare tool checked into the repo. Check out my test branch https://github.com/sunshowers/cargo-guppy/tree/cargo-compare-fix, then run:
PROPTEST_MULTIPLIER=64 PROPTEST_VERBOSE=1 cargo test --release -p cargo-compare -- inside_outside --nocapture
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.
Research direction
Start by reproducing the issue in the linked cargo-guppy fixture at fixtures/workspace/inside-outside/workspace with the provided cargo +nightly build command. Compare the host and target rustc invocations and verify that proc-macro features from the initial set are excluded from target resolution while remaining available for the host.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100