Skip to content

Fix deduplication in cargo tree (fixes #9599)#16606

Open
Nutomic wants to merge 2 commits intorust-lang:masterfrom
Nutomic:tree-duplicates
Open

Fix deduplication in cargo tree (fixes #9599)#16606
Nutomic wants to merge 2 commits intorust-lang:masterfrom
Nutomic:tree-duplicates

Conversation

@Nutomic
Copy link

@Nutomic Nutomic commented Feb 9, 2026

What does this PR try to resolve?

cargo tree --duplicates wrongly shows the same crate version multiple times if it is used with different features, or as both normal dependency and dev dependency. #9599 has more details.

How to test and review this PR?

Ran the code as cargo run -- tree --manifest-path /path/to/Cargo.toml -d and compared the output to stable cargo.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 9, 2026

r? @epage

rustbot has assigned @epage.
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: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, for bugfixes, we usually follow a variant of atomic commit pattern:

  1. Commit a test that asserts the current buggy behavior (passes).
  2. In the next commit, fix the bug and update the test/snapshot.

Every commit passes, and the test/snapshot diff shows the behavior change.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure I understand. The test in this file already asserts the current behaviour and passes. Do you simply want me to squash the two commits in this PR into one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any changes to the test (like adding optdep 2.0.0), should be made in the first commit.

The 2nd commit should then only show the impact caused by the bug fix to the test (only the stdout_data should change).

Copy link
Author

Choose a reason for hiding this comment

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

Updated, I hope its right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Command-tree S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants