Skip to content

Commit

Permalink
rustdoc: Handle associated types on inlined impls
Browse files Browse the repository at this point in the history
Fix #21348
  • Loading branch information
tomjakubowski committed Jan 18, 2015
1 parent 8224e0e commit 159236a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/librustdoc/clean/inline.rs
Expand Up @@ -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();
Expand Down
14 changes: 12 additions & 2 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -2520,14 +2520,14 @@ impl Clean<Item> for ty::AssociatedType {
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,
}),
Expand Down Expand Up @@ -2559,6 +2559,16 @@ impl Clean<Item> for ast::Typedef {
}
}

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 {
Expand Down

0 comments on commit 159236a

Please sign in to comment.