Skip to content

Commit

Permalink
Fix intra-doc links for associated constants
Browse files Browse the repository at this point in the history
Previously, only associated functions would be resolved.
  • Loading branch information
jyn514 committed Aug 30, 2020
1 parent 1dc748f commit 1404784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc/intra-link-prim-assoc.rs
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 1404784

Please sign in to comment.