Skip to content

Breaking change: cargo metadata no longer distinguishes between "magical" features from optional deps and normal features #10543

Open
@Manishearth

Description

@Manishearth

Problem

In the past, optional dependencies in Cargo would automatically generate a feature. This would not turn up in cargo metadata; tools were supposed to use the fact that they are optional dependencies to deduce this.

Now, with the advent of dep: syntax, optional dependencies automatically add a "foo" = ["dep:foo"] key. It is no longer possible to distinguish between magical optional features and explicit features. This is means that the user's intent is lost, and tools like cargo-all-features can no longer work well.

For example, cargo-all-features has a skip_optional_dependencies flag that allows one to only test permutations of explicitly defined features. This behavior has silently changed on 1.60, making the tool suddenly start taking forever in CI (see frewsxcv/cargo-all-features#29)

Steps

Run cargo metadata on any crate with optional dependencies before and after 1.60, and see the difference.

Possible Solution(s)

No response

Notes

I personally consider this a breaking change to the metadata; but even if we're okay with that level of change I do think that there should be some way to distinguish between user-supplied and magically-created deps, and ideally some way to do this that allows one to distinguish between the old format and the new one

Version

cargo 1.58.0 (f01b232bc 2022-01-19)
release: 1.58.0
commit-hash: f01b232bc7f4d94f0c4603930a5a96277715eb8c
commit-date: 2022-01-19
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Debian rodete (rodete) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-featuresArea: features — conditional compilationC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.regression-from-stable-to-stableRegression in stable that worked in a previous stable release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions