From 30e526805dc5ce51c683059beb881828dfa0099d Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 8 Aug 2017 15:22:04 -0500 Subject: [PATCH] rustdoc: add new "Implementations on Foreign Types" section to traits --- src/librustdoc/clean/mod.rs | 10 +++++ src/librustdoc/html/render.rs | 70 ++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index aab44ddce0e..60651bd617f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1651,6 +1651,16 @@ impl GetDefId for Type { fn def_id(&self) -> Option { match *self { ResolvedPath { did, .. } => Some(did), + Primitive(p) => ::html::render::cache().primitive_locations.get(&p).cloned(), + BorrowedRef { type_: box Generic(..), .. } => + Primitive(PrimitiveType::Reference).def_id(), + BorrowedRef { ref type_, .. } => type_.def_id(), + Tuple(..) => Primitive(PrimitiveType::Tuple).def_id(), + BareFunction(..) => Primitive(PrimitiveType::Fn).def_id(), + Slice(..) => Primitive(PrimitiveType::Slice).def_id(), + Array(..) => Primitive(PrimitiveType::Array).def_id(), + RawPointer(..) => Primitive(PrimitiveType::RawPointer).def_id(), + QPath { ref self_type, .. } => self_type.def_id(), _ => None, } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index cc84e340c74..8e0ce73c4ad 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2416,12 +2416,12 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?; let cache = cache(); - write!(w, " + let impl_header = "

Implementors

")?; write!(w, r#"