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: Preprocess intra-doc links consistently between crate loader and link resolver #84066

Merged
merged 1 commit into from
Apr 12, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 10, 2021

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

@jyn514 jyn514 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-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2021
@jyn514
Copy link
Member Author

jyn514 commented Apr 10, 2021

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 jyn514 force-pushed the consistent-link-strippping branch 2 times, most recently from d6d3a46 to 27799b3 Compare April 10, 2021 21:56
@jyn514 jyn514 changed the title [WIP] rustdoc: Preprocess intra-doc links consistently rustdoc: Preprocess intra-doc links consistently between crate loader and link resolver Apr 10, 2021
@jyn514
Copy link
Member Author

jyn514 commented Apr 10, 2021

Ok, this should be ready for review.

@jyn514 jyn514 force-pushed the consistent-link-strippping branch from 030b4b3 to e3bd08a Compare April 11, 2021 02:30
Previously, rustdoc would panic on links to external crates if they were
surrounded by backticks.
@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 11, 2021

📌 Commit 47d1ed9 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 Apr 11, 2021
@@ -892,6 +892,117 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
}
}

crate enum PreprocessingError<'a> {
Anchor(AnchorFailure),
Disambiguator(Range<usize>, String),
Copy link
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
Copy link
Member

Manishearth commented Apr 11, 2021

@bors r-

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

r=me

@bors bors 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

Fixes rust-lang#84046
@bors bors merged commit 47d1ed9 into rust-lang:master Apr 12, 2021
@rustbot rustbot 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
Member

camelid commented Apr 13, 2021

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

@jyn514
Copy link
Member Author

jyn514 commented Apr 13, 2021

@camelid it was merged as part of #84101

@camelid
Copy link
Member

camelid commented Apr 13, 2021

Ah, that makes sense.

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 S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

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