Skip to content

namespaced-features allows implicitly named features with overlapping optional deps #8047

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

Closed
ehuss opened this issue Mar 27, 2020 · 0 comments · Fixed by #8799
Closed

namespaced-features allows implicitly named features with overlapping optional deps #8047

ehuss opened this issue Mar 27, 2020 · 0 comments · Fixed by #8799
Labels
A-namespaced-features Area: namespaced-features C-bug Category: bug

Comments

@ehuss
Copy link
Contributor

ehuss commented Mar 27, 2020

With namespaced-features, if a feature name overlaps with an optional dependency, Cargo seems to allow an implicit feature by that name, but that doesn't seem right.

Problem
Given this:

cargo-features = ["namespaced-features"]

[package]
name = "foo"
version = "0.1.0"
namespaced-features = true

[dependencies]
bitflags = {version="*", optional=true}

[features]
foo = ["bitflags"]

Normally if you have a feature on the right-hand-side of a feature definition, it must be a real feature. However, in this case Cargo lets it slide, which it normally doesn't.

cargo build --features bitflags <-- doesn't build bitflags

I would expect, at least, following the rules, you would need to specify:

bitflags = []

But on top of that, I think creating features names that overlap with optional dependencies is probably not the best behavior, and likely to be confusing.

Notes

cargo 1.44.0-nightly (7019b3ed3 2020-03-17)

cc @djc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-namespaced-features Area: namespaced-features C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant