Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't treat host/target duplicates as duplicates #10466

Merged
merged 2 commits into from
Mar 30, 2022

Conversation

Rustin170506
Copy link
Member

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
@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
@Rustin170506
Copy link
Member Author

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 🙇🏾‍♂️

src/cargo/ops/tree/graph.rs Outdated Show resolved Hide resolved
src/cargo/ops/tree/graph.rs Outdated Show resolved Hide resolved
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! 💚 💙 💜 💛 ❤️

Signed-off-by: hi-rustin <[email protected]>

Better code

Signed-off-by: hi-rustin <[email protected]>
@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