#159771·Rust

Invalid broken link lint suggestion when referencing disambiguous attribute macro

Author: sleepycatcodingCreated Jul 23, 2026Updated Sep 17, 2026
LabelsT-rustdocA-diagnosticsC-bugA-intra-doc-linksA-suggestion-diagnosticsD-invalid-suggestion

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 (6f72b5dd5 2026-07-22)

Additional Details