Skip to content

Invalid broken link lint suggestion when referencing disambiguous attribute macro #159771

Description

@sleepycatcoding

Code

#![feature(macro_attr)]

mod example {}

#[macro_export]
macro_rules! example {
    attr() () => {

    };
}


/// Check out my cool macro [`example`](crate::example!)
fn main() {}

Reproduction Steps

Run cargo doc

Expected Outcome

When there is an ambiguity in a intra-doc link when referencing a macro_rules! defined attribute macro, rustdoc's recommended fix is wrong, If applying the suggested ambiguator, it will complain about an unknown ambiguator.
I either expect attribute@ to be supported, or the suggestion be changed to macro@ which works as expected.

Actual Output

warning: incompatible link kind for `crate::example`
  --> src/main.rs:13:41
   |
13 | /// Check out my cool macro [`example`](crate::example!)
   |                                         ^^^^^^^^^^^^^^^ this link resolved to an attribute macro, which is not a macro
   |
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
help: to link to the attribute macro, prefix with `attribute@`
   |
13 - /// Check out my cool macro [`example`](crate::example!)
13 + /// Check out my cool macro [`example`](attribute@crate::example)
   |

After applying suggested fix

warning: unknown disambiguator `attribute`
  --> src/main.rs:13:41
   |
13 | /// Check out my cool macro [`example`](attribute@crate::example)
   |                                         ^^^^^^^^^
   |
   = note: see https://doc.rust-lang.org/nightly/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

Version

rustdoc 1.99.0-nightly (6f72b5d 2026-07-22)

Additional Details

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 nameA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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