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

Cargo check has false negatives in a workspace with internal dependencies #12470

Closed
Wodann opened this issue Aug 9, 2023 · 2 comments
Closed
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@Wodann
Copy link

Wodann commented Aug 9, 2023

Problem

When using a workspace that has multiple crates that depend on each other, enabling of feature flags prevents running of cargo check --no-default-features on all crates.

Steps

Example workspace:

  • crates
    • A [features: Foo]
    • B [depends on: A with feature Foo enabled]

Running

cargo c --no-default-features

inside {workspace-dir}/crates/A will cause errors when anything that should be hidden behind the Foo feature flag is referenced

cargo c --no-default-features --all

inside {workspace-dir} does not cause any errors.

Possible Solution(s)

I'd potentially expect two version of A to be checked:

  • One that complies with the cargo check --no-default-features command
  • One that suffices the dependency for B (Foo enabled)

Notes

No response

Version

cargo 1.70.0 (ec8a8a0ca 2023-04-25)
release: 1.70.0
commit-hash: ec8a8a0cabb0e0cadef58902470f6c7ee7868bdc
commit-date: 2023-04-25
host: x86_64-pc-windows-msvc
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:Schannel)
os: Windows 10.0.22621 (Windows 10 Home) [64-bit]
@Wodann Wodann added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 9, 2023
@epage
Copy link
Contributor

epage commented Aug 9, 2023

We generally refer to this as "feature unification" and this is expected. When only do one build combination within a run. I believe #4463 is the most relevant existing issue for this.

One workaround is to use tools like cargo-hack to do multiple cargo check runs.

Going to go ahead and close this but if there is something I missed, let us know and we can re-open it!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
@weihanglo
Copy link
Member

For more on feature unification, see https://doc.rust-lang.org/cargo/reference/features.html#feature-unification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants