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] Misleading error message for ambiguous link to associated type/const #108653

Closed
ModProg opened this issue Mar 2, 2023 · 1 comment · Fixed by #109104
Closed

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

ModProg opened this issue Mar 2, 2023 · 1 comment · Fixed by #109104
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ModProg
Copy link
Contributor

ModProg commented Mar 2, 2023

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

@ModProg ModProg added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 2, 2023
@ModProg ModProg changed the title Misleading error message for ambiguous link to associated type/const [rustdoc] Misleading error message for ambiguous link to associated type/const Mar 2, 2023
@ModProg
Copy link
Contributor Author

ModProg commented Mar 2, 2023

Probably a related error with enum variant + trait:

enum Enum {
    IDENT,
}

/// [`Self::IDENT`]
impl Trait for Enum {
    type IDENT = usize;

    const IDENT: usize = 10;
}
warning: `Self::IDENT` is both an enum and an enum
  --> src/main.rs:11:7
   |
11 | /// [`Self::IDENT`]
   |       ^^^^^^^^^^^ ambiguous link
   |
help: to link to the enum, prefix with `enum@`
   |
11 | /// [`enum@Self::IDENT`]
   |       +++++
help: to link to the enum, prefix with `enum@`
   |
11 | /// [`enum@Self::IDENT`]
   |       +++++

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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
1 participant