Repository navigation
implement package feature unification - #15684
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use |
ad48f18 to
e94564d
Compare
e94564d to
c6090d5
Compare
|
Thanks for moving this forward! |
c6090d5 to
e5a3134
Compare
|
Feel free to edit the commits as needed |
b10f5d9 to
2457810
Compare
|
I've also just added a test with weak dependencies, which works. I tried to also add namespaced |
2457810 to
d28a30f
Compare
d28a30f to
a8b46d7
Compare
a8b46d7 to
52725c0
Compare
|
Just need to double check on one question (#15684 (comment)) but otherwise, this looks good. Thanks for your work on this and patience through the review feedback! |
cd1cff4 to
20021a9
Compare
Honestly, this has been a blast. I wouldn't say I needed pretty much any patience with how fast you were reacting to each iteration. Thanks for the time and reviews! |
| #[cargo_test] | ||
| fn package_feature_unification_grandchild_cli_features() { | ||
| let p = project() | ||
| .file( | ||
| "Cargo.toml", | ||
| r#" | ||
| [workspace] | ||
| resolver = "2" | ||
| members = ["parent", "child", "grandchild"] | ||
| "#, | ||
| ) | ||
| .file( | ||
| "grandchild/Cargo.toml", |
There was a problem hiding this comment.
Whats the intention of this test?
There was a problem hiding this comment.
I tried to cover what you were talking about regarding turning on features of non-selected dependency crates inside a workspace. I thought it would be different in some cases based on feature-unification but it's consistent.
Do you want me to remove this?
There was a problem hiding this comment.
There are three cases for foo in foo/bar
- A workspace member
- A direct dep of a workspace member
- An indirect dep of a workspace member
In #15684 (comment), I was talking about (2) while this test covers (1).
There was a problem hiding this comment.
Right, I tried to cover the first two cases in the original package_feature_unification_cli_features.
Here I tried specifically to get close to 3 but since that does not work in the general case, I tried to get closer to it by the indirect dependency being part of the workspace, but either not being selected or being excluded.
I was unsure about how some of the scenarios would (or wouldn't) work but arguably since all of the cases work the same way regardless of feature-unification, it might not belong here as it's more of a general features test. Or it might as it should be the same for all of them.
So I can either leave this as is, move it somewhere or just remove it completely.
And if you want the other cases covered more than they are in the other test, feel free to tell me.
There was a problem hiding this comment.
Right, I tried to cover the first two cases in the original package_feature_unification_cli_features.
Ok, that looks to be the case "check -p a -F a/a,outside/b".
So I can either leave this as is, move it somewhere or just remove it completely.
Unsure but we should at least make the name more clear that this is focused on activating features for specific packages only within a workspace, contracted with package_feature_unification_cli_features which focused on a combination of workspace members and registry dependencies while having a similar name of package_feature_unification_grandchild_cli_features.
There was a problem hiding this comment.
I've renamed the second one to feature_unification_of_cli_features_within_workspace. I didn't come up with anything more descriptive yet reasonable than package_feature_unification_cli_features for the first one so I've left that as is.
20021a9 to
f7b58c2
Compare
|
@mladedav looks like there is a conflict? |
f7b58c2 to
e4a616b
Compare
|
Right, I've rebased this on top of master now |
|
Thanks! |
Update cargo 14 commits in 930b4f62cfcd1f0eabdb30a56d91bf6844b739bf..eabb4cd923deb73e714f7ad3f5234d68ca284dbe 2025-06-28 14:58:43 +0000 to 2025-07-09 22:07:55 +0000 - feat: Implementation and tests for `multiple-build-scripts` (rust-lang/cargo#15704) - perf: Speed up TOML parsing by upgrading toml (rust-lang/cargo#15736) - Mark cachelock tests that rely on interprocess blocking behaviour as unsupported on AIX. (rust-lang/cargo#15734) - feat(publish): Stabilize multi-package publishing (rust-lang/cargo#15636) - Update to Rust 2024 (rust-lang/cargo#15732) - Clarify package ID specifications in SBOMs are fully qualified (rust-lang/cargo#15731) - chore(deps): update cargo-semver-checks to v0.42.0 (rust-lang/cargo#15730) - test: Switch config tests to use snapshots (rust-lang/cargo#15729) - implement package feature unification (rust-lang/cargo#15684) - chore: Upgrade dependencies (rust-lang/cargo#15722) - Report valid file name when we can't find a build target for `name = "foo.rs"` (rust-lang/cargo#15707) - chore(release): Publish build-rs on release (rust-lang/cargo#15708) - Override `Cargo.lock` checksums when doing a dry-run `publish` (rust-lang/cargo#15711) - test(rustfix): Update for nightly (rust-lang/cargo#15717) r? ghost
### What does this PR try to resolve? Fixes a bug introduced by #15684 where the incorrect list of package specs was being returned from `resolve_ws_with_opts` depending on the feature unification mode. This resulted in things like `cargo tree` producing the wrong output under workspace feature unification mode. #16584 attempted to address this but it didn't fix the root cause of the issue. I also cleaned up some of the logic in `resolve_ws_with_opts` so it's less confusing. Fixes #16583. ### How to test and review this PR? Verify that the changes to `resolve_ws_with_opts` look correct. Feature unification tests should pass for each individual commit.
View all comments
What does this PR try to resolve?
Implements another part of feature unification (#14774, rfc). The
workspaceoption was implemented in #15157, this adds thepackageoption.How to test and review this PR?
The important change is changing
WorkspaceResolveso it can contain multipleResolvedFeatures. Along with that, it also needs to know which specs those features are resolved for. This was used in several other places:cargo fix --edition(from 2018 to 2021) - I think it should be ok to disallow usingcargo fix --editionwhen someone already uses this feature.cargo tree- I just use the first feature set. This is definitely not ideal, but I'm not entirely sure what's the correct solution here. Printing multiple trees? Disallowing this, forcing users to select only one package?Based on comments in #15157 I've added tests first with
selectedfeature unification and then changed that after implementation. I'm not sure if that's how you expect the tests to be added first, if not, I can change the history.I've expanded the test checking that this is ignored for
cargo installalthough it should work the same way even if it is not ignored (selectedandpackageare the same thing when just one package is selected).