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: Suggest a correct disambiguator if the link is otherwise correct #83867

Open
jyn514 opened this issue Apr 5, 2021 · 0 comments
Open
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 E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 5, 2021

Given the following code:

//! [nod@x]
//! [f@foo]
mod x {}

fn foo() {}
macro_rules! foo {
  () => {}
}

The current output is:

warning: unknown disambiguator `nod`
 --> unknown-disambiguator.rs:1:6
  |
1 | //! [nod@x]
  |      ^^^
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unknown disambiguator `f`
 --> unknown-disambiguator.rs:2:6
  |
2 | //! [f@foo]
  |      ^

Ideally the output should look like:

warning: unknown disambiguator `nod`
 --> unknown-disambiguator.rs:1:6
  |
1 | //! [nod@x]
  |      ^^^
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
  = help: remove the disambiguator: `[x]`

warning: unknown disambiguator `f`
 --> unknown-disambiguator.rs:2:6
  |
2 | //! [f@foo]
  |      ^
  = help: link to the function: `[foo()]`
  = help: link to the macro: `[foo!()]`

This will be tricky because right now resolving links is intermingled with emitting warnings, there's no way to say "will this link resolve".

cc @lopopolo, #83859

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. 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 labels Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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 E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants