feat(toml): allow overriding inherited default-features in 2024#17126
feat(toml): allow overriding inherited default-features in 2024#171260xPoe wants to merge 7 commits into
Conversation
c1ee481 to
a6548d4
Compare
Impl RFC 3945, on Edition 2024+ allow workspace members to override the workspace dependency's `default-features` setting. Earlier editions are unchanged: setting `default-features` on an inherited dependency is still ignored with a warning. Signed-off-by: 0xPoe <techregister@pm.me>
a6548d4 to
72f4119
Compare
Signed-off-by: 0xPoe <techregister@pm.me>
72f4119 to
62db596
Compare
|
Will we need to update https://doc.rust-lang.org/edition-guide/rust-2024/cargo-inherited-default-features.html as part of this? |
`cargo add --no-default-features` (or `--default-features`) against a dependency inherited from `[workspace.dependencies]` is now allowed when the package is on Edition 2024+, matching the manifest behavior. Earlier editions still error, pointing the user to the workspace manifest. Signed-off-by: 0xPoe <techregister@pm.me>
Signed-off-by: 0xPoe <techregister@pm.me>
Signed-off-by: 0xPoe <techregister@pm.me>
f2f677f to
17595ac
Compare
Yes, I will create a PR for this. |
33ca750 to
1b14f50
Compare
There was a problem hiding this comment.
🔢 Self-check (PR reviewed by myself and ready for feedback)
-
Code compiles successfully
-
Unit tests added
-
No AI-generated elegant nonsense in PR.
-
Comments added where necessary
-
PR title and description updated
-
Documentation updated
-
PR size is reasonable
| - [`default-features`][default-features] (Edition 2024 packages, requires Rust 1.98+): | ||
| Overrides the value set in `[workspace.dependencies]`. | ||
| If neither the package nor the workspace specifies `default-features`, it defaults to `true`. | ||
| Before Rust 1.98, or in earlier editions, package-level `default-features = false` |
There was a problem hiding this comment.
Not sure if this is the perfect word for it, and not sure how detailed we should be here.
| false, | ||
| None, | ||
| true, | ||
| None, |
There was a problem hiding this comment.
Do we have a test case for
$ cargo init
$ cargo add foo --default-featuresie explicit --default-features with the foo = "1.0" case
There was a problem hiding this comment.
No, we don’t have a case that compiles with cargo init, especially with edition 2024. So I added a new one.
There was a problem hiding this comment.
Just dropped it, as I had a conversation with @epage offline. He didn’t mean to literally have cargo init here, but to start with a fresh Cargo.toml. A test would exist to make sure --default-features doesn’t set default-features = true when it isn’t needed, as tests/testsuite/cargo_add/default_features already covered this. So I dropped my last commit.
e97fffa to
62a3dd8
Compare
Signed-off-by: 0xPoe <techregister@pm.me>
Signed-off-by: 0xPoe <techregister@pm.me>
62a3dd8 to
0cf7b7e
Compare
|
@epage has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
0cf7b7e to
c4ed736
Compare
|
Nothing changed, just dropped an unnecessary test commit. See: #17126 (comment) |
|
☔ The latest upstream changes (possibly #17230) made this pull request unmergeable. Please resolve the merge conflicts. |
What does this PR try to resolve?
close #16959
Implement RFC 3945, on Edition 2024+ allow workspace members to override the workspace dependency's
default-featuressetting.Earlier editions are unchanged: setting
default-featureson an inherited dependency is still ignored with a warning.Also, this change would allow
cargo add X --no-default-features -p Y, but only on Edition 2024+.How to test and review this PR?
Review and check it commit by commit.
r?@ghost