intellij-rust.github.io icon indicating copy to clipboard operation
intellij-rust.github.io copied to clipboard

Implicit dependency features

Open MixusMinimax opened this issue 3 years ago • 0 comments

Starting with rust 1.60, making a dependency optional no longer creates an implicit feature, but uses the dep: syntax instead.

This is important as it disables the ability to enable internal dependencies of a crate by using the features list.

Current Behavior

Crate A:

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

[dependencies]
bar = { version = "1.2.3", optional = true }

[features]
example = ["bar"]
# This will show a warning, even though it works with ^1.60:
# example = ["dep:bar"]

Crate B (depends on A):

[dependencies]
foo = { version = "2.2.2", features = ["bar"] }
# This is a problem, because I should not be able to enable "bar",
# rather only what is explicitly defined in [features].

Expected Behavior

Crate A:

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

[dependencies]
bar = { version = "1.2.3", optional = true }

[features]
example = ["dep:bar"]

Crate B (depends on A):

[dependencies]
foo = { version = "2.2.2", features = ["bar"] }
# This will now not work, as feature "bar" doesn't exist. You can only use the feature "example".

MixusMinimax avatar Sep 27 '22 15:09 MixusMinimax