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

Lint on unknown intra-doc link disambiguators #83543

Merged
merged 4 commits into from
Mar 30, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Mar 27, 2021

No description provided.

@camelid camelid added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 27, 2021
@rust-highfive
Copy link
Collaborator

Some changes occurred in intra-doc-links.

cc @jyn514

@rust-highfive
Copy link
Collaborator

r? @jyn514

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 27, 2021
@camelid camelid force-pushed the lint-unknown-disambiguator branch from 922b888 to 0ffc9b3 Compare March 27, 2021 01:18
@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the lint-unknown-disambiguator branch from 0ffc9b3 to 4572e7f Compare March 27, 2021 02:50
@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 Mar 28, 2021
camelid added 2 commits March 28, 2021 17:18
And, now that we do that, we can remove the explanatory note since the
error span should make it clear what the disambiguator is.
@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 Mar 29, 2021
Comment on lines +14 to +36
error: unknown disambiguator `bar`
--> $DIR/unknown-disambiguator.rs:3:35
|
LL | //! Linking to [foo@banana] and [`bar@banana!()`].
| ^^^

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:34
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:48
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^

error: unknown disambiguator ``
--> $DIR/unknown-disambiguator.rs:6:31
|
LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()).
| ^
Copy link
Member Author

@camelid camelid Mar 29, 2021

Choose a reason for hiding this comment

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

I don't think this is caused by my change, but any idea why it's reporting diagnostics for line 3, then line 9, and then back to line 6? It's kind of confusing that they're out of order.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, sorry. Probably it's something to do with how pulldown-cmark returns the links.

@camelid camelid force-pushed the lint-unknown-disambiguator branch from 091f43f to 141df6f Compare March 29, 2021 00:27
Comment on lines +14 to +36
error: unknown disambiguator `bar`
--> $DIR/unknown-disambiguator.rs:3:35
|
LL | //! Linking to [foo@banana] and [`bar@banana!()`].
| ^^^

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:34
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:48
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^

error: unknown disambiguator ``
--> $DIR/unknown-disambiguator.rs:6:31
|
LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()).
| ^
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, sorry. Probably it's something to do with how pulldown-cmark returns the links.

Comment on lines +1507 to +1513
let after_first_backtick_group = ori_link.link.bytes().position(|b| b != b'`').unwrap_or(0);
let before_second_backtick_group = ori_link
.link
.bytes()
.skip(after_first_backtick_group)
.position(|b| b == b'`')
.unwrap_or(ori_link.link.len());
Copy link
Member

Choose a reason for hiding this comment

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

I think this will break on things like

[`a`b`c`]

but that seems fine, that's an awful abuse of rustdoc.

Copy link
Member Author

Choose a reason for hiding this comment

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

It actually works correctly! But I imagine there are some edge cases that don't work correctly.

error: unknown disambiguator `foo`
  --> src/test/rustdoc-ui/intra-doc/unknown-disambiguator.rs:12:7
   |
12 | //! [`foo@`b`c`]
   |       ^^^

@jyn514
Copy link
Member

jyn514 commented Mar 29, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Mar 29, 2021

📌 Commit 141df6f 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 Mar 29, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 29, 2021
… r=jyn514

Lint on unknown intra-doc link disambiguators
This was referenced Mar 29, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 30, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#82331 (alloc: Added `as_slice` method to `BinaryHeap` collection)
 - rust-lang#83130 (escape_ascii take 2)
 - rust-lang#83374 (unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs)
 - rust-lang#83543 (Lint on unknown intra-doc link disambiguators)
 - rust-lang#83636 (Add a regression test for issue-82792)
 - rust-lang#83643 (Remove a FIXME resolved by rust-lang#73578)
 - rust-lang#83644 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 25ade69 into rust-lang:master Mar 30, 2021
@rustbot rustbot added this to the 1.53.0 milestone Mar 30, 2021
@camelid camelid deleted the lint-unknown-disambiguator branch March 30, 2021 20:08
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 A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. 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