Skip to content

Commit f5a4282

Browse files
committed
Add some documentation about unstable namespaced-features feature
1 parent dc5d023 commit f5a4282

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/doc/src/reference/unstable.md

+27
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,30 @@ opt-level = 3
227227
```
228228

229229
Overrides can only be specified for dev and release profiles.
230+
231+
232+
### Namespaced features
233+
* Original issue: [#1286](https://github.com/rust-lang/cargo/issues/1286)
234+
235+
Currently, it is not possible to have a feature and a dependency with the same
236+
name in the manifest. If you set `namespaced-features` to `true`, the namespaces
237+
for features and dependencies are separated. The effect of this is that, in the
238+
feature requirements, dependencies have to be prefixed with `crate:`. Like this:
239+
240+
```toml
241+
[project]
242+
namespaced-features = true
243+
244+
[features]
245+
bar = ["crate:baz", "foo"]
246+
foo = []
247+
248+
[dependencies]
249+
baz = { version = "0.1", optional = true }
250+
```
251+
252+
To prevent unnecessary boilerplate from having to explicitly declare features
253+
for each optional dependency, implicit features get created for any optional
254+
dependencies where a feature of the same name is not defined. However, if
255+
a feature of the same name as a dependency is defined, that feature must
256+
include the dependency as a requirement, as `foo = ["crate:foo"]`.

0 commit comments

Comments
 (0)