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

rustdoc: Cleanup ExternalCrate #86889

Merged
merged 2 commits into from
Jul 18, 2021
Merged

rustdoc: Cleanup ExternalCrate #86889

merged 2 commits into from
Jul 18, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Jul 5, 2021

  • Remove unnecessary CrateNum from Cache.externs
  • Remove trival impl Clean for CrateNum

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 5, 2021
@rust-highfive
Copy link
Collaborator

r? @ollie27

(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 Jul 5, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jul 5, 2021

r? @camelid

@rust-highfive rust-highfive assigned camelid and unassigned ollie27 Jul 5, 2021
Copy link
Member

@camelid camelid left a comment

Choose a reason for hiding this comment

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

Thanks, this is great! I have two comments:

Comment on lines 40 to 41
externs.sort_by(|&(a, _), &(b, _)| a.cmp(&b));
externs.sort_unstable();
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if maybe it would be better to sort_unstable_by_key(|c| c.crate_num) instead (and then remove the Ord derive from ExternalCrate), to make it more explicit what the crates are being sorted by. Also, it would the code more resilient to change in ExternalCrate. But I'm okay with leaving it how it is now if that's what you'd prefer. What do you think?

Copy link
Member

@camelid camelid Jul 5, 2021

Choose a reason for hiding this comment

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

Actually, on second thought, why do we sort the externs at all? Is it to prevent non-determinism? Can you try switching it to use BTreeSet instead? (If you don't want to do it now, that's okay, but I wanted to mention it.)

Copy link
Member Author

Choose a reason for hiding this comment

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

The order is used here: https://github.com/rust-lang/rust/blob/23fdc18eb68b1ec5daee2d095441d47afb0ce89e/src/librustdoc/formats/cache.rs#L161-L165
I have no idea why, the comment doesn't make much sense to me since the crate number has very little relation to the dependency depth it's at. I would be fine with removing it.

Copy link
Member Author

@jyn514 jyn514 Jul 6, 2021

Choose a reason for hiding this comment

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

Oh! This would be a great way to handle #73423, we can have different docs in core than in std. I didn't realize rustdoc silently overwrote the old docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out the sort can't be removed :/ it would cause the docs in core to take precedence over those defined in downstream crates. That wouldn't be a problem, except that doc(primitive) is stable for some reason and it would be a change in observable behavior.

I'll add back the sorting. I still think this is the right approach for fixing 73423 though.

@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2021
@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 force-pushed the crate-cleanup branch 2 times, most recently from 23fdc18 to cbfad16 Compare July 6, 2021 01:11
@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 6, 2021
@bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member

camelid commented Jul 16, 2021

I will hopefully be able to review this in the next few days.

@camelid
Copy link
Member

camelid commented Jul 16, 2021

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 16, 2021

📌 Commit a30fa08 has been approved by camelid

@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 Jul 16, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 17, 2021
rustdoc: Cleanup ExternalCrate

- Remove unnecessary CrateNum from Cache.externs
- Remove trival impl Clean for CrateNum
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#86763 (Add a regression test for issue-63355)
 - rust-lang#86814 (Recover from a misplaced inner doc comment)
 - rust-lang#86843 (Check that const parameters of trait methods have compatible types)
 - rust-lang#86889 (rustdoc: Cleanup ExternalCrate)
 - rust-lang#87092 (Remove nondeterminism in multiple-definitions test)
 - rust-lang#87170 (Add diagnostic items for Clippy)
 - rust-lang#87183 (fix typo in compile_fail doctest)
 - rust-lang#87205 (rustc_middle: remove redundant clone)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit eef5108 into rust-lang:master Jul 18, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 18, 2021
@jyn514 jyn514 deleted the crate-cleanup branch July 18, 2021 12:17
camelid added a commit to camelid/rust that referenced this pull request Oct 30, 2021
Now that rust-lang#73423 is fixed, sorting should no longer be necessary.
See also this discussion [1].

[1]: rust-lang#86889 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants