From 08d3a74a8f2538714129386f3f1a7153c49c9300 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 27 Jun 2020 00:22:03 -0700 Subject: [PATCH 1/2] Allow for parentheses after macro intra-doc-links --- src/librustdoc/passes/collect_intra_doc_links.rs | 3 +++ 1 file changed, 3 insertions(+) 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"); From fe351e9b8eb19aeda4a34f4c64c75ffb60600cc0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Jul 2020 10:27:48 -0700 Subject: [PATCH 2/2] Add test --- src/test/rustdoc/intra-links.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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'