From 14047849920fa42361286eeef5f0f09436195643 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 29 Aug 2020 21:21:23 -0400 Subject: [PATCH] Fix intra-doc links for associated constants Previously, only associated functions would be resolved. --- src/librustdoc/passes/collect_intra_doc_links.rs | 7 ++++--- src/test/rustdoc/intra-link-prim-assoc.rs | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/test/rustdoc/intra-link-prim-assoc.rs diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 65d116b9c670c..412ab30a603b7 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -261,9 +261,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ns, impl_, ) - .and_then(|item| match item.kind { - ty::AssocKind::Fn => Some("method"), - _ => None, + .map(|item| match item.kind { + ty::AssocKind::Fn => "method", + ty::AssocKind::Const => "associatedconstant", + ty::AssocKind::Type => "associatedtype", }) .map(|out| (prim, Some(format!("{}#{}.{}", path, out, item_name)))); if let Some(link) = link { diff --git a/src/test/rustdoc/intra-link-prim-assoc.rs b/src/test/rustdoc/intra-link-prim-assoc.rs new file mode 100644 index 0000000000000..c0066885e1991 --- /dev/null +++ b/src/test/rustdoc/intra-link-prim-assoc.rs @@ -0,0 +1,5 @@ +// ignore-tidy-linelength +#![deny(broken_intra_doc_links)] + +//! [i32::MAX] +// @has intra_link_prim_assoc/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX"