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 clean part 1 #88810

Merged
merged 8 commits into from
Sep 12, 2021
Merged

rustdoc: Cleanup clean part 1 #88810

merged 8 commits into from
Sep 12, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Sep 10, 2021

Split out from #88379.

These commits are completely independent of each other, and each is a fairly
small change (the last few are new commits; they are not from #88379):

  • Remove unnecessary Cache.*_did fields
  • rustdoc: Get symbol for TyParam directly
  • Create a valid Res in external_path()
  • Remove unused hir_id parameter from resolve_type
  • Fix redundant arguments in external_path()
  • Remove unnecessary is_trait argument
  • rustdoc: Cleanup a pattern match in external_generic_args()

r? @jyn514

They can be obtained by accessing the `TyCtxt` where they are needed.
@camelid camelid 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 Sep 10, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member Author

camelid commented Sep 10, 2021

It looks like 6b2ee44 is causing CI to fail because some part of rustdoc relies on the Path having a Res::Err. But it works fine in my larger "Cleanup clean" PR, so one of my other cleanups must have fixed that other part of rustdoc in some way. I'll drop that commit from this one and leave it for part 2.

@camelid camelid force-pushed the cleanup-pt1 branch 2 times, most recently from 93a880f to 481bc33 Compare September 10, 2021 19:01
@camelid
Copy link
Member Author

camelid commented Sep 10, 2021

Actually, the test failure was just because the ordering of the where bounds changed (this is why it changed in the "Cleanup clean" PR). So, I re-added the commit and updated its commit message:

The order of the where bounds on auto trait impls changed because
rustdoc currently sorts auto trait where bounds based on the Debug
output for the bound. Now that the bounds have an actual Res, they are
being unintentionally sorted by their DefId rather than their path.
So, I had to update a test for the change in ordering of the rendered
bounds.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

LGTM with nits fixed

src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
Comment on lines 148 to 149
did: DefId,
trait_did: Option<DefId>,
Copy link
Member

Choose a reason for hiding this comment

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

did and trait_did will never be different if trait_did.is_some(), right? Could you change trait_did: Option<DefId> to is_trait: bool instead to avoid them getting out of sync?

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 did that, and then I did one better: It actually looks like is_trait is not even necessary. It is only used for sugaring Fn trait bounds, and rustdoc already checks that the did is a Fn* lang item.

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 made them as two separate commits, but I can squash them together if you would prefer.

The order of the `where` bounds on auto trait impls changed because
rustdoc currently sorts auto trait `where` bounds based on the `Debug`
output for the bound. Now that the bounds have an actual `Res`, they are
being unintentionally sorted by their `DefId` rather than their path.
So, I had to update a test for the change in ordering of the rendered
bounds.
@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 Sep 11, 2021
If the path is for a trait, it is always true that `trait_did ==
Some(did)`, so instead, `external_path()` now takes an `is_trait`
boolean.
It was only used for sugaring `Fn` trait bounds, and rustdoc already
checks that the `did` is for a `Fn` (or `FnMut`, `FnOnce`) lang item,
so it's not necessary to also check that the `did` belongs to a trait.
@camelid camelid 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 Sep 11, 2021
@jyn514
Copy link
Member

jyn514 commented Sep 12, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Sep 12, 2021

📌 Commit 280fc2d has been approved by jyn514

@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 Sep 12, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 12, 2021
rustdoc: Cleanup `clean` part 1

Split out from rust-lang#88379.

These commits are completely independent of each other, and each is a fairly
small change (the last few are new commits; they are not from rust-lang#88379):

- Remove unnecessary `Cache.*_did` fields
- rustdoc: Get symbol for `TyParam` directly
- Create a valid `Res` in `external_path()`
- Remove unused `hir_id` parameter from `resolve_type`
- Fix redundant arguments in `external_path()`
- Remove unnecessary `is_trait` argument
- rustdoc: Cleanup a pattern match in `external_generic_args()`

r? `@jyn514`
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2021
…arth

Rollup of 7 pull requests

Successful merges:

 - rust-lang#88336 ( Detect stricter constraints on gats where clauses in impls vs trait)
 - rust-lang#88677 (rustc: Remove local variable IDs from `Export`s)
 - rust-lang#88699 (Remove extra unshallow from cherry-pick checker)
 - rust-lang#88709 (generic_const_exprs: use thir for abstract consts instead of mir)
 - rust-lang#88711 (Rework DepthFirstSearch API)
 - rust-lang#88810 (rustdoc: Cleanup `clean` part 1)
 - rust-lang#88813 (explicitly link to external `ena` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b3af37a into rust-lang:master Sep 12, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 12, 2021
@camelid camelid deleted the cleanup-pt1 branch September 12, 2021 18:56
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.

6 participants