Skip to content

rustdoc: Suggest a correct disambiguator if the link is otherwise correct #83867

@jyn514

Description

@jyn514

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions