Closed
Description
Problem
Activation of an foo/bar
feature dependency where foo
is not an optional dependency results causes a manifest error in edition 2024:
[dependencies]
foo = "..."
bar = { version = "...", optional = true }
[features]
bar = ["dep:bar", "foo/bar"] # -> ["dep:bar", "foo/bar", "dep:foo"]
...results in...
feature `bar` includes `dep:foo`, but `foo` is not an optional dependency
Explanation
#14221 introduces implicit activation of dep:
for non-weak dependencies when parsing/updating the manifest in edition 2024. This issue appears to be to due to a missing check for whether or not the dependency of the activated feature is marked as optional.
This issue was also brought up in a comment post-merge, and in a Zulip discussion.
Reproducible example
cargo-features = ["edition2024"]
[package]
name = "foobar"
edition = "2024"
version = "0.1.0"
[dependencies]
chrono = "0.4.38"
serde = { version = "1.0.204", optional = true }
[features]
serde = ["dep:serde", "chrono/serde"] # -> ["dep:serde", "chrono/serde", "dep:chrono"]
Version
cargo --version
:
cargo 1.82.0-nightly (5f6b9a922 2024-07-19)
release: 1.82.0-nightly
commit-hash: 5f6b9a92201d78af75dc24f14662c3e2dacbbbe1
commit-date: 2024-07-19