about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-02 00:09:44 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-02 09:18:32 -0700
commitf02f739a825219a4bb5d12df2f646ea67c434a33 (patch)
tree7e4684eda4df06f1aeb1cc26aa77ccff3f628328 /src
parent287af7fa1a2230b25d2ffe98c5cc623ad34c6287 (diff)
downloadrust-f02f739a825219a4bb5d12df2f646ea67c434a33.tar.gz
rust-f02f739a825219a4bb5d12df2f646ea67c434a33.zip
rustdoc: Correctly inline required/provided methods
Apparently relying on provided_source in ty::Method is unreliable!

Closes #14594
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/inline.rs19
-rw-r--r--src/librustdoc/clean/mod.rs9
2 files changed, 16 insertions, 12 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 9a3a68894ab..575dd057867 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -129,7 +129,7 @@ pub fn record_extern_fqn(cx: &core::DocContext,
     match cx.maybe_typed {
         core::Typed(ref tcx) => {
             let fqn = csearch::get_item_path(tcx, did);
-            let fqn = fqn.move_iter().map(|i| i.to_str().to_string()).collect();
+            let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
             cx.external_paths.borrow_mut().get_mut_ref().insert(did, (fqn, kind));
         }
         core::NotTyped(..) => {}
@@ -138,10 +138,18 @@ pub fn record_extern_fqn(cx: &core::DocContext,
 
 pub fn build_external_trait(tcx: &ty::ctxt, did: ast::DefId) -> clean::Trait {
     let def = ty::lookup_trait_def(tcx, did);
-    let methods = ty::trait_methods(tcx, did);
+    let methods = ty::trait_methods(tcx, did).clean();
+    let provided = ty::provided_trait_methods(tcx, did);
+    let mut methods = methods.move_iter().map(|meth| {
+        if provided.iter().any(|a| a.def_id == meth.def_id) {
+            clean::Provided(meth)
+        } else {
+            clean::Required(meth)
+        }
+    });
     clean::Trait {
         generics: def.generics.clean(),
-        methods: methods.iter().map(|i| i.clean()).collect(),
+        methods: methods.collect(),
         parents: Vec::new(), // FIXME: this is likely wrong
     }
 }
@@ -263,10 +271,7 @@ fn build_impl(cx: &core::DocContext,
         if method.vis != ast::Public && associated_trait.is_none() {
             return None
         }
-        let mut item = match ty::method(tcx, *did).clean() {
-            clean::Provided(item) => item,
-            clean::Required(item) => item,
-        };
+        let mut item = ty::method(tcx, *did).clean();
         item.inner = match item.inner.clone() {
             clean::TyMethodItem(clean::TyMethod {
                 fn_style, decl, self_, generics
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 856619882c5..a289d767f95 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -942,9 +942,8 @@ impl Clean<TraitMethod> for ast::TraitMethod {
     }
 }
 
-impl Clean<TraitMethod> for ty::Method {
-    fn clean(&self) -> TraitMethod {
-        let m = if self.provided_source.is_some() {Provided} else {Required};
+impl Clean<Item> for ty::Method {
+    fn clean(&self) -> Item {
         let cx = super::ctxtkey.get().unwrap();
         let tcx = match cx.maybe_typed {
             core::Typed(ref tcx) => tcx,
@@ -972,7 +971,7 @@ impl Clean<TraitMethod> for ty::Method {
             }
         };
 
-        m(Item {
+        Item {
             name: Some(self.ident.clean()),
             visibility: Some(ast::Inherited),
             def_id: self.def_id,
@@ -984,7 +983,7 @@ impl Clean<TraitMethod> for ty::Method {
                 self_: self_,
                 decl: (self.def_id, &sig).clean(),
             })
-        })
+        }
     }
 }