From 287af7fa1a2230b25d2ffe98c5cc623ad34c6287 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 1 Jun 2014 11:30:53 -0700 Subject: [PATCH] rustdoc: Deduplicate lists of implementors Inlining caused implementors to show up multiple times. cc #14584 --- src/librustdoc/html/render.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 16becde164ff..2caedbc2c1cc 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -108,6 +108,7 @@ pub enum ExternalLocation { /// Metadata about an implementor of a trait. pub struct Implementor { + def_id: ast::DefId, generics: clean::Generics, trait_: clean::Type, for_: clean::Type, @@ -531,6 +532,11 @@ fn write_shared(cx: &Context, try!(write!(&mut f, r"implementors['{}'] = [", krate.name)); for imp in imps.iter() { + // If the trait and implementation are in the same crate, then + // there's no need to emit information about it (there's inlining + // going on). If they're in different crates then the crate defining + // the trait will be interested in our implementation. + if imp.def_id.krate == did.krate { continue } try!(write!(&mut f, r#""impl{} {} for {}","#, imp.generics, imp.trait_, imp.for_)); } @@ -759,6 +765,7 @@ impl DocFolder for Cache { Vec::new() }); v.push(Implementor { + def_id: item.def_id, generics: i.generics.clone(), trait_: i.trait_.get_ref().clone(), for_: i.for_.clone(),