Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 implicit feature migration deletes dependency features #14010

Closed
ehuss opened this issue Jun 4, 2024 · 8 comments · Fixed by #14018
Closed

2024 implicit feature migration deletes dependency features #14010

ehuss opened this issue Jun 4, 2024 · 8 comments · Fixed by #14018
Assignees
Labels
A-editions Area: edition-specific issues A-features Area: features — conditional compilation C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jun 4, 2024

Problem

Migrating to 2024 causes foo/feature_name features to get removed for optional dependencies. Those need to be preserved.

Steps

Example manifest:

cargo-features = ["edition2024"]
[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0.203", optional = true }

[features]
serde = ["serde/derive"]

Running cargo fix --edition on this will result in:

serde = ["dep:serde"]

Note that the /derive feature got removed.

Possible Solution(s)

When there is a ["foo/feature_name"] syntax in the [features] table, and dep:foo isn't found anywhere in the [features] table, it should be rewritten to be ["dep:foo", "foo/feature_name"]. Some things to be careful of:

  • Adjust all places that foo/xxx is found (such as x = ["foo/a"] and y = ["foo/b"], both x and y need a "dep:foo")
  • Should not disturb any other features (like ["foo/feature_name", "bar"] would be rewritten to ["dep:foo", "foo/feature_name", "bar"])
  • Should avoid duplicates (["foo/a", "foo/b"] should not have two dep:foo entries added).

Notes

No response

Version

cargo 1.80.0-nightly (7a6fad098 2024-05-31)
release: 1.80.0-nightly
commit-hash: 7a6fad0984d28c8330974636972aa296b67c4513
commit-date: 2024-05-31
host: aarch64-apple-darwin
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0 (sys:0.4.72+curl-8.6.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.5.0 [64-bit]
@ehuss ehuss added C-bug Category: bug A-editions Area: edition-specific issues S-triage Status: This issue is waiting on initial triage. labels Jun 4, 2024
@epage

This comment was marked as resolved.

@epage epage added the A-features Area: features — conditional compilation label Jun 4, 2024
@ehuss

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@linyihai
Copy link
Contributor

linyihai commented Jun 5, 2024

So "dep_name/feature_name" is different from "dep:dep_name", "dep_name?/feature_name" in that the implicit feature doesn't get suppressed.
Yes, I suppose so.

And then the most important step is:
Then If the dep_name/dep_name_feature or dep_name?/dep_name_feature exists, then we should keep them when applying Cargo fix ?

@epage

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-editions Area: edition-specific issues A-features Area: features — conditional compilation C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants