Skip to content

Rustdoc reports intradoc link errors twice if there are multiple links #77681

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jyn514 opened this issue Oct 7, 2020 · 2 comments · Fixed by #77859
Closed

Rustdoc reports intradoc link errors twice if there are multiple links #77681

jyn514 opened this issue Oct 7, 2020 · 2 comments · Fixed by #77859
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Oct 7, 2020

I tried this code:

/// Links to [a] [twice][a]
///
/// [a]: not_found
pub fn f() {}

I expected to see this happen: Rustdoc warns once, because there is only one reference link.

Instead, this happened: Rustdoc warns twice, because there are multiple uses of the reference link.

warning: unresolved link to `not_found`
 --> tmp.rs:3:10
  |
3 | /// [a]: not_found
  |          ^^^^^^^^^ the module `tmp` contains no item named `not_found`
  |
  = note: `#[warn(broken_intra_doc_links)]` on by default
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `not_found`
 --> tmp.rs:3:10
  |
3 | /// [a]: not_found
  |          ^^^^^^^^^ the module `tmp` contains no item named `not_found`
  |
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Meta

rustdoc +nightly --version: rustdoc 1.48.0-nightly (8fe73e8 2020-10-01)

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Oct 7, 2020
@jyn514
Copy link
Member Author

jyn514 commented Oct 7, 2020

This is part of a larger ~iffy approach that rustdoc is taking: it looks at each link over and over again even if it doesn't need to. Instead it could cache the links per-module, which would not only fix this error but speed up the pass quite a bit.

@jyn514 jyn514 added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Oct 7, 2020
@bugadani
Copy link
Contributor

bugadani commented Oct 8, 2020

Ah this issue is fun!

If I place the error marker on the link resolution, it's no longer considered an intra-doc link, because it contains a /.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 15, 2020
Rustdoc: Cache resolved links in current module

A step towards rust-lang#77681
@bors bors closed this as completed in 8018418 Jan 3, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants