Skip to content

Conversation

0xPoe
Copy link
Member

@0xPoe 0xPoe commented Mar 8, 2022

What does this PR try to resolve?

close #9519

Don't treat host/target duplicates as duplicates.

How should we test and review this PR?

  • Unit test.
  • Create a manifest where a dependency shows up as both a normal dependency and a build-dependency. Run cargo tree -d --target x86_64-unknown-linux-gnu

@rust-highfive
Copy link

r? @alexcrichton

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 8, 2022
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@0xPoe 0xPoe force-pushed the rustin-patch-tree branch from 3d79ee3 to 58906aa Compare March 8, 2022 16:52
@alexcrichton
Copy link
Member

Thanks for the PR, but I'm going to be stepping down from the Cargo team so I'm going to un-assign myself from this. The Cargo team will help review this when they get a chance.

@alexcrichton alexcrichton removed their assignment Mar 8, 2022
@0xPoe
Copy link
Member Author

0xPoe commented Mar 9, 2022

r? @ehuss

Since you created the issue, you might be interested in looking at it.

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Thanks for this patch. Looks reasonable to me overall!
I am just a little picky 🙇🏾‍♂️

@0xPoe 0xPoe requested review from weihanglo March 30, 2022 12:02
Comment on lines 253 to 254
!seen_pkg.contains(&ignore_kind_package)
&& seen_pkg.insert(ignore_kind_package)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I didn't say it clear in #10466 (comment). What do you think about dropping contains and using only insert operation here? This is only a little improvement and might not affect the performance but to me it's eye-pleasing 😆

Suggested change
!seen_pkg.contains(&ignore_kind_package)
&& seen_pkg.insert(ignore_kind_package)
seen_pkg.insert(ignore_kind_package)

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if this would make this code less readable? Maybe determining if it exists is a better indication that we need to de-dupe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed!

Copy link
Member

@weihanglo weihanglo Mar 30, 2022

Choose a reason for hiding this comment

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

Oh I just noticed that we can push it further by collecting to a HashSet:

indexes.into_iter().map(....).collect::<HashSet<_>>().len() > 1

Sorry about the back-and-forth, but this actually looks better and is a common dedup pattern I guess. We don't need that seen_pkg anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great way! Addressed!
Thanks for your review! 💚 💙 💜 💛 ❤️

@0xPoe 0xPoe force-pushed the rustin-patch-tree branch from 469314b to cad9ea8 Compare March 30, 2022 14:05
Signed-off-by: hi-rustin <rustin.liu@gmail.com>

Better code

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@0xPoe 0xPoe force-pushed the rustin-patch-tree branch from cad9ea8 to c45c2a5 Compare March 30, 2022 14:07
@weihanglo
Copy link
Member

Thanks for your work!

@bors r+

@bors
Copy link
Contributor

bors commented Mar 30, 2022

📌 Commit c45c2a5 has been approved by weihanglo

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2022
@bors
Copy link
Contributor

bors commented Mar 30, 2022

⌛ Testing commit c45c2a5 with merge aefc3cf...

@bors
Copy link
Contributor

bors commented Mar 30, 2022

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing aefc3cf to master...

@bors bors merged commit aefc3cf into rust-lang:master Mar 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 31, 2022
Update cargo

13 commits in 109bfbd055325ef87a6e7f63d67da7e838f8300b..1ef1e0a12723ce9548d7da2b63119de9002bead8
2022-03-17 21:43:09 +0000 to 2022-03-31 00:17:18 +0000
- Support `-Zmultitarget` in cargo config (rust-lang/cargo#10473)
- doc: Fix document url for libcurl format (rust-lang/cargo#10515)
- Fix wrong info in "Environment variables" docs (rust-lang/cargo#10513)
- Use the correct flag in --locked --offline error message (rust-lang/cargo#10512)
- Don't treat host/target duplicates as duplicates (rust-lang/cargo#10466)
- Unstable --keep-going flag (rust-lang/cargo#10383)
- Part 1 of RFC2906 - Packages can inherit fields from their root workspace (rust-lang/cargo#10497)
- Remove unused profile support for -Zpanic-abort-tests (rust-lang/cargo#10495)
- HTTP registry implementation (rust-lang/cargo#10470)
- Add a notice about review capacity. (rust-lang/cargo#10501)
- Add tests for ignoring symlinks (rust-lang/cargo#10047)
- Update doc string for deps_of/compute_deps. (rust-lang/cargo#10494)
- Consistently use crate::display_error on errors during drain (rust-lang/cargo#10394)
@ehuss ehuss added this to the 1.61.0 milestone Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo tree -d with --target can be confusing
6 participants