Skip to content

fix: return correct package specs when resolving workspace deps - #17469

Merged
weihanglo merged 4 commits into
rust-lang:masterfrom
aliu:feature-unification-cargo-tree
Sep 16, 2026
Merged

weihanglo merged 4 commits into
rust-lang:masterfrom
aliu:feature-unification-cargo-tree

Conversation

@aliu

@aliu aliu commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

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.

Keeping the project source code contents empty makes it clearer that
we're only testing the behavior of `cargo tree`. Also, use the
`--format` flag to display features as `-e features` is unaffected by
the different feature unification modes.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2026
@rustbot

rustbot commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo
  • Random selection from epage, weihanglo

@weihanglo weihanglo added the Z-feature-unification Nightly: resolver.feature-unifiication label Sep 14, 2026
Comment thread src/ops/resolve.rs
Comment on lines +332 to 341
pkg_set.warn_no_lib_packages_and_artifact_libs_overlapping_deps(
ws,
&resolved_with_overrides,
&member_ids,
has_dev_units,
requested_targets,
target_data,
force_all_targets,
)?;

@weihanglo weihanglo Sep 14, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the move of warn_no_lib_packages_and_artifact_libs_overlapping_deps can be split into its own fix commit I guess. It indeed fixes a duplicate warning issue. I don't think it worth a test though.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out a good way to split this out into a separate commit so I'm just keeping it as is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind me splitting it and push directly to your branch? You can re-commit and rewrite afterward if you like or don't like.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that. Let me know if you are find merging as-is or you want to do any cleanup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh why didn't I think of that 🤦‍♂️. Yeah LGTM, thanks!

Comment thread src/ops/resolve.rs Resolved
Comment thread tests/testsuite/feature_unification.rs Resolved
Comment thread tests/testsuite/feature_unification.rs Resolved
@aliu
aliu force-pushed the feature-unification-cargo-tree branch from 8adf998 to 92acf45 Compare September 15, 2026 09:49
Comment thread src/ops/resolve.rs
Comment on lines +332 to 341
pkg_set.warn_no_lib_packages_and_artifact_libs_overlapping_deps(
ws,
&resolved_with_overrides,
&member_ids,
has_dev_units,
requested_targets,
target_data,
force_all_targets,
)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind me splitting it and push directly to your branch? You can re-commit and rewrite afterward if you like or don't like.

├── common feature "a"
│ └── common v0.1.0 ([ROOT]/foo/common)
├── common feature "default" (command-line)
├── common feature "default"

@weihanglo weihanglo Sep 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to call out this UI change. I am not even sure if this is a fix or a regression. Not a blocker though.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think technically this is a fix since it restores the old behavior.

@weihanglo
weihanglo force-pushed the feature-unification-cargo-tree branch from 92acf45 to d3a1adb Compare September 15, 2026 23:09
Comment thread src/ops/resolve.rs
Comment on lines +332 to 341
pkg_set.warn_no_lib_packages_and_artifact_libs_overlapping_deps(
ws,
&resolved_with_overrides,
&member_ids,
has_dev_units,
requested_targets,
target_data,
force_all_targets,
)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that. Let me know if you are find merging as-is or you want to do any cleanup.

@weihanglo
weihanglo added this pull request to the merge queue Sep 16, 2026
Merged via the queue into rust-lang:master with commit c8703d8 Sep 16, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Sep 16, 2026
Update cargo submodule

9 commits in 7941be6fb416b4cd9666aef7b858dfea25587a8c..495c385d0875c4ba51eb72ea0448a2d4c018b8d4
2026-09-11 20:47:37 +0000 to 2026-09-16 12:48:58 +0000
- Report the number of errors with `build.warnings='deny'` (rust-lang/cargo#17479)
- fix: return correct package specs when resolving workspace deps (rust-lang/cargo#17469)
- refactor(config): Consolidate more config table definitions (rust-lang/cargo#17480)
- fix(git): For git cli, tell users what config we aren't forwarding on error (rust-lang/cargo#17477)
- Lower the lint level of `manual_readme` and `non_kebab_case_bins` to `allow` (rust-lang/cargo#17478)
- fix(trim-paths)!: unremap file in one JSON doc (rust-lang/cargo#17476)
- feat(manifest): support `feature-documentation` in manifests (rust-lang/cargo#17447)
- chore: Add Muscraft to the review rotation (rust-lang/cargo#17471)
- Specify `--edition` in `messages` tests (rust-lang/cargo#17470)

r? Urgau 
for the debugger script part

---

🤖 LLM disclosure: I probably should have tested this change manually, though I let LLM verify it working, sorry. Will do a manual test when I have time or if somebody beats me on that.
@rustbot rustbot added this to the 1.100.0 milestone Sep 16, 2026
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 17, 2026
Update cargo submodule

9 commits in 7941be6fb416b4cd9666aef7b858dfea25587a8c..495c385d0875c4ba51eb72ea0448a2d4c018b8d4
2026-09-11 20:47:37 +0000 to 2026-09-16 12:48:58 +0000
- Report the number of errors with `build.warnings='deny'` (rust-lang/cargo#17479)
- fix: return correct package specs when resolving workspace deps (rust-lang/cargo#17469)
- refactor(config): Consolidate more config table definitions (rust-lang/cargo#17480)
- fix(git): For git cli, tell users what config we aren't forwarding on error (rust-lang/cargo#17477)
- Lower the lint level of `manual_readme` and `non_kebab_case_bins` to `allow` (rust-lang/cargo#17478)
- fix(trim-paths)!: unremap file in one JSON doc (rust-lang/cargo#17476)
- feat(manifest): support `feature-documentation` in manifests (rust-lang/cargo#17447)
- chore: Add Muscraft to the review rotation (rust-lang/cargo#17471)
- Specify `--edition` in `messages` tests (rust-lang/cargo#17470)

r? Urgau 
for the debugger script part

---

🤖 LLM disclosure: I probably should have tested this change manually, though I let LLM verify it working, sorry. Will do a manual test when I have time or if somebody beats me on that.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 17, 2026
Update cargo submodule

9 commits in 7941be6fb416b4cd9666aef7b858dfea25587a8c..495c385d0875c4ba51eb72ea0448a2d4c018b8d4
2026-09-11 20:47:37 +0000 to 2026-09-16 12:48:58 +0000
- Report the number of errors with `build.warnings='deny'` (rust-lang/cargo#17479)
- fix: return correct package specs when resolving workspace deps (rust-lang/cargo#17469)
- refactor(config): Consolidate more config table definitions (rust-lang/cargo#17480)
- fix(git): For git cli, tell users what config we aren't forwarding on error (rust-lang/cargo#17477)
- Lower the lint level of `manual_readme` and `non_kebab_case_bins` to `allow` (rust-lang/cargo#17478)
- fix(trim-paths)!: unremap file in one JSON doc (rust-lang/cargo#17476)
- feat(manifest): support `feature-documentation` in manifests (rust-lang/cargo#17447)
- chore: Add Muscraft to the review rotation (rust-lang/cargo#17471)
- Specify `--edition` in `messages` tests (rust-lang/cargo#17470)

r? Urgau 
for the debugger script part

---

🤖 LLM disclosure: I probably should have tested this change manually, though I let LLM verify it working, sorry. Will do a manual test when I have time or if somebody beats me on that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-feature-unification Nightly: resolver.feature-unifiication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo tree output with feature-unification with workspace shows other workspace members

3 participants