rustdoc: Correctly inline required/provided methods

Apparently relying on provided_source in ty::Method is unreliable!

Closes #14594
This commit is contained in:
Alex Crichton 2014-06-02 00:09:44 -07:00
parent 287af7fa1a
commit f02f739a82
2 changed files with 16 additions and 12 deletions

View file

@ -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

View file

@ -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(),
})
})
}
}
}