rustdoc: Handle associated types on inlined impls

Fix #21348
This commit is contained in:
Tom Jakubowski 2015-01-17 22:39:01 -08:00
parent 8224e0ed3d
commit 159236a63b
2 changed files with 27 additions and 5 deletions

View File

@ -319,9 +319,21 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
};
Some(item)
}
ty::TypeTraitItem(_) => {
// FIXME(pcwalton): Implement.
None
ty::TypeTraitItem(ref assoc_ty) => {
let did = assoc_ty.def_id;
let type_scheme = ty::lookup_item_type(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, subst::ParamSpace::TypeSpace).clean(cx);
Some(clean::Item {
name: Some(assoc_ty.name.clean(cx)),
inner: clean::TypedefItem(typedef),
source: clean::Span::empty(),
attrs: vec![],
visibility: None,
stability: stability::lookup(tcx, did).clean(cx),
def_id: did
})
}
}
}).collect();

View File

@ -2520,14 +2520,14 @@ fn clean(&self, cx: &DocContext) -> Item {
source: DUMMY_SP.clean(cx),
name: Some(self.name.clean(cx)),
attrs: Vec::new(),
// FIXME(#18048): this is wrong, but cross-crate associated types are broken
// anyway, for the time being.
inner: AssociatedTypeItem(TyParam {
name: self.name.clean(cx),
did: ast::DefId {
krate: 0,
node: ast::DUMMY_NODE_ID
},
// FIXME(#20727): bounds are missing and need to be filled in from the
// predicates on the trait itself
bounds: vec![],
default: None,
}),
@ -2559,6 +2559,16 @@ fn clean(&self, cx: &DocContext) -> Item {
}
}
impl<'a> Clean<Typedef> for (ty::TypeScheme<'a>, ParamSpace) {
fn clean(&self, cx: &DocContext) -> Typedef {
let (ref ty_scheme, ps) = *self;
Typedef {
type_: ty_scheme.ty.clean(cx),
generics: (&ty_scheme.generics, ps).clean(cx)
}
}
}
fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
t: ty::Ty, name: &str,
fallback: fn(Box<Type>) -> Type) -> Type {