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: resolve intra-doc links when checking HTML #93605

Merged

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Feb 2, 2022

Similar to #86451

CC #67799

Given this test case:

#![warn(rustdoc::invalid_html_tags)]
#![warn(rustdoc::broken_intra_doc_links)]

pub struct ExistentStruct<T>(T);

/// This [test][ExistentStruct<i32>] thing!
pub struct NoError;

This pull request silences the following, spurious warning:

warning: unclosed HTML tag `i32`
 --> test.rs:6:31
  |
6 | /// This [test][ExistentStruct<i32>] thing!
  |                               ^^^^^
  |
note: the lint level is defined here
 --> test.rs:1:9
  |
1 | #![warn(rustdoc::invalid_html_tags)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try marking as source code
  |
6 | /// This [test][`ExistentStruct<i32>`] thing!
  |                 +                   +

warning: 1 warning emitted

@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 2, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2022
@notriddle notriddle force-pushed the notriddle/rustdoc-html-tags-resolve branch from 634d879 to e0d4279 Compare February 2, 2022 23:47
@notriddle notriddle force-pushed the notriddle/rustdoc-html-tags-resolve branch from e0d4279 to 6821010 Compare February 12, 2022 00:07
@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle force-pushed the notriddle/rustdoc-html-tags-resolve branch from 6821010 to 1d23c7c Compare February 12, 2022 00:49
@GuillaumeGomez
Copy link
Member

Other than the nits, looks good to me. Let's hear from @camelid about this too!

r? @camelid

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Now it looks good to me! 👍


let mut replacer = |broken_link: BrokenLink<'_>| {
if let Some(link) =
link_names.iter().find(|link| *link.original_text == *broken_link.reference)
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it might be kind of slow... maybe worth addressing in the future (not in this PR).

Copy link
Member

Choose a reason for hiding this comment

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

We will run a perf check just to be sure the impact isn't too big, otherwise it'll have to be fixed in this PR (good catch!).

@camelid
Copy link
Member

camelid commented Feb 15, 2022

Am I correct in thinking that this change just improves lint warnings and does not add new syntax? Also, could you post what the errors looked like before this change? Thanks. Other than that, I have no objections. I haven't reviewed the code in detail though.

@camelid
Copy link
Member

camelid commented Feb 15, 2022

r? @GuillaumeGomez
@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 15, 2022
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 15, 2022
@notriddle
Copy link
Contributor Author

Am I correct in thinking that this change just improves lint warnings and does not add new syntax?

That’s the idea, yes. This way, when you use generics with intra-doc links, you don’t get spurious warnings about unclosed tags.

@GuillaumeGomez
Copy link
Member

Also, could you post what the errors looked like before this change?

@notriddle Can you show examples please?

@notriddle
Copy link
Contributor Author

@GuillaumeGomez

Given the following test case:

#![warn(rustdoc::invalid_html_tags)]
#![warn(rustdoc::broken_intra_doc_links)]

pub struct ExistentStruct<T>(T);

/// This [test][ExistentStruct<i32>] thing!
pub struct NoError;

This pull request silences the following, spurious warning:

warning: unclosed HTML tag `i32`
 --> test.rs:6:31
  |
6 | /// This [test][ExistentStruct<i32>] thing!
  |                               ^^^^^
  |
note: the lint level is defined here
 --> test.rs:1:9
  |
1 | #![warn(rustdoc::invalid_html_tags)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try marking as source code
  |
6 | /// This [test][`ExistentStruct<i32>`] thing!
  |                 +                   +

warning: 1 warning emitted

@GuillaumeGomez
Copy link
Member

Thanks for the explanations! Let's run a perf check and see if we need to work on perf before merging.

@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 Feb 15, 2022
@bors
Copy link
Contributor

bors commented Feb 15, 2022

⌛ Trying commit 7fe679c29f8b64dc2a00a719989c5e3e747bf0b3 with merge 3a112530c438a994fa3c69af84a30ebf311b95c4...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3a112530c438a994fa3c69af84a30ebf311b95c4): comparison url.

Summary: This benchmark run did not return any relevant results. 10 results were found to be statistically significant but too small to be relevant.

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.

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 16, 2022
@camelid camelid removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 16, 2022
@GuillaumeGomez
Copy link
Member

Perfect! Let's move forward then. Thanks!

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 16, 2022

📌 Commit 7fe679c29f8b64dc2a00a719989c5e3e747bf0b3 has been approved by GuillaumeGomez

@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 Feb 16, 2022
@notriddle notriddle force-pushed the notriddle/rustdoc-html-tags-resolve branch from 7fe679c to 1a6d41c Compare February 16, 2022 16:15
@notriddle
Copy link
Contributor Author

@bors r=GuillaumeGomez

Squashed the nit-fix commit in.

@bors
Copy link
Contributor

bors commented Feb 16, 2022

📌 Commit 1a6d41c has been approved by GuillaumeGomez

@bors
Copy link
Contributor

bors commented Feb 17, 2022

⌛ Testing commit 1a6d41c with merge 8d51c58456739df3bc9036f185d720d0efb5ccba...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Feb 17, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 17, 2022
@GuillaumeGomez
Copy link
Member

@bors retry

@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 Feb 17, 2022
@bors
Copy link
Contributor

bors commented Feb 20, 2022

⌛ Testing commit 1a6d41c with merge 6d7aa47...

@bors
Copy link
Contributor

bors commented Feb 20, 2022

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing 6d7aa47 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 20, 2022
@bors bors merged commit 6d7aa47 into rust-lang:master Feb 20, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 20, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6d7aa47): comparison url.

Summary: This benchmark run did not return any relevant results.

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

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

8 participants