Optional dependencies with same name


#1

Imagine that you have something like:

[dependencies.clap]
version = "2"
optional = true

[build-dependencies.clap]
version = "2"
default-features = false
optional = true

Then you reference clap dependency from one of your features, which one would be referenced? Both?

P.S. this is not entirely theoretical case, see https://pagure.io/fedora-rust/rust2rpm/pull-request/60#comment-67442


#2

Features are currently conflated across dependencies / dev-dependencies / build-dependencies. There are a few issues about this in the Cargo issue tracker – see rust-lang/cargo#4361, rust-lang/cargo#4664, rust-lang/cargo#5730. So:

[features]
x = ["clap/..."]

would affect both.

This may change in the future.


#3

IIUC, that technically it is merged, Right?

So if one has default-features=false and other doesn’t, cargo will always make sure that clap always have default-features enabled. Right?


#4

You could try it to make sure, but yes that is my understanding.