Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sunshowers opened this issue Jun 2, 2020 · 3 comments
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug

Comments

@sunshowers
Copy link
Contributor

sunshowers commented Jun 2, 2020

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

@sunshowers sunshowers added the C-bug Category: bug label Jun 2, 2020
@sunshowers sunshowers changed the title v2 resolver: proc macros specified in initials participate in feature resolution for host v2 resolver: proc macros specified in initials participate in feature resolution for both target and host Jun 2, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 2, 2020

There is a comment here discussing this issue.

I'm trying to think if it would be possible to special-case this, but there are many edge cases that are difficult to deal with. I'm not sure if it is feasible to do it any other way.

@ehuss ehuss added the A-features2 Area: issues specifically related to the v2 feature resolver label Jun 2, 2020
@sunshowers
Copy link
Contributor Author

sunshowers commented Jun 2, 2020

Sounds good, thanks! Just wanted to make sure it was on the radar. If you decide not to fix it, feel free to close this issue and I can refer to it in guppy.

@leighmcculloch
Copy link

Another example that reproduces this is detailed in #10827.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants