use syntax::ast_util::PostExpansionMethod;
use syntax::attr;
use syntax::attr::{AttributeMethods, AttrMetaMethods};
-use syntax::codemap::Pos;
+use syntax::codemap::{DUMMY_SP, Pos};
use syntax::parse::token::InternedString;
use syntax::parse::token;
use syntax::ptr::P;
pub name: String,
pub module: Option<Item>,
pub externs: Vec<(ast::CrateNum, ExternalCrate)>,
- pub primitives: Vec<Primitive>,
+ pub primitives: Vec<PrimitiveType>,
}
impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
ModuleItem(ref mut m) => m,
_ => continue,
};
- let prim = match Primitive::find(child.attrs.as_slice()) {
+ let prim = match PrimitiveType::find(child.attrs.as_slice()) {
Some(prim) => prim,
None => continue,
};
pub struct ExternalCrate {
pub name: String,
pub attrs: Vec<Attribute>,
- pub primitives: Vec<Primitive>,
+ pub primitives: Vec<PrimitiveType>,
}
impl Clean<ExternalCrate> for cstore::crate_metadata {
_ => return
};
let attrs = inline::load_attrs(cx, tcx, did);
- Primitive::find(attrs.as_slice()).map(|prim| primitives.push(prim));
+ PrimitiveType::find(attrs.as_slice()).map(|prim| primitives.push(prim));
})
});
ExternalCrate {
/// `static`s from an extern block
ForeignStaticItem(Static),
MacroItem(Macro),
- PrimitiveItem(Primitive),
+ PrimitiveItem(PrimitiveType),
+ AssociatedTypeItem,
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, Encodable, Decodable)]
pub struct Trait {
- pub items: Vec<TraitItem>,
+ pub items: Vec<TraitMethod>,
pub generics: Generics,
pub bounds: Vec<TyParamBound>,
}
}
#[deriving(Clone, Encodable, Decodable)]
-pub enum TraitItem {
+pub enum TraitMethod {
RequiredMethod(Item),
ProvidedMethod(Item),
+ TypeTraitItem(Item),
}
-impl TraitItem {
+impl TraitMethod {
pub fn is_req(&self) -> bool {
match self {
&RequiredMethod(..) => true,
match *self {
RequiredMethod(ref item) => item,
ProvidedMethod(ref item) => item,
+ TypeTraitItem(ref item) => item,
}
}
}
-impl Clean<TraitItem> for ast::TraitItem {
- fn clean(&self, cx: &DocContext) -> TraitItem {
+impl Clean<TraitMethod> for ast::TraitItem {
+ fn clean(&self, cx: &DocContext) -> TraitMethod {
match self {
&ast::RequiredMethod(ref t) => RequiredMethod(t.clean(cx)),
&ast::ProvidedMethod(ref t) => ProvidedMethod(t.clean(cx)),
+ &ast::TypeTraitItem(ref t) => TypeTraitItem(t.clean(cx)),
}
}
}
#[deriving(Clone, Encodable, Decodable)]
-pub enum ImplItem {
+pub enum ImplMethod {
MethodImplItem(Item),
+ TypeImplItem(Item),
}
-impl Clean<ImplItem> for ast::ImplItem {
- fn clean(&self, cx: &DocContext) -> ImplItem {
+impl Clean<ImplMethod> for ast::ImplItem {
+ fn clean(&self, cx: &DocContext) -> ImplMethod {
match self {
&ast::MethodImplItem(ref t) => MethodImplItem(t.clean(cx)),
+ &ast::TypeImplItem(ref t) => TypeImplItem(t.clean(cx)),
}
}
}
fn clean(&self, cx: &DocContext) -> Item {
match *self {
ty::MethodTraitItem(ref mti) => mti.clean(cx),
+ ty::TypeTraitItem(ref tti) => tti.clean(cx),
}
}
}
/// For references to self
Self(ast::DefId),
/// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
- Primitive(Primitive),
+ Primitive(PrimitiveType),
Closure(Box<ClosureDecl>),
Proc(Box<ClosureDecl>),
/// extern "ABI" fn
}
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
-pub enum Primitive {
+pub enum PrimitiveType {
Int, I8, I16, I32, I64,
Uint, U8, U16, U32, U64,
F32, F64,
TypeStruct,
TypeTrait,
TypeVariant,
+ TypeTypedef,
}
-impl Primitive {
- fn from_str(s: &str) -> Option<Primitive> {
+impl PrimitiveType {
+ fn from_str(s: &str) -> Option<PrimitiveType> {
match s.as_slice() {
"int" => Some(Int),
"i8" => Some(I8),
}
}
- fn find(attrs: &[Attribute]) -> Option<Primitive> {
+ fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
for attr in attrs.iter() {
let list = match *attr {
List(ref k, ref l) if k.as_slice() == "doc" => l,
if k.as_slice() == "primitive" => v.as_slice(),
_ => continue,
};
- match Primitive::from_str(value) {
+ match PrimitiveType::from_str(value) {
Some(p) => return Some(p),
None => {}
}
items: self.items.clean(cx).into_iter().map(|ti| {
match ti {
MethodImplItem(i) => i,
+ TypeImplItem(i) => i,
}
}).collect(),
derived: detect_derived(self.attrs.as_slice()),
fn register_def(cx: &DocContext, def: def::Def) -> ast::DefId {
let (did, kind) = match def {
def::DefFn(i, _) => (i, TypeFunction),
- def::DefTy(i) => (i, TypeEnum),
+ def::DefTy(i, false) => (i, TypeTypedef),
+ def::DefTy(i, true) => (i, TypeEnum),
def::DefTrait(i) => (i, TypeTrait),
def::DefStruct(i) => (i, TypeStruct),
def::DefMod(i) => (i, TypeModule),
}
}
+impl Clean<Item> for ast::AssociatedType {
+ fn clean(&self, cx: &DocContext) -> Item {
+ Item {
+ source: self.span.clean(cx),
+ name: Some(self.ident.clean(cx)),
+ attrs: self.attrs.clean(cx),
+ inner: AssociatedTypeItem,
+ visibility: None,
+ def_id: ast_util::local_def(self.id),
+ stability: None,
+ }
+ }
+}
+
+impl Clean<Item> for ty::AssociatedType {
+ fn clean(&self, cx: &DocContext) -> Item {
+ Item {
+ source: DUMMY_SP.clean(cx),
+ name: Some(self.ident.clean(cx)),
+ attrs: Vec::new(),
+ inner: AssociatedTypeItem,
+ visibility: None,
+ def_id: self.def_id,
+ stability: None,
+ }
+ }
+}
+
+impl Clean<Item> for ast::Typedef {
+ fn clean(&self, cx: &DocContext) -> Item {
+ Item {
+ source: self.span.clean(cx),
+ name: Some(self.ident.clean(cx)),
+ attrs: self.attrs.clean(cx),
+ inner: TypedefItem(Typedef {
+ type_: self.typ.clean(cx),
+ generics: Generics {
+ lifetimes: Vec::new(),
+ type_params: Vec::new(),
+ },
+ }),
+ visibility: None,
+ def_id: ast_util::local_def(self.id),
+ stability: None,
+ }
+ }
+}
+
fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
t: ty::t, name: &str,
fallback: fn(Box<Type>) -> Type) -> Type {