Skip to content

v2 resolver: proc macros specified in initials participate in feature resolution for both target and host #8312

@sunshowers

Description

@sunshowers

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

Test workspace is here.

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-feature is 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 15bb455, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-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