From f5a4282e0bffad9048437d3d11288fc152e33022 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 23 Apr 2018 09:18:08 +0200 Subject: [PATCH] Add some documentation about unstable namespaced-features feature --- src/doc/src/reference/unstable.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 483e5e253..ca004ccce 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -227,3 +227,30 @@ opt-level = 3 ``` Overrides can only be specified for dev and release profiles. + + +### Namespaced features +* Original issue: [#1286](https://github.com/rust-lang/cargo/issues/1286) + +Currently, it is not possible to have a feature and a dependency with the same +name in the manifest. If you set `namespaced-features` to `true`, the namespaces +for features and dependencies are separated. The effect of this is that, in the +feature requirements, dependencies have to be prefixed with `crate:`. Like this: + +```toml +[project] +namespaced-features = true + +[features] +bar = ["crate:baz", "foo"] +foo = [] + +[dependencies] +baz = { version = "0.1", optional = true } +``` + +To prevent unnecessary boilerplate from having to explicitly declare features +for each optional dependency, implicit features get created for any optional +dependencies where a feature of the same name is not defined. However, if +a feature of the same name as a dependency is defined, that feature must +include the dependency as a requirement, as `foo = ["crate:foo"]`. -- 2.30.2