Skip to content

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

@ehuss

Description

@ehuss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions