Skip to content

Activation of features of non-optional dependencies breaks manifest for 2024 edition #14283

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-editionsArea: edition-specific issuesArea: edition-specific issuesA-featuresArea: features — conditional compilationArea: features — conditional compilationA-namespaced-featuresArea: namespaced-featuresArea: namespaced-featuresC-bugCategory: bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions