about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustdoc/clean/inline.rs7
-rw-r--r--src/librustdoc/clean/mod.rs5
-rw-r--r--src/librustdoc/core.rs4
-rw-r--r--src/librustdoc/fold.rs9
-rw-r--r--src/librustdoc/html/render.rs20
-rw-r--r--src/test/auxiliary/issue-13698.rs16
-rw-r--r--src/test/rustdoc/issue-13698.rs25
7 files changed, 63 insertions, 23 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index aa17bf20d74..e4b2e82b21b 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -331,9 +331,10 @@ fn build_impl(cx: &DocContext,
                 let did = assoc_ty.def_id;
                 let type_scheme = ty::lookup_item_type(tcx, did);
                 let predicates = ty::lookup_predicates(tcx, did);
-                // Not sure the choice of ParamSpace actually matters here, because an
-                // associated type won't have generics on the LHS
-                let typedef = (type_scheme, predicates, subst::ParamSpace::TypeSpace).clean(cx);
+                // Not sure the choice of ParamSpace actually matters here,
+                // because an associated type won't have generics on the LHS
+                let typedef = (type_scheme, predicates,
+                               subst::ParamSpace::TypeSpace).clean(cx);
                 Some(clean::Item {
                     name: Some(assoc_ty.name.clean(cx)),
                     inner: clean::TypedefItem(typedef),
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index e0ed83f4019..53824d088ee 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -44,9 +44,10 @@ use rustc::middle::subst::{self, ParamSpace, VecPerParamSpace};
 use rustc::middle::ty;
 use rustc::middle::stability;
 
+use std::collections::HashMap;
+use std::path::PathBuf;
 use std::rc::Rc;
 use std::u32;
-use std::path::PathBuf;
 
 use core::DocContext;
 use doctree;
@@ -119,6 +120,7 @@ pub struct Crate {
     pub module: Option<Item>,
     pub externs: Vec<(ast::CrateNum, ExternalCrate)>,
     pub primitives: Vec<PrimitiveType>,
+    pub external_traits: HashMap<ast::DefId, Trait>,
 }
 
 impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
@@ -197,6 +199,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
             module: Some(module),
             externs: externs,
             primitives: primitives,
+            external_traits: cx.external_traits.borrow_mut().take().unwrap(),
         }
     }
 }
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 113a622b07a..a637ba9f297 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -75,7 +75,6 @@ pub struct CrateAnalysis {
     pub exported_items: privacy::ExportedItems,
     pub public_items: privacy::PublicItems,
     pub external_paths: ExternalPaths,
-    pub external_traits: RefCell<Option<HashMap<ast::DefId, clean::Trait>>>,
     pub external_typarams: RefCell<Option<HashMap<ast::DefId, String>>>,
     pub inlined: RefCell<Option<HashSet<ast::DefId>>>,
 }
@@ -155,7 +154,6 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
         exported_items: exported_items,
         public_items: public_items,
         external_paths: RefCell::new(None),
-        external_traits: RefCell::new(None),
         external_typarams: RefCell::new(None),
         inlined: RefCell::new(None),
     };
@@ -168,8 +166,6 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
 
     let external_paths = ctxt.external_paths.borrow_mut().take();
     *analysis.external_paths.borrow_mut() = external_paths;
-    let map = ctxt.external_traits.borrow_mut().take();
-    *analysis.external_traits.borrow_mut() = map;
     let map = ctxt.external_typarams.borrow_mut().take();
     *analysis.external_typarams.borrow_mut() = map;
     let map = ctxt.inlined.borrow_mut().take();
diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs
index cdeeacfb783..0a1860c66f2 100644
--- a/src/librustdoc/fold.rs
+++ b/src/librustdoc/fold.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use clean::*;
-use std::iter::Extend;
+use std::collections::HashMap;
 use std::mem::{replace, swap};
 
 pub trait DocFolder : Sized {
@@ -80,6 +80,13 @@ pub trait DocFolder : Sized {
         c.module = match replace(&mut c.module, None) {
             Some(module) => self.fold_item(module), None => None
         };
+        let external_traits = replace(&mut c.external_traits, HashMap::new());
+        c.external_traits = external_traits.into_iter().map(|(k, mut v)| {
+            let items = replace(&mut v.items, Vec::new());
+            v.items = items.into_iter().filter_map(|i| self.fold_item(i))
+                           .collect();
+            (k, v)
+        }).collect();
         return c;
     }
 }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ac097d051b2..da59ffd785a 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -44,6 +44,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 use std::io::{self, BufWriter, BufReader};
 use std::iter::repeat;
+use std::mem;
 use std::path::{PathBuf, Path};
 use std::str;
 use std::sync::Arc;
@@ -383,9 +384,7 @@ pub fn run(mut krate: clean::Crate,
         privmod: false,
         public_items: public_items,
         orphan_methods: Vec::new(),
-        traits: analysis.as_ref().map(|a| {
-            a.external_traits.borrow_mut().take().unwrap()
-        }).unwrap_or(HashMap::new()),
+        traits: mem::replace(&mut krate.external_traits, HashMap::new()),
         typarams: analysis.as_ref().map(|a| {
             a.external_typarams.borrow_mut().take().unwrap()
         }).unwrap_or(HashMap::new()),
@@ -2239,7 +2238,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
     }
 
     try!(write!(w, "<div class='impl-items'>"));
-    for trait_item in &i.impl_.items {
+    for trait_item in i.impl_.items.iter() {
         try!(doctraititem(w, trait_item, true));
     }
 
@@ -2262,17 +2261,10 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
     // default methods which weren't overridden in the implementation block.
     // FIXME: this also needs to be done for associated types, whenever defaults
     // for them work.
-    match i.impl_.trait_ {
-        Some(clean::ResolvedPath { did, .. }) => {
-            try!({
-                match cache().traits.get(&did) {
-                    Some(t) => try!(render_default_methods(w, t, &i.impl_)),
-                    None => {}
-                }
-                Ok(())
-            })
+    if let Some(clean::ResolvedPath { did, .. }) = i.impl_.trait_ {
+        if let Some(t) = cache().traits.get(&did) {
+            try!(render_default_methods(w, t, &i.impl_));
         }
-        Some(..) | None => {}
     }
     try!(write!(w, "</div>"));
     Ok(())
diff --git a/src/test/auxiliary/issue-13698.rs b/src/test/auxiliary/issue-13698.rs
new file mode 100644
index 00000000000..0bb2133c833
--- /dev/null
+++ b/src/test/auxiliary/issue-13698.rs
@@ -0,0 +1,16 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub trait Foo {
+    #[doc(hidden)]
+    fn foo(&self) {}
+}
+
+impl Foo for i32 {}
diff --git a/src/test/rustdoc/issue-13698.rs b/src/test/rustdoc/issue-13698.rs
new file mode 100644
index 00000000000..81cee0998ab
--- /dev/null
+++ b/src/test/rustdoc/issue-13698.rs
@@ -0,0 +1,25 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue-13698.rs
+
+extern crate issue_13698;
+
+pub struct Foo;
+// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo'
+impl issue_13698::Foo for Foo {}
+
+pub trait Bar {
+    #[doc(hidden)]
+    fn bar(&self) {}
+}
+
+// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn bar'
+impl Bar for Foo {}