Cargo: Optional dependencies cannot enable features

Created on 21 Aug 2015  ·  3Comments  ·  Source: rust-lang/cargo

In crate X, with an optional dependency A and a mandatory dependency B of X, the feature A associated to the former cannot enable a feature with the same name in B. This means an additional feature bearing a different name must be introduced, making things messy.

Most helpful comment

I’ve also found it confusing that features and (optional?) dependencies share the same namespace.

All 3 comments

Use case:

I am adding SIMD optimisations to rust-encoding. I want the feature to be named "simd" and to enable the same feature in the internal crate encoding-types.

[features]
simd = ["encoding-types/enable-simd"]

[dependencies.simd]
git = "https://github.com/nox/simd"
rev = "438780ca236b1ed2caf032edebda9c9362eaabc6"
optional = true

This won't work because you can't have an optional dependency and a feature bear the same name.

I’ve also found it confusing that features and (optional?) dependencies share the same namespace.

Yeah for now you'll have to choose a separate feature name to activate features and dependencies, otherwise though this is covered by #1286 so I'm going to close in favor of that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

japaric picture japaric  ·  3Comments

sdroege picture sdroege  ·  3Comments

JustAPerson picture JustAPerson  ·  3Comments

fprijate picture fprijate  ·  3Comments

rodoufu picture rodoufu  ·  3Comments