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

intra-doc: Use an enum to represent URL fragments #92088

Merged
merged 2 commits into from
Dec 28, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Dec 18, 2021

This is a step in the direction of computing the links more lazily,
which I think will simplify the implementation of intra-doc links.
This will also make it easier to eventually use the actual Res for
associated items, enum variants, and fields, rather than their HTML
page's Res.

r? @jyn514

@camelid camelid added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-cleanup Category: PRs that clean code up or issues documenting cleanup. labels Dec 18, 2021
@rust-highfive
Copy link
Collaborator

Some changes occurred in intra-doc-links.

cc @jyn514

Some changes occurred in clean/types.rs.

cc @camelid

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 18, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 18, 2021
@@ -732,7 +764,7 @@ fn resolve_associated_trait_item(
item_name: Symbol,
ns: Namespace,
cx: &mut DocContext<'_>,
) -> Option<(ty::AssocKind, DefId)> {
) -> Option<ty::AssocItem> {
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is not strictly necessary, but it seems like a good refactoring. The reason I made the change is that I was going to make UrlFragment::from_assoc_item take a ty::AssocItem and use that to get the defaultness, but that caused some tests to fail.

@camelid
Copy link
Member Author

camelid commented Dec 18, 2021

This may affect perf, so @bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 18, 2021
@bors
Copy link
Contributor

bors commented Dec 18, 2021

⌛ Trying commit a074157f6b4975ebd2d80fac9c588969aab366d5 with merge b097a2fe84360de4b3bc3e854766482bf11c4acf...

@bors
Copy link
Contributor

bors commented Dec 18, 2021

☀️ Try build successful - checks-actions
Build commit: b097a2fe84360de4b3bc3e854766482bf11c4acf (b097a2fe84360de4b3bc3e854766482bf11c4acf)

@rust-timer
Copy link
Collaborator

Queued b097a2fe84360de4b3bc3e854766482bf11c4acf with parent 91a0600, future comparison URL.

Comment on lines +275 to +277
/// Render the fragment, including the leading `#`.
impl std::fmt::Display for UrlFragment {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
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 thought adding a Display impl would be the best way to go, but I could be convinced of changing this to a method that takes &mut String or similar because

  • it would then have an explanatory method name (e.g., make it clear that it includes the #)
  • it might be more efficient since it avoids the Result and using Formatter

Some((kind, field.did)),
))
let fragment = if def.is_enum() {
// FIXME: how can the field be a variant?
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be fixed after #92075 is merged.

@@ -457,8 +505,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
path_str: &'path str,
ns: Namespace,
module_id: DefId,
extra_fragment: &Option<String>,
) -> Result<(Res, Option<String>), ErrorKind<'path>> {
extra_fragment: &Option<UrlFragment>,
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 believe this and other instances of extra_fragment are always user-written fragments.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b097a2fe84360de4b3bc3e854766482bf11c4acf): comparison url.

Summary: This change led to moderate relevant regressions 😿 in compiler performance.

  • Moderate regression in instruction counts (up to 3.2% on incr-patched: println builds of regression-31157)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 19, 2021
@camelid
Copy link
Member Author

camelid commented Dec 19, 2021

The rustc changes (including in the summary comment) are all spurious. Not sure what to do about those other than cc @rylev (let me know if I should stop pinging you for these).

The rustdoc changes show small improvements across many benchmarks.

@camelid
Copy link
Member Author

camelid commented Dec 19, 2021

max-rss shows small, low-significance regressions, but the biggest regressions are for benchmarks in which I don't think there are even intra-doc links. So probably mostly spurious.

@camelid
Copy link
Member Author

camelid commented Dec 27, 2021

Since Joshua is on vacation, r? @Manishearth

@rust-highfive rust-highfive assigned Manishearth and unassigned jyn514 Dec 27, 2021
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

lgtm! r=me with the merge conflicts addressed

This is a step in the direction of computing the links more lazily,
which I think will simplify the implementation of intra-doc links.
This will also make it easier to eventually use the actual `Res` for
associated items, enum variants, and fields, rather than their HTML
page's `Res`.
@camelid
Copy link
Member Author

camelid commented Dec 28, 2021

Thanks for the review!

@bors r=Manishearth rollup=never

@bors
Copy link
Contributor

bors commented Dec 28, 2021

📌 Commit ae2bc69 has been approved by Manishearth

@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 Dec 28, 2021
@bors
Copy link
Contributor

bors commented Dec 28, 2021

⌛ Testing commit ae2bc69 with merge cc65bf3...

@bors
Copy link
Contributor

bors commented Dec 28, 2021

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing cc65bf3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 28, 2021
@bors bors merged commit cc65bf3 into rust-lang:master Dec 28, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 28, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cc65bf3): comparison url.

Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.

  • Small improvement in instruction counts (up to -0.8% on incr-unchanged builds of externs)
  • Moderate regression in instruction counts (up to 1.1% on incr-unchanged builds of deeply-nested-async)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@camelid camelid deleted the intra-doc-cleanup branch December 28, 2021 19:12
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 6, 2022
…anishearth

rustdoc: Remove the intra-doc links side channel

The side channel made the code much more complex and harder to
understand. It was added as a temporary workaround in
0c99d80, but it's no longer necessary.

The addition of `UrlFragment` in rust-lang#92088 was the key to getting rid of
the side channel. The semantic information (rather than the strings that
used to be used for fragments) that is now captured by `UrlFragment` is
enough to obviate the side channel. An additional change had to be made
to `UrlFragment` in this PR to make this possible: it now records
`DefId`s rather than item names.

This PR also consolidates the checks for anchor conflicts into one place.

r? `@Manishearth`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 11, 2022
…ishearth

rustdoc: Remove the intra-doc links side channel

The side channel made the code much more complex and harder to
understand. It was added as a temporary workaround in
0c99d80, but it's no longer necessary.

The addition of `UrlFragment` in rust-lang#92088 was the key to getting rid of
the side channel. The semantic information (rather than the strings that
used to be used for fragments) that is now captured by `UrlFragment` is
enough to obviate the side channel. An additional change had to be made
to `UrlFragment` in this PR to make this possible: it now records
`DefId`s rather than item names.

This PR also consolidates the checks for anchor conflicts into one place.

r? `@Manishearth`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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