diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index f1d1bf439f171..4fcf6ceb44d50 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -602,6 +602,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { kind = Some(ValueNS); disambiguator = Some(&prefix[..prefix.len() - 1]); link.trim_start_matches(prefix) + } else if link.ends_with("!()") { + kind = Some(MacroNS); + link.trim_end_matches("!()") } else if link.ends_with("()") { kind = Some(ValueNS); disambiguator = Some("fn"); diff --git a/src/test/rustdoc/intra-links.rs b/src/test/rustdoc/intra-links.rs index c6725f526aa2a..751c10925c017 100644 --- a/src/test/rustdoc/intra-links.rs +++ b/src/test/rustdoc/intra-links.rs @@ -46,6 +46,8 @@ macro_rules! this_macro { () => {}; } +// @has intra_links/struct.ThisType.html '//a/@href' '../intra_links/macro.this_macro.html' +/// another link to [`this_macro!()`] pub struct ThisType; impl ThisType { @@ -70,7 +72,7 @@ pub trait SoAmbiguous {} pub fn SoAmbiguous() {} -// @has - '//a/@href' '../intra_links/struct.ThisType.html' +// @has intra_links/struct.SomeOtherType.html '//a/@href' '../intra_links/struct.ThisType.html' // @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method' // @has - '//a/@href' '../intra_links/enum.ThisEnum.html' // @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant'