Setting features for dev-dependencies in [features] causes crate to be unusable as dependency


#1

So I have 3 crates with the following Cargo.toml files.
some_tests:

[package]
name = "some_tests"
version = "0.0.0"

[features]
default = [use-std]
use-std = []

Foo:

[package]
name = "foo"
version = "0.0.0"

[dev-dependencies]
some_tests = {path = "../some_tests", default-features = false}

[features]
default = [use-std]
use-std = ["some_tests/use-std"]

And bar:

[package]
name = "bar"
version = "0.0.0"

[dependencies]
foo = {path = "../foo", default-features = false}

[features]
default = [use-std]
use-std = ["foo/use-std"]

Rationale behind such structure is that I want to be able to disable some parts of test suit which are not compatible with no_std. foo gets compiled all right, but then I try to compile bar I get the following error:

error: Package `foo v0.0.0 (file:///path/to/foo)` does not have these features: `some_tests`

As I understand problem is that dev-dependencies do not propagate to higher level crates, so then I try to compile bar cargo can’t see some_tests dependency for foo thus failing to set necessary feature.

How can be this fixed or is there a better way of doing this?


#2

This is https://github.com/rust-lang/cargo/issues/2596


#3

This issue was closed in favor of this issue: https://github.com/rust-lang/cargo/issues/1796
Looks like last comment there mentions my problem:

Actually, it also shows up when:

  • The exact same dependency is used as both a dev and non-dev dependency.
  • The dependency does not specify any features.
  • The dev-dependency version says default-features=false.

It’s a shame, but it seems there is no solution for this issue in sight.