diff --git a/src/rustdoc_ng/clean.rs b/src/rustdoc_ng/clean.rs index ed18fc04fad..fefd679e20b 100644 --- a/src/rustdoc_ng/clean.rs +++ b/src/rustdoc_ng/clean.rs @@ -657,7 +657,7 @@ impl Clean for ast::variant_kind { } } -impl Clean<~str> for syntax::codemap::span { +impl Clean<~str> for syntax::codemap::Span { fn clean(&self) -> ~str { let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess.codemap; cm.span_to_str(*self) @@ -697,7 +697,7 @@ fn path_to_str(p: &ast::Path) -> ~str { s } -impl Clean<~str> for ast::ident { +impl Clean<~str> for ast::Ident { fn clean(&self) -> ~str { its(self).to_owned() } @@ -779,15 +779,13 @@ impl Clean for doctree::Static { pub enum Mutability { Mutable, Immutable, - Const, } -impl Clean for ast::mutability { +impl Clean for ast::Mutability { fn clean(&self) -> Mutability { match self { - &ast::m_mutbl => Mutable, - &ast::m_imm => Immutable, - &ast::m_const => Const + &ast::MutMutable => Mutable, + &ast::MutImmutable => Immutable, } } } @@ -885,7 +883,7 @@ trait ToSource { fn to_src(&self) -> ~str; } -impl ToSource for syntax::codemap::span { +impl ToSource for syntax::codemap::Span { fn to_src(&self) -> ~str { debug!("converting span %s to snippet", self.clean()); let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess.codemap.clone(); @@ -912,23 +910,23 @@ fn lit_to_str(lit: &ast::lit) -> ~str { } } -fn name_from_pat(p: &ast::pat) -> ~str { +fn name_from_pat(p: &ast::Pat) -> ~str { use syntax::ast::*; match p.node { - pat_wild => ~"_", - pat_ident(_, ref p, _) => path_to_str(p), - pat_enum(ref p, _) => path_to_str(p), - pat_struct(*) => fail!("tried to get argument name from pat_struct, \ - which is not allowed in function arguments"), - pat_tup(*) => ~"(tuple arg NYI)", - pat_box(p) => name_from_pat(p), - pat_uniq(p) => name_from_pat(p), - pat_region(p) => name_from_pat(p), - pat_lit(*) => fail!("tried to get argument name from pat_lit, \ - which is not allowed in function arguments"), - pat_range(*) => fail!("tried to get argument name from pat_range, \ - which is not allowed in function arguments"), - pat_vec(*) => fail!("tried to get argument name from pat_vec, \ + PatWild => ~"_", + PatIdent(_, ref p, _) => path_to_str(p), + PatEnum(ref p, _) => path_to_str(p), + PatStruct(*) => fail!("tried to get argument name from pat_struct, \ + which is not allowed in function arguments"), + PatTup(*) => ~"(tuple arg NYI)", + PatBox(p) => name_from_pat(p), + PatUniq(p) => name_from_pat(p), + PatRegion(p) => name_from_pat(p), + PatLit(*) => fail!("tried to get argument name from pat_lit, \ + which is not allowed in function arguments"), + PatRange(*) => fail!("tried to get argument name from pat_range, \ + which is not allowed in function arguments"), + PatVec(*) => fail!("tried to get argument name from pat_vec, \ which is not allowed in function arguments") } } @@ -945,23 +943,6 @@ fn remove_comment_tags(s: &str) -> ~str { } } -/*fn collapse_docs(attrs: ~[Attribute]) -> ~[Attribute] { - let mut docstr = ~""; - for at in attrs.iter() { - match *at { - //XXX how should these be separated? - NameValue(~"doc", ref s) => docstr.push_str(fmt!("%s ", clean_comment_body(s.clone()))), - _ => () - } - } - let mut a = attrs.iter().filter(|&a| match a { - &NameValue(~"doc", _) => false, - _ => true - }).map(|x| x.clone()).collect::<~[Attribute]>(); - a.push(NameValue(~"doc", docstr.trim().to_owned())); - a -}*/ - /// Given a Type, resolve it using the def_map fn resolve_type(t: &Type) -> Type { use syntax::ast::*; @@ -984,21 +965,21 @@ fn resolve_type(t: &Type) -> Type { }; let def_id = match *d { - def_fn(i, _) => i, - def_self(i, _) | def_self_ty(i) => return Self(i), - def_ty(i) => i, - def_trait(i) => { - debug!("saw def_trait in def_to_id"); + DefFn(i, _) => i, + DefSelf(i, _) | DefSelfTy(i) => return Self(i), + DefTy(i) => i, + DefTrait(i) => { + debug!("saw DefTrait in def_to_id"); i }, - def_prim_ty(p) => match p { + DefPrimTy(p) => match p { ty_str => return String, ty_bool => return Bool, _ => return Primitive(p) }, - def_ty_param(i, _) => return Generic(i.node), - def_struct(i) => i, - def_typaram_binder(i) => { + DefTyParam(i, _) => return Generic(i.node), + DefStruct(i) => i, + DefTyParamBinder(i) => { debug!("found a typaram_binder, what is it? %d", i); return TyParamBinder(i); }, @@ -1011,10 +992,10 @@ fn resolve_type(t: &Type) -> Type { let mut ty = ~""; do csearch::each_path(sess.cstore, def_id.crate) |pathstr, deflike, _vis| { match deflike { - decoder::dl_def(di) => { + decoder::DlDef(di) => { let d2 = match di { - def_fn(i, _) | def_ty(i) | def_trait(i) | - def_struct(i) | def_mod(i) => Some(i), + DefFn(i, _) | DefTy(i) | DefTrait(i) | + DefStruct(i) | DefMod(i) => Some(i), _ => None, }; if d2.is_some() { @@ -1023,10 +1004,10 @@ fn resolve_type(t: &Type) -> Type { debug!("found external def: %?", di); path = pathstr.to_owned(); ty = match di { - def_fn(*) => ~"fn", - def_ty(*) => ~"enum", - def_trait(*) => ~"trait", - def_prim_ty(p) => match p { + DefFn(*) => ~"fn", + DefTy(*) => ~"enum", + DefTrait(*) => ~"trait", + DefPrimTy(p) => match p { ty_str => ~"str", ty_bool => ~"bool", ty_int(t) => match t.to_str() { @@ -1036,9 +1017,9 @@ fn resolve_type(t: &Type) -> Type { ty_uint(t) => t.to_str(), ty_float(t) => t.to_str() }, - def_ty_param(*) => ~"generic", - def_struct(*) => ~"struct", - def_typaram_binder(*) => ~"typaram_binder", + DefTyParam(*) => ~"generic", + DefStruct(*) => ~"struct", + DefTyParamBinder(*) => ~"typaram_binder", x => fail!("resolved external maps to a weird def %?", x), }; diff --git a/src/rustdoc_ng/doctree.rs b/src/rustdoc_ng/doctree.rs index d5ad0fca30f..3b553608c1a 100644 --- a/src/rustdoc_ng/doctree.rs +++ b/src/rustdoc_ng/doctree.rs @@ -2,14 +2,14 @@ //! manner (and with prettier names) before cleaning. use syntax; -use syntax::codemap::span; +use syntax::codemap::Span; use syntax::ast; -use syntax::ast::{ident, NodeId}; +use syntax::ast::{Ident, NodeId}; pub struct Module { - name: Option, + name: Option, attrs: ~[ast::Attribute], - where: span, + where: Span, structs: ~[Struct], enums: ~[Enum], fns: ~[Function], @@ -24,7 +24,7 @@ pub struct Module { } impl Module { - pub fn new(name: Option) -> Module { + pub fn new(name: Option) -> Module { Module { name : name, id: 0, @@ -65,11 +65,11 @@ pub struct Struct { vis: ast::visibility, id: NodeId, struct_type: StructType, - name: ident, + name: Ident, generics: ast::Generics, attrs: ~[ast::Attribute], fields: ~[@ast::struct_field], - where: span, + where: Span, } pub struct Enum { @@ -78,58 +78,58 @@ pub struct Enum { generics: ast::Generics, attrs: ~[ast::Attribute], id: NodeId, - where: span, - name: ident, + where: Span, + name: Ident, } pub struct Variant { - name: ident, + name: Ident, attrs: ~[ast::Attribute], kind: ast::variant_kind, id: ast::NodeId, vis: ast::visibility, - where: span, + where: Span, } pub struct Function { decl: ast::fn_decl, attrs: ~[ast::Attribute], id: NodeId, - name: ident, + name: Ident, vis: ast::visibility, - where: span, + where: Span, generics: ast::Generics, } pub struct Typedef { ty: ast::Ty, gen: ast::Generics, - name: ast::ident, + name: Ident, id: ast::NodeId, attrs: ~[ast::Attribute], - where: span, + where: Span, vis: ast::visibility, } pub struct Static { type_: ast::Ty, - mutability: ast::mutability, - expr: @ast::expr, - name: ast::ident, + mutability: ast::Mutability, + expr: @ast::Expr, + name: Ident, attrs: ~[ast::Attribute], vis: ast::visibility, id: ast::NodeId, - where: span, + where: Span, } pub struct Trait { - name: ast::ident, + name: Ident, methods: ~[ast::trait_method], //should be TraitMethod generics: ast::Generics, parents: ~[ast::trait_ref], attrs: ~[ast::Attribute], id: ast::NodeId, - where: span, + where: Span, vis: ast::visibility, } @@ -139,7 +139,7 @@ pub struct Impl { for_: ast::Ty, methods: ~[@ast::method], attrs: ~[ast::Attribute], - where: span, + where: Span, vis: ast::visibility, id: ast::NodeId, } diff --git a/src/rustdoc_ng/visit_ast.rs b/src/rustdoc_ng/visit_ast.rs index 2e437a028ec..4ece4a1f039 100644 --- a/src/rustdoc_ng/visit_ast.rs +++ b/src/rustdoc_ng/visit_ast.rs @@ -3,7 +3,7 @@ use syntax::abi::AbiSet; use syntax::{ast, ast_map}; -use syntax::codemap::span; +use syntax::codemap::Span; use doctree::*; use std::local_data; @@ -79,7 +79,7 @@ impl RustdocVisitor { } } - fn visit_mod_contents(span: span, attrs: ~[ast::Attribute], vis: + fn visit_mod_contents(span: Span, attrs: ~[ast::Attribute], vis: ast::visibility, id: ast::NodeId, m: &ast::_mod) -> Module { let am = local_data::get(super::ctxtkey, |x| *x.unwrap()).tycx.items; let name = match am.find(&id) {