Skip to content

[rustdoc] Misleading error message for ambiguous link to associated type/const #108653

Closed
@ModProg

Description

@ModProg

Code

/// [`Trait::IDENT`]
trait Trait {
    type IDENT;
    const IDENT: usize;
}

Run cargo doc

Current output

warning: `Trait::IDENT` is both a trait and a trait
 --> src/main.rs:1:7
  |
1 | /// [`Trait::IDENT`]
  |       ^^^^^^^^^^^^ ambiguous link
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
help: to link to the trait, prefix with `trait@`
  |
1 | /// [`trait@Trait::IDENT`]
  |       ++++++
help: to link to the trait, prefix with `trait@`
  |
1 | /// [`trait@Trait::IDENT`]
  |       ++++++

warning: `doc_` (bin "doc_" doc) generated 1 warning

Desired output

warning: `Trait::IDENT` is both a const and a type
 --> src/main.rs:1:7
  |
1 | /// [`Trait::IDENT`]
  |       ^^^^^^^^^^^^ ambiguous link
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
help: to link to the const, prefix with `const@`
  |
1 | /// [`const@Trait::IDENT`]
  |       ++++++
help: to link to the type, prefix with `type@`
  |
1 | /// [`type@Trait::IDENT`]
  |       ++++++

warning: `doc_` (bin "doc_" doc) generated 1 warning

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler 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