1
Fork 0

rustdoc: Render associated types on traits and impls

This commit is contained in:
Tom Jakubowski 2014-11-20 11:22:09 -08:00
parent bad1062caa
commit dd4c7c00d8
6 changed files with 96 additions and 40 deletions

View file

@ -336,7 +336,7 @@ pub enum ItemEnum {
ForeignStaticItem(Static),
MacroItem(Macro),
PrimitiveItem(PrimitiveType),
AssociatedTypeItem,
AssociatedTypeItem(TyParam),
}
#[deriving(Clone, Encodable, Decodable)]
@ -982,6 +982,8 @@ impl Clean<Type> for ast::PolyTraitRef {
}
}
/// An item belonging to a trait, whether a method or associated. Could be named
/// TraitItem except that's already taken by an exported enum variant.
#[deriving(Clone, Encodable, Decodable)]
pub enum TraitMethod {
RequiredMethod(Item),
@ -1002,6 +1004,12 @@ impl TraitMethod {
_ => false,
}
}
pub fn is_type(&self) -> bool {
match self {
&TypeTraitItem(..) => true,
_ => false,
}
}
pub fn item<'a>(&'a self) -> &'a Item {
match *self {
RequiredMethod(ref item) => item,
@ -2211,7 +2219,7 @@ impl Clean<Item> for ast::AssociatedType {
source: self.ty_param.span.clean(cx),
name: Some(self.ty_param.ident.clean(cx)),
attrs: self.attrs.clean(cx),
inner: AssociatedTypeItem,
inner: AssociatedTypeItem(self.ty_param.clean(cx)),
visibility: None,
def_id: ast_util::local_def(self.ty_param.id),
stability: None,
@ -2225,7 +2233,17 @@ impl Clean<Item> for ty::AssociatedType {
source: DUMMY_SP.clean(cx),
name: Some(self.name.clean(cx)),
attrs: Vec::new(),
inner: AssociatedTypeItem,
// 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
},
bounds: vec![],
default: None
}),
visibility: None,
def_id: self.def_id,
stability: None,