diff options
| author | bors <bors@rust-lang.org> | 2020-08-30 02:36:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-30 02:36:48 +0000 |
| commit | f6d910c85251191becdf2bed78219be66ebb1d3a (patch) | |
| tree | 08733741a83482d60f23b8cedc0afcd0c40e7acf /src | |
| parent | 62850d882b1f546783d064ca3b51d1f85b92eeb7 (diff) | |
| parent | 14047849920fa42361286eeef5f0f09436195643 (diff) | |
| download | rust-f6d910c85251191becdf2bed78219be66ebb1d3a.tar.gz rust-f6d910c85251191becdf2bed78219be66ebb1d3a.zip | |
Auto merge of #76093 - jyn514:prim-assoc-items, r=Manishearth
Fix intra-doc links for associated constants Previously, only associated functions would be resolved. Fixes the issues in https://github.com/rust-lang/rust/pull/75969#discussion_r477898003. I'm a little uncomfortable hard-coding the string constants, but it looks like that's how it's done elsewhere. I might make a follow-up PR at some point putting it in one place. Not sure how to test associated types, since AFAIK there aren't any on primitives. r? @Manishearth
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 7 | ||||
| -rw-r--r-- | src/test/rustdoc/intra-link-prim-assoc.rs | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 65d116b9c67..412ab30a603 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 00000000000..c0066885e19 --- /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" |
