Skip to content

rustdoc: Preprocess intra-doc links consistently between crate loader and link resolver - #84066

Merged
bors merged 1 commit into
rust-lang:masterfrom
jyn514:consistent-link-strippping
Apr 12, 2021
Merged

rustdoc: Preprocess intra-doc links consistently between crate loader and link resolver#84066
bors merged 1 commit into
rust-lang:masterfrom
jyn514:consistent-link-strippping

Conversation

@jyn514

@jyn514jyn514 commented Apr 10, 2021

Copy link
Copy Markdown
Member

Previously, rustdoc would panic on links to external crates if they were
surrounded by backticks or the first path segment contained generics.

This is more extensive than the fix I suggested in #84046; it makes the preprocessing exactly the same rather than trying to duplicate only the necessary logic. This makes fixing the generics a lot easier as it turns out.

Fixes#84046.

r? @Manishearth

@jyn514jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Apr 10, 2021
@rust-highfive

This comment has been minimized.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2021
@jyn514

jyn514 commented Apr 10, 2021

Copy link
Copy Markdown
MemberAuthor

Line 1072 also needs to be part of the function or it will panic on that too:

 if path_str.contains(['<', '>'].as_slice()) {
stripped_path_string = match strip_generics_from_path(path_str) {

@rust-log-analyzer

This comment has been minimized.

@jyn514
jyn514force-pushed the consistent-link-strippping branch 2 times, most recently from d6d3a46 to 27799b3CompareApril 10, 2021 21:56
@jyn514jyn514 changed the title [WIP] rustdoc: Preprocess intra-doc links consistentlyrustdoc: Preprocess intra-doc links consistently between crate loader and link resolverApr 10, 2021
Comment threadsrc/librustdoc/passes/collect_intra_doc_links.rs Outdated
@jyn514

Copy link
Copy Markdown
MemberAuthor

Ok, this should be ready for review.

Comment threadsrc/librustdoc/passes/collect_intra_doc_links.rs Outdated
Comment threadsrc/librustdoc/passes/collect_intra_doc_links.rs Outdated
@jyn514
jyn514force-pushed the consistent-link-strippping branch from 030b4b3 to e3bd08aCompareApril 11, 2021 02:30
Previously, rustdoc would panic on links to external crates if they were
surrounded by backticks.
@Manishearth

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Apr 11, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 47d1ed9 has been approved by Manishearth

@borsbors 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 Apr 11, 2021

crate enum PreprocessingError<'a> {
Anchor(AnchorFailure),
Disambiguator(Range<usize>, String),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: worth having comments on each one explaining what the error is

@Manishearth

Manishearth commented Apr 11, 2021

Copy link
Copy Markdown
Member

@bors r-

I'm going to let @jyn514 choose how to land this PR and #84101

r=me

@borsbors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 11, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 11, 2021
rustdoc: Move crate loader to collect_intra_doc_links::early
This groups the similar code together, and also allows making most of collect_intra_doc_links private again.
This builds on rust-lang#84066, but it wouldn't be too hard to base it off master if you want this to land first.
Helps with rust-lang#83761.
r? manishearth
Fixesrust-lang#84046
@bors
bors merged commit 47d1ed9 into rust-lang:masterApr 12, 2021
@rustbotrustbot added this to the 1.53.0 milestone Apr 12, 2021
@jyn514
jyn514 deleted the consistent-link-strippping branch April 12, 2021 03:32
@camelid

Copy link
Copy Markdown
Member

Hmm, somehow this PR still got merged after being r-'d?

@jyn514

Copy link
Copy Markdown
MemberAuthor

@camelid it was merged as part of #84101

@camelid

Copy link
Copy Markdown
Member

Ah, that makes sense.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameS-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-rustdocRelevant 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.

Rustdoc ICE: Referencing a workspace crate's root in an intra-doc link triggers an ICE

8 participants

@jyn514@rust-highfive@rust-log-analyzer@Manishearth@bors@camelid@klensy@rustbot