diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-01-09 15:05:33 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-01-09 22:25:28 +0200 |
| commit | 6b221768cfe4585a70cc5c3b647ceda0c7319c25 (patch) | |
| tree | 68619cc855b67175b0d03b2d27449d1a3184bf6d | |
| parent | 63ba93f91d6988506fd25a91c7d80820818159ab (diff) | |
| download | rust-6b221768cfe4585a70cc5c3b647ceda0c7319c25.tar.gz rust-6b221768cfe4585a70cc5c3b647ceda0c7319c25.zip | |
libsyntax: Renamed types, traits and enum variants to CamelCase.
142 files changed, 4222 insertions, 4325 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index a73c3cf6b5c..0284dc3b92d 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -38,7 +38,8 @@ use extra::hex::ToHex; use extra::tempfile::TempDir; use syntax::abi; use syntax::ast; -use syntax::ast_map::{path, path_mod, path_name, path_pretty_name}; +use syntax::ast_map::{PathMod, PathName, PathPrettyName}; +use syntax::ast_map; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::crateid::CrateId; @@ -583,7 +584,7 @@ pub fn sanitize(s: &str) -> ~str { return result; } -pub fn mangle(sess: Session, ss: path, +pub fn mangle(sess: Session, ss: ast_map::Path, hash: Option<&str>, vers: Option<&str>) -> ~str { // Follow C++ namespace-mangling style, see // http://en.wikipedia.org/wiki/Name_mangling for more info. @@ -609,7 +610,7 @@ pub fn mangle(sess: Session, ss: path, // First, connect each component with <len, name> pairs. for s in ss.iter() { match *s { - path_name(s) | path_mod(s) | path_pretty_name(s, _) => { + PathName(s) | PathMod(s) | PathPrettyName(s, _) => { push(sess.str_of(s)) } } @@ -625,7 +626,7 @@ pub fn mangle(sess: Session, ss: path, let mut hash = match hash { Some(s) => s.to_owned(), None => ~"" }; for s in ss.iter() { match *s { - path_pretty_name(_, extra) => { + PathPrettyName(_, extra) => { let hi = (extra >> 32) as u32 as uint; let lo = extra as u32 as uint; hash.push_char(EXTRA_CHARS[hi % EXTRA_CHARS.len()] as char); @@ -647,7 +648,7 @@ pub fn mangle(sess: Session, ss: path, } pub fn exported_name(sess: Session, - path: path, + path: ast_map::Path, hash: &str, vers: &str) -> ~str { // The version will get mangled to have a leading '_', but it makes more @@ -662,7 +663,7 @@ pub fn exported_name(sess: Session, } pub fn mangle_exported_name(ccx: &CrateContext, - path: path, + path: ast_map::Path, t: ty::t) -> ~str { let hash = get_symbol_hash(ccx, t); return exported_name(ccx.sess, path, @@ -676,8 +677,8 @@ pub fn mangle_internal_name_by_type_only(ccx: &CrateContext, let s = ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); return mangle(ccx.sess, - ~[path_name(ccx.sess.ident_of(name)), - path_name(ccx.sess.ident_of(s))], + ~[PathName(ccx.sess.ident_of(name)), + PathName(ccx.sess.ident_of(s))], Some(hash.as_slice()), None); } @@ -689,20 +690,21 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext, let hash = get_symbol_hash(ccx, t); let (_, name) = gensym_name(name); return mangle(ccx.sess, - ~[path_name(ccx.sess.ident_of(s)), name], + ~[PathName(ccx.sess.ident_of(s)), name], Some(hash.as_slice()), None); } pub fn mangle_internal_name_by_path_and_seq(ccx: &CrateContext, - mut path: path, + mut path: ast_map::Path, flav: &str) -> ~str { let (_, name) = gensym_name(flav); path.push(name); mangle(ccx.sess, path, None, None) } -pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str { +pub fn mangle_internal_name_by_path(ccx: &CrateContext, + path: ast_map::Path) -> ~str { mangle(ccx.sess, path, None, None) } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 6a0687d1346..4657d697323 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -164,7 +164,7 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &input) pub fn phase_2_configure_and_expand(sess: Session, cfg: ast::CrateConfig, mut crate: ast::Crate) - -> (ast::Crate, syntax::ast_map::map) { + -> (ast::Crate, syntax::ast_map::Map) { let time_passes = sess.time_passes(); sess.building_library.set(session::building_library(sess.opts, &crate)); @@ -220,7 +220,7 @@ pub struct CrateAnalysis { /// structures carrying the results of the analysis. pub fn phase_3_run_analysis_passes(sess: Session, crate: &ast::Crate, - ast_map: syntax::ast_map::map) -> CrateAnalysis { + ast_map: syntax::ast_map::Map) -> CrateAnalysis { let time_passes = sess.time_passes(); @@ -515,29 +515,29 @@ struct IdentifiedAnnotation { contents: (), } -impl pprust::pp_ann for IdentifiedAnnotation { - fn pre(&self, node: pprust::ann_node) { +impl pprust::PpAnn for IdentifiedAnnotation { + fn pre(&self, node: pprust::AnnNode) { match node { - pprust::node_expr(s, _) => pprust::popen(s), + pprust::NodeExpr(s, _) => pprust::popen(s), _ => () } } - fn post(&self, node: pprust::ann_node) { + fn post(&self, node: pprust::AnnNode) { match node { - pprust::node_item(s, item) => { + pprust::NodeItem(s, item) => { pp::space(&mut s.s); pprust::synth_comment(s, item.id.to_str()); } - pprust::node_block(s, blk) => { + pprust::NodeBlock(s, blk) => { pp::space(&mut s.s); pprust::synth_comment(s, ~"block " + blk.id.to_str()); } - pprust::node_expr(s, expr) => { + pprust::NodeExpr(s, expr) => { pp::space(&mut s.s); pprust::synth_comment(s, expr.id.to_str()); pprust::pclose(s); } - pprust::node_pat(s, pat) => { + pprust::NodePat(s, pat) => { pp::space(&mut s.s); pprust::synth_comment(s, ~"pat " + pat.id.to_str()); } @@ -549,17 +549,17 @@ struct TypedAnnotation { analysis: CrateAnalysis, } -impl pprust::pp_ann for TypedAnnotation { - fn pre(&self, node: pprust::ann_node) { +impl pprust::PpAnn for TypedAnnotation { + fn pre(&self, node: pprust::AnnNode) { match node { - pprust::node_expr(s, _) => pprust::popen(s), + pprust::NodeExpr(s, _) => pprust::popen(s), _ => () } } - fn post(&self, node: pprust::ann_node) { + fn post(&self, node: pprust::AnnNode) { let tcx = self.analysis.ty_cx; match node { - pprust::node_expr(s, expr) => { + pprust::NodeExpr(s, expr) => { pp::space(&mut s.s); pp::word(&mut s.s, "as"); pp::space(&mut s.s); @@ -589,16 +589,16 @@ pub fn pretty_print_input(sess: Session, PpmIdentified | PpmExpandedIdentified => { @IdentifiedAnnotation { contents: (), - } as @pprust::pp_ann + } as @pprust::PpAnn } PpmTyped => { let ast_map = ast_map.expect("--pretty=typed missing ast_map"); let analysis = phase_3_run_analysis_passes(sess, &crate, ast_map); @TypedAnnotation { analysis: analysis - } as @pprust::pp_ann + } as @pprust::PpAnn } - _ => @pprust::no_ann::new() as @pprust::pp_ann, + _ => @pprust::NoAnn as @pprust::PpAnn, }; let src = sess.codemap.get_filemap(source_name(input)).src; @@ -662,10 +662,10 @@ pub fn build_target_config(sopts: @session::options, "unknown architecture: " + sopts.target_triple) }; let (int_type, uint_type) = match arch { - abi::X86 => (ast::ty_i32, ast::ty_u32), - abi::X86_64 => (ast::ty_i64, ast::ty_u64), - abi::Arm => (ast::ty_i32, ast::ty_u32), - abi::Mips => (ast::ty_i32, ast::ty_u32) + abi::X86 => (ast::TyI32, ast::TyU32), + abi::X86_64 => (ast::TyI64, ast::TyU64), + abi::Arm => (ast::TyI32, ast::TyU32), + abi::Mips => (ast::TyI32, ast::TyU32) }; let target_triple = sopts.target_triple.clone(); let target_strs = match arch { @@ -1116,7 +1116,7 @@ pub fn build_output_filenames(input: &input, } pub fn early_error(emitter: &diagnostic::Emitter, msg: &str) -> ! { - emitter.emit(None, msg, diagnostic::fatal); + emitter.emit(None, msg, diagnostic::Fatal); fail!(); } diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index a8a948db4e1..0176c3fa1e0 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -19,7 +19,7 @@ use middle::lint; use syntax::attr::AttrMetaMethods; use syntax::ast::NodeId; -use syntax::ast::{int_ty, uint_ty}; +use syntax::ast::{IntTy, UintTy}; use syntax::codemap::Span; use syntax::diagnostic; use syntax::parse::ParseSess; @@ -35,8 +35,8 @@ pub struct config { os: abi::Os, arch: abi::Architecture, target_strs: target_strs::t, - int_type: int_ty, - uint_type: uint_ty, + int_type: IntTy, + uint_type: UintTy, } pub static verbose: uint = 1 << 0; @@ -368,7 +368,7 @@ impl Session_ { } // pointless function, now... - pub fn intr(&self) -> @syntax::parse::token::ident_interner { + pub fn intr(&self) -> @syntax::parse::token::IdentInterner { token::get_ident_interner() } } diff --git a/src/librustc/front/assign_node_ids_and_map.rs b/src/librustc/front/assign_node_ids_and_map.rs index bf950f1d686..d77ef1f3534 100644 --- a/src/librustc/front/assign_node_ids_and_map.rs +++ b/src/librustc/front/assign_node_ids_and_map.rs @@ -24,6 +24,6 @@ impl ast_map::FoldOps for NodeIdAssigner { } } -pub fn assign_node_ids_and_map(sess: Session, crate: ast::Crate) -> (ast::Crate, ast_map::map) { +pub fn assign_node_ids_and_map(sess: Session, crate: ast::Crate) -> (ast::Crate, ast_map::Map) { ast_map::map_crate(sess.diagnostic(), crate, NodeIdAssigner { sess: sess }) } diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 1ddc2cf6696..0c41b35f6ea 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -9,7 +9,7 @@ // except according to those terms. -use syntax::fold::ast_fold; +use syntax::fold::Folder; use syntax::{ast, fold, attr}; use syntax::codemap; @@ -24,18 +24,17 @@ pub fn strip_unconfigured_items(crate: ast::Crate) -> ast::Crate { strip_items(crate, |attrs| in_cfg(config, attrs)) } -impl<'a> fold::ast_fold for Context<'a> { - fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod { +impl<'a> fold::Folder for Context<'a> { + fn fold_mod(&mut self, module: &ast::Mod) -> ast::Mod { fold_mod(self, module) } fn fold_block(&mut self, block: ast::P<ast::Block>) -> ast::P<ast::Block> { fold_block(self, block) } - fn fold_foreign_mod(&mut self, foreign_module: &ast::foreign_mod) - -> ast::foreign_mod { - fold_foreign_mod(self, foreign_module) + fn fold_foreign_mod(&mut self, foreign_mod: &ast::ForeignMod) -> ast::ForeignMod { + fold_foreign_mod(self, foreign_mod) } - fn fold_item_underscore(&mut self, item: &ast::item_) -> ast::item_ { + fn fold_item_underscore(&mut self, item: &ast::Item_) -> ast::Item_ { fold_item_underscore(self, item) } } @@ -49,8 +48,8 @@ pub fn strip_items(crate: ast::Crate, ctxt.fold_crate(crate) } -fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item) - -> Option<&'r ast::view_item> { +fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::ViewItem) + -> Option<&'r ast::ViewItem> { if view_item_in_cfg(cx, view_item) { Some(view_item) } else { @@ -58,7 +57,7 @@ fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item) } } -fn fold_mod(cx: &mut Context, m: &ast::_mod) -> ast::_mod { +fn fold_mod(cx: &mut Context, m: &ast::Mod) -> ast::Mod { let filtered_items = m.items.iter() .filter(|&a| item_in_cfg(cx, *a)) .flat_map(|&x| cx.fold_item(x).move_iter()) @@ -66,14 +65,14 @@ fn fold_mod(cx: &mut Context, m: &ast::_mod) -> ast::_mod { let filtered_view_items = m.view_items.iter().filter_map(|a| { filter_view_item(cx, a).map(|x| cx.fold_view_item(x)) }).collect(); - ast::_mod { + ast::Mod { view_items: filtered_view_items, items: filtered_items } } -fn filter_foreign_item(cx: &Context, item: @ast::foreign_item) - -> Option<@ast::foreign_item> { +fn filter_foreign_item(cx: &Context, item: @ast::ForeignItem) + -> Option<@ast::ForeignItem> { if foreign_item_in_cfg(cx, item) { Some(item) } else { @@ -81,7 +80,7 @@ fn filter_foreign_item(cx: &Context, item: @ast::foreign_item) } } -fn fold_foreign_mod(cx: &mut Context, nm: &ast::foreign_mod) -> ast::foreign_mod { +fn fold_foreign_mod(cx: &mut Context, nm: &ast::ForeignMod) -> ast::ForeignMod { let filtered_items = nm.items .iter() .filter_map(|a| filter_foreign_item(cx, *a)) @@ -89,41 +88,41 @@ fn fold_foreign_mod(cx: &mut Context, nm: &ast::foreign_mod) -> ast::foreign_mod let filtered_view_items = nm.view_items.iter().filter_map(|a| { filter_view_item(cx, a).map(|x| cx.fold_view_item(x)) }).collect(); - ast::foreign_mod { + ast::ForeignMod { abis: nm.abis, view_items: filtered_view_items, items: filtered_items } } -fn fold_item_underscore(cx: &mut Context, item: &ast::item_) -> ast::item_ { +fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ { let item = match *item { - ast::item_impl(ref a, ref b, c, ref methods) => { + ast::ItemImpl(ref a, ref b, c, ref methods) => { let methods = methods.iter().filter(|m| method_in_cfg(cx, **m)) .map(|x| *x).collect(); - ast::item_impl((*a).clone(), (*b).clone(), c, methods) + ast::ItemImpl((*a).clone(), (*b).clone(), c, methods) } - ast::item_trait(ref a, ref b, ref methods) => { + ast::ItemTrait(ref a, ref b, ref methods) => { let methods = methods.iter() .filter(|m| trait_method_in_cfg(cx, *m) ) .map(|x| (*x).clone()) .collect(); - ast::item_trait((*a).clone(), (*b).clone(), methods) + ast::ItemTrait((*a).clone(), (*b).clone(), methods) } - ast::item_struct(def, ref generics) => { - ast::item_struct(fold_struct(cx, def), generics.clone()) + ast::ItemStruct(def, ref generics) => { + ast::ItemStruct(fold_struct(cx, def), generics.clone()) } - ast::item_enum(ref def, ref generics) => { + ast::ItemEnum(ref def, ref generics) => { let mut variants = def.variants.iter().map(|c| c.clone()).filter(|m| { (cx.in_cfg)(m.node.attrs) }).map(|v| { match v.node.kind { - ast::tuple_variant_kind(..) => v, - ast::struct_variant_kind(def) => { + ast::TupleVariantKind(..) => v, + ast::StructVariantKind(def) => { let def = fold_struct(cx, def); @codemap::Spanned { - node: ast::variant_ { - kind: ast::struct_variant_kind(def), + node: ast::Variant_ { + kind: ast::StructVariantKind(def), ..v.node.clone() }, ..*v @@ -131,7 +130,7 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::item_) -> ast::item_ { } } }); - ast::item_enum(ast::enum_def { + ast::ItemEnum(ast::EnumDef { variants: variants.collect(), }, generics.clone()) } @@ -141,11 +140,11 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::item_) -> ast::item_ { fold::noop_fold_item_underscore(&item, cx) } -fn fold_struct(cx: &Context, def: &ast::struct_def) -> @ast::struct_def { +fn fold_struct(cx: &Context, def: &ast::StructDef) -> @ast::StructDef { let mut fields = def.fields.iter().map(|c| c.clone()).filter(|m| { (cx.in_cfg)(m.node.attrs) }); - @ast::struct_def { + @ast::StructDef { fields: fields.collect(), ctor_id: def.ctor_id, } @@ -183,26 +182,26 @@ fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> { }) } -fn item_in_cfg(cx: &Context, item: @ast::item) -> bool { +fn item_in_cfg(cx: &Context, item: &ast::Item) -> bool { return (cx.in_cfg)(item.attrs); } -fn foreign_item_in_cfg(cx: &Context, item: @ast::foreign_item) -> bool { +fn foreign_item_in_cfg(cx: &Context, item: &ast::ForeignItem) -> bool { return (cx.in_cfg)(item.attrs); } -fn view_item_in_cfg(cx: &Context, item: &ast::view_item) -> bool { +fn view_item_in_cfg(cx: &Context, item: &ast::ViewItem) -> bool { return (cx.in_cfg)(item.attrs); } -fn method_in_cfg(cx: &Context, meth: @ast::method) -> bool { +fn method_in_cfg(cx: &Context, meth: &ast::Method) -> bool { return (cx.in_cfg)(meth.attrs); } -fn trait_method_in_cfg(cx: &Context, meth: &ast::trait_method) -> bool { +fn trait_method_in_cfg(cx: &Context, meth: &ast::TraitMethod) -> bool { match *meth { - ast::required(ref meth) => (cx.in_cfg)(meth.attrs), - ast::provided(@ref meth) => (cx.in_cfg)(meth.attrs) + ast::Required(ref meth) => (cx.in_cfg)(meth.attrs), + ast::Provided(@ref meth) => (cx.in_cfg)(meth.attrs) } } diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index 9f9d931cc13..9bd7c8fc44a 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -100,12 +100,12 @@ impl Visitor<()> for Context { } } - fn visit_view_item(&mut self, i: &ast::view_item, _: ()) { + fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) { match i.node { - ast::view_item_use(ref paths) => { + ast::ViewItemUse(ref paths) => { for path in paths.iter() { match path.node { - ast::view_path_glob(..) => { + ast::ViewPathGlob(..) => { self.gate_feature("globs", path.span, "glob import statements are \ experimental and possibly buggy"); @@ -119,7 +119,7 @@ impl Visitor<()> for Context { visit::walk_view_item(self, i, ()) } - fn visit_item(&mut self, i: &ast::item, _:()) { + fn visit_item(&mut self, i: &ast::Item, _:()) { for attr in i.attrs.iter() { if "thread_local" == attr.name() { self.gate_feature("thread_local", i.span, @@ -129,10 +129,10 @@ impl Visitor<()> for Context { } } match i.node { - ast::item_enum(ref def, _) => { + ast::ItemEnum(ref def, _) => { for variant in def.variants.iter() { match variant.node.kind { - ast::struct_variant_kind(..) => { + ast::StructVariantKind(..) => { self.gate_feature("struct_variant", variant.span, "enum struct variants are \ experimental and possibly buggy"); @@ -142,7 +142,7 @@ impl Visitor<()> for Context { } } - ast::item_foreign_mod(..) => { + ast::ItemForeignMod(..) => { if attr::contains_name(i.attrs, "link_args") { self.gate_feature("link_args", i.span, "the `link_args` attribute is not portable \ @@ -157,8 +157,8 @@ impl Visitor<()> for Context { visit::walk_item(self, i, ()); } - fn visit_mac(&mut self, macro: &ast::mac, _: ()) { - let ast::mac_invoc_tt(ref path, _, _) = macro.node; + fn visit_mac(&mut self, macro: &ast::Mac, _: ()) { + let ast::MacInvocTT(ref path, _, _) = macro.node; if path.segments.last().identifier == self.sess.ident_of("macro_rules") { self.gate_feature("macro_rules", path.span, "macro definitions are \ @@ -173,14 +173,14 @@ impl Visitor<()> for Context { fn visit_ty(&mut self, t: &ast::Ty, _: ()) { match t.node { - ast::ty_closure(closure) if closure.onceness == ast::Once && + ast::TyClosure(closure) if closure.onceness == ast::Once && closure.sigil != ast::OwnedSigil => { self.gate_feature("once_fns", t.span, "once functions are \ experimental and likely to be removed"); }, - ast::ty_box(_) => { self.gate_box(t.span); } + ast::TyBox(_) => { self.gate_box(t.span); } _ => {} } diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 6df996178c8..ae593783213 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -16,7 +16,7 @@ use syntax::ast; use syntax::attr; use syntax::codemap::DUMMY_SP; use syntax::codemap; -use syntax::fold::ast_fold; +use syntax::fold::Folder; use syntax::fold; use syntax::opt_vec; use syntax::util::small_vector::SmallVector; @@ -55,41 +55,41 @@ struct StandardLibraryInjector { sess: Session, } -impl fold::ast_fold for StandardLibraryInjector { +impl fold::Folder for StandardLibraryInjector { fn fold_crate(&mut self, crate: ast::Crate) -> ast::Crate { - let mut vis = ~[ast::view_item { - node: ast::view_item_extern_mod(self.sess.ident_of("std"), - Some((format!("std\\#{}", VERSION).to_managed(), - ast::CookedStr)), - ast::DUMMY_NODE_ID), + let mut vis = ~[ast::ViewItem { + node: ast::ViewItemExternMod(self.sess.ident_of("std"), + Some((format!("std\\#{}", VERSION).to_managed(), + ast::CookedStr)), + ast::DUMMY_NODE_ID), attrs: ~[], - vis: ast::private, + vis: ast::Private, span: DUMMY_SP }]; if use_uv(&crate) && !self.sess.building_library.get() { - vis.push(ast::view_item { - node: ast::view_item_extern_mod(self.sess.ident_of("green"), - Some((format!("green\\#{}", VERSION).to_managed(), - ast::CookedStr)), - ast::DUMMY_NODE_ID), + vis.push(ast::ViewItem { + node: ast::ViewItemExternMod(self.sess.ident_of("green"), + Some((format!("green\\#{}", VERSION).to_managed(), + ast::CookedStr)), + ast::DUMMY_NODE_ID), attrs: ~[], - vis: ast::private, + vis: ast::Private, span: DUMMY_SP }); - vis.push(ast::view_item { - node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"), - Some((format!("rustuv\\#{}", VERSION).to_managed(), - ast::CookedStr)), - ast::DUMMY_NODE_ID), + vis.push(ast::ViewItem { + node: ast::ViewItemExternMod(self.sess.ident_of("rustuv"), + Some((format!("rustuv\\#{}", VERSION).to_managed(), + ast::CookedStr)), + ast::DUMMY_NODE_ID), attrs: ~[], - vis: ast::private, + vis: ast::Private, span: DUMMY_SP }); } vis.push_all(crate.module.view_items); - let mut new_module = ast::_mod { + let mut new_module = ast::Mod { view_items: vis, ..crate.module.clone() }; @@ -106,7 +106,7 @@ impl fold::ast_fold for StandardLibraryInjector { } } - fn fold_item(&mut self, item: @ast::item) -> SmallVector<@ast::item> { + fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> { if !no_prelude(item.attrs) { // only recur if there wasn't `#[no_implicit_prelude];` // on this item, i.e. this means that the prelude is not @@ -117,7 +117,7 @@ impl fold::ast_fold for StandardLibraryInjector { } } - fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod { + fn fold_mod(&mut self, module: &ast::Mod) -> ast::Mod { let prelude_path = ast::Path { span: DUMMY_SP, global: false, @@ -135,19 +135,18 @@ impl fold::ast_fold for StandardLibraryInjector { ], }; - let vp = @spanned(ast::view_path_glob(prelude_path, - ast::DUMMY_NODE_ID)); - let vi2 = ast::view_item { - node: ast::view_item_use(~[vp]), + let vp = @spanned(ast::ViewPathGlob(prelude_path, ast::DUMMY_NODE_ID)); + let vi2 = ast::ViewItem { + node: ast::ViewItemUse(~[vp]), attrs: ~[], - vis: ast::private, + vis: ast::Private, span: DUMMY_SP, }; let vis = vec::append(~[vi2], module.view_items); // FIXME #2543: Bad copy. - let new_module = ast::_mod { + let new_module = ast::Mod { view_items: vis, ..(*module).clone() }; diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 6acd3060e9f..f78f1b2407d 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -23,7 +23,7 @@ use syntax::attr; use syntax::codemap::{DUMMY_SP, Span, ExpnInfo, NameAndSpan, MacroAttribute}; use syntax::codemap; use syntax::ext::base::ExtCtxt; -use syntax::fold::ast_fold; +use syntax::fold::Folder; use syntax::fold; use syntax::opt_vec; use syntax::print::pprust; @@ -67,7 +67,7 @@ struct TestHarnessGenerator { cx: TestCtxt, } -impl fold::ast_fold for TestHarnessGenerator { +impl fold::Folder for TestHarnessGenerator { fn fold_crate(&mut self, c: ast::Crate) -> ast::Crate { let folded = fold::noop_fold_crate(c, self); @@ -79,7 +79,7 @@ impl fold::ast_fold for TestHarnessGenerator { } } - fn fold_item(&mut self, i: @ast::item) -> SmallVector<@ast::item> { + fn fold_item(&mut self, i: @ast::Item) -> SmallVector<@ast::Item> { { let mut path = self.cx.path.borrow_mut(); path.get().push(i.ident); @@ -89,8 +89,8 @@ impl fold::ast_fold for TestHarnessGenerator { if is_test_fn(&self.cx, i) || is_bench_fn(i) { match i.node { - ast::item_fn(_, purity, _, _, _) - if purity == ast::unsafe_fn => { + ast::ItemFn(_, purity, _, _, _) + if purity == ast::UnsafeFn => { let sess = self.cx.sess; sess.span_fatal(i.span, "unsafe functions cannot be used for \ @@ -123,13 +123,13 @@ impl fold::ast_fold for TestHarnessGenerator { res } - fn fold_mod(&mut self, m: &ast::_mod) -> ast::_mod { + fn fold_mod(&mut self, m: &ast::Mod) -> ast::Mod { // Remove any #[main] from the AST so it doesn't clash with // the one we're going to add. Only if compiling an executable. - fn nomain(cx: &TestCtxt, item: @ast::item) -> @ast::item { + fn nomain(cx: &TestCtxt, item: @ast::Item) -> @ast::Item { if !cx.sess.building_library.get() { - @ast::item { + @ast::Item { attrs: item.attrs.iter().filter_map(|attr| { if "main" != attr.name() { Some(*attr) @@ -144,7 +144,7 @@ impl fold::ast_fold for TestHarnessGenerator { } } - let mod_nomain = ast::_mod { + let mod_nomain = ast::Mod { view_items: m.view_items.clone(), items: m.items.iter().map(|i| nomain(&self.cx, *i)).collect(), }; @@ -190,14 +190,14 @@ fn strip_test_functions(crate: ast::Crate) -> ast::Crate { }) } -fn is_test_fn(cx: &TestCtxt, i: @ast::item) -> bool { +fn is_test_fn(cx: &TestCtxt, i: @ast::Item) -> bool { let has_test_attr = attr::contains_name(i.attrs, "test"); - fn has_test_signature(i: @ast::item) -> bool { + fn has_test_signature(i: @ast::Item) -> bool { match &i.node { - &ast::item_fn(ref decl, _, _, ref generics, _) => { + &ast::ItemFn(ref decl, _, _, ref generics, _) => { let no_output = match decl.output.node { - ast::ty_nil => true, + ast::TyNil => true, _ => false }; decl.inputs.is_empty() @@ -219,15 +219,15 @@ fn is_test_fn(cx: &TestCtxt, i: @ast::item) -> bool { return has_test_attr && has_test_signature(i); } -fn is_bench_fn(i: @ast::item) -> bool { +fn is_bench_fn(i: @ast::Item) -> bool { let has_bench_attr = attr::contains_name(i.attrs, "bench"); - fn has_test_signature(i: @ast::item) -> bool { + fn has_test_signature(i: @ast::Item) -> bool { match i.node { - ast::item_fn(ref decl, _, _, ref generics, _) => { + ast::ItemFn(ref decl, _, _, ref generics, _) => { let input_cnt = decl.inputs.len(); let no_output = match decl.output.node { - ast::ty_nil => true, + ast::TyNil => true, _ => false }; let tparm_cnt = generics.ty_params.len(); @@ -243,7 +243,7 @@ fn is_bench_fn(i: @ast::item) -> bool { return has_bench_attr && has_test_signature(i); } -fn is_ignored(cx: &TestCtxt, i: @ast::item) -> bool { +fn is_ignored(cx: &TestCtxt, i: @ast::Item) -> bool { i.attrs.iter().any(|attr| { // check ignore(cfg(foo, bar)) "ignore" == attr.name() && match attr.meta_item_list() { @@ -253,13 +253,13 @@ fn is_ignored(cx: &TestCtxt, i: @ast::item) -> bool { }) } -fn should_fail(i: @ast::item) -> bool { +fn should_fail(i: @ast::Item) -> bool { attr::contains_name(i.attrs, "should_fail") } -fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod { +fn add_test_module(cx: &TestCtxt, m: &ast::Mod) -> ast::Mod { let testmod = mk_test_module(cx); - ast::_mod { + ast::Mod { items: vec::append_one(m.items.clone(), testmod), ..(*m).clone() } @@ -284,28 +284,28 @@ mod __test { */ -fn mk_std(cx: &TestCtxt) -> ast::view_item { +fn mk_std(cx: &TestCtxt) -> ast::ViewItem { let id_extra = cx.sess.ident_of("extra"); let vi = if cx.is_extra { - ast::view_item_use( - ~[@nospan(ast::view_path_simple(id_extra, - path_node(~[id_extra]), - ast::DUMMY_NODE_ID))]) + ast::ViewItemUse( + ~[@nospan(ast::ViewPathSimple(id_extra, + path_node(~[id_extra]), + ast::DUMMY_NODE_ID))]) } else { - ast::view_item_extern_mod(id_extra, - Some((format!("extra\\#{}", VERSION).to_managed(), - ast::CookedStr)), - ast::DUMMY_NODE_ID) + ast::ViewItemExternMod(id_extra, + Some((format!("extra\\#{}", VERSION).to_managed(), + ast::CookedStr)), + ast::DUMMY_NODE_ID) }; - ast::view_item { + ast::ViewItem { node: vi, attrs: ~[], - vis: ast::public, + vis: ast::Public, span: DUMMY_SP } } -fn mk_test_module(cx: &TestCtxt) -> @ast::item { +fn mk_test_module(cx: &TestCtxt) -> @ast::Item { // Link to extra let view_items = ~[mk_std(cx)]; @@ -322,22 +322,22 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item { } )).unwrap(); - let testmod = ast::_mod { + let testmod = ast::Mod { view_items: view_items, items: ~[mainfn, tests], }; - let item_ = ast::item_mod(testmod); + let item_ = ast::ItemMod(testmod); // This attribute tells resolve to let us call unexported functions let resolve_unexported_attr = attr::mk_attr(attr::mk_word_item(@"!resolve_unexported")); - let item = ast::item { + let item = ast::Item { ident: cx.sess.ident_of("__test"), attrs: ~[resolve_unexported_attr], id: ast::DUMMY_NODE_ID, node: item_, - vis: ast::public, + vis: ast::Public, span: DUMMY_SP, }; @@ -375,7 +375,7 @@ fn path_node_global(ids: ~[ast::Ident]) -> ast::Path { } } -fn mk_tests(cx: &TestCtxt) -> @ast::item { +fn mk_tests(cx: &TestCtxt) -> @ast::Item { // The vector of test_descs for this crate let test_descs = mk_test_descs(cx); @@ -422,8 +422,8 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr { debug!("encoding {}", ast_util::path_name_i(path)); - let name_lit: ast::lit = - nospan(ast::lit_str(ast_util::path_name_i(path).to_managed(), ast::CookedStr)); + let name_lit: ast::Lit = + nospan(ast::LitStr(ast_util::path_name_i(path).to_managed(), ast::CookedStr)); let name_expr = @ast::Expr { id: ast::DUMMY_NODE_ID, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 5aacef182fa..82fed27b565 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -363,8 +363,8 @@ impl diagnostic::Emitter for RustcEmitter { fn emit(&self, cmsp: Option<(&codemap::CodeMap, codemap::Span)>, msg: &str, - lvl: diagnostic::level) { - if lvl == diagnostic::fatal { + lvl: diagnostic::Level) { + if lvl == diagnostic::Fatal { let this = unsafe { cast::transmute_mut(self) }; this.ch_capture.send(fatal) } @@ -434,7 +434,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) { diagnostic::DefaultEmitter.emit( None, diagnostic::ice_msg("unexpected failure"), - diagnostic::error); + diagnostic::Error); let xs = [ ~"the compiler hit an unexpected failure path. \ @@ -446,7 +446,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) { for note in xs.iter() { diagnostic::DefaultEmitter.emit(None, *note, - diagnostic::note) + diagnostic::Note) } } // Fail so the process returns a failure code diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 8b3d5062e15..2d86a36dd60 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -83,11 +83,11 @@ pub static tag_item_super_trait_ref: uint = 0x33u; // discriminator value for variants pub static tag_disr_val: uint = 0x34u; -// used to encode ast_map::path and ast_map::path_elt +// used to encode ast_map::Path and ast_map::PathElem pub static tag_path: uint = 0x40u; pub static tag_path_len: uint = 0x41u; -pub static tag_path_elt_mod: uint = 0x42u; -pub static tag_path_elt_name: uint = 0x43u; +pub static tag_path_elem_mod: uint = 0x42u; +pub static tag_path_elem_name: uint = 0x43u; pub static tag_item_field: uint = 0x44u; pub static tag_struct_mut: uint = 0x45u; @@ -191,9 +191,9 @@ pub static tag_impls_impl: uint = 0x84; pub static tag_items_data_item_inherent_impl: uint = 0x85; pub static tag_items_data_item_extension_impl: uint = 0x86; -pub static tag_path_elt_pretty_name: uint = 0x87; -pub static tag_path_elt_pretty_name_ident: uint = 0x88; -pub static tag_path_elt_pretty_name_extra: uint = 0x89; +pub static tag_path_elem_pretty_name: uint = 0x87; +pub static tag_path_elem_pretty_name_ident: uint = 0x88; +pub static tag_path_elem_pretty_name_extra: uint = 0x89; pub static tag_region_param_def: uint = 0x100; pub static tag_region_param_def_ident: uint = 0x101; diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 7f4e5b5d9ab..6508da88f3d 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -24,7 +24,7 @@ use syntax::attr::AttrMetaMethods; use syntax::codemap::{Span, DUMMY_SP}; use syntax::diagnostic::SpanHandler; use syntax::parse::token; -use syntax::parse::token::ident_interner; +use syntax::parse::token::IdentInterner; use syntax::crateid::CrateId; use syntax::visit; @@ -33,7 +33,7 @@ use syntax::visit; pub fn read_crates(sess: Session, crate: &ast::Crate, os: loader::Os, - intr: @ident_interner) { + intr: @IdentInterner) { let mut e = Env { sess: sess, os: os, @@ -58,11 +58,11 @@ struct ReadCrateVisitor<'a> { } impl<'a> visit::Visitor<()> for ReadCrateVisitor<'a> { - fn visit_view_item(&mut self, a: &ast::view_item, _: ()) { + fn visit_view_item(&mut self, a: &ast::ViewItem, _: ()) { visit_view_item(self.e, a); visit::walk_view_item(self, a, ()); } - fn visit_item(&mut self, a: &ast::item, _: ()) { + fn visit_item(&mut self, a: &ast::Item, _: ()) { visit_item(self.e, a); visit::walk_item(self, a, ()); } @@ -114,7 +114,7 @@ struct Env { os: loader::Os, crate_cache: @RefCell<~[cache_entry]>, next_crate_num: ast::CrateNum, - intr: @ident_interner + intr: @IdentInterner } fn visit_crate(e: &Env, c: &ast::Crate) { @@ -130,9 +130,9 @@ fn visit_crate(e: &Env, c: &ast::Crate) { } } -fn visit_view_item(e: &mut Env, i: &ast::view_item) { +fn visit_view_item(e: &mut Env, i: &ast::ViewItem) { match i.node { - ast::view_item_extern_mod(ident, path_opt, id) => { + ast::ViewItemExternMod(ident, path_opt, id) => { let ident = token::ident_to_str(&ident); debug!("resolving extern mod stmt. ident: {:?} path_opt: {:?}", ident, path_opt); @@ -164,9 +164,9 @@ fn visit_view_item(e: &mut Env, i: &ast::view_item) { } } -fn visit_item(e: &Env, i: &ast::item) { +fn visit_item(e: &Env, i: &ast::Item) { match i.node { - ast::item_foreign_mod(ref fm) => { + ast::ItemForeignMod(ref fm) => { if fm.abis.is_rust() || fm.abis.is_intrinsic() { return; } diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index ffb6eb36792..6dad364e661 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -26,8 +26,8 @@ use syntax::diagnostic::expect; pub struct StaticMethodInfo { ident: ast::Ident, def_id: ast::DefId, - purity: ast::purity, - vis: ast::visibility, + purity: ast::Purity, + vis: ast::Visibility, } pub fn get_symbol(cstore: @cstore::CStore, def: ast::DefId) -> ~str { @@ -55,7 +55,7 @@ pub fn each_child_of_item(cstore: @cstore::CStore, def_id: ast::DefId, callback: |decoder::DefLike, ast::Ident, - ast::visibility|) { + ast::Visibility|) { let crate_data = cstore.get_crate_data(def_id.crate); let get_crate_data: decoder::GetCrateDataCb = |cnum| { cstore.get_crate_data(cnum) @@ -72,7 +72,7 @@ pub fn each_top_level_item_of_crate(cstore: @cstore::CStore, cnum: ast::CrateNum, callback: |decoder::DefLike, ast::Ident, - ast::visibility|) { + ast::Visibility|) { let crate_data = cstore.get_crate_data(cnum); let get_crate_data: decoder::GetCrateDataCb = |cnum| { cstore.get_crate_data(cnum) @@ -83,20 +83,20 @@ pub fn each_top_level_item_of_crate(cstore: @cstore::CStore, callback) } -pub fn get_item_path(tcx: ty::ctxt, def: ast::DefId) -> ast_map::path { +pub fn get_item_path(tcx: ty::ctxt, def: ast::DefId) -> ast_map::Path { let cstore = tcx.cstore; let cdata = cstore.get_crate_data(def.crate); let path = decoder::get_item_path(cdata, def.node); // FIXME #1920: This path is not always correct if the crate is not linked // into the root namespace. - vec::append(~[ast_map::path_mod(tcx.sess.ident_of( + vec::append(~[ast_map::PathMod(tcx.sess.ident_of( cdata.name))], path) } pub enum found_ast { - found(ast::inlined_item), - found_parent(ast::DefId, ast::inlined_item), + found(ast::InlinedItem), + found_parent(ast::DefId, ast::InlinedItem), not_found, } @@ -133,7 +133,7 @@ pub fn get_method(tcx: ty::ctxt, def: ast::DefId) -> ty::Method { pub fn get_method_name_and_explicit_self(cstore: @cstore::CStore, def: ast::DefId) - -> (ast::Ident, ast::explicit_self_) + -> (ast::Ident, ast::ExplicitSelf_) { let cdata = cstore.get_crate_data(def.crate); decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node) @@ -257,7 +257,7 @@ pub fn get_impl_method(cstore: @cstore::CStore, pub fn get_item_visibility(cstore: @cstore::CStore, def_id: ast::DefId) - -> ast::visibility { + -> ast::Visibility { let cdata = cstore.get_crate_data(def_id.crate); decoder::get_item_visibility(cdata, def_id.node) } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index f567665256b..5be69e9452c 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -18,7 +18,7 @@ use metadata::loader; use std::cell::RefCell; use std::hashmap::HashMap; use syntax::ast; -use syntax::parse::token::ident_interner; +use syntax::parse::token::IdentInterner; // A map from external crate numbers (as decoded from some crate file) to // local crate numbers (as generated during this session). Each external @@ -66,14 +66,14 @@ pub struct CStore { priv used_crate_sources: RefCell<~[CrateSource]>, priv used_libraries: RefCell<~[(~str, NativeLibaryKind)]>, priv used_link_args: RefCell<~[~str]>, - intr: @ident_interner + intr: @IdentInterner } // Map from NodeId's of local extern mod statements to crate numbers type extern_mod_crate_map = HashMap<ast::NodeId, ast::CrateNum>; impl CStore { - pub fn new(intr: @ident_interner) -> CStore { + pub fn new(intr: @IdentInterner) -> CStore { CStore { metas: RefCell::new(HashMap::new()), extern_mod_crate_map: RefCell::new(HashMap::new()), diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 4e4ab981bf6..ca35b1ae96b 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -36,7 +36,7 @@ use extra::ebml; use extra::serialize::Decodable; use syntax::ast_map; use syntax::attr; -use syntax::parse::token::{ident_interner, special_idents}; +use syntax::parse::token::{IdentInterner, special_idents}; use syntax::print::pprust; use syntax::ast; use syntax::codemap; @@ -152,14 +152,14 @@ fn item_family(item: ebml::Doc) -> Family { } } -fn item_visibility(item: ebml::Doc) -> ast::visibility { +fn item_visibility(item: ebml::Doc) -> ast::Visibility { match reader::maybe_get_doc(item, tag_items_data_item_visibility) { - None => ast::public, + None => ast::Public, Some(visibility_doc) => { match reader::doc_as_u8(visibility_doc) as char { - 'y' => ast::public, - 'n' => ast::private, - 'i' => ast::inherited, + 'y' => ast::Public, + 'n' => ast::Private, + 'i' => ast::Inherited, _ => fail!("unknown visibility character") } } @@ -306,7 +306,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> ~[ast::DefId] { return ids; } -pub fn item_path(item_doc: ebml::Doc) -> ast_map::path { +pub fn item_path(item_doc: ebml::Doc) -> ast_map::Path { let path_doc = reader::get_doc(item_doc, tag_path); let len_doc = reader::get_doc(path_doc, tag_path_len); @@ -314,21 +314,21 @@ pub fn item_path(item_doc: ebml::Doc) -> ast_map::path { let mut result = vec::with_capacity(len); reader::docs(path_doc, |tag, elt_doc| { - if tag == tag_path_elt_mod { + if tag == tag_path_elem_mod { let str = elt_doc.as_str_slice(); - result.push(ast_map::path_mod(token::str_to_ident(str))); - } else if tag == tag_path_elt_name { + result.push(ast_map::PathMod(token::str_to_ident(str))); + } else if tag == tag_path_elem_name { let str = elt_doc.as_str_slice(); - result.push(ast_map::path_name(token::str_to_ident(str))); - } else if tag == tag_path_elt_pretty_name { + result.push(ast_map::PathName(token::str_to_ident(str))); + } else if tag == tag_path_elem_pretty_name { let name_doc = reader::get_doc(elt_doc, - tag_path_elt_pretty_name_ident); + tag_path_elem_pretty_name_ident); let extra_doc = reader::get_doc(elt_doc, - tag_path_elt_pretty_name_extra); + tag_path_elem_pretty_name_extra); let str = name_doc.as_str_slice(); let extra = reader::doc_as_u64(extra_doc); - result.push(ast_map::path_pretty_name(token::str_to_ident(str), - extra)); + result.push(ast_map::PathPrettyName(token::str_to_ident(str), + extra)); } else { // ignore tag_path_len element } @@ -338,7 +338,7 @@ pub fn item_path(item_doc: ebml::Doc) -> ast_map::path { return result; } -fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::Ident { +fn item_name(intr: @IdentInterner, item: ebml::Doc) -> ast::Ident { let name = reader::get_doc(item, tag_paths_data_name); let string = name.as_str_slice(); match intr.find_equiv(&string) { @@ -354,12 +354,12 @@ pub fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum) ImmStatic => DlDef(ast::DefStatic(did, false)), MutStatic => DlDef(ast::DefStatic(did, true)), Struct => DlDef(ast::DefStruct(did)), - UnsafeFn => DlDef(ast::DefFn(did, ast::unsafe_fn)), - Fn => DlDef(ast::DefFn(did, ast::impure_fn)), - ForeignFn => DlDef(ast::DefFn(did, ast::extern_fn)), + UnsafeFn => DlDef(ast::DefFn(did, ast::UnsafeFn)), + Fn => DlDef(ast::DefFn(did, ast::ImpureFn)), + ForeignFn => DlDef(ast::DefFn(did, ast::ExternFn)), StaticMethod | UnsafeStaticMethod => { - let purity = if fam == UnsafeStaticMethod { ast::unsafe_fn } else - { ast::impure_fn }; + let purity = if fam == UnsafeStaticMethod { ast::UnsafeFn } else + { ast::ImpureFn }; // def_static_method carries an optional field of its enclosing // trait or enclosing impl (if this is an inherent static method). // So we need to detect whether this is in a trait or not, which @@ -475,7 +475,7 @@ pub fn get_impl_vtables(cdata: Cmd, } -pub fn get_impl_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, +pub fn get_impl_method(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId, name: ast::Ident) -> Option<ast::DefId> { let items = reader::get_doc(reader::Doc(cdata.data()), tag_items); let mut found = None; @@ -524,13 +524,13 @@ pub fn each_lang_item(cdata: Cmd, f: |ast::NodeId, uint| -> bool) -> bool { }) } -fn each_child_of_item_or_crate(intr: @ident_interner, +fn each_child_of_item_or_crate(intr: @IdentInterner, cdata: Cmd, item_doc: ebml::Doc, get_crate_data: GetCrateDataCb, callback: |DefLike, ast::Ident, - ast::visibility|) { + ast::Visibility|) { // Iterate over all children. let _ = reader::tagged_docs(item_doc, tag_mod_child, |child_info_doc| { let child_def_id = reader::with_doc_data(child_info_doc, @@ -644,7 +644,7 @@ fn each_child_of_item_or_crate(intr: @ident_interner, cdata.cnum); // These items have a public visibility because they're part of // a public re-export. - callback(def_like, token::str_to_ident(name), ast::public); + callback(def_like, token::str_to_ident(name), ast::Public); } } @@ -653,11 +653,11 @@ fn each_child_of_item_or_crate(intr: @ident_interner, } /// Iterates over each child of the given item. -pub fn each_child_of_item(intr: @ident_interner, +pub fn each_child_of_item(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId, get_crate_data: GetCrateDataCb, - callback: |DefLike, ast::Ident, ast::visibility|) { + callback: |DefLike, ast::Ident, ast::Visibility|) { // Find the item. let root_doc = reader::Doc(cdata.data()); let items = reader::get_doc(root_doc, tag_items); @@ -674,12 +674,12 @@ pub fn each_child_of_item(intr: @ident_interner, } /// Iterates over all the top-level crate items. -pub fn each_top_level_item_of_crate(intr: @ident_interner, +pub fn each_top_level_item_of_crate(intr: @IdentInterner, cdata: Cmd, get_crate_data: GetCrateDataCb, callback: |DefLike, ast::Ident, - ast::visibility|) { + ast::Visibility|) { let root_doc = reader::Doc(cdata.data()); let misc_info_doc = reader::get_doc(root_doc, tag_misc_info); let crate_items_doc = reader::get_doc(misc_info_doc, @@ -692,15 +692,15 @@ pub fn each_top_level_item_of_crate(intr: @ident_interner, callback) } -pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path { +pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::Path { item_path(lookup_item(id, cdata.data())) } pub type decode_inlined_item<'a> = 'a |cdata: @cstore::crate_metadata, tcx: ty::ctxt, - path: ast_map::path, + path: ast_map::Path, par_doc: ebml::Doc| - -> Option<ast::inlined_item>; + -> Option<ast::InlinedItem>; pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, id: ast::NodeId, @@ -730,7 +730,7 @@ pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, } } -pub fn get_enum_variants(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, +pub fn get_enum_variants(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) -> ~[@ty::VariantInfo] { let data = cdata.data(); let items = reader::get_doc(reader::Doc(data), tag_items); @@ -760,13 +760,13 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, // for variants -- TEST -- tjc id: *did, disr_val: disr_val, - vis: ast::inherited}); + vis: ast::Inherited}); disr_val += 1; } return infos; } -fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ { +fn get_explicit_self(item: ebml::Doc) -> ast::ExplicitSelf_ { fn get_mutability(ch: u8) -> ast::Mutability { match ch as char { 'i' => ast::MutImmutable, @@ -780,21 +780,17 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ { let explicit_self_kind = string[0]; match explicit_self_kind as char { - 's' => { return ast::sty_static; } - 'v' => { return ast::sty_value(get_mutability(string[1])); } - '@' => { return ast::sty_box(get_mutability(string[1])); } - '~' => { return ast::sty_uniq(get_mutability(string[1])); } - '&' => { - // FIXME(#4846) expl. region - return ast::sty_region(None, get_mutability(string[1])); - } - _ => { - fail!("unknown self type code: `{}`", explicit_self_kind as char); - } + 's' => ast::SelfStatic, + 'v' => ast::SelfValue(get_mutability(string[1])), + '@' => ast::SelfBox(get_mutability(string[1])), + '~' => ast::SelfUniq(get_mutability(string[1])), + // FIXME(#4846) expl. region + '&' => ast::SelfRegion(None, get_mutability(string[1])), + _ => fail!("unknown self type code: `{}`", explicit_self_kind as char) } } -fn item_impl_methods(intr: @ident_interner, cdata: Cmd, item: ebml::Doc, +fn item_impl_methods(intr: @IdentInterner, cdata: Cmd, item: ebml::Doc, tcx: ty::ctxt) -> ~[@ty::Method] { let mut rslt = ~[]; reader::tagged_docs(item, tag_item_impl_method, |doc| { @@ -807,7 +803,7 @@ fn item_impl_methods(intr: @ident_interner, cdata: Cmd, item: ebml::Doc, } /// Returns information about the given implementation. -pub fn get_impl(intr: @ident_interner, cdata: Cmd, impl_id: ast::NodeId, +pub fn get_impl(intr: @IdentInterner, cdata: Cmd, impl_id: ast::NodeId, tcx: ty::ctxt) -> ty::Impl { let data = cdata.data(); @@ -823,9 +819,9 @@ pub fn get_impl(intr: @ident_interner, cdata: Cmd, impl_id: ast::NodeId, } pub fn get_method_name_and_explicit_self( - intr: @ident_interner, + intr: @IdentInterner, cdata: Cmd, - id: ast::NodeId) -> (ast::Ident, ast::explicit_self_) + id: ast::NodeId) -> (ast::Ident, ast::ExplicitSelf_) { let method_doc = lookup_item(id, cdata.data()); let name = item_name(intr, method_doc); @@ -833,7 +829,7 @@ pub fn get_method_name_and_explicit_self( (name, explicit_self) } -pub fn get_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, +pub fn get_method(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) -> ty::Method { let method_doc = lookup_item(id, cdata.data()); @@ -893,7 +889,7 @@ pub fn get_item_variances(cdata: Cmd, id: ast::NodeId) -> ty::ItemVariances { Decodable::decode(&mut decoder) } -pub fn get_provided_trait_methods(intr: @ident_interner, cdata: Cmd, +pub fn get_provided_trait_methods(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) -> ~[@ty::Method] { let data = cdata.data(); @@ -947,7 +943,7 @@ pub fn get_type_name_if_impl(cdata: Cmd, ret } -pub fn get_static_methods_if_impl(intr: @ident_interner, +pub fn get_static_methods_if_impl(intr: @IdentInterner, cdata: Cmd, node_id: ast::NodeId) -> Option<~[StaticMethodInfo]> { @@ -977,8 +973,8 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, StaticMethod | UnsafeStaticMethod => { let purity; match item_family(impl_method_doc) { - StaticMethod => purity = ast::impure_fn, - UnsafeStaticMethod => purity = ast::unsafe_fn, + StaticMethod => purity = ast::ImpureFn, + UnsafeStaticMethod => purity = ast::UnsafeFn, _ => fail!() } @@ -1009,16 +1005,16 @@ pub fn get_item_attrs(cdata: Cmd, }); } -fn struct_field_family_to_visibility(family: Family) -> ast::visibility { +fn struct_field_family_to_visibility(family: Family) -> ast::Visibility { match family { - PublicField => ast::public, - PrivateField => ast::private, - InheritedField => ast::inherited, + PublicField => ast::Public, + PrivateField => ast::Private, + InheritedField => ast::Inherited, _ => fail!() } } -pub fn get_struct_fields(intr: @ident_interner, cdata: Cmd, id: ast::NodeId) +pub fn get_struct_fields(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId) -> ~[ty::field_ty] { let data = cdata.data(); let item = lookup_item(id, data); @@ -1042,7 +1038,7 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: Cmd, id: ast::NodeId) result.push(ty::field_ty { name: special_idents::unnamed_field.name, id: did, - vis: ast::inherited, + vis: ast::Inherited, }); true }); @@ -1050,7 +1046,7 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: Cmd, id: ast::NodeId) } pub fn get_item_visibility(cdata: Cmd, id: ast::NodeId) - -> ast::visibility { + -> ast::Visibility { item_visibility(lookup_item(id, cdata.data())) } @@ -1109,7 +1105,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::Attribute] { return attrs; } -fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str, +fn list_crate_attributes(intr: @IdentInterner, md: ebml::Doc, hash: &str, out: &mut io::Writer) { write!(out, "=Crate Attributes ({})=\n", hash); @@ -1179,7 +1175,7 @@ pub fn get_crate_vers(data: &[u8]) -> @str { } } -pub fn list_crate_metadata(intr: @ident_interner, bytes: &[u8], +pub fn list_crate_metadata(intr: @IdentInterner, bytes: &[u8], out: &mut io::Writer) { let hash = get_crate_hash(bytes); let md = reader::Doc(bytes); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 0f5d5d293d6..a860b148aa9 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -49,16 +49,16 @@ use writer = extra::ebml::writer; // used by astencode: type abbrev_map = @RefCell<HashMap<ty::t, tyencode::ty_abbrev>>; -/// A borrowed version of ast::inlined_item. +/// A borrowed version of ast::InlinedItem. pub enum InlinedItemRef<'a> { - ii_item_ref(&'a ast::item), - ii_method_ref(ast::DefId, bool, &'a ast::method), - ii_foreign_ref(&'a ast::foreign_item) + IIItemRef(&'a ast::Item), + IIMethodRef(ast::DefId, bool, &'a ast::Method), + IIForeignRef(&'a ast::ForeignItem) } pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], + path: &[ast_map::PathElem], ii: InlinedItemRef|; pub struct EncodeParams<'a> { @@ -318,17 +318,17 @@ fn encode_parent_item(ebml_w: &mut writer::Encoder, id: DefId) { fn encode_struct_fields(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - def: @struct_def) { + def: @StructDef) { for f in def.fields.iter() { match f.node.kind { - named_field(ident, vis) => { + NamedField(ident, vis) => { ebml_w.start_tag(tag_item_field); encode_struct_field_family(ebml_w, vis); encode_name(ecx, ebml_w, ident); encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); } - unnamed_field => { + UnnamedField => { ebml_w.start_tag(tag_item_unnamed_field); encode_def_id(ebml_w, local_def(f.node.id)); ebml_w.end_tag(); @@ -340,8 +340,8 @@ fn encode_struct_fields(ecx: &EncodeContext, fn encode_enum_variant_info(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, id: NodeId, - variants: &[P<variant>], - path: &[ast_map::path_elt], + variants: &[P<Variant>], + path: &[ast_map::PathElem], index: @RefCell<~[entry<i64>]>, generics: &ast::Generics) { debug!("encode_enum_variant_info(id={:?})", id); @@ -362,20 +362,20 @@ fn encode_enum_variant_info(ecx: &EncodeContext, ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); match variant.node.kind { - ast::tuple_variant_kind(_) => encode_family(ebml_w, 'v'), - ast::struct_variant_kind(_) => encode_family(ebml_w, 'V') + ast::TupleVariantKind(_) => encode_family(ebml_w, 'v'), + ast::StructVariantKind(_) => encode_family(ebml_w, 'V') } encode_name(ecx, ebml_w, variant.node.name); encode_parent_item(ebml_w, local_def(id)); encode_visibility(ebml_w, variant.node.vis); encode_attributes(ebml_w, variant.node.attrs); match variant.node.kind { - ast::tuple_variant_kind(ref args) + ast::TupleVariantKind(ref args) if args.len() > 0 && generics.ty_params.len() == 0 => { encode_symbol(ecx, ebml_w, variant.node.id); } - ast::tuple_variant_kind(_) => {}, - ast::struct_variant_kind(def) => { + ast::TupleVariantKind(_) => {}, + ast::StructVariantKind(def) => { let idx = encode_info_for_struct(ecx, ebml_w, path, def.fields, index); encode_struct_fields(ecx, ebml_w, def); @@ -390,7 +390,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext, encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(ecx.tcx, def_id)); encode_path(ecx, ebml_w, path, - ast_map::path_name(variant.node.name)); + ast_map::PathName(variant.node.name)); ebml_w.end_tag(); disr_val += 1; i += 1; @@ -399,23 +399,23 @@ fn encode_enum_variant_info(ecx: &EncodeContext, fn encode_path(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], - name: ast_map::path_elt) { - fn encode_path_elt(ecx: &EncodeContext, + path: &[ast_map::PathElem], + name: ast_map::PathElem) { + fn encode_path_elem(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - elt: ast_map::path_elt) { + elt: ast_map::PathElem) { match elt { - ast_map::path_mod(n) => { - ebml_w.wr_tagged_str(tag_path_elt_mod, ecx.tcx.sess.str_of(n)); + ast_map::PathMod(n) => { + ebml_w.wr_tagged_str(tag_path_elem_mod, ecx.tcx.sess.str_of(n)); } - ast_map::path_name(n) => { - ebml_w.wr_tagged_str(tag_path_elt_name, ecx.tcx.sess.str_of(n)); + ast_map::PathName(n) => { + ebml_w.wr_tagged_str(tag_path_elem_name, ecx.tcx.sess.str_of(n)); } - ast_map::path_pretty_name(n, extra) => { - ebml_w.start_tag(tag_path_elt_pretty_name); - ebml_w.wr_tagged_str(tag_path_elt_pretty_name_ident, + ast_map::PathPrettyName(n, extra) => { + ebml_w.start_tag(tag_path_elem_pretty_name); + ebml_w.wr_tagged_str(tag_path_elem_pretty_name_ident, ecx.tcx.sess.str_of(n)); - ebml_w.wr_tagged_u64(tag_path_elt_pretty_name_extra, extra); + ebml_w.wr_tagged_u64(tag_path_elem_pretty_name_extra, extra); ebml_w.end_tag(); } } @@ -424,9 +424,9 @@ fn encode_path(ecx: &EncodeContext, ebml_w.start_tag(tag_path); ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32); for pe in path.iter() { - encode_path_elt(ecx, ebml_w, *pe); + encode_path_elem(ecx, ebml_w, *pe); } - encode_path_elt(ecx, ebml_w, name); + encode_path_elem(ecx, ebml_w, name); ebml_w.end_tag(); } @@ -457,7 +457,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext, let implementations = implementations.borrow(); for &base_impl in implementations.get().iter() { for &m in base_impl.methods.iter() { - if m.explicit_self == ast::sty_static { + if m.explicit_self == ast::SelfStatic { encode_reexported_static_method(ecx, ebml_w, exp, m.def_id, m.ident); } @@ -478,7 +478,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext, match trait_methods_cache.get().find(&exp.def_id) { Some(methods) => { for &m in methods.iter() { - if m.explicit_self == ast::sty_static { + if m.explicit_self == ast::SelfStatic { encode_reexported_static_method(ecx, ebml_w, exp, m.def_id, m.ident); } @@ -492,11 +492,11 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext, fn encode_reexported_static_methods(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - mod_path: &[ast_map::path_elt], + mod_path: &[ast_map::PathElem], exp: &middle::resolve::Export2) { let items = ecx.tcx.items.borrow(); match items.get().find(&exp.def_id.node) { - Some(&ast_map::node_item(item, path)) => { + Some(&ast_map::NodeItem(item, path)) => { let original_name = ecx.tcx.sess.str_of(item.ident); // @@ -533,10 +533,10 @@ fn encode_reexported_static_methods(ecx: &EncodeContext, /// * For enums, iterates through the node IDs of the variants. /// /// * For newtype structs, iterates through the node ID of the constructor. -fn each_auxiliary_node_id(item: @item, callback: |NodeId| -> bool) -> bool { +fn each_auxiliary_node_id(item: @Item, callback: |NodeId| -> bool) -> bool { let mut continue_ = true; match item.node { - item_enum(ref enum_def, _) => { + ItemEnum(ref enum_def, _) => { for variant in enum_def.variants.iter() { continue_ = callback(variant.node.id); if !continue_ { @@ -544,12 +544,12 @@ fn each_auxiliary_node_id(item: @item, callback: |NodeId| -> bool) -> bool { } } } - item_struct(struct_def, _) => { + ItemStruct(struct_def, _) => { // If this is a newtype struct, return the constructor. match struct_def.ctor_id { Some(ctor_id) if struct_def.fields.len() > 0 && struct_def.fields[0].node.kind == - ast::unnamed_field => { + ast::UnnamedField => { continue_ = callback(ctor_id); } _ => {} @@ -564,7 +564,7 @@ fn each_auxiliary_node_id(item: @item, callback: |NodeId| -> bool) -> bool { fn encode_reexports(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, id: NodeId, - path: &[ast_map::path_elt]) { + path: &[ast_map::PathElem]) { debug!("(encoding info for module) encoding reexports for {}", id); let reexports2 = ecx.reexports2.borrow(); match reexports2.get().find(&id) { @@ -597,11 +597,11 @@ fn encode_reexports(ecx: &EncodeContext, fn encode_info_for_mod(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - md: &_mod, + md: &Mod, id: NodeId, - path: &[ast_map::path_elt], + path: &[ast_map::PathElem], name: Ident, - vis: visibility) { + vis: Visibility) { ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(id)); encode_family(ebml_w, 'm'); @@ -622,7 +622,7 @@ fn encode_info_for_mod(ecx: &EncodeContext, }); match item.node { - item_impl(..) => { + ItemImpl(..) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl {} \ ({:?}/{:?})", @@ -638,11 +638,11 @@ fn encode_info_for_mod(ecx: &EncodeContext, } } - encode_path(ecx, ebml_w, path, ast_map::path_mod(name)); + encode_path(ecx, ebml_w, path, ast_map::PathMod(name)); encode_visibility(ebml_w, vis); // Encode the reexports of this module, if this module is public. - if vis == public { + if vis == Public { debug!("(encoding info for module) encoding reexports for {}", id); encode_reexports(ecx, ebml_w, id, path); } @@ -651,47 +651,47 @@ fn encode_info_for_mod(ecx: &EncodeContext, } fn encode_struct_field_family(ebml_w: &mut writer::Encoder, - visibility: visibility) { + visibility: Visibility) { encode_family(ebml_w, match visibility { - public => 'g', - private => 'j', - inherited => 'N' + Public => 'g', + Private => 'j', + Inherited => 'N' }); } -fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) { +fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: Visibility) { ebml_w.start_tag(tag_items_data_item_visibility); let ch = match visibility { - public => 'y', - private => 'n', - inherited => 'i', + Public => 'y', + Private => 'n', + Inherited => 'i', }; ebml_w.wr_str(str::from_char(ch)); ebml_w.end_tag(); } -fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explicit_self_) { +fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::ExplicitSelf_) { ebml_w.start_tag(tag_item_trait_method_explicit_self); // Encode the base self type. match explicit_self { - sty_static => { + SelfStatic => { ebml_w.writer.write(&[ 's' as u8 ]); } - sty_value(m) => { + SelfValue(m) => { ebml_w.writer.write(&[ 'v' as u8 ]); encode_mutability(ebml_w, m); } - sty_region(_, m) => { + SelfRegion(_, m) => { // FIXME(#4846) encode custom lifetime ebml_w.writer.write(&[ '&' as u8 ]); encode_mutability(ebml_w, m); } - sty_box(m) => { + SelfBox(m) => { ebml_w.writer.write(&[ '@' as u8 ]); encode_mutability(ebml_w, m); } - sty_uniq(m) => { + SelfUniq(m) => { ebml_w.writer.write(&[ '~' as u8 ]); encode_mutability(ebml_w, m); } @@ -727,8 +727,8 @@ fn encode_provided_source(ebml_w: &mut writer::Encoder, /* Returns an index of items in this class */ fn encode_info_for_struct(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], - fields: &[struct_field], + path: &[ast_map::PathElem], + fields: &[StructField], global_index: @RefCell<~[entry<i64>]>) -> ~[entry<i64>] { /* Each class has its own index, since different classes @@ -739,8 +739,8 @@ fn encode_info_for_struct(ecx: &EncodeContext, private fields to get the offsets right */ for field in fields.iter() { let (nm, vis) = match field.node.kind { - named_field(nm, vis) => (nm, vis), - unnamed_field => (special_idents::unnamed_field, inherited) + NamedField(nm, vis) => (nm, vis), + UnnamedField => (special_idents::unnamed_field, Inherited) }; let id = field.node.id; @@ -757,7 +757,7 @@ fn encode_info_for_struct(ecx: &EncodeContext, tcx.sess.str_of(nm), id); encode_struct_field_family(ebml_w, vis); encode_name(ecx, ebml_w, nm); - encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_path(ecx, ebml_w, path, ast_map::PathName(nm)); encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); encode_def_id(ebml_w, local_def(id)); ebml_w.end_tag(); @@ -767,7 +767,7 @@ fn encode_info_for_struct(ecx: &EncodeContext, fn encode_info_for_struct_ctor(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], + path: &[ast_map::PathElem], name: ast::Ident, ctor_id: NodeId, index: @RefCell<~[entry<i64>]>, @@ -785,7 +785,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext, encode_family(ebml_w, 'f'); encode_name(ecx, ebml_w, name); encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); - encode_path(ecx, ebml_w, path, ast_map::path_name(name)); + encode_path(ecx, ebml_w, path, ast_map::PathName(name)); encode_parent_item(ebml_w, local_def(struct_id)); let item_symbols = ecx.item_symbols.borrow(); @@ -810,7 +810,7 @@ fn encode_method_ty_fields(ecx: &EncodeContext, encode_explicit_self(ebml_w, method_ty.explicit_self); let purity = method_ty.fty.purity; match method_ty.explicit_self { - ast::sty_static => { + ast::SelfStatic => { encode_family(ebml_w, purity_static_method_family(purity)); } _ => encode_family(ebml_w, purity_fn_family(purity)) @@ -821,10 +821,10 @@ fn encode_method_ty_fields(ecx: &EncodeContext, fn encode_info_for_method(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, m: &ty::Method, - impl_path: &[ast_map::path_elt], + impl_path: &[ast_map::PathElem], is_default_impl: bool, parent_id: NodeId, - ast_method_opt: Option<@method>) { + ast_method_opt: Option<@Method>) { debug!("encode_info_for_method: {:?} {}", m.def_id, ecx.tcx.sess.str_of(m.ident)); @@ -837,7 +837,7 @@ fn encode_info_for_method(ecx: &EncodeContext, let tpt = lookup_item_type(ecx.tcx, m.def_id); encode_bounds_and_type(ebml_w, ecx, &tpt); - encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + encode_path(ecx, ebml_w, impl_path, ast_map::PathName(m.ident)); match ast_method_opt { Some(ast_method) => encode_attributes(ebml_w, ast_method.attrs), None => () @@ -849,7 +849,7 @@ fn encode_info_for_method(ecx: &EncodeContext, || should_inline(ast_method.attrs) { (ecx.encode_inlined_item)( ecx, ebml_w, impl_path, - ii_method_ref(local_def(parent_id), false, ast_method)); + IIMethodRef(local_def(parent_id), false, ast_method)); } else { encode_symbol(ecx, ebml_w, m.def_id.node); } @@ -858,19 +858,19 @@ fn encode_info_for_method(ecx: &EncodeContext, ebml_w.end_tag(); } -fn purity_fn_family(p: purity) -> char { +fn purity_fn_family(p: Purity) -> char { match p { - unsafe_fn => 'u', - impure_fn => 'f', - extern_fn => 'e' + UnsafeFn => 'u', + ImpureFn => 'f', + ExternFn => 'e' } } -fn purity_static_method_family(p: purity) -> char { +fn purity_static_method_family(p: Purity) -> char { match p { - unsafe_fn => 'U', - impure_fn => 'F', - _ => fail!("extern fn can't be static") + UnsafeFn => 'U', + ImpureFn => 'F', + _ => fail!("extern fn can't be static") } } @@ -921,13 +921,13 @@ fn encode_extension_implementations(ecx: &EncodeContext, fn encode_info_for_item(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - item: &item, + item: &Item, index: @RefCell<~[entry<i64>]>, - path: &[ast_map::path_elt], - vis: ast::visibility) { + path: &[ast_map::PathElem], + vis: ast::Visibility) { let tcx = ecx.tcx; - fn add_to_index(item: &item, ebml_w: &writer::Encoder, + fn add_to_index(item: &Item, ebml_w: &writer::Encoder, index: @RefCell<~[entry<i64>]>) { let mut index = index.borrow_mut(); index.get().push(entry { @@ -942,7 +942,7 @@ fn encode_info_for_item(ecx: &EncodeContext, let def_id = local_def(item.id); match item.node { - item_static(_, m, _) => { + ItemStatic(_, m, _) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); @@ -954,7 +954,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); encode_symbol(ecx, ebml_w, item.id); encode_name(ecx, ebml_w, item.ident); - let elt = ast_map::path_pretty_name(item.ident, item.id as u64); + let elt = ast_map::PathPrettyName(item.ident, item.id as u64); encode_path(ecx, ebml_w, path, elt); let non_inlineable; @@ -964,12 +964,12 @@ fn encode_info_for_item(ecx: &EncodeContext, } if !non_inlineable { - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item_ref(item)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, IIItemRef(item)); } encode_visibility(ebml_w, vis); ebml_w.end_tag(); } - item_fn(_, purity, _, ref generics, _) => { + ItemFn(_, purity, _, ref generics, _) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); @@ -977,17 +977,17 @@ fn encode_info_for_item(ecx: &EncodeContext, let tps_len = generics.ty_params.len(); encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); encode_attributes(ebml_w, item.attrs); if tps_len > 0u || should_inline(item.attrs) { - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item_ref(item)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, IIItemRef(item)); } else { encode_symbol(ecx, ebml_w, item.id); } encode_visibility(ebml_w, vis); ebml_w.end_tag(); } - item_mod(ref m) => { + ItemMod(ref m) => { add_to_index(); encode_info_for_mod(ecx, ebml_w, @@ -997,13 +997,13 @@ fn encode_info_for_item(ecx: &EncodeContext, item.ident, item.vis); } - item_foreign_mod(ref fm) => { + ItemForeignMod(ref fm) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); encode_family(ebml_w, 'n'); encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); // Encode all the items in this module. for foreign_item in fm.items.iter() { @@ -1014,18 +1014,18 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_visibility(ebml_w, vis); ebml_w.end_tag(); } - item_ty(..) => { + ItemTy(..) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); encode_family(ebml_w, 'y'); encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); encode_visibility(ebml_w, vis); ebml_w.end_tag(); } - item_enum(ref enum_definition, ref generics) => { + ItemEnum(ref enum_definition, ref generics) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); @@ -1038,8 +1038,8 @@ fn encode_info_for_item(ecx: &EncodeContext, for v in (*enum_definition).variants.iter() { encode_variant_id(ebml_w, local_def(v.node.id)); } - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item_ref(item)); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, IIItemRef(item)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); // Encode inherent implementations for this enumeration. encode_inherent_implementations(ecx, ebml_w, def_id); @@ -1055,7 +1055,7 @@ fn encode_info_for_item(ecx: &EncodeContext, index, generics); } - item_struct(struct_def, _) => { + ItemStruct(struct_def, _) => { /* First, encode the fields These come first because we need to write them to make the index, and the index needs to be in the item for the @@ -1075,7 +1075,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_item_variances(ebml_w, ecx, item.id); encode_name(ecx, ebml_w, item.ident); encode_attributes(ebml_w, item.attrs); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); encode_visibility(ebml_w, vis); /* Encode def_ids for each field and method @@ -1083,7 +1083,7 @@ fn encode_info_for_item(ecx: &EncodeContext, needs to know*/ encode_struct_fields(ecx, ebml_w, struct_def); - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item_ref(item)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, IIItemRef(item)); // Encode inherent implementations for this structure. encode_inherent_implementations(ecx, ebml_w, def_id); @@ -1096,7 +1096,7 @@ fn encode_info_for_item(ecx: &EncodeContext, // If this is a tuple- or enum-like struct, encode the type of the // constructor. if struct_def.fields.len() > 0 && - struct_def.fields[0].node.kind == ast::unnamed_field { + struct_def.fields[0].node.kind == ast::UnnamedField { let ctor_id = match struct_def.ctor_id { Some(ctor_id) => ctor_id, None => ecx.tcx.sess.bug("struct def didn't have ctor id"), @@ -1111,7 +1111,7 @@ fn encode_info_for_item(ecx: &EncodeContext, def_id.node); } } - item_impl(_, ref opt_trait, ty, ref ast_methods) => { + ItemImpl(_, ref opt_trait, ty, ref ast_methods) => { // We need to encode information about the default methods we // have inherited, so we drive this based on the impl structure. let impls = tcx.impls.borrow(); @@ -1125,8 +1125,8 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_name(ecx, ebml_w, item.ident); encode_attributes(ebml_w, item.attrs); match ty.node { - ast::ty_path(ref path, ref bounds, _) if path.segments - .len() == 1 => { + ast::TyPath(ref path, ref bounds, _) if path.segments + .len() == 1 => { assert!(bounds.is_none()); encode_impl_type_basename(ecx, ebml_w, ast_util::path_to_ident(path)); @@ -1180,7 +1180,7 @@ fn encode_info_for_item(ecx: &EncodeContext, ast_method) } } - item_trait(_, ref super_traits, ref ms) => { + ItemTrait(_, ref super_traits, ref ms) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); @@ -1204,7 +1204,7 @@ fn encode_info_for_item(ecx: &EncodeContext, ebml_w.wr_str(def_to_str(method_def_id)); ebml_w.end_tag(); } - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, path, ast_map::PathName(item.ident)); // FIXME(#8559): This should use the tcx's supertrait cache instead of // reading the AST's list, because the former has already filtered out // the builtin-kinds-as-supertraits. See corresponding fixme in decoder. @@ -1240,11 +1240,11 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_parent_item(ebml_w, def_id); let mut trait_path = vec::append(~[], path); - trait_path.push(ast_map::path_name(item.ident)); - encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident)); + trait_path.push(ast_map::PathName(item.ident)); + encode_path(ecx, ebml_w, trait_path, ast_map::PathName(method_ty.ident)); match method_ty.explicit_self { - sty_static => { + SelfStatic => { encode_family(ebml_w, purity_static_method_family( method_ty.fty.purity)); @@ -1261,16 +1261,16 @@ fn encode_info_for_item(ecx: &EncodeContext, } match ms[i] { - required(ref tm) => { + Required(ref tm) => { encode_attributes(ebml_w, tm.attrs); encode_method_sort(ebml_w, 'r'); } - provided(m) => { + Provided(m) => { encode_attributes(ebml_w, m.attrs); // If this is a static method, we've already encoded // this. - if method_ty.explicit_self != sty_static { + if method_ty.explicit_self != SelfStatic { // XXX: I feel like there is something funny going on. let tpt = ty::lookup_item_type(tcx, method_def_id); encode_bounds_and_type(ebml_w, ecx, &tpt); @@ -1278,7 +1278,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_method_sort(ebml_w, 'p'); (ecx.encode_inlined_item)( ecx, ebml_w, path, - ii_method_ref(def_id, true, m)); + IIMethodRef(def_id, true, m)); } } @@ -1288,15 +1288,15 @@ fn encode_info_for_item(ecx: &EncodeContext, // Encode inherent implementations for this trait. encode_inherent_implementations(ecx, ebml_w, def_id); } - item_mac(..) => fail!("item macros unimplemented") + ItemMac(..) => fail!("item macros unimplemented") } } fn encode_info_for_foreign_item(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - nitem: &foreign_item, + nitem: &ForeignItem, index: @RefCell<~[entry<i64>]>, - path: &ast_map::path, + path: &ast_map::Path, abi: AbiSet) { { let mut index = index.borrow_mut(); @@ -1308,20 +1308,20 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext, ebml_w.start_tag(tag_items_data_item); match nitem.node { - foreign_item_fn(..) => { + ForeignItemFn(..) => { encode_def_id(ebml_w, local_def(nitem.id)); - encode_family(ebml_w, purity_fn_family(impure_fn)); + encode_family(ebml_w, purity_fn_family(ImpureFn)); encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(ecx.tcx,local_def(nitem.id))); encode_name(ecx, ebml_w, nitem.ident); if abi.is_intrinsic() { - (ecx.encode_inlined_item)(ecx, ebml_w, *path, ii_foreign_ref(nitem)); + (ecx.encode_inlined_item)(ecx, ebml_w, *path, IIForeignRef(nitem)); } else { encode_symbol(ecx, ebml_w, nitem.id); } - encode_path(ecx, ebml_w, *path, ast_map::path_name(nitem.ident)); + encode_path(ecx, ebml_w, *path, ast_map::PathName(nitem.ident)); } - foreign_item_static(_, mutbl) => { + ForeignItemStatic(_, mutbl) => { encode_def_id(ebml_w, local_def(nitem.id)); if mutbl { encode_family(ebml_w, 'b'); @@ -1331,7 +1331,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext, encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); encode_symbol(ecx, ebml_w, nitem.id); encode_name(ecx, ebml_w, nitem.ident); - encode_path(ecx, ebml_w, *path, ast_map::path_name(nitem.ident)); + encode_path(ecx, ebml_w, *path, ast_map::PathName(nitem.ident)); } } ebml_w.end_tag(); @@ -1339,14 +1339,14 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext, fn my_visit_expr(_e: &Expr) { } -fn my_visit_item(i: &item, - items: ast_map::map, +fn my_visit_item(i: &Item, + items: ast_map::Map, ebml_w: &mut writer::Encoder, ecx_ptr: *int, index: @RefCell<~[entry<i64>]>) { let items = items.borrow(); match items.get().get_copy(&i.id) { - ast_map::node_item(_, pt) => { + ast_map::NodeItem(_, pt) => { let mut ebml_w = unsafe { ebml_w.unsafe_clone() }; @@ -1358,14 +1358,14 @@ fn my_visit_item(i: &item, } } -fn my_visit_foreign_item(ni: &foreign_item, - items: ast_map::map, +fn my_visit_foreign_item(ni: &ForeignItem, + items: ast_map::Map, ebml_w: &mut writer::Encoder, ecx_ptr:*int, index: @RefCell<~[entry<i64>]>) { let items = items.borrow(); match items.get().get_copy(&ni.id) { - ast_map::node_foreign_item(_, abi, _, pt) => { + ast_map::NodeForeignItem(_, abi, _, pt) => { debug!("writing foreign item {}::{}", ast_map::path_to_str( *pt, @@ -1392,7 +1392,7 @@ fn my_visit_foreign_item(ni: &foreign_item, struct EncodeVisitor<'a,'b> { ebml_w_for_visit_item: &'a mut writer::Encoder<'b>, ecx_ptr:*int, - items: ast_map::map, + items: ast_map::Map, index: @RefCell<~[entry<i64>]>, } @@ -1401,7 +1401,7 @@ impl<'a,'b> visit::Visitor<()> for EncodeVisitor<'a,'b> { visit::walk_expr(self, ex, ()); my_visit_expr(ex); } - fn visit_item(&mut self, i: &item, _: ()) { + fn visit_item(&mut self, i: &Item, _: ()) { visit::walk_item(self, i, ()); my_visit_item(i, self.items, @@ -1409,7 +1409,7 @@ impl<'a,'b> visit::Visitor<()> for EncodeVisitor<'a,'b> { self.ecx_ptr, self.index); } - fn visit_foreign_item(&mut self, ni: &foreign_item, _: ()) { + fn visit_foreign_item(&mut self, ni: &ForeignItem, _: ()) { visit::walk_foreign_item(self, ni, ()); my_visit_foreign_item(ni, self.items, @@ -1438,7 +1438,7 @@ fn encode_info_for_items(ecx: &EncodeContext, CRATE_NODE_ID, [], syntax::parse::token::special_idents::invalid, - public); + Public); let items = ecx.tcx.items; // See comment in `encode_side_tables_for_ii` in astencode @@ -1531,7 +1531,7 @@ fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @MetaItem) { } MetaNameValue(name, value) => { match value.node { - lit_str(value, _) => { + LitStr(value, _) => { ebml_w.start_tag(tag_meta_item_name_value); ebml_w.start_tag(tag_meta_item_name); ebml_w.writer.write(name.as_bytes()); @@ -1698,9 +1698,9 @@ struct ImplVisitor<'a,'b> { } impl<'a,'b> Visitor<()> for ImplVisitor<'a,'b> { - fn visit_item(&mut self, item: &item, _: ()) { + fn visit_item(&mut self, item: &Item, _: ()) { match item.node { - item_impl(_, Some(ref trait_ref), _, _) => { + ItemImpl(_, Some(ref trait_ref), _, _) => { let def_map = self.ecx.tcx.def_map; let def_map = def_map.borrow(); let trait_def = def_map.get().get_copy(&trait_ref.ref_id); diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index d4f940ab486..12bfcb4b198 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -20,7 +20,7 @@ use metadata::filesearch::{FileMatches, FileDoesntMatch}; use metadata::filesearch; use syntax::codemap::Span; use syntax::diagnostic::SpanHandler; -use syntax::parse::token::ident_interner; +use syntax::parse::token::IdentInterner; use syntax::crateid::CrateId; use syntax::attr; use syntax::attr::AttrMetaMethods; @@ -52,7 +52,7 @@ pub struct Context { version: @str, hash: @str, os: Os, - intr: @ident_interner + intr: @IdentInterner } pub struct Library { @@ -376,7 +376,7 @@ pub fn read_meta_section_name(os: Os) -> &'static str { } // A diagnostic function for dumping crate metadata to an output stream -pub fn list_file_metadata(intr: @ident_interner, +pub fn list_file_metadata(intr: @IdentInterner, os: Os, path: &Path, out: &mut io::Writer) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index f0cb4533968..5f57aef2b16 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -302,16 +302,16 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { 'u' => return ty::mk_uint(), 'M' => { match next(st) { - 'b' => return ty::mk_mach_uint(ast::ty_u8), - 'w' => return ty::mk_mach_uint(ast::ty_u16), - 'l' => return ty::mk_mach_uint(ast::ty_u32), - 'd' => return ty::mk_mach_uint(ast::ty_u64), - 'B' => return ty::mk_mach_int(ast::ty_i8), - 'W' => return ty::mk_mach_int(ast::ty_i16), - 'L' => return ty::mk_mach_int(ast::ty_i32), - 'D' => return ty::mk_mach_int(ast::ty_i64), - 'f' => return ty::mk_mach_float(ast::ty_f32), - 'F' => return ty::mk_mach_float(ast::ty_f64), + 'b' => return ty::mk_mach_uint(ast::TyU8), + 'w' => return ty::mk_mach_uint(ast::TyU16), + 'l' => return ty::mk_mach_uint(ast::TyU32), + 'd' => return ty::mk_mach_uint(ast::TyU64), + 'B' => return ty::mk_mach_int(ast::TyI8), + 'W' => return ty::mk_mach_int(ast::TyI16), + 'L' => return ty::mk_mach_int(ast::TyI32), + 'D' => return ty::mk_mach_int(ast::TyI64), + 'f' => return ty::mk_mach_float(ast::TyF32), + 'F' => return ty::mk_mach_float(ast::TyF64), _ => fail!("parse_ty: bad numeric type") } } @@ -463,12 +463,12 @@ fn parse_hex(st: &mut PState) -> uint { }; } -fn parse_purity(c: char) -> purity { +fn parse_purity(c: char) -> Purity { match c { - 'u' => unsafe_fn, - 'i' => impure_fn, - 'c' => extern_fn, - _ => fail!("parse_purity: bad purity {}", c) + 'u' => UnsafeFn, + 'i' => ImpureFn, + 'c' => ExternFn, + _ => fail!("parse_purity: bad purity {}", c) } } diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 448e15352ca..8929859b2d6 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -249,26 +249,26 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) { ty::ty_char => mywrite!(w, "c"), ty::ty_int(t) => { match t { - ty_i => mywrite!(w, "i"), - ty_i8 => mywrite!(w, "MB"), - ty_i16 => mywrite!(w, "MW"), - ty_i32 => mywrite!(w, "ML"), - ty_i64 => mywrite!(w, "MD") + TyI => mywrite!(w, "i"), + TyI8 => mywrite!(w, "MB"), + TyI16 => mywrite!(w, "MW"), + TyI32 => mywrite!(w, "ML"), + TyI64 => mywrite!(w, "MD") } } ty::ty_uint(t) => { match t { - ty_u => mywrite!(w, "u"), - ty_u8 => mywrite!(w, "Mb"), - ty_u16 => mywrite!(w, "Mw"), - ty_u32 => mywrite!(w, "Ml"), - ty_u64 => mywrite!(w, "Md") + TyU => mywrite!(w, "u"), + TyU8 => mywrite!(w, "Mb"), + TyU16 => mywrite!(w, "Mw"), + TyU32 => mywrite!(w, "Ml"), + TyU64 => mywrite!(w, "Md") } } ty::ty_float(t) => { match t { - ty_f32 => mywrite!(w, "Mf"), - ty_f64 => mywrite!(w, "MF"), + TyF32 => mywrite!(w, "Mf"), + TyF64 => mywrite!(w, "MF"), } } ty::ty_enum(def, ref substs) => { @@ -349,11 +349,11 @@ fn enc_sigil(w: &mut MemWriter, sigil: Sigil) { } } -fn enc_purity(w: &mut MemWriter, p: purity) { +fn enc_purity(w: &mut MemWriter, p: Purity) { match p { - impure_fn => mywrite!(w, "i"), - unsafe_fn => mywrite!(w, "u"), - extern_fn => mywrite!(w, "c") + ImpureFn => mywrite!(w, "i"), + UnsafeFn => mywrite!(w, "u"), + ExternFn => mywrite!(w, "c") } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index b0f0c71e91d..9541afe719b 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -27,7 +27,7 @@ use util::ppaux::ty_to_str; use syntax::{ast, ast_map, ast_util, codemap, fold}; use syntax::codemap::Span; use syntax::diagnostic::SpanHandler; -use syntax::fold::ast_fold; +use syntax::fold::Folder; use syntax::parse::token; use syntax; @@ -62,8 +62,8 @@ struct DecodeContext { struct ExtendedDecodeContext { dcx: @DecodeContext, - from_id_range: ast_util::id_range, - to_id_range: ast_util::id_range + from_id_range: ast_util::IdRange, + to_id_range: ast_util::IdRange } trait tr { @@ -79,13 +79,13 @@ trait tr_intern { pub fn encode_inlined_item(ecx: &e::EncodeContext, ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], + path: &[ast_map::PathElem], ii: e::InlinedItemRef, maps: Maps) { let ident = match ii { - e::ii_item_ref(i) => i.ident, - e::ii_foreign_ref(i) => i.ident, - e::ii_method_ref(_, _, m) => m.ident, + e::IIItemRef(i) => i.ident, + e::IIForeignRef(i) => i.ident, + e::IIMethodRef(_, _, m) => m.ident, }; debug!("> Encoding inlined item: {}::{} ({})", ast_map::path_to_str(path, token::get_ident_interner()), @@ -110,9 +110,9 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, pub fn decode_inlined_item(cdata: @cstore::crate_metadata, tcx: ty::ctxt, maps: Maps, - path: &[ast_map::path_elt], + path: &[ast_map::PathElem], par_doc: ebml::Doc) - -> Option<ast::inlined_item> { + -> Option<ast::InlinedItem> { let dcx = @DecodeContext { cdata: cdata, tcx: tcx, @@ -138,9 +138,9 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata, path.to_owned(), raw_ii); let ident = match ii { - ast::ii_item(i) => i.ident, - ast::ii_foreign(i) => i.ident, - ast::ii_method(_, _, m) => m.ident, + ast::IIItem(i) => i.ident, + ast::IIForeign(i) => i.ident, + ast::IIMethod(_, _, m) => m.ident, }; debug!("Fn named: {}", tcx.sess.str_of(ident)); debug!("< Decoded inlined fn: {}::{}", @@ -148,7 +148,7 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata, tcx.sess.str_of(ident)); decode_side_tables(xcx, ast_doc); match ii { - ast::ii_item(i) => { + ast::IIItem(i) => { debug!(">>> DECODED ITEM >>>\n{}\n<<< DECODED ITEM <<<", syntax::print::pprust::item_to_str(i, tcx.sess.intr())); } @@ -163,13 +163,13 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata, // Enumerating the IDs which appear in an AST fn reserve_id_range(sess: Session, - from_id_range: ast_util::id_range) -> ast_util::id_range { + from_id_range: ast_util::IdRange) -> ast_util::IdRange { // Handle the case of an empty range: if from_id_range.empty() { return from_id_range; } let cnt = from_id_range.max - from_id_range.min; let to_id_min = sess.reserve_node_ids(cnt); let to_id_max = to_id_min + cnt; - ast_util::id_range { min: to_id_min, max: to_id_max } + ast_util::IdRange { min: to_id_min, max: to_id_max } } impl ExtendedDecodeContext { @@ -296,7 +296,7 @@ impl<D:serialize::Decoder> def_id_decoder_helpers for D { // We also have to adjust the spans: for now we just insert a dummy span, // but eventually we should add entries to the local codemap as required. -fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) { +fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::InlinedItem) { ebml_w.start_tag(c::tag_tree as uint); item.encode(ebml_w); ebml_w.end_tag(); @@ -304,7 +304,7 @@ fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) { struct NestedItemsDropper; -impl ast_fold for NestedItemsDropper { +impl Folder for NestedItemsDropper { fn fold_block(&mut self, blk: ast::P<ast::Block>) -> ast::P<ast::Block> { let stmts_sans_items = blk.stmts.iter().filter_map(|stmt| { match stmt.node { @@ -343,19 +343,19 @@ impl ast_fold for NestedItemsDropper { // As it happens, trans relies on the fact that we do not export // nested items, as otherwise it would get confused when translating // inlined items. -fn simplify_ast(ii: e::InlinedItemRef) -> ast::inlined_item { +fn simplify_ast(ii: e::InlinedItemRef) -> ast::InlinedItem { let mut fld = NestedItemsDropper; match ii { // HACK we're not dropping items. - e::ii_item_ref(i) => ast::ii_item(fold::noop_fold_item(i, &mut fld) - .expect_one("expected one item")), - e::ii_method_ref(d, p, m) => ast::ii_method(d, p, fold::noop_fold_method(m, &mut fld)), - e::ii_foreign_ref(i) => ast::ii_foreign(fold::noop_fold_foreign_item(i, &mut fld)) + e::IIItemRef(i) => ast::IIItem(fold::noop_fold_item(i, &mut fld) + .expect_one("expected one item")), + e::IIMethodRef(d, p, m) => ast::IIMethod(d, p, fold::noop_fold_method(m, &mut fld)), + e::IIForeignRef(i) => ast::IIForeign(fold::noop_fold_foreign_item(i, &mut fld)) } } -fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { +fn decode_ast(par_doc: ebml::Doc) -> ast::InlinedItem { let chi_doc = par_doc.get(c::tag_tree as uint); let mut d = reader::Decoder(chi_doc); Decodable::decode(&mut d) @@ -376,18 +376,18 @@ impl ast_map::FoldOps for AstRenumberer { fn renumber_and_map_ast(xcx: @ExtendedDecodeContext, diag: @SpanHandler, - map: ast_map::map, - path: ast_map::path, - ii: ast::inlined_item) -> ast::inlined_item { + map: ast_map::Map, + path: ast_map::Path, + ii: ast::InlinedItem) -> ast::InlinedItem { ast_map::map_decoded_item(diag, map, path, AstRenumberer { xcx: xcx }, |fld| { match ii { - ast::ii_item(i) => { - ast::ii_item(fld.fold_item(i).expect_one("expected one item")) + ast::IIItem(i) => { + ast::IIItem(fld.fold_item(i).expect_one("expected one item")) } - ast::ii_method(d, is_provided, m) => { - ast::ii_method(xcx.tr_def_id(d), is_provided, fld.fold_method(m)) + ast::IIMethod(d, is_provided, m) => { + ast::IIMethod(xcx.tr_def_id(d), is_provided, fld.fold_method(m)) } - ast::ii_foreign(i) => ast::ii_foreign(fld.fold_foreign_item(i)) + ast::IIForeign(i) => ast::IIForeign(fld.fold_foreign_item(i)) } }) } @@ -595,7 +595,7 @@ impl<'a> read_method_map_entry_helper for reader::Decoder<'a> { explicit_self: this.read_struct_field("explicit_self", 2, |this| { - let explicit_self: ast::explicit_self_ = Decodable::decode(this); + let explicit_self: ast::ExplicitSelf_ = Decodable::decode(this); explicit_self }), origin: this.read_struct_field("origin", 1, |this| { @@ -921,7 +921,7 @@ impl<'a,'b> ast_util::IdVisitingOperation for fn encode_side_tables_for_ii(ecx: &e::EncodeContext, maps: Maps, ebml_w: &mut writer::Encoder, - ii: &ast::inlined_item) { + ii: &ast::InlinedItem) { ebml_w.start_tag(c::tag_table as uint); let mut new_ebml_w = unsafe { ebml_w.unsafe_clone() @@ -1418,14 +1418,14 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, // Testing of astencode_gen #[cfg(test)] -fn encode_item_ast(ebml_w: &mut writer::Encoder, item: @ast::item) { +fn encode_item_ast(ebml_w: &mut writer::Encoder, item: @ast::Item) { ebml_w.start_tag(c::tag_tree as uint); (*item).encode(ebml_w); ebml_w.end_tag(); } #[cfg(test)] -fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item { +fn decode_item_ast(par_doc: ebml::Doc) -> @ast::Item { let chi_doc = par_doc.get(c::tag_tree as uint); let mut d = reader::Decoder(chi_doc); @Decodable::decode(&mut d) @@ -1464,7 +1464,7 @@ fn mk_ctxt() -> @fake_ext_ctxt { } #[cfg(test)] -fn roundtrip(in_item: Option<@ast::item>) { +fn roundtrip(in_item: Option<@ast::Item>) { use std::io::mem::MemWriter; let in_item = in_item.unwrap(); @@ -1515,15 +1515,15 @@ fn test_simplification() { return alist {eq_fn: eq_int, data: ~[]}; } ).unwrap(); - let item_in = e::ii_item_ref(item); + let item_in = e::IIItemRef(item); let item_out = simplify_ast(item_in); - let item_exp = ast::ii_item(quote_item!(cx, + let item_exp = ast::IIItem(quote_item!(cx, fn new_int_alist<B>() -> alist<int, B> { return alist {eq_fn: eq_int, data: ~[]}; } ).unwrap()); match (item_out, item_exp) { - (ast::ii_item(item_out), ast::ii_item(item_exp)) => { + (ast::IIItem(item_out), ast::IIItem(item_exp)) => { assert!(pprust::item_to_str(item_out, token::get_ident_interner()) == pprust::item_to_str(item_exp, diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index cf5a02d48e0..ea7979b855e 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -51,7 +51,7 @@ impl<'a> Visitor<()> for CheckLoanCtxt<'a> { fn visit_pat(&mut self, p: &ast::Pat, _: ()) { check_loans_in_pat(self, p); } - fn visit_fn(&mut self, fk: &visit::fn_kind, fd: &ast::fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl, b: &ast::Block, s: Span, n: ast::NodeId, _: ()) { check_loans_in_fn(self, fk, fd, b, s, n); } @@ -682,19 +682,18 @@ impl<'a> CheckLoanCtxt<'a> { } fn check_loans_in_fn<'a>(this: &mut CheckLoanCtxt<'a>, - fk: &visit::fn_kind, - decl: &ast::fn_decl, + fk: &visit::FnKind, + decl: &ast::FnDecl, body: &ast::Block, sp: Span, id: ast::NodeId) { match *fk { - visit::fk_item_fn(..) | - visit::fk_method(..) => { + visit::FkItemFn(..) | visit::FkMethod(..) => { // Don't process nested items. return; } - visit::fk_fn_block(..) => { + visit::FkFnBlock(..) => { check_captured_variables(this, id, sp); } } diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index b03c5b88780..e35bafd6ebf 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -28,12 +28,12 @@ use util::ppaux::{Repr}; use std::cell::RefCell; use syntax::ast; -use syntax::ast_util::id_range; +use syntax::ast_util::IdRange; use syntax::codemap::Span; use syntax::print::pprust; use syntax::visit; -use syntax::visit::{Visitor, fn_kind}; -use syntax::ast::{Expr, fn_decl, Block, NodeId, Stmt, Pat, Local}; +use syntax::visit::{Visitor, FnKind}; +use syntax::ast::{Expr, FnDecl, Block, NodeId, Stmt, Pat, Local}; mod lifetime; mod restrictions; @@ -67,7 +67,7 @@ mod gather_moves; /// because it would have to be rooted for a region greater than `root_ub`. struct GatherLoanCtxt<'a> { bccx: &'a BorrowckCtxt, - id_range: id_range, + id_range: IdRange, move_data: move_data::MoveData, all_loans: @RefCell<~[Loan]>, item_ub: ast::NodeId, @@ -81,7 +81,7 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> { fn visit_block(&mut self, b: &Block, _: ()) { gather_loans_in_block(self, b); } - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, b: &Block, + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { gather_loans_in_fn(self, fk, fd, b, s, n); } @@ -98,16 +98,14 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> { // #7740: Do not visit items here, not even fn items nor methods // of impl items; the outer loop in borrowck/mod will visit them // for us in turn. Thus override visit_item's walk with a no-op. - fn visit_item(&mut self, _: &ast::item, _: ()) { } + fn visit_item(&mut self, _: &ast::Item, _: ()) { } } -pub fn gather_loans(bccx: &BorrowckCtxt, - decl: &ast::fn_decl, - body: &ast::Block) - -> (id_range, @RefCell<~[Loan]>, move_data::MoveData) { +pub fn gather_loans(bccx: &BorrowckCtxt, decl: &ast::FnDecl, body: &ast::Block) + -> (IdRange, @RefCell<~[Loan]>, move_data::MoveData) { let mut glcx = GatherLoanCtxt { bccx: bccx, - id_range: id_range::max(), + id_range: IdRange::max(), all_loans: @RefCell::new(~[]), item_ub: body.id, repeating_ids: ~[body.id], @@ -129,19 +127,16 @@ fn add_pat_to_id_range(this: &mut GatherLoanCtxt, visit::walk_pat(this, p, ()); } -fn gather_loans_in_fn(this: &mut GatherLoanCtxt, - fk: &fn_kind, - decl: &ast::fn_decl, - body: &ast::Block, - sp: Span, - id: ast::NodeId) { +fn gather_loans_in_fn(this: &mut GatherLoanCtxt, fk: &FnKind, + decl: &ast::FnDecl, body: &ast::Block, + sp: Span, id: ast::NodeId) { match fk { - &visit::fk_item_fn(..) | &visit::fk_method(..) => { + &visit::FkItemFn(..) | &visit::FkMethod(..) => { fail!("cannot occur, due to visit_item override"); } // Visit closures as part of the containing item. - &visit::fk_fn_block(..) => { + &visit::FkFnBlock(..) => { this.push_repeating_id(body.id); visit::walk_fn(this, fk, decl, body, sp, id, ()); this.pop_repeating_id(body.id); @@ -677,7 +672,7 @@ impl<'a> GatherLoanCtxt<'a> { } fn gather_fn_arg_patterns(&mut self, - decl: &ast::fn_decl, + decl: &ast::FnDecl, body: &ast::Block) { /*! * Walks the patterns for fn arguments, checking that they diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 1cf019ce9cc..5160233ecbf 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -28,8 +28,8 @@ use syntax::ast_map; use syntax::codemap::Span; use syntax::parse::token; use syntax::visit; -use syntax::visit::{Visitor,fn_kind}; -use syntax::ast::{fn_decl,Block,NodeId}; +use syntax::visit::{Visitor, FnKind}; +use syntax::ast::{FnDecl, Block, NodeId}; macro_rules! if_ok( ($inp: expr) => ( @@ -61,7 +61,7 @@ impl Clone for LoanDataFlowOperator { pub type LoanDataFlow = DataFlowContext<LoanDataFlowOperator>; impl Visitor<()> for BorrowckCtxt { - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { borrowck_fn(self, fk, fd, b, s, n); } @@ -114,18 +114,17 @@ pub fn check_crate(tcx: ty::ctxt, } fn borrowck_fn(this: &mut BorrowckCtxt, - fk: &visit::fn_kind, - decl: &ast::fn_decl, + fk: &FnKind, + decl: &ast::FnDecl, body: &ast::Block, sp: Span, id: ast::NodeId) { match fk { - &visit::fk_fn_block(..) => { + &visit::FkFnBlock(..) => { // Closures are checked as part of their containing fn item. } - &visit::fk_item_fn(..) | - &visit::fk_method(..) => { + &visit::FkItemFn(..) | &visit::FkMethod(..) => { debug!("borrowck_fn(id={:?})", id); // Check the body of fn items. @@ -553,7 +552,7 @@ impl BorrowckCtxt { move_data::MoveExpr => { let items = self.tcx.items.borrow(); let (expr_ty, expr_span) = match items.get().find(&move.id) { - Some(&ast_map::node_expr(expr)) => { + Some(&ast_map::NodeExpr(expr)) => { (ty::expr_ty_adjusted(self.tcx, expr), expr.span) } r => self.tcx.sess.bug(format!("MoveExpr({:?}) maps to {:?}, not Expr", @@ -581,7 +580,7 @@ impl BorrowckCtxt { move_data::Captured => { let items = self.tcx.items.borrow(); let (expr_ty, expr_span) = match items.get().find(&move.id) { - Some(&ast_map::node_expr(expr)) => { + Some(&ast_map::NodeExpr(expr)) => { (ty::expr_ty_adjusted(self.tcx, expr), expr.span) } r => self.tcx.sess.bug(format!("Captured({:?}) maps to {:?}, not Expr", @@ -771,7 +770,7 @@ impl BorrowckCtxt { LpVar(id) => { let items = self.tcx.items.borrow(); match items.get().find(&id) { - Some(&ast_map::node_local(ref ident, _)) => { + Some(&ast_map::NodeLocal(ref ident, _)) => { out.push_str(token::ident_to_str(ident)); } r => { diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index f6d1417d0de..e61ebd39ca7 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -566,7 +566,7 @@ impl FlowedMoveData { pub fn new(move_data: MoveData, tcx: ty::ctxt, method_map: typeck::method_map, - id_range: ast_util::id_range, + id_range: ast_util::IdRange, body: &ast::Block) -> FlowedMoveData { let mut dfcx_moves = { diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 1ca5faf9176..b440be8b0be 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -23,14 +23,14 @@ use syntax::visit; struct CheckCrateVisitor { sess: Session, - ast_map: ast_map::map, + ast_map: ast_map::Map, def_map: resolve::DefMap, method_map: typeck::method_map, tcx: ty::ctxt, } impl Visitor<bool> for CheckCrateVisitor { - fn visit_item(&mut self, i: &item, env: bool) { + fn visit_item(&mut self, i: &Item, env: bool) { check_item(self, self.sess, self.ast_map, self.def_map, i, env); } fn visit_pat(&mut self, p: &Pat, env: bool) { @@ -44,7 +44,7 @@ impl Visitor<bool> for CheckCrateVisitor { pub fn check_crate(sess: Session, crate: &Crate, - ast_map: ast_map::map, + ast_map: ast_map::Map, def_map: resolve::DefMap, method_map: typeck::method_map, tcx: ty::ctxt) { @@ -61,23 +61,23 @@ pub fn check_crate(sess: Session, pub fn check_item(v: &mut CheckCrateVisitor, sess: Session, - ast_map: ast_map::map, + ast_map: ast_map::Map, def_map: resolve::DefMap, - it: &item, + it: &Item, _is_const: bool) { match it.node { - item_static(_, _, ex) => { - v.visit_expr(ex, true); - check_item_recursion(sess, ast_map, def_map, it); - } - item_enum(ref enum_definition, _) => { - for var in (*enum_definition).variants.iter() { - for ex in var.node.disr_expr.iter() { - v.visit_expr(*ex, true); + ItemStatic(_, _, ex) => { + v.visit_expr(ex, true); + check_item_recursion(sess, ast_map, def_map, it); + } + ItemEnum(ref enum_definition, _) => { + for var in (*enum_definition).variants.iter() { + for ex in var.node.disr_expr.iter() { + v.visit_expr(*ex, true); + } } } - } - _ => visit::walk_item(v, it, false) + _ => visit::walk_item(v, it, false) } } @@ -86,7 +86,7 @@ pub fn check_pat(v: &mut CheckCrateVisitor, p: &Pat, _is_const: bool) { match e.node { ExprVstore( @Expr { node: ExprLit(@codemap::Spanned { - node: lit_str(..), + node: LitStr(..), ..}), .. }, ExprVstoreUniq @@ -120,7 +120,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor, "cannot do allocations in constant expressions"); return; } - ExprLit(@codemap::Spanned {node: lit_str(..), ..}) => { } + ExprLit(@codemap::Spanned {node: LitStr(..), ..}) => { } ExprBinary(..) | ExprUnary(..) => { let method_map = method_map.borrow(); if method_map.get().contains_key(&e.id) { @@ -211,9 +211,9 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } struct CheckItemRecursionVisitor<'a> { - root_it: &'a item, + root_it: &'a Item, sess: Session, - ast_map: ast_map::map, + ast_map: ast_map::Map, def_map: resolve::DefMap, idstack: ~[NodeId] } @@ -221,9 +221,9 @@ struct CheckItemRecursionVisitor<'a> { // Make sure a const item doesn't recursively refer to itself // FIXME: Should use the dependency graph when it's available (#1356) pub fn check_item_recursion(sess: Session, - ast_map: ast_map::map, + ast_map: ast_map::Map, def_map: resolve::DefMap, - it: &item) { + it: &Item) { let mut visitor = CheckItemRecursionVisitor { root_it: it, @@ -236,7 +236,7 @@ pub fn check_item_recursion(sess: Session, } impl<'a> Visitor<()> for CheckItemRecursionVisitor<'a> { - fn visit_item(&mut self, it: &item, _: ()) { + fn visit_item(&mut self, it: &Item, _: ()) { if self.idstack.iter().any(|x| x == &(it.id)) { self.sess.span_fatal(self.root_it.span, "recursive constant"); } @@ -254,7 +254,7 @@ impl<'a> Visitor<()> for CheckItemRecursionVisitor<'a> { ast_util::is_local(def_id) => { let ast_map = self.ast_map.borrow(); match ast_map.get().get_copy(&def_id.node) { - ast_map::node_item(it, _) => { + ast_map::NodeItem(it, _) => { self.visit_item(it, ()); } _ => fail!("const not bound to an item") diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index 456c9341654..c1be9ea69ea 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -29,7 +29,7 @@ pub fn check_crate(tcx: ty::ctxt, crate: &ast::Crate) { } impl Visitor<Context> for CheckLoopVisitor { - fn visit_item(&mut self, i: &ast::item, _cx: Context) { + fn visit_item(&mut self, i: &ast::Item, _cx: Context) { visit::walk_item(self, i, Normal); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index de39c7129b7..47a90311c31 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -25,7 +25,7 @@ use syntax::ast::*; use syntax::ast_util::{unguarded_pat, walk_pat}; use syntax::codemap::{Span, DUMMY_SP, Spanned}; use syntax::visit; -use syntax::visit::{Visitor,fn_kind}; +use syntax::visit::{Visitor, FnKind}; struct MatchCheckCtxt { tcx: ty::ctxt, @@ -44,7 +44,7 @@ impl Visitor<()> for CheckMatchVisitor { fn visit_local(&mut self, l: &Local, _: ()) { check_local(self, self.cx, l, ()); } - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, b: &Block, s: Span, n: NodeId, _: ()) { + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, self.cx, fk, fd, b, s, n, ()); } } @@ -843,8 +843,8 @@ fn check_local(v: &mut CheckMatchVisitor, fn check_fn(v: &mut CheckMatchVisitor, cx: &MatchCheckCtxt, - kind: &visit::fn_kind, - decl: &fn_decl, + kind: &FnKind, + decl: &FnDecl, body: &Block, sp: Span, id: NodeId, @@ -879,7 +879,7 @@ fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool { is_refutable(cx, sub) } PatWild | PatWildMulti | PatIdent(_, _, None) => { false } - PatLit(@Expr {node: ExprLit(@Spanned { node: lit_nil, ..}), ..}) => { + PatLit(@Expr {node: ExprLit(@Spanned { node: LitNil, ..}), ..}) => { // "()" false } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index bd27900e9cc..340c8d67ce3 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -97,7 +97,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt, enum_def: ast::DefId, variant_def: ast::DefId) -> Option<@Expr> { - fn variant_expr(variants: &[ast::P<ast::variant>], id: ast::NodeId) -> Option<@Expr> { + fn variant_expr(variants: &[ast::P<ast::Variant>], id: ast::NodeId) -> Option<@Expr> { for variant in variants.iter() { if variant.node.id == id { return variant.node.disr_expr; @@ -111,8 +111,8 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt, let items = tcx.items.borrow(); match items.get().find(&enum_def.node) { None => None, - Some(&ast_map::node_item(it, _)) => match it.node { - item_enum(ast::enum_def { variants: ref variants }, _) => { + Some(&ast_map::NodeItem(it, _)) => match it.node { + ItemEnum(ast::EnumDef { variants: ref variants }, _) => { variant_expr(*variants, variant_def.node) } _ => None @@ -140,8 +140,8 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt, maps, /*bad*/ c.clone(), d)) { - csearch::found(ast::ii_item(item)) => match item.node { - item_enum(ast::enum_def { variants: ref variants }, _) => { + csearch::found(ast::IIItem(item)) => match item.node { + ItemEnum(ast::EnumDef { variants: ref variants }, _) => { variant_expr(*variants, variant_def.node) } _ => None @@ -164,8 +164,8 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, def_id: ast::DefId) let items = tcx.items.borrow(); match items.get().find(&def_id.node) { None => None, - Some(&ast_map::node_item(it, _)) => match it.node { - item_static(_, ast::MutImmutable, const_expr) => { + Some(&ast_map::NodeItem(it, _)) => match it.node { + ItemStatic(_, ast::MutImmutable, const_expr) => { Some(const_expr) } _ => None @@ -189,8 +189,8 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, def_id: ast::DefId) }; let e = match csearch::maybe_get_item_ast(tcx, def_id, |a, b, c, d| astencode::decode_inlined_item(a, b, maps, c, d)) { - csearch::found(ast::ii_item(item)) => match item.node { - item_static(_, ast::MutImmutable, const_expr) => Some(const_expr), + csearch::found(ast::IIItem(item)) => match item.node { + ItemStatic(_, ast::MutImmutable, const_expr) => Some(const_expr), _ => None }, _ => None @@ -219,7 +219,7 @@ impl ConstEvalVisitor { let cn = match e.node { ast::ExprLit(lit) => { match lit.node { - ast::lit_str(..) | ast::lit_float(..) => general_const, + ast::LitStr(..) | ast::LitFloat(..) => general_const, _ => integral_const } } @@ -497,19 +497,19 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) } } -pub fn lit_to_const(lit: &lit) -> const_val { +pub fn lit_to_const(lit: &Lit) -> const_val { match lit.node { - lit_str(s, _) => const_str(s), - lit_binary(data) => const_binary(data), - lit_char(n) => const_uint(n as u64), - lit_int(n, _) => const_int(n), - lit_uint(n, _) => const_uint(n), - lit_int_unsuffixed(n) => const_int(n), - lit_float(n, _) => const_float(from_str::<f64>(n).unwrap() as f64), - lit_float_unsuffixed(n) => - const_float(from_str::<f64>(n).unwrap() as f64), - lit_nil => const_int(0i64), - lit_bool(b) => const_bool(b) + LitStr(s, _) => const_str(s), + LitBinary(data) => const_binary(data), + LitChar(n) => const_uint(n as u64), + LitInt(n, _) => const_int(n), + LitUint(n, _) => const_uint(n), + LitIntUnsuffixed(n) => const_int(n), + LitFloat(n, _) => const_float(from_str::<f64>(n).unwrap() as f64), + LitFloatUnsuffixed(n) => + const_float(from_str::<f64>(n).unwrap() as f64), + LitNil => const_int(0i64), + LitBool(b) => const_bool(b) } } @@ -535,6 +535,6 @@ pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: &Expr, b: &Expr) -> Option<bool> { compare_lit_exprs(tcx, a, b).map(|val| val == 0) } -pub fn lit_eq(a: &lit, b: &lit) -> Option<bool> { +pub fn lit_eq(a: &Lit, b: &Lit) -> Option<bool> { compare_const_vals(&lit_to_const(a), &lit_to_const(b)).map(|val| val == 0) } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index ab19cdf627f..c50190f0b68 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -24,7 +24,7 @@ use std::vec; use std::hashmap::HashMap; use syntax::ast; use syntax::ast_util; -use syntax::ast_util::id_range; +use syntax::ast_util::IdRange; use syntax::print::{pp, pprust}; use middle::ty; use middle::typeck; @@ -87,13 +87,13 @@ struct LoopScope<'a> { break_bits: ~[uint] } -impl<O:DataFlowOperator> pprust::pp_ann for DataFlowContext<O> { - fn pre(&self, node: pprust::ann_node) { +impl<O:DataFlowOperator> pprust::PpAnn for DataFlowContext<O> { + fn pre(&self, node: pprust::AnnNode) { let (ps, id) = match node { - pprust::node_expr(ps, expr) => (ps, expr.id), - pprust::node_block(ps, blk) => (ps, blk.id), - pprust::node_item(ps, _) => (ps, 0), - pprust::node_pat(ps, pat) => (ps, pat.id) + pprust::NodeExpr(ps, expr) => (ps, expr.id), + pprust::NodeBlock(ps, blk) => (ps, blk.id), + pprust::NodeItem(ps, _) => (ps, 0), + pprust::NodePat(ps, pat) => (ps, pat.id) }; if self.nodeid_to_bitset.contains_key(&id) { @@ -127,7 +127,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> { pub fn new(tcx: ty::ctxt, method_map: typeck::method_map, oper: O, - id_range: id_range, + id_range: IdRange, bits_per_id: uint) -> DataFlowContext<O> { let words_per_id = (bits_per_id + uint::bits - 1) / uint::bits; @@ -353,9 +353,8 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> { } fn pretty_print_to(@self, wr: ~io::Writer, blk: &ast::Block) { - let mut ps = pprust::rust_printer_annotated(wr, - self.tcx.sess.intr(), - self as @pprust::pp_ann); + let mut ps = pprust::rust_printer_annotated(wr, self.tcx.sess.intr(), + self as @pprust::PpAnn); pprust::cbox(&mut ps, pprust::indent_unit); pprust::ibox(&mut ps, 0u); pprust::print_block(&mut ps, blk); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 6c821862a02..e7136358aad 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -27,7 +27,7 @@ use syntax::visit::Visitor; use syntax::visit; // Any local node that may call something in its body block should be -// explored. For example, if it's a live node_item that is a +// explored. For example, if it's a live NodeItem that is a // function, then we should explore its block to check for codes that // may need to be marked as live. fn should_explore(tcx: ty::ctxt, def_id: ast::DefId) -> bool { @@ -37,10 +37,10 @@ fn should_explore(tcx: ty::ctxt, def_id: ast::DefId) -> bool { let items = tcx.items.borrow(); match items.get().find(&def_id.node) { - Some(&ast_map::node_item(..)) - | Some(&ast_map::node_method(..)) - | Some(&ast_map::node_foreign_item(..)) - | Some(&ast_map::node_trait_method(..)) => true, + Some(&ast_map::NodeItem(..)) + | Some(&ast_map::NodeMethod(..)) + | Some(&ast_map::NodeForeignItem(..)) + | Some(&ast_map::NodeTraitMethod(..)) => true, _ => false } } @@ -144,27 +144,27 @@ impl MarkSymbolVisitor { } } - fn visit_node(&mut self, node: &ast_map::ast_node) { + fn visit_node(&mut self, node: &ast_map::Node) { match *node { - ast_map::node_item(item, _) => { + ast_map::NodeItem(item, _) => { match item.node { - ast::item_fn(..) - | ast::item_ty(..) - | ast::item_enum(..) - | ast::item_struct(..) - | ast::item_static(..) => { + ast::ItemFn(..) + | ast::ItemTy(..) + | ast::ItemEnum(..) + | ast::ItemStruct(..) + | ast::ItemStatic(..) => { visit::walk_item(self, item, ()); } _ => () } } - ast_map::node_trait_method(trait_method, _, _) => { + ast_map::NodeTraitMethod(trait_method, _, _) => { visit::walk_trait_method(self, trait_method, ()); } - ast_map::node_method(method, _, _) => { + ast_map::NodeMethod(method, _, _) => { visit::walk_block(self, method.body, ()); } - ast_map::node_foreign_item(foreign_item, _, _, _) => { + ast_map::NodeForeignItem(foreign_item, _, _, _) => { visit::walk_foreign_item(self, foreign_item, ()); } _ => () @@ -190,7 +190,7 @@ impl Visitor<()> for MarkSymbolVisitor { visit::walk_path(self, path, ()); } - fn visit_item(&mut self, _item: &ast::item, _: ()) { + fn visit_item(&mut self, _item: &ast::Item, _: ()) { // Do not recurse into items. These items will be added to the // worklist and recursed into manually if necessary. } @@ -204,14 +204,14 @@ struct TraitMethodSeeder { } impl Visitor<()> for TraitMethodSeeder { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { match item.node { - ast::item_impl(_, Some(ref _trait_ref), _, ref methods) => { + ast::ItemImpl(_, Some(ref _trait_ref), _, ref methods) => { for method in methods.iter() { self.worklist.push(method.id); } } - ast::item_mod(..) | ast::item_fn(..) => { + ast::ItemMod(..) | ast::ItemFn(..) => { visit::walk_item(self, item, ()); } _ => () @@ -265,19 +265,19 @@ fn find_live(tcx: ty::ctxt, symbol_visitor.live_symbols } -fn should_warn(item: &ast::item) -> bool { +fn should_warn(item: &ast::Item) -> bool { match item.node { - ast::item_static(..) - | ast::item_fn(..) - | ast::item_enum(..) - | ast::item_struct(..) => true, + ast::ItemStatic(..) + | ast::ItemFn(..) + | ast::ItemEnum(..) + | ast::ItemStruct(..) => true, _ => false } } -fn get_struct_ctor_id(item: &ast::item) -> Option<ast::NodeId> { +fn get_struct_ctor_id(item: &ast::Item) -> Option<ast::NodeId> { match item.node { - ast::item_struct(struct_def, _) => struct_def.ctor_id, + ast::ItemStruct(struct_def, _) => struct_def.ctor_id, _ => None } } @@ -335,7 +335,7 @@ impl DeadVisitor { } impl Visitor<()> for DeadVisitor { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { let ctor_id = get_struct_ctor_id(item); if !self.symbol_is_live(item.id, ctor_id) && should_warn(item) { self.warn_dead_code(item.id, item.span, &item.ident); @@ -343,19 +343,19 @@ impl Visitor<()> for DeadVisitor { visit::walk_item(self, item, ()); } - fn visit_foreign_item(&mut self, fi: &ast::foreign_item, _: ()) { + fn visit_foreign_item(&mut self, fi: &ast::ForeignItem, _: ()) { if !self.symbol_is_live(fi.id, None) { self.warn_dead_code(fi.id, fi.span, &fi.ident); } visit::walk_foreign_item(self, fi, ()); } - fn visit_fn(&mut self, fk: &visit::fn_kind, - _: &ast::fn_decl, block: &ast::Block, + fn visit_fn(&mut self, fk: &visit::FnKind, + _: &ast::FnDecl, block: &ast::Block, span: codemap::Span, id: ast::NodeId, _: ()) { - // Have to warn method here because methods are not ast::item + // Have to warn method here because methods are not ast::Item match *fk { - visit::fk_method(..) => { + visit::FkMethod(..) => { let ident = visit::name_of_fn(fk); if !self.symbol_is_live(id, None) { self.warn_dead_code(id, span, &ident); @@ -367,10 +367,10 @@ impl Visitor<()> for DeadVisitor { } // Overwrite so that we don't warn the trait method itself. - fn visit_trait_method(&mut self, trait_method: &ast::trait_method, _: ()) { + fn visit_trait_method(&mut self, trait_method: &ast::TraitMethod, _: ()) { match *trait_method { - ast::provided(method) => visit::walk_block(self, method.body, ()), - ast::required(_) => () + ast::Provided(method) => visit::walk_block(self, method.body, ()), + ast::Required(_) => () } } } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 86e590d3326..f46e570bb9d 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -29,8 +29,8 @@ enum UnsafeContext { fn type_is_unsafe_function(ty: ty::t) -> bool { match ty::get(ty).sty { - ty::ty_bare_fn(ref f) => f.purity == ast::unsafe_fn, - ty::ty_closure(ref f) => f.purity == ast::unsafe_fn, + ty::ty_bare_fn(ref f) => f.purity == ast::UnsafeFn, + ty::ty_closure(ref f) => f.purity == ast::UnsafeFn, _ => false, } } @@ -81,14 +81,14 @@ impl EffectCheckVisitor { } impl Visitor<()> for EffectCheckVisitor { - fn visit_fn(&mut self, fn_kind: &visit::fn_kind, fn_decl: &ast::fn_decl, + fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl, block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) { let (is_item_fn, is_unsafe_fn) = match *fn_kind { - visit::fk_item_fn(_, _, purity, _) => - (true, purity == ast::unsafe_fn), - visit::fk_method(_, _, method) => - (true, method.purity == ast::unsafe_fn), + visit::FkItemFn(_, _, purity, _) => + (true, purity == ast::UnsafeFn), + visit::FkMethod(_, _, method) => + (true, method.purity == ast::UnsafeFn), _ => (false, false), }; diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 4688818c055..d6e4ad64182 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -11,7 +11,7 @@ use driver::session; use driver::session::Session; -use syntax::ast::{Crate, NodeId, item, item_fn}; +use syntax::ast::{Crate, NodeId, Item, ItemFn}; use syntax::ast_map; use syntax::attr; use syntax::codemap::Span; @@ -22,7 +22,7 @@ use syntax::visit::Visitor; struct EntryContext { session: Session, - ast_map: ast_map::map, + ast_map: ast_map::Map, // The top-level function called 'main' main_fn: Option<(NodeId, Span)>, @@ -39,12 +39,12 @@ struct EntryContext { } impl Visitor<()> for EntryContext { - fn visit_item(&mut self, item: &item, _:()) { + fn visit_item(&mut self, item: &Item, _:()) { find_item(item, self); } } -pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) { +pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::Map) { if session.building_library.get() { // No need to find a main function return; @@ -70,14 +70,14 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) configure_main(&mut ctxt); } -fn find_item(item: &item, ctxt: &mut EntryContext) { +fn find_item(item: &Item, ctxt: &mut EntryContext) { match item.node { - item_fn(..) => { + ItemFn(..) => { if item.ident.name == special_idents::main.name { { let ast_map = ctxt.ast_map.borrow(); match ast_map.get().find(&item.id) { - Some(&ast_map::node_item(_, path)) => { + Some(&ast_map::NodeItem(_, path)) => { if path.len() == 0 { // This is a top-level function so can be 'main' if ctxt.main_fn.is_none() { diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index de951193cda..4ee8eb4108d 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -20,7 +20,6 @@ use syntax::codemap::Span; use syntax::{ast, ast_util}; use syntax::visit; use syntax::visit::Visitor; -use syntax::ast::{item}; // A vector of defs representing the free variables referred to in a function. // (The def_upvar will already have been stripped). @@ -40,7 +39,7 @@ struct CollectFreevarsVisitor { impl Visitor<int> for CollectFreevarsVisitor { - fn visit_item(&mut self, _: &item, _: int) { + fn visit_item(&mut self, _: &ast::Item, _: int) { // ignore_item } @@ -112,7 +111,7 @@ struct AnnotateFreevarsVisitor { } impl Visitor<()> for AnnotateFreevarsVisitor { - fn visit_fn(&mut self, fk: &visit::fn_kind, fd: &ast::fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl, blk: &ast::Block, s: Span, nid: ast::NodeId, _: ()) { let vars = collect_freevars(self.def_map, blk); self.freevars.insert(nid, vars); diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 4d0c9de82c1..c3d050ac559 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -62,7 +62,7 @@ impl Visitor<()> for Context { check_expr(self, ex); } - fn visit_fn(&mut self, fk: &visit::fn_kind, fd: &fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } @@ -70,7 +70,7 @@ impl Visitor<()> for Context { fn visit_ty(&mut self, t: &Ty, _: ()) { check_ty(self, t); } - fn visit_item(&mut self, i: &item, _: ()) { + fn visit_item(&mut self, i: &Item, _: ()) { check_item(self, i); } } @@ -116,7 +116,7 @@ fn check_struct_safe_for_destructor(cx: &mut Context, } } -fn check_impl_of_trait(cx: &mut Context, it: &item, trait_ref: &trait_ref, self_type: &Ty) { +fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_type: &Ty) { let def_map = cx.tcx.def_map.borrow(); let ast_trait_def = def_map.get() .find(&trait_ref.ref_id) @@ -145,7 +145,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &item, trait_ref: &trait_ref, self_ // If this is a destructor, check kinds. if cx.tcx.lang_items.drop_trait() == Some(trait_def_id) { match self_type.node { - ty_path(_, ref bounds, path_node_id) => { + TyPath(_, ref bounds, path_node_id) => { assert!(bounds.is_none()); let struct_def = def_map.get().get_copy(&path_node_id); let struct_did = ast_util::def_id_of_def(struct_def); @@ -159,10 +159,10 @@ fn check_impl_of_trait(cx: &mut Context, it: &item, trait_ref: &trait_ref, self_ } } -fn check_item(cx: &mut Context, item: &item) { +fn check_item(cx: &mut Context, item: &Item) { if !attr::contains_name(item.attrs, "unsafe_destructor") { match item.node { - item_impl(_, Some(ref trait_ref), self_type, _) => { + ItemImpl(_, Some(ref trait_ref), self_type, _) => { check_impl_of_trait(cx, item, trait_ref, self_type); } _ => {} @@ -246,8 +246,8 @@ fn with_appropriate_checker(cx: &Context, // to the copy/move kind bounds. Then recursively check the function body. fn check_fn( cx: &mut Context, - fk: &visit::fn_kind, - decl: &fn_decl, + fk: &visit::FnKind, + decl: &FnDecl, body: &Block, sp: Span, fn_id: NodeId) { @@ -353,20 +353,20 @@ fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: fn check_ty(cx: &mut Context, aty: &Ty) { match aty.node { - ty_path(_, _, id) => { - let node_type_substs = cx.tcx.node_type_substs.borrow(); - let r = node_type_substs.get().find(&id); - for ts in r.iter() { - let def_map = cx.tcx.def_map.borrow(); - let did = ast_util::def_id_of_def(def_map.get().get_copy(&id)); - let type_param_defs = - ty::lookup_item_type(cx.tcx, did).generics.type_param_defs; - for (&ty, type_param_def) in ts.iter().zip(type_param_defs.iter()) { - check_typaram_bounds(cx, aty.id, aty.span, ty, type_param_def) - } - } - } - _ => {} + TyPath(_, _, id) => { + let node_type_substs = cx.tcx.node_type_substs.borrow(); + let r = node_type_substs.get().find(&id); + for ts in r.iter() { + let def_map = cx.tcx.def_map.borrow(); + let did = ast_util::def_id_of_def(def_map.get().get_copy(&id)); + let type_param_defs = + ty::lookup_item_type(cx.tcx, did).generics.type_param_defs; + for (&ty, type_param_def) in ts.iter().zip(type_param_defs.iter()) { + check_typaram_bounds(cx, aty.id, aty.span, ty, type_param_def) + } + } + } + _ => {} } visit::walk_ty(cx, aty, ()); } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 844a27668db..f95fec4c9df 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -109,7 +109,7 @@ struct LanguageItemVisitor<'a> { } impl<'a> Visitor<()> for LanguageItemVisitor<'a> { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { match extract(item.attrs) { Some(value) => { let item_index = self.this.item_refs.find_equiv(&value).map(|x| *x); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 7d8e8f7d6f3..a954c59ff12 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -380,7 +380,7 @@ struct Context<'a> { method_map: typeck::method_map, // Items exported by the crate; used by the missing_doc lint. exported_items: &'a privacy::ExportedItems, - // The id of the current `ast::struct_def` being walked. + // The id of the current `ast::StructDef` being walked. cur_struct_def_id: ast::NodeId, // Whether some ancestor of the current node was marked // #[doc(hidden)]. @@ -569,7 +569,7 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) { ast::ExprWhile(cond, _) => { match cond.node { ast::ExprLit(@codemap::Spanned { - node: ast::lit_bool(true), ..}) => + node: ast::LitBool(true), ..}) => { cx.span_lint(while_true, e.span, "denote infinite loops with loop { ... }"); @@ -623,14 +623,14 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { ast::ExprLit(lit) => { match ty::get(ty::expr_ty(cx.tcx, e)).sty { ty::ty_int(t) => { - let int_type = if t == ast::ty_i { + let int_type = if t == ast::TyI { cx.tcx.sess.targ_cfg.int_type } else { t }; let (min, max) = int_ty_range(int_type); let mut lit_val: i64 = match lit.node { - ast::lit_int(v, _) => v, - ast::lit_uint(v, _) => v as i64, - ast::lit_int_unsuffixed(v) => v, + ast::LitInt(v, _) => v, + ast::LitUint(v, _) => v as i64, + ast::LitIntUnsuffixed(v) => v, _ => fail!() }; if cx.negated_expr_id == e.id { @@ -642,14 +642,14 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { } }, ty::ty_uint(t) => { - let uint_type = if t == ast::ty_u { + let uint_type = if t == ast::TyU { cx.tcx.sess.targ_cfg.uint_type } else { t }; let (min, max) = uint_ty_range(uint_type); let lit_val: u64 = match lit.node { - ast::lit_int(v, _) => v as u64, - ast::lit_uint(v, _) => v, - ast::lit_int_unsuffixed(v) => v as u64, + ast::LitInt(v, _) => v as u64, + ast::LitUint(v, _) => v, + ast::LitIntUnsuffixed(v) => v as u64, _ => fail!() }; if lit_val < min || lit_val > max { @@ -688,23 +688,23 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { // for int & uint, be conservative with the warnings, so that the // warnings are consistent between 32- and 64-bit platforms - fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) { + fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) { match int_ty { - ast::ty_i => (i64::min_value, i64::max_value), - ast::ty_i8 => (i8::min_value as i64, i8::max_value as i64), - ast::ty_i16 => (i16::min_value as i64, i16::max_value as i64), - ast::ty_i32 => (i32::min_value as i64, i32::max_value as i64), - ast::ty_i64 => (i64::min_value, i64::max_value) + ast::TyI => (i64::min_value, i64::max_value), + ast::TyI8 => (i8::min_value as i64, i8::max_value as i64), + ast::TyI16 => (i16::min_value as i64, i16::max_value as i64), + ast::TyI32 => (i32::min_value as i64, i32::max_value as i64), + ast::TyI64 => (i64::min_value, i64::max_value) } } - fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) { + fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) { match uint_ty { - ast::ty_u => (u64::min_value, u64::max_value), - ast::ty_u8 => (u8::min_value as u64, u8::max_value as u64), - ast::ty_u16 => (u16::min_value as u64, u16::max_value as u64), - ast::ty_u32 => (u32::min_value as u64, u32::max_value as u64), - ast::ty_u64 => (u64::min_value, u64::max_value) + ast::TyU => (u64::min_value, u64::max_value), + ast::TyU8 => (u8::min_value as u64, u8::max_value as u64), + ast::TyU16 => (u16::min_value as u64, u16::max_value as u64), + ast::TyU32 => (u32::min_value as u64, u32::max_value as u64), + ast::TyU64 => (u64::min_value, u64::max_value) } } @@ -723,9 +723,9 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { let (min, max) = int_ty_range(int_ty); let lit_val: i64 = match lit.node { ast::ExprLit(li) => match li.node { - ast::lit_int(v, _) => v, - ast::lit_uint(v, _) => v as i64, - ast::lit_int_unsuffixed(v) => v, + ast::LitInt(v, _) => v, + ast::LitUint(v, _) => v as i64, + ast::LitIntUnsuffixed(v) => v, _ => return true }, _ => fail!() @@ -736,9 +736,9 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { let (min, max): (u64, u64) = uint_ty_range(uint_ty); let lit_val: u64 = match lit.node { ast::ExprLit(li) => match li.node { - ast::lit_int(v, _) => v as u64, - ast::lit_uint(v, _) => v, - ast::lit_int_unsuffixed(v) => v as u64, + ast::LitInt(v, _) => v as u64, + ast::LitUint(v, _) => v, + ast::LitIntUnsuffixed(v) => v as u64, _ => return true }, _ => fail!() @@ -758,18 +758,18 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) { } } -fn check_item_ctypes(cx: &Context, it: &ast::item) { +fn check_item_ctypes(cx: &Context, it: &ast::Item) { fn check_ty(cx: &Context, ty: &ast::Ty) { match ty.node { - ast::ty_path(_, _, id) => { + ast::TyPath(_, _, id) => { let def_map = cx.tcx.def_map.borrow(); match def_map.get().get_copy(&id) { - ast::DefPrimTy(ast::ty_int(ast::ty_i)) => { + ast::DefPrimTy(ast::TyInt(ast::TyI)) => { cx.span_lint(ctypes, ty.span, "found rust type `int` in foreign module, while \ libc::c_int or libc::c_long should be used"); } - ast::DefPrimTy(ast::ty_uint(ast::ty_u)) => { + ast::DefPrimTy(ast::TyUint(ast::TyU)) => { cx.span_lint(ctypes, ty.span, "found rust type `uint` in foreign module, while \ libc::c_uint or libc::c_ulong should be used"); @@ -785,12 +785,12 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) { _ => () } } - ast::ty_ptr(ref mt) => { check_ty(cx, mt.ty) } - _ => () + ast::TyPtr(ref mt) => { check_ty(cx, mt.ty) } + _ => {} } } - fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) { + fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) { for input in decl.inputs.iter() { check_ty(cx, input.ty); } @@ -798,13 +798,11 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) { } match it.node { - ast::item_foreign_mod(ref nmod) if !nmod.abis.is_intrinsic() => { + ast::ItemForeignMod(ref nmod) if !nmod.abis.is_intrinsic() => { for ni in nmod.items.iter() { match ni.node { - ast::foreign_item_fn(decl, _) => { - check_foreign_fn(cx, decl); - } - ast::foreign_item_static(t, _) => { check_ty(cx, t); } + ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, decl), + ast::ForeignItemStatic(t, _) => check_ty(cx, t) } } } @@ -854,12 +852,12 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) { } } -fn check_heap_item(cx: &Context, it: &ast::item) { +fn check_heap_item(cx: &Context, it: &ast::Item) { match it.node { - ast::item_fn(..) | - ast::item_ty(..) | - ast::item_enum(..) | - ast::item_struct(..) => check_heap_type(cx, it.span, + ast::ItemFn(..) | + ast::ItemTy(..) | + ast::ItemEnum(..) | + ast::ItemStruct(..) => check_heap_type(cx, it.span, ty::node_id_to_type(cx.tcx, it.id)), _ => () @@ -867,7 +865,7 @@ fn check_heap_item(cx: &Context, it: &ast::item) { // If it's a struct, we also have to check the fields' types match it.node { - ast::item_struct(struct_def, _) => { + ast::ItemStruct(struct_def, _) => { for struct_field in struct_def.fields.iter() { check_heap_type(cx, struct_field.span, ty::node_id_to_type(cx.tcx, @@ -977,7 +975,7 @@ fn check_path_statement(cx: &Context, s: &ast::Stmt) { } } -fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) { +fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) { fn is_camel_case(cx: ty::ctxt, ident: ast::Ident) -> bool { let ident = cx.sess.str_of(ident); assert!(!ident.is_empty()); @@ -999,13 +997,13 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) { } match it.node { - ast::item_ty(..) | ast::item_struct(..) => { + ast::ItemTy(..) | ast::ItemStruct(..) => { check_case(cx, "type", it.ident, it.span) } - ast::item_trait(..) => { + ast::ItemTrait(..) => { check_case(cx, "trait", it.ident, it.span) } - ast::item_enum(ref enum_definition, _) => { + ast::ItemEnum(ref enum_definition, _) => { check_case(cx, "type", it.ident, it.span); for variant in enum_definition.variants.iter() { check_case(cx, "variant", variant.node.name, variant.span); @@ -1015,10 +1013,10 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) { } } -fn check_item_non_uppercase_statics(cx: &Context, it: &ast::item) { +fn check_item_non_uppercase_statics(cx: &Context, it: &ast::Item) { match it.node { // only check static constants - ast::item_static(_, ast::MutImmutable, _) => { + ast::ItemStatic(_, ast::MutImmutable, _) => { let s = cx.tcx.sess.str_of(it.ident); // check for lowercase letters rather than non-uppercase // ones (some scripts don't have a concept of @@ -1112,7 +1110,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) { ast::ExprVstore(e2, ast::ExprVstoreUniq) | ast::ExprVstore(e2, ast::ExprVstoreBox) => { match e2.node { - ast::ExprLit(@codemap::Spanned{node: ast::lit_str(..), ..}) | + ast::ExprLit(@codemap::Spanned{node: ast::LitStr(..), ..}) | ast::ExprVec(..) => VectorAllocation, _ => return } @@ -1182,19 +1180,19 @@ fn check_missing_doc_attrs(cx: &Context, } } -fn check_missing_doc_item(cx: &Context, it: &ast::item) { +fn check_missing_doc_item(cx: &Context, it: &ast::Item) { let desc = match it.node { - ast::item_fn(..) => "a function", - ast::item_mod(..) => "a module", - ast::item_enum(..) => "an enum", - ast::item_struct(..) => "a struct", - ast::item_trait(..) => "a trait", + ast::ItemFn(..) => "a function", + ast::ItemMod(..) => "a module", + ast::ItemEnum(..) => "an enum", + ast::ItemStruct(..) => "a struct", + ast::ItemTrait(..) => "a trait", _ => return }; check_missing_doc_attrs(cx, Some(it.id), it.attrs, it.span, desc); } -fn check_missing_doc_method(cx: &Context, m: &ast::method) { +fn check_missing_doc_method(cx: &Context, m: &ast::Method) { let did = ast::DefId { crate: ast::LOCAL_CRATE, node: m.id @@ -1231,16 +1229,16 @@ fn check_missing_doc_ty_method(cx: &Context, tm: &ast::TypeMethod) { check_missing_doc_attrs(cx, Some(tm.id), tm.attrs, tm.span, "a type method"); } -fn check_missing_doc_struct_field(cx: &Context, sf: &ast::struct_field) { +fn check_missing_doc_struct_field(cx: &Context, sf: &ast::StructField) { match sf.node.kind { - ast::named_field(_, vis) if vis != ast::private => + ast::NamedField(_, vis) if vis != ast::Private => check_missing_doc_attrs(cx, Some(cx.cur_struct_def_id), sf.node.attrs, sf.span, "a struct field"), _ => {} } } -fn check_missing_doc_variant(cx: &Context, v: &ast::variant) { +fn check_missing_doc_variant(cx: &Context, v: &ast::Variant) { check_missing_doc_attrs(cx, Some(v.node.id), v.node.attrs, v.span, "a variant"); } @@ -1345,7 +1343,7 @@ fn check_stability(cx: &Context, e: &ast::Expr) { } impl<'a> Visitor<()> for Context<'a> { - fn visit_item(&mut self, it: &ast::item, _: ()) { + fn visit_item(&mut self, it: &ast::Item, _: ()) { self.with_lint_attrs(it.attrs, |cx| { check_item_ctypes(cx, it); check_item_non_camel_case_types(cx, it); @@ -1360,14 +1358,14 @@ impl<'a> Visitor<()> for Context<'a> { }) } - fn visit_foreign_item(&mut self, it: &ast::foreign_item, _: ()) { + fn visit_foreign_item(&mut self, it: &ast::ForeignItem, _: ()) { self.with_lint_attrs(it.attrs, |cx| { check_attrs_usage(cx, it.attrs); visit::walk_foreign_item(cx, it, ()); }) } - fn visit_view_item(&mut self, i: &ast::view_item, _: ()) { + fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) { self.with_lint_attrs(i.attrs, |cx| { check_attrs_usage(cx, i.attrs); visit::walk_view_item(cx, i, ()); @@ -1414,14 +1412,14 @@ impl<'a> Visitor<()> for Context<'a> { visit::walk_stmt(self, s, ()); } - fn visit_fn(&mut self, fk: &visit::fn_kind, decl: &ast::fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, decl: &ast::FnDecl, body: &ast::Block, span: Span, id: ast::NodeId, _: ()) { let recurse = |this: &mut Context| { visit::walk_fn(this, fk, decl, body, span, id, ()); }; match *fk { - visit::fk_method(_, _, m) => { + visit::FkMethod(_, _, m) => { self.with_lint_attrs(m.attrs, |cx| { check_missing_doc_method(cx, m); check_attrs_usage(cx, m.attrs); @@ -1447,7 +1445,7 @@ impl<'a> Visitor<()> for Context<'a> { } fn visit_struct_def(&mut self, - s: &ast::struct_def, + s: &ast::StructDef, i: ast::Ident, g: &ast::Generics, id: ast::NodeId, @@ -1458,7 +1456,7 @@ impl<'a> Visitor<()> for Context<'a> { self.cur_struct_def_id = old_id; } - fn visit_struct_field(&mut self, s: &ast::struct_field, _: ()) { + fn visit_struct_field(&mut self, s: &ast::StructField, _: ()) { self.with_lint_attrs(s.node.attrs, |cx| { check_missing_doc_struct_field(cx, s); check_attrs_usage(cx, s.node.attrs); @@ -1467,7 +1465,7 @@ impl<'a> Visitor<()> for Context<'a> { }) } - fn visit_variant(&mut self, v: &ast::variant, g: &ast::Generics, _: ()) { + fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics, _: ()) { self.with_lint_attrs(v.node.attrs, |cx| { check_missing_doc_variant(cx, v); check_attrs_usage(cx, v.node.attrs); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 3f82974c8aa..8ffb78f8ac4 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -122,7 +122,7 @@ use syntax::codemap::Span; use syntax::parse::token::special_idents; use syntax::print::pprust::{expr_to_str, block_to_str}; use syntax::{visit, ast_util}; -use syntax::visit::{Visitor,fn_kind}; +use syntax::visit::{Visitor, FnKind}; #[deriving(Eq)] struct Variable(uint); @@ -164,7 +164,7 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str { struct LivenessVisitor; impl Visitor<@IrMaps> for LivenessVisitor { - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, b: &Block, s: Span, n: NodeId, e: @IrMaps) { + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, e: @IrMaps) { visit_fn(self, fk, fd, b, s, n, e); } fn visit_local(&mut self, l: &Local, e: @IrMaps) { visit_local(self, l, e); } @@ -364,7 +364,7 @@ impl IrMaps { } impl Visitor<()> for Liveness { - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, b: &Block, s: Span, n: NodeId, _: ()) { + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } fn visit_local(&mut self, l: &Local, _: ()) { @@ -379,8 +379,8 @@ impl Visitor<()> for Liveness { } fn visit_fn(v: &mut LivenessVisitor, - fk: &visit::fn_kind, - decl: &fn_decl, + fk: &FnKind, + decl: &FnDecl, body: &Block, sp: Span, id: NodeId, @@ -407,16 +407,16 @@ fn visit_fn(v: &mut LivenessVisitor, // Add `this`, whether explicit or implicit. match *fk { - visit::fk_method(_, _, method) => { + visit::FkMethod(_, _, method) => { match method.explicit_self.node { - sty_value(_) | sty_region(..) | sty_box(_) | sty_uniq(_) => { + SelfValue(_) | SelfRegion(..) | SelfBox(_) | SelfUniq(_) => { fn_maps.add_variable(Arg(method.self_id, special_idents::self_)); } - sty_static => {} + SelfStatic => {} } } - visit::fk_item_fn(..) | visit::fk_fn_block(..) => {} + visit::FkItemFn(..) | visit::FkFnBlock(..) => {} } // gather up the various local variables, significant expressions, @@ -932,7 +932,7 @@ impl Liveness { // _______________________________________________________________________ - pub fn compute(&self, decl: &fn_decl, body: &Block) -> LiveNode { + pub fn compute(&self, decl: &FnDecl, body: &Block) -> LiveNode { // if there is a `break` or `again` at the top level, then it's // effectively a return---this only occurs in `for` loops, // where the body is really a closure. @@ -957,7 +957,7 @@ impl Liveness { entry_ln } - pub fn propagate_through_fn_block(&self, _: &fn_decl, blk: &Block) + pub fn propagate_through_fn_block(&self, _: &FnDecl, blk: &Block) -> LiveNode { // the fallthrough exit is only for those cases where we do not // explicitly return: @@ -1554,8 +1554,8 @@ fn check_expr(this: &mut Liveness, expr: &Expr) { } fn check_fn(_v: &Liveness, - _fk: &visit::fn_kind, - _decl: &fn_decl, + _fk: &FnKind, + _decl: &FnDecl, _body: &Block, _sp: Span, _id: NodeId) { @@ -1573,7 +1573,7 @@ impl Liveness { pub fn check_ret(&self, id: NodeId, sp: Span, - _fk: &visit::fn_kind, + _fk: &FnKind, entry_ln: LiveNode) { if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() { // if no_ret_var is live, then we fall off the end of the @@ -1665,7 +1665,7 @@ impl Liveness { if name.len() == 0 || name[0] == ('_' as u8) { None } else { Some(name) } } - pub fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) { + pub fn warn_about_unused_args(&self, decl: &FnDecl, entry_ln: LiveNode) { for arg in decl.inputs.iter() { pat_util::pat_bindings(self.tcx.def_map, arg.pat, diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 0d45a87f3f9..fa83726a464 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -193,7 +193,7 @@ enum UseMode { } impl visit::Visitor<()> for VisitContext { - fn visit_fn(&mut self, fk: &visit::fn_kind, fd: &fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { compute_modes_for_fn(self, fk, fd, b, s, n); } @@ -248,8 +248,8 @@ fn compute_modes_for_local<'a>(cx: &mut VisitContext, } fn compute_modes_for_fn(cx: &mut VisitContext, - fk: &visit::fn_kind, - decl: &fn_decl, + fk: &visit::FnKind, + decl: &FnDecl, body: &Block, span: Span, id: NodeId) { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 9b297aa8792..767ca7fcc70 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -50,20 +50,20 @@ struct ParentVisitor { } impl Visitor<()> for ParentVisitor { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { self.parents.insert(item.id, self.curparent); let prev = self.curparent; match item.node { - ast::item_mod(..) => { self.curparent = item.id; } + ast::ItemMod(..) => { self.curparent = item.id; } // Enum variants are parented to the enum definition itself beacuse // they inherit privacy - ast::item_enum(ref def, _) => { + ast::ItemEnum(ref def, _) => { for variant in def.variants.iter() { // If variants are private, then their logical "parent" is // the enclosing module because everyone in the enclosing // module can still use the private variant - if variant.node.vis == ast::private { + if variant.node.vis == ast::Private { self.parents.insert(variant.node.id, self.curparent); // Otherwise, if the variant is public, then the parent is @@ -80,11 +80,11 @@ impl Visitor<()> for ParentVisitor { // method to the root. In this case, if the trait is private, then // parent all the methods to the trait to indicate that they're // private. - ast::item_trait(_, _, ref methods) if item.vis != ast::public => { + ast::ItemTrait(_, _, ref methods) if item.vis != ast::Public => { for m in methods.iter() { match *m { - ast::provided(ref m) => self.parents.insert(m.id, item.id), - ast::required(ref m) => self.parents.insert(m.id, item.id), + ast::Provided(ref m) => self.parents.insert(m.id, item.id), + ast::Required(ref m) => self.parents.insert(m.id, item.id), }; } } @@ -95,12 +95,12 @@ impl Visitor<()> for ParentVisitor { self.curparent = prev; } - fn visit_foreign_item(&mut self, a: &ast::foreign_item, _: ()) { + fn visit_foreign_item(&mut self, a: &ast::ForeignItem, _: ()) { self.parents.insert(a.id, self.curparent); visit::walk_foreign_item(self, a, ()); } - fn visit_fn(&mut self, a: &visit::fn_kind, b: &ast::fn_decl, + fn visit_fn(&mut self, a: &visit::FnKind, b: &ast::FnDecl, c: &ast::Block, d: Span, id: ast::NodeId, _: ()) { // We already took care of some trait methods above, otherwise things // like impl methods and pub trait methods are parented to the @@ -111,7 +111,7 @@ impl Visitor<()> for ParentVisitor { visit::walk_fn(self, a, b, c, d, id, ()); } - fn visit_struct_def(&mut self, s: &ast::struct_def, i: ast::Ident, + fn visit_struct_def(&mut self, s: &ast::StructDef, i: ast::Ident, g: &ast::Generics, n: ast::NodeId, _: ()) { // Struct constructors are parented to their struct definitions because // they essentially are the struct definitions. @@ -124,14 +124,14 @@ impl Visitor<()> for ParentVisitor { // all the fields. for field in s.fields.iter() { let vis = match field.node.kind { - ast::named_field(_, vis) => vis, - ast::unnamed_field => continue + ast::NamedField(_, vis) => vis, + ast::UnnamedField => continue }; // Private fields are scoped to this module, so parent them directly // to the module instead of the struct. This is similar to the case // of private enum variants. - if vis == ast::private { + if vis == ast::Private { self.parents.insert(field.node.id, self.curparent); // Otherwise public fields are scoped to the visibility of the @@ -196,9 +196,9 @@ impl<'a> EmbargoVisitor<'a> { } impl<'a> Visitor<()> for EmbargoVisitor<'a> { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { let orig_all_pub = self.prev_public; - self.prev_public = orig_all_pub && item.vis == ast::public; + self.prev_public = orig_all_pub && item.vis == ast::Public; if self.prev_public { self.public_items.insert(item.id); } @@ -207,11 +207,11 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { match item.node { // impls/extern blocks do not break the "public chain" because they // cannot have visibility qualifiers on them anyway - ast::item_impl(..) | ast::item_foreign_mod(..) => {} + ast::ItemImpl(..) | ast::ItemForeignMod(..) => {} // Traits are a little special in that even if they themselves are // not public they may still be exported. - ast::item_trait(..) => { + ast::ItemTrait(..) => { self.prev_exported = self.exported_trait(item.id); } @@ -219,7 +219,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { // `pub` is explicitly listed. _ => { self.prev_exported = - (orig_all_exported && item.vis == ast::public) || + (orig_all_exported && item.vis == ast::Public) || self.reexports.contains(&item.id); } } @@ -230,9 +230,9 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { match item.node { // Enum variants inherit from their parent, so if the enum is // public all variants are public unless they're explicitly priv - ast::item_enum(ref def, _) if public_first => { + ast::ItemEnum(ref def, _) if public_first => { for variant in def.variants.iter() { - if variant.node.vis != ast::private { + if variant.node.vis != ast::Private { self.exported_items.insert(variant.node.id); } } @@ -257,9 +257,9 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { // undefined symbols at linkage time if this case is not handled. // // * Private trait impls for private types can be completely ignored - ast::item_impl(_, _, ref ty, ref methods) => { + ast::ItemImpl(_, _, ref ty, ref methods) => { let public_ty = match ty.node { - ast::ty_path(_, _, id) => { + ast::TyPath(_, _, id) => { let def_map = self.tcx.def_map.borrow(); match def_map.get().get_copy(&id) { ast::DefPrimTy(..) => true, @@ -281,9 +281,9 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { if public_ty || public_trait { for method in methods.iter() { let meth_public = match method.explicit_self.node { - ast::sty_static => public_ty, + ast::SelfStatic => public_ty, _ => true, - } && method.vis == ast::public; + } && method.vis == ast::Public; if meth_public || tr.is_some() { self.exported_items.insert(method.id); } @@ -293,14 +293,14 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { // Default methods on traits are all public so long as the trait // is public - ast::item_trait(_, _, ref methods) if public_first => { + ast::ItemTrait(_, _, ref methods) if public_first => { for method in methods.iter() { match *method { - ast::provided(ref m) => { + ast::Provided(ref m) => { debug!("provided {}", m.id); self.exported_items.insert(m.id); } - ast::required(ref m) => { + ast::Required(ref m) => { debug!("required {}", m.id); self.exported_items.insert(m.id); } @@ -309,7 +309,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { } // Struct constructors are public if the struct is all public. - ast::item_struct(ref def, _) if public_first => { + ast::ItemStruct(ref def, _) if public_first => { match def.ctor_id { Some(id) => { self.exported_items.insert(id); } None => {} @@ -325,13 +325,13 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { self.prev_public = orig_all_pub; } - fn visit_foreign_item(&mut self, a: &ast::foreign_item, _: ()) { - if self.prev_exported && a.vis == ast::public { + fn visit_foreign_item(&mut self, a: &ast::ForeignItem, _: ()) { + if self.prev_exported && a.vis == ast::Public { self.exported_items.insert(a.id); } } - fn visit_mod(&mut self, m: &ast::_mod, _sp: Span, id: ast::NodeId, _: ()) { + fn visit_mod(&mut self, m: &ast::Mod, _sp: Span, id: ast::NodeId, _: ()) { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_exported { @@ -402,7 +402,7 @@ impl<'a> PrivacyVisitor<'a> { None => { debug!("privacy - found a method {:?}", meth.vis); - if meth.vis == ast::public { + if meth.vis == ast::Public { Allowable } else { ExternallyDenied @@ -449,30 +449,30 @@ impl<'a> PrivacyVisitor<'a> { // invocation. // FIXME(#10573) is this the right behavior? Why not consider // where the method was defined? - Some(&ast_map::node_method(ref m, imp, _)) => { + Some(&ast_map::NodeMethod(ref m, imp, _)) => { match ty::impl_trait_ref(self.tcx, imp) { Some(..) => return Allowable, - _ if m.vis == ast::public => return Allowable, + _ if m.vis == ast::Public => return Allowable, _ => m.vis } } - Some(&ast_map::node_trait_method(..)) => { + Some(&ast_map::NodeTraitMethod(..)) => { return Allowable; } // This is not a method call, extract the visibility as one // would normally look at it - Some(&ast_map::node_item(it, _)) => it.vis, - Some(&ast_map::node_foreign_item(_, _, v, _)) => v, - Some(&ast_map::node_variant(ref v, _, _)) => { + Some(&ast_map::NodeItem(it, _)) => it.vis, + Some(&ast_map::NodeForeignItem(_, _, v, _)) => v, + Some(&ast_map::NodeVariant(ref v, _, _)) => { // sadly enum variants still inherit visibility, so only // break out of this is explicitly private - if v.node.vis == ast::private { break } - ast::public // need to move up a level (to the enum) + if v.node.vis == ast::Private { break } + ast::Public // need to move up a level (to the enum) } - _ => ast::public, + _ => ast::Public, }; - if vis != ast::public { break } + if vis != ast::Public { break } // if we've reached the root, then everything was allowable and this // access is public. if closest_private_id == ast::CRATE_NODE_ID { return Allowable } @@ -540,10 +540,10 @@ impl<'a> PrivacyVisitor<'a> { } let items = self.tcx.items.borrow(); match items.get().find(&id) { - Some(&ast_map::node_item(item, _)) => { + Some(&ast_map::NodeItem(item, _)) => { let desc = match item.node { - ast::item_mod(..) => "module", - ast::item_trait(..) => "trait", + ast::ItemMod(..) => "module", + ast::ItemTrait(..) => "trait", _ => return false, }; let msg = format!("{} `{}` is private", desc, @@ -565,7 +565,7 @@ impl<'a> PrivacyVisitor<'a> { for field in fields.iter() { if field.name != ident.name { continue; } // public fields are public everywhere - if field.vis != ast::private { break } + if field.vis != ast::Private { break } if !is_local(field.id) || !self.private_accessible(field.id.node) { self.tcx.sess.span_err(span, format!("field `{}` is private", @@ -638,7 +638,7 @@ impl<'a> PrivacyVisitor<'a> { } impl<'a> Visitor<()> for PrivacyVisitor<'a> { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { // Do not check privacy inside items with the resolve_unexported // attribute. This is used for the test runner. if attr::contains_name(item.attrs, "!resolve_unexported") { @@ -722,15 +722,14 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> { visit::walk_expr(self, expr, ()); } - fn visit_view_item(&mut self, a: &ast::view_item, _: ()) { + fn visit_view_item(&mut self, a: &ast::ViewItem, _: ()) { match a.node { - ast::view_item_extern_mod(..) => {} - ast::view_item_use(ref uses) => { + ast::ViewItemExternMod(..) => {} + ast::ViewItemUse(ref uses) => { for vpath in uses.iter() { match vpath.node { - ast::view_path_simple(..) | - ast::view_path_glob(..) => {} - ast::view_path_list(_, ref list, _) => { + ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {} + ast::ViewPathList(_, ref list, _) => { for pid in list.iter() { debug!("privacy - list {}", pid.node.id); let seg = ast::PathSegment { @@ -796,7 +795,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> { visit::walk_pat(self, pattern, ()); } - fn visit_foreign_item(&mut self, fi: &ast::foreign_item, _: ()) { + fn visit_foreign_item(&mut self, fi: &ast::ForeignItem, _: ()) { self.in_foreign = true; visit::walk_foreign_item(self, fi, ()); self.in_foreign = false; @@ -818,7 +817,7 @@ struct SanePrivacyVisitor { } impl Visitor<()> for SanePrivacyVisitor { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { if self.in_fn { self.check_all_inherited(item); } else { @@ -826,14 +825,14 @@ impl Visitor<()> for SanePrivacyVisitor { } let orig_in_fn = util::replace(&mut self.in_fn, match item.node { - ast::item_mod(..) => false, // modules turn privacy back on + ast::ItemMod(..) => false, // modules turn privacy back on _ => self.in_fn, // otherwise we inherit }); visit::walk_item(self, item, ()); self.in_fn = orig_in_fn; } - fn visit_fn(&mut self, fk: &visit::fn_kind, fd: &ast::fn_decl, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl, b: &ast::Block, s: Span, n: ast::NodeId, _: ()) { // This catches both functions and methods let orig_in_fn = util::replace(&mut self.in_fn, true); @@ -847,42 +846,42 @@ impl SanePrivacyVisitor { /// ensures that there are no extraneous qualifiers that don't actually do /// anything. In theory these qualifiers wouldn't parse, but that may happen /// later on down the road... - fn check_sane_privacy(&self, item: &ast::item) { + fn check_sane_privacy(&self, item: &ast::Item) { let tcx = self.tcx; - let check_inherited = |sp: Span, vis: ast::visibility, note: &str| { - if vis != ast::inherited { + let check_inherited = |sp: Span, vis: ast::Visibility, note: &str| { + if vis != ast::Inherited { tcx.sess.span_err(sp, "unnecessary visibility qualifier"); if note.len() > 0 { tcx.sess.span_note(sp, note); } } }; - let check_not_priv = |sp: Span, vis: ast::visibility, note: &str| { - if vis == ast::private { + let check_not_priv = |sp: Span, vis: ast::Visibility, note: &str| { + if vis == ast::Private { tcx.sess.span_err(sp, "unnecessary `priv` qualifier"); if note.len() > 0 { tcx.sess.span_note(sp, note); } } }; - let check_struct = |def: &@ast::struct_def| { + let check_struct = |def: &@ast::StructDef| { for f in def.fields.iter() { match f.node.kind { - ast::named_field(_, ast::public) => { + ast::NamedField(_, ast::Public) => { tcx.sess.span_err(f.span, "unnecessary `pub` \ visibility"); } - ast::named_field(_, ast::private) => { + ast::NamedField(_, ast::Private) => { // Fields should really be private by default... } - ast::named_field(..) | ast::unnamed_field => {} + ast::NamedField(..) | ast::UnnamedField => {} } } }; match item.node { // implementations of traits don't need visibility qualifiers because // that's controlled by having the trait in scope. - ast::item_impl(_, Some(..), _, ref methods) => { + ast::ItemImpl(_, Some(..), _, ref methods) => { check_inherited(item.span, item.vis, "visibility qualifiers have no effect on trait \ impls"); @@ -891,7 +890,7 @@ impl SanePrivacyVisitor { } } - ast::item_impl(_, _, _, ref methods) => { + ast::ItemImpl(_, _, _, ref methods) => { check_inherited(item.span, item.vis, "place qualifiers on individual methods instead"); for i in methods.iter() { @@ -899,7 +898,7 @@ impl SanePrivacyVisitor { default"); } } - ast::item_foreign_mod(ref fm) => { + ast::ItemForeignMod(ref fm) => { check_inherited(item.span, item.vis, "place qualifiers on individual functions \ instead"); @@ -909,48 +908,48 @@ impl SanePrivacyVisitor { } } - ast::item_enum(ref def, _) => { + ast::ItemEnum(ref def, _) => { for v in def.variants.iter() { match v.node.vis { - ast::public => { - if item.vis == ast::public { + ast::Public => { + if item.vis == ast::Public { tcx.sess.span_err(v.span, "unnecessary `pub` \ visibility"); } } - ast::private => { - if item.vis != ast::public { + ast::Private => { + if item.vis != ast::Public { tcx.sess.span_err(v.span, "unnecessary `priv` \ visibility"); } } - ast::inherited => {} + ast::Inherited => {} } match v.node.kind { - ast::struct_variant_kind(ref s) => check_struct(s), - ast::tuple_variant_kind(..) => {} + ast::StructVariantKind(ref s) => check_struct(s), + ast::TupleVariantKind(..) => {} } } } - ast::item_struct(ref def, _) => check_struct(def), + ast::ItemStruct(ref def, _) => check_struct(def), - ast::item_trait(_, _, ref methods) => { + ast::ItemTrait(_, _, ref methods) => { for m in methods.iter() { match *m { - ast::provided(ref m) => { + ast::Provided(ref m) => { check_inherited(m.span, m.vis, "unnecessary visibility"); } - ast::required(..) => {} + ast::Required(..) => {} } } } - ast::item_static(..) | - ast::item_fn(..) | ast::item_mod(..) | ast::item_ty(..) | - ast::item_mac(..) => { + ast::ItemStatic(..) | + ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) | + ast::ItemMac(..) => { check_not_priv(item.span, item.vis, "items are private by \ default"); } @@ -959,58 +958,58 @@ impl SanePrivacyVisitor { /// When inside of something like a function or a method, visibility has no /// control over anything so this forbids any mention of any visibility - fn check_all_inherited(&self, item: &ast::item) { + fn check_all_inherited(&self, item: &ast::Item) { let tcx = self.tcx; - let check_inherited = |sp: Span, vis: ast::visibility| { - if vis != ast::inherited { + let check_inherited = |sp: Span, vis: ast::Visibility| { + if vis != ast::Inherited { tcx.sess.span_err(sp, "visibility has no effect inside functions"); } }; - let check_struct = |def: &@ast::struct_def| { + let check_struct = |def: &@ast::StructDef| { for f in def.fields.iter() { match f.node.kind { - ast::named_field(_, p) => check_inherited(f.span, p), - ast::unnamed_field => {} + ast::NamedField(_, p) => check_inherited(f.span, p), + ast::UnnamedField => {} } } }; check_inherited(item.span, item.vis); match item.node { - ast::item_impl(_, _, _, ref methods) => { + ast::ItemImpl(_, _, _, ref methods) => { for m in methods.iter() { check_inherited(m.span, m.vis); } } - ast::item_foreign_mod(ref fm) => { + ast::ItemForeignMod(ref fm) => { for i in fm.items.iter() { check_inherited(i.span, i.vis); } } - ast::item_enum(ref def, _) => { + ast::ItemEnum(ref def, _) => { for v in def.variants.iter() { check_inherited(v.span, v.node.vis); match v.node.kind { - ast::struct_variant_kind(ref s) => check_struct(s), - ast::tuple_variant_kind(..) => {} + ast::StructVariantKind(ref s) => check_struct(s), + ast::TupleVariantKind(..) => {} } } } - ast::item_struct(ref def, _) => check_struct(def), + ast::ItemStruct(ref def, _) => check_struct(def), - ast::item_trait(_, _, ref methods) => { + ast::ItemTrait(_, _, ref methods) => { for m in methods.iter() { match *m { - ast::required(..) => {} - ast::provided(ref m) => check_inherited(m.span, m.vis), + ast::Required(..) => {} + ast::Provided(ref m) => check_inherited(m.span, m.vis), } } } - ast::item_static(..) | - ast::item_fn(..) | ast::item_mod(..) | ast::item_ty(..) | - ast::item_mac(..) => {} + ast::ItemStatic(..) | + ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) | + ast::ItemMac(..) => {} } } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 3165527b326..b95901b8d78 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -44,21 +44,21 @@ fn generics_require_inlining(generics: &ast::Generics) -> bool { // Returns true if the given item must be inlined because it may be // monomorphized or it was marked with `#[inline]`. This will only return // true for functions. -fn item_might_be_inlined(item: &ast::item) -> bool { +fn item_might_be_inlined(item: &ast::Item) -> bool { if attributes_specify_inlining(item.attrs) { return true } match item.node { - ast::item_impl(ref generics, _, _, _) | - ast::item_fn(_, _, _, ref generics, _) => { + ast::ItemImpl(ref generics, _, _, _) | + ast::ItemFn(_, _, _, ref generics, _) => { generics_require_inlining(generics) } _ => false, } } -fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::method, +fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::Method, impl_src: ast::DefId) -> bool { if attributes_specify_inlining(method.attrs) || generics_require_inlining(&method.generics) { @@ -68,7 +68,7 @@ fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::method, { let items = tcx.items.borrow(); match items.get().find(&impl_src.node) { - Some(&ast_map::node_item(item, _)) => { + Some(&ast_map::NodeItem(item, _)) => { item_might_be_inlined(item) } Some(..) | None => { @@ -187,7 +187,7 @@ impl Visitor<()> for MarkSymbolVisitor { visit::walk_expr(self, expr, ()) } - fn visit_item(&mut self, _item: &ast::item, _: ()) { + fn visit_item(&mut self, _item: &ast::Item, _: ()) { // Do not recurse into items. These items will be added to the worklist // and recursed into manually if necessary. } @@ -215,19 +215,19 @@ impl ReachableContext { let node_id = def_id.node; let items = tcx.items.borrow(); match items.get().find(&node_id) { - Some(&ast_map::node_item(item, _)) => { + Some(&ast_map::NodeItem(item, _)) => { match item.node { - ast::item_fn(..) => item_might_be_inlined(item), + ast::ItemFn(..) => item_might_be_inlined(item), _ => false, } } - Some(&ast_map::node_trait_method(trait_method, _, _)) => { + Some(&ast_map::NodeTraitMethod(trait_method, _, _)) => { match *trait_method { - ast::required(_) => false, - ast::provided(_) => true, + ast::Required(_) => false, + ast::Provided(_) => true, } } - Some(&ast_map::node_method(method, impl_did, _)) => { + Some(&ast_map::NodeMethod(method, impl_did, _)) => { if generics_require_inlining(&method.generics) || attributes_specify_inlining(method.attrs) { true @@ -236,9 +236,9 @@ impl ReachableContext { // impl require inlining, this method does too. assert!(impl_did.crate == ast::LOCAL_CRATE); match items.get().find(&impl_did.node) { - Some(&ast_map::node_item(item, _)) => { + Some(&ast_map::NodeItem(item, _)) => { match item.node { - ast::item_impl(ref generics, _, _, _) => { + ast::ItemImpl(ref generics, _, _, _) => { generics_require_inlining(generics) } _ => false @@ -308,7 +308,7 @@ impl ReachableContext { } } - fn propagate_node(&self, node: &ast_map::ast_node, + fn propagate_node(&self, node: &ast_map::Node, search_item: ast::NodeId, visitor: &mut MarkSymbolVisitor) { if !self.tcx.sess.building_library.get() { @@ -318,9 +318,9 @@ impl ReachableContext { // but all other rust-only interfaces can be private (they will not // participate in linkage after this product is produced) match *node { - ast_map::node_item(item, _) => { + ast_map::NodeItem(item, _) => { match item.node { - ast::item_fn(_, ast::extern_fn, _, _, _) => { + ast::ItemFn(_, ast::ExternFn, _, _, _) => { let mut reachable_symbols = self.reachable_symbols.borrow_mut(); reachable_symbols.get().insert(search_item); @@ -340,9 +340,9 @@ impl ReachableContext { } match *node { - ast_map::node_item(item, _) => { + ast_map::NodeItem(item, _) => { match item.node { - ast::item_fn(_, _, _, _, search_block) => { + ast::ItemFn(_, _, _, _, search_block) => { if item_might_be_inlined(item) { visit::walk_block(visitor, search_block, ()) } @@ -350,7 +350,7 @@ impl ReachableContext { // Statics with insignificant addresses are not reachable // because they're inlined specially into all other crates. - ast::item_static(..) => { + ast::ItemStatic(..) => { if attr::contains_name(item.attrs, "address_insignificant") { let mut reachable_symbols = @@ -362,10 +362,10 @@ impl ReachableContext { // These are normal, nothing reachable about these // inherently and their children are already in the // worklist, as determined by the privacy pass - ast::item_ty(..) | - ast::item_mod(..) | ast::item_foreign_mod(..) | - ast::item_impl(..) | ast::item_trait(..) | - ast::item_struct(..) | ast::item_enum(..) => {} + ast::ItemTy(..) | + ast::ItemMod(..) | ast::ItemForeignMod(..) | + ast::ItemImpl(..) | ast::ItemTrait(..) | + ast::ItemStruct(..) | ast::ItemEnum(..) => {} _ => { self.tcx.sess.span_bug(item.span, @@ -374,25 +374,25 @@ impl ReachableContext { } } } - ast_map::node_trait_method(trait_method, _, _) => { + ast_map::NodeTraitMethod(trait_method, _, _) => { match *trait_method { - ast::required(..) => { + ast::Required(..) => { // Keep going, nothing to get exported } - ast::provided(ref method) => { + ast::Provided(ref method) => { visit::walk_block(visitor, method.body, ()) } } } - ast_map::node_method(method, did, _) => { + ast_map::NodeMethod(method, did, _) => { if method_might_be_inlined(self.tcx, method, did) { visit::walk_block(visitor, method.body, ()) } } // Nothing to recurse on for these - ast_map::node_foreign_item(..) | - ast_map::node_variant(..) | - ast_map::node_struct_ctor(..) => {} + ast_map::NodeForeignItem(..) | + ast_map::NodeVariant(..) | + ast_map::NodeStructCtor(..) => {} _ => { let ident_interner = token::get_ident_interner(); let desc = ast_map::node_id_to_str(self.tcx.items, diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 05d9ee42afa..ef755b12d15 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -29,8 +29,8 @@ use std::cell::RefCell; use std::hashmap::{HashMap, HashSet}; use syntax::codemap::Span; use syntax::{ast, visit}; -use syntax::visit::{Visitor,fn_kind}; -use syntax::ast::{Block,item,fn_decl,NodeId,Arm,Pat,Stmt,Expr,Local}; +use syntax::visit::{Visitor, FnKind}; +use syntax::ast::{Block, Item, FnDecl, NodeId, Arm, Pat, Stmt, Expr, Local}; /** The region maps encode information about region relationships. @@ -425,7 +425,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, } fn resolve_item(visitor: &mut RegionResolutionVisitor, - item: &ast::item, + item: &ast::Item, cx: Context) { // Items create a new outer block scope as far as we're concerned. let new_cx = Context {var_parent: None, parent: None, ..cx}; @@ -433,8 +433,8 @@ fn resolve_item(visitor: &mut RegionResolutionVisitor, } fn resolve_fn(visitor: &mut RegionResolutionVisitor, - fk: &visit::fn_kind, - decl: &ast::fn_decl, + fk: &FnKind, + decl: &ast::FnDecl, body: &ast::Block, sp: Span, id: ast::NodeId, @@ -453,7 +453,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor, var_parent: Some(body.id), ..cx}; match *fk { - visit::fk_method(_, _, method) => { + visit::FkMethod(_, _, method) => { visitor.region_maps.record_parent(method.self_id, body.id); } _ => {} @@ -463,13 +463,10 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor, // The body of the fn itself is either a root scope (top-level fn) // or it continues with the inherited scope (closures). let body_cx = match *fk { - visit::fk_item_fn(..) | - visit::fk_method(..) => { + visit::FkItemFn(..) | visit::FkMethod(..) => { Context {parent: None, var_parent: None, ..cx} } - visit::fk_fn_block(..) => { - cx - } + visit::FkFnBlock(..) => cx }; visitor.visit_block(body, body_cx); } @@ -480,11 +477,11 @@ impl Visitor<Context> for RegionResolutionVisitor { resolve_block(self, b, cx); } - fn visit_item(&mut self, i: &item, cx: Context) { + fn visit_item(&mut self, i: &Item, cx: Context) { resolve_item(self, i, cx); } - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, cx: Context) { resolve_fn(self, fk, fd, b, s, n, cx); } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index e4d816b91bd..cd190dc999b 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -21,7 +21,7 @@ use syntax::ast; use syntax::ast_util::{def_id_of_def, local_def, mtwt_resolve}; use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method}; use syntax::parse::token; -use syntax::parse::token::{ident_interner, interner_get}; +use syntax::parse::token::{IdentInterner, interner_get}; use syntax::parse::token::special_idents; use syntax::print::pprust::path_to_str; use syntax::codemap::{Span, DUMMY_SP, Pos}; @@ -133,11 +133,11 @@ enum NameDefinition { enum SelfBinding { NoSelfBinding, - HasSelfBinding(NodeId, explicit_self) + HasSelfBinding(NodeId, ExplicitSelf) } impl Visitor<()> for Resolver { - fn visit_item(&mut self, item: &item, _: ()) { + fn visit_item(&mut self, item: &Item, _: ()) { self.resolve_item(item); } fn visit_arm(&mut self, arm: &Arm, _: ()) { @@ -735,13 +735,11 @@ fn NameBindings() -> NameBindings { /// Interns the names of the primitive types. struct PrimitiveTypeTable { - primitive_types: HashMap<Name,prim_ty>, + primitive_types: HashMap<Name, PrimTy>, } impl PrimitiveTypeTable { - fn intern(&mut self, - string: &str, - primitive_type: prim_ty) { + fn intern(&mut self, string: &str, primitive_type: PrimTy) { self.primitive_types.insert(token::intern(string), primitive_type); } } @@ -751,21 +749,21 @@ fn PrimitiveTypeTable() -> PrimitiveTypeTable { primitive_types: HashMap::new() }; - table.intern("bool", ty_bool); - table.intern("char", ty_char); - table.intern("f32", ty_float(ty_f32)); - table.intern("f64", ty_float(ty_f64)); - table.intern("int", ty_int(ty_i)); - table.intern("i8", ty_int(ty_i8)); - table.intern("i16", ty_int(ty_i16)); - table.intern("i32", ty_int(ty_i32)); - table.intern("i64", ty_int(ty_i64)); - table.intern("str", ty_str); - table.intern("uint", ty_uint(ty_u)); - table.intern("u8", ty_uint(ty_u8)); - table.intern("u16", ty_uint(ty_u16)); - table.intern("u32", ty_uint(ty_u32)); - table.intern("u64", ty_uint(ty_u64)); + table.intern("bool", TyBool); + table.intern("char", TyChar); + table.intern("f32", TyFloat(TyF32)); + table.intern("f64", TyFloat(TyF64)); + table.intern("int", TyInt(TyI)); + table.intern("i8", TyInt(TyI8)); + table.intern("i16", TyInt(TyI16)); + table.intern("i32", TyInt(TyI32)); + table.intern("i64", TyInt(TyI64)); + table.intern("str", TyStr); + table.intern("uint", TyUint(TyU)); + table.intern("u8", TyUint(TyU8)); + table.intern("u16", TyUint(TyU16)); + table.intern("u32", TyUint(TyU32)); + table.intern("u64", TyUint(TyU64)); return table; } @@ -841,7 +839,7 @@ struct Resolver { session: @Session, lang_items: LanguageItems, - intr: @ident_interner, + intr: @IdentInterner, graph_root: @NameBindings, @@ -898,12 +896,12 @@ struct BuildReducedGraphVisitor<'a> { impl<'a> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'a> { - fn visit_item(&mut self, item: &item, context: ReducedGraphParent) { + fn visit_item(&mut self, item: &Item, context: ReducedGraphParent) { let p = self.resolver.build_reduced_graph_for_item(item, context); visit::walk_item(self, item, p); } - fn visit_foreign_item(&mut self, foreign_item: &foreign_item, + fn visit_foreign_item(&mut self, foreign_item: &ForeignItem, context: ReducedGraphParent) { self.resolver.build_reduced_graph_for_foreign_item(foreign_item, context, @@ -913,7 +911,7 @@ impl<'a> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'a> { }) } - fn visit_view_item(&mut self, view_item: &view_item, context: ReducedGraphParent) { + fn visit_view_item(&mut self, view_item: &ViewItem, context: ReducedGraphParent) { self.resolver.build_reduced_graph_for_view_item(view_item, context); } @@ -927,7 +925,7 @@ impl<'a> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'a> { struct UnusedImportCheckVisitor<'a> { resolver: &'a Resolver } impl<'a> Visitor<()> for UnusedImportCheckVisitor<'a> { - fn visit_view_item(&mut self, vi: &view_item, _: ()) { + fn visit_view_item(&mut self, vi: &ViewItem, _: ()) { self.resolver.check_for_item_unused_imports(vi); visit::walk_view_item(self, vi, ()); } @@ -1141,16 +1139,16 @@ impl Resolver { /// Constructs the reduced graph for one item. fn build_reduced_graph_for_item(&mut self, - item: &item, - parent: ReducedGraphParent) - -> ReducedGraphParent + item: &Item, + parent: ReducedGraphParent) + -> ReducedGraphParent { let ident = item.ident; let sp = item.span; - let is_public = item.vis == ast::public; + let is_public = item.vis == ast::Public; match item.node { - item_mod(..) => { + ItemMod(..) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateModules, sp); @@ -1160,16 +1158,16 @@ impl Resolver { Some(def_id), NormalModuleKind, false, - item.vis == ast::public, + item.vis == ast::Public, sp); ModuleReducedGraphParent(name_bindings.get_module()) } - item_foreign_mod(..) => parent, + ItemForeignMod(..) => parent, // These items live in the value namespace. - item_static(_, m, _) => { + ItemStatic(_, m, _) => { let (name_bindings, _) = self.add_child(ident, parent, ForbidDuplicateValues, sp); let mutbl = m == ast::MutMutable; @@ -1178,7 +1176,7 @@ impl Resolver { (DefStatic(local_def(item.id), mutbl), sp, is_public); parent } - item_fn(_, purity, _, _, _) => { + ItemFn(_, purity, _, _, _) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateValues, sp); @@ -1188,7 +1186,7 @@ impl Resolver { } // These items live in the type namespace. - item_ty(..) => { + ItemTy(..) => { let (name_bindings, _) = self.add_child(ident, parent, ForbidDuplicateTypes, sp); @@ -1197,7 +1195,7 @@ impl Resolver { parent } - item_enum(ref enum_definition, _) => { + ItemEnum(ref enum_definition, _) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateTypes, sp); @@ -1215,7 +1213,7 @@ impl Resolver { } // These items live in both the type and value namespaces. - item_struct(struct_def, _) => { + ItemStruct(struct_def, _) => { // Adding to both Type and Value namespaces or just Type? let (forbid, ctor_id) = match struct_def.ctor_id { Some(ctor_id) => (ForbidDuplicateTypesAndValues, Some(ctor_id)), @@ -1241,7 +1239,7 @@ impl Resolver { new_parent } - item_impl(_, None, ty, ref methods) => { + ItemImpl(_, None, ty, ref methods) => { // If this implements an anonymous trait, then add all the // methods within to a new module, if the type was defined // within this module. @@ -1252,7 +1250,7 @@ impl Resolver { // Create the module and add all methods. match ty.node { - ty_path(ref path, _, _) if path.segments.len() == 1 => { + TyPath(ref path, _, _) if path.segments.len() == 1 => { let name = path_to_ident(path); let existing_parent_opt = { @@ -1305,7 +1303,7 @@ impl Resolver { ForbidDuplicateValues, method.span); let def = match method.explicit_self.node { - sty_static => { + SelfStatic => { // Static methods become // `def_static_method`s. DefStaticMethod(local_def(method.id), @@ -1320,7 +1318,7 @@ impl Resolver { } }; - let is_public = method.vis == ast::public; + let is_public = method.vis == ast::Public; method_name_bindings.define_value(def, method.span, is_public); @@ -1332,9 +1330,9 @@ impl Resolver { parent } - item_impl(_, Some(_), _, _) => parent, + ItemImpl(_, Some(_), _, _) => parent, - item_trait(_, _, ref methods) => { + ItemTrait(_, _, ref methods) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateTypes, sp); @@ -1344,7 +1342,7 @@ impl Resolver { Some(local_def(item.id)), TraitModuleKind, false, - item.vis == ast::public, + item.vis == ast::Public, sp); let module_parent = ModuleReducedGraphParent(name_bindings. get_module()); @@ -1358,7 +1356,7 @@ impl Resolver { // Add it as a name in the trait module. let def = match ty_m.explicit_self.node { - sty_static => { + SelfStatic => { // Static methods become `def_static_method`s. DefStaticMethod(local_def(ty_m.id), FromTrait(local_def(item.id)), @@ -1380,7 +1378,7 @@ impl Resolver { // Add it to the trait info if not static. match ty_m.explicit_self.node { - sty_static => {} + SelfStatic => {} _ => { method_names.insert(ident.name, ()); } @@ -1403,7 +1401,7 @@ impl Resolver { new_parent } - item_mac(..) => { + ItemMac(..) => { fail!("item macros unimplemented") } } @@ -1412,7 +1410,7 @@ impl Resolver { // Constructs the reduced graph for one variant. Variants exist in the // type and/or value namespaces. fn build_reduced_graph_for_variant(&mut self, - variant: &variant, + variant: &Variant, item_id: DefId, parent: ReducedGraphParent, parent_public: bool) { @@ -1420,17 +1418,17 @@ impl Resolver { // XXX: this is unfortunate to have to do this privacy calculation // here. This should be living in middle::privacy, but it's // necessary to keep around in some form becaues of glob imports... - let is_public = parent_public && variant.node.vis != ast::private; + let is_public = parent_public && variant.node.vis != ast::Private; match variant.node.kind { - tuple_variant_kind(_) => { + TupleVariantKind(_) => { let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues, variant.span); child.define_value(DefVariant(item_id, local_def(variant.node.id), false), variant.span, is_public); } - struct_variant_kind(_) => { + StructVariantKind(_) => { let (child, _) = self.add_child(ident, parent, ForbidDuplicateTypesAndValues, variant.span); child.define_type(DefVariant(item_id, @@ -1443,11 +1441,10 @@ impl Resolver { /// Constructs the reduced graph for one 'view item'. View items consist /// of imports and use directives. - fn build_reduced_graph_for_view_item(&mut self, - view_item: &view_item, - parent: ReducedGraphParent) { + fn build_reduced_graph_for_view_item(&mut self, view_item: &ViewItem, + parent: ReducedGraphParent) { match view_item.node { - view_item_use(ref view_paths) => { + ViewItemUse(ref view_paths) => { for view_path in view_paths.iter() { // Extract and intern the module part of the path. For // globs and lists, the path is found directly in the AST; @@ -1455,7 +1452,7 @@ impl Resolver { let mut module_path = ~[]; match view_path.node { - view_path_simple(_, ref full_path, _) => { + ViewPathSimple(_, ref full_path, _) => { let path_len = full_path.segments.len(); assert!(path_len != 0); @@ -1468,8 +1465,8 @@ impl Resolver { } } - view_path_glob(ref module_ident_path, _) | - view_path_list(ref module_ident_path, _, _) => { + ViewPathGlob(ref module_ident_path, _) | + ViewPathList(ref module_ident_path, _, _) => { for segment in module_ident_path.segments.iter() { module_path.push(segment.identifier) } @@ -1478,9 +1475,9 @@ impl Resolver { // Build up the import directives. let module_ = self.get_module_from_parent(parent); - let is_public = view_item.vis == ast::public; + let is_public = view_item.vis == ast::Public; match view_path.node { - view_path_simple(binding, ref full_path, id) => { + ViewPathSimple(binding, ref full_path, id) => { let source_ident = full_path.segments.last().identifier; let subclass = @SingleImport(binding, @@ -1492,7 +1489,7 @@ impl Resolver { id, is_public); } - view_path_list(_, ref source_idents, _) => { + ViewPathList(_, ref source_idents, _) => { for source_ident in source_idents.iter() { let name = source_ident.node.name; let subclass = @SingleImport(name, name); @@ -1505,7 +1502,7 @@ impl Resolver { is_public); } } - view_path_glob(_, id) => { + ViewPathGlob(_, id) => { self.build_import_directive(module_, module_path, @GlobImport, @@ -1517,7 +1514,7 @@ impl Resolver { } } - view_item_extern_mod(name, _, node_id) => { + ViewItemExternMod(name, _, node_id) => { // n.b. we don't need to look at the path option here, because cstore already did match self.session.cstore.find_extern_mod_stmt_cnum(node_id) { Some(crate_id) => { @@ -1550,19 +1547,19 @@ impl Resolver { /// Constructs the reduced graph for one foreign item. fn build_reduced_graph_for_foreign_item(&mut self, - foreign_item: &foreign_item, + foreign_item: &ForeignItem, parent: ReducedGraphParent, f: |&mut Resolver, ReducedGraphParent|) { let name = foreign_item.ident; - let is_public = foreign_item.vis == ast::public; + let is_public = foreign_item.vis == ast::Public; let (name_bindings, new_parent) = self.add_child(name, parent, ForbidDuplicateValues, foreign_item.span); match foreign_item.node { - foreign_item_fn(_, ref generics) => { - let def = DefFn(local_def(foreign_item.id), unsafe_fn); + ForeignItemFn(_, ref generics) => { + let def = DefFn(local_def(foreign_item.id), UnsafeFn); name_bindings.define_value(def, foreign_item.span, is_public); self.with_type_parameter_rib( @@ -1572,7 +1569,7 @@ impl Resolver { NormalRibKind), |this| f(this, new_parent)); } - foreign_item_static(_, m) => { + ForeignItemStatic(_, m) => { let def = DefStatic(local_def(foreign_item.id), m); name_bindings.define_value(def, foreign_item.span, is_public); @@ -1613,7 +1610,7 @@ impl Resolver { fn handle_external_def(&mut self, def: Def, - vis: visibility, + vis: Visibility, child_name_bindings: @NameBindings, final_ident: &str, ident: Ident, @@ -1621,7 +1618,7 @@ impl Resolver { debug!("(building reduced graph for \ external crate) building external def, priv {:?}", vis); - let is_public = vis == ast::public; + let is_public = vis == ast::Public; let is_exported = is_public && match new_parent { ModuleReducedGraphParent(module) => { match module.def_id.get() { @@ -1669,7 +1666,7 @@ impl Resolver { // We assume the parent is visible, or else we wouldn't have seen // it. Also variants are public-by-default if the parent was also // public. - let is_public = vis != ast::private; + let is_public = vis != ast::Private; if is_struct { child_name_bindings.define_type(def, DUMMY_SP, is_public); self.structs.insert(variant_id); @@ -1703,7 +1700,7 @@ impl Resolver { self.session.str_of(method_name)); // Add it to the trait info if not static. - if explicit_self != sty_static { + if explicit_self != SelfStatic { interned_method_names.insert(method_name.name); } if is_exported { @@ -1767,7 +1764,7 @@ impl Resolver { root: @Module, def_like: DefLike, ident: Ident, - visibility: visibility) { + visibility: Visibility) { match def_like { DlDef(def) => { // Add the new child item, if necessary. @@ -1881,7 +1878,7 @@ impl Resolver { method_name_bindings.define_value( def, DUMMY_SP, - visibility == ast::public); + visibility == ast::Public); } } @@ -3633,7 +3630,7 @@ impl Resolver { visit::walk_crate(self, crate, ()); } - fn resolve_item(&mut self, item: &item) { + fn resolve_item(&mut self, item: &Item) { debug!("(resolving item) resolving {}", self.session.str_of(item.ident)); @@ -3641,7 +3638,7 @@ impl Resolver { // enum item: resolve all the variants' discrs, // then resolve the ty params - item_enum(ref enum_def, ref generics) => { + ItemEnum(ref enum_def, ref generics) => { for variant in (*enum_def).variants.iter() { for dis_expr in variant.node.disr_expr.iter() { // resolve the discriminator expr @@ -3664,7 +3661,7 @@ impl Resolver { }); } - item_ty(_, ref generics) => { + ItemTy(_, ref generics) => { self.with_type_parameter_rib(HasTypeParameters(generics, item.id, 0, @@ -3674,7 +3671,7 @@ impl Resolver { }); } - item_impl(ref generics, + ItemImpl(ref generics, ref implemented_traits, self_type, ref methods) => { @@ -3685,7 +3682,7 @@ impl Resolver { *methods); } - item_trait(ref generics, ref traits, ref methods) => { + ItemTrait(ref generics, ref traits, ref methods) => { // Create a new rib for the self type. let self_type_rib = @Rib::new(NormalRibKind); { @@ -3719,7 +3716,7 @@ impl Resolver { // FIXME #4951: Do we need a node ID here? match *method { - required(ref ty_m) => { + ast::Required(ref ty_m) => { this.with_type_parameter_rib (HasTypeParameters(&ty_m.generics, item.id, @@ -3739,7 +3736,7 @@ impl Resolver { this.resolve_type(ty_m.decl.output); }); } - provided(m) => { + ast::Provided(m) => { this.resolve_method(MethodRibKind(item.id, Provided(m.id)), m, @@ -3753,24 +3750,24 @@ impl Resolver { type_ribs.get().pop(); } - item_struct(ref struct_def, ref generics) => { + ItemStruct(ref struct_def, ref generics) => { self.resolve_struct(item.id, generics, struct_def.fields); } - item_mod(ref module_) => { + ItemMod(ref module_) => { self.with_scope(Some(item.ident), |this| { this.resolve_module(module_, item.span, item.ident, item.id); }); } - item_foreign_mod(ref foreign_module) => { + ItemForeignMod(ref foreign_module) => { self.with_scope(Some(item.ident), |this| { for foreign_item in foreign_module.items.iter() { match foreign_item.node { - foreign_item_fn(_, ref generics) => { + ForeignItemFn(_, ref generics) => { this.with_type_parameter_rib( HasTypeParameters( generics, foreign_item.id, 0, @@ -3779,7 +3776,7 @@ impl Resolver { *foreign_item, ())); } - foreign_item_static(..) => { + ForeignItemStatic(..) => { visit::walk_foreign_item(this, *foreign_item, ()); @@ -3789,7 +3786,7 @@ impl Resolver { }); } - item_fn(fn_decl, _, _, ref generics, block) => { + ItemFn(fn_decl, _, _, ref generics, block) => { self.resolve_function(OpaqueFunctionRibKind, Some(fn_decl), HasTypeParameters @@ -3801,15 +3798,15 @@ impl Resolver { NoSelfBinding); } - item_static(..) => { + ItemStatic(..) => { self.with_constant_rib(|this| { visit::walk_item(this, item, ()); }); } - item_mac(..) => { - fail!("item macros unimplemented") - } + ItemMac(..) => { + fail!("item macros unimplemented") + } } } @@ -3895,7 +3892,7 @@ impl Resolver { fn resolve_function(&mut self, rib_kind: RibKind, - optional_declaration: Option<P<fn_decl>>, + optional_declaration: Option<P<FnDecl>>, type_parameters: TypeParameters, block: P<Block>, self_binding: SelfBinding) { @@ -3932,7 +3929,7 @@ impl Resolver { } HasSelfBinding(self_node_id, explicit_self) => { let mutable = match explicit_self.node { - sty_uniq(m) | sty_value(m) if m == MutMutable => true, + SelfUniq(m) | SelfValue(m) if m == MutMutable => true, _ => false }; let def_like = DlDef(DefSelf(self_node_id, mutable)); @@ -3996,7 +3993,7 @@ impl Resolver { fn resolve_trait_reference(&mut self, id: NodeId, - trait_reference: &trait_ref, + trait_reference: &TraitRef, reference_type: TraitReferenceType) { match self.resolve_path(id, &trait_reference.path, TypeNS, true) { None => { @@ -4020,11 +4017,11 @@ impl Resolver { fn resolve_struct(&mut self, id: NodeId, generics: &Generics, - fields: &[struct_field]) { - let mut ident_map: HashMap<ast::Ident, &struct_field> = HashMap::new(); + fields: &[StructField]) { + let mut ident_map: HashMap<ast::Ident, &StructField> = HashMap::new(); for field in fields.iter() { match field.node.kind { - named_field(ident, _) => { + NamedField(ident, _) => { match ident_map.find(&ident) { Some(&prev_field) => { let ident_str = self.session.str_of(ident); @@ -4062,7 +4059,7 @@ impl Resolver { // to be NormalRibKind? fn resolve_method(&mut self, rib_kind: RibKind, - method: @method, + method: @Method, outer_type_parameter_count: uint) { let method_generics = &method.generics; let type_parameters = @@ -4072,8 +4069,8 @@ impl Resolver { rib_kind); // we only have self ty if it is a non static method let self_binding = match method.explicit_self.node { - sty_static => { NoSelfBinding } - _ => { HasSelfBinding(method.self_id, method.explicit_self) } + SelfStatic => NoSelfBinding, + _ => HasSelfBinding(method.self_id, method.explicit_self) }; self.resolve_function(rib_kind, @@ -4086,9 +4083,9 @@ impl Resolver { fn resolve_implementation(&mut self, id: NodeId, generics: &Generics, - opt_trait_reference: &Option<trait_ref>, + opt_trait_reference: &Option<TraitRef>, self_type: &Ty, - methods: &[@method]) { + methods: &[@Method]) { // If applicable, create a rib for the type parameters. let outer_type_parameter_count = generics.ty_params.len(); self.with_type_parameter_rib(HasTypeParameters(generics, @@ -4160,14 +4157,11 @@ impl Resolver { }); } - fn resolve_module(&mut self, - module_: &_mod, - _span: Span, - _name: Ident, - id: NodeId) { + fn resolve_module(&mut self, module: &Mod, _span: Span, + _name: Ident, id: NodeId) { // Write the implementations in scope into the module metadata. debug!("(resolving module) resolving module ID {}", id); - visit::walk_mod(self, module_, ()); + visit::walk_mod(self, module, ()); } fn resolve_local(&mut self, local: &Local) { @@ -4305,7 +4299,7 @@ impl Resolver { // Like path expressions, the interpretation of path types depends // on whether the path has multiple elements in it or not. - ty_path(ref path, ref bounds, path_id) => { + TyPath(ref path, ref bounds, path_id) => { // This is a path in the type namespace. Walk through scopes // scopes looking for it. let mut result_def = None; @@ -4387,7 +4381,7 @@ impl Resolver { }); } - ty_closure(c) => { + TyClosure(c) => { c.bounds.as_ref().map(|bounds| { for bound in bounds.iter() { self.resolve_type_parameter_bound(ty.id, bound); @@ -5548,20 +5542,20 @@ impl Resolver { visit::walk_crate(&mut visitor, crate, ()); } - fn check_for_item_unused_imports(&self, vi: &view_item) { + fn check_for_item_unused_imports(&self, vi: &ViewItem) { // Ignore is_public import statements because there's no way to be sure // whether they're used or not. Also ignore imports with a dummy span // because this means that they were generated in some fashion by the // compiler and we don't need to consider them. - if vi.vis == public { return } + if vi.vis == Public { return } if vi.span == DUMMY_SP { return } match vi.node { - view_item_extern_mod(..) => {} // ignore - view_item_use(ref path) => { + ViewItemExternMod(..) => {} // ignore + ViewItemUse(ref path) => { for p in path.iter() { match p.node { - view_path_simple(_, _, id) | view_path_glob(_, id) => { + ViewPathSimple(_, _, id) | ViewPathGlob(_, id) => { if !self.used_imports.contains(&id) { self.session.add_lint(unused_imports, id, p.span, @@ -5569,7 +5563,7 @@ impl Resolver { } } - view_path_list(_, ref list, _) => { + ViewPathList(_, ref list, _) => { for i in list.iter() { if !self.used_imports.contains(&i.node.id) { self.session.add_lint(unused_imports, diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 929661122ab..b26b47dc119 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -57,21 +57,21 @@ pub fn crate(sess: session::Session, crate: &ast::Crate) impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext { fn visit_item(&mut self, - item: &ast::item, + item: &ast::Item, _: &'a ScopeChain<'a>) { let scope = match item.node { - ast::item_fn(..) | // fn lifetimes get added in visit_fn below - ast::item_mod(..) | - ast::item_mac(..) | - ast::item_foreign_mod(..) | - ast::item_static(..) => { + ast::ItemFn(..) | // fn lifetimes get added in visit_fn below + ast::ItemMod(..) | + ast::ItemMac(..) | + ast::ItemForeignMod(..) | + ast::ItemStatic(..) => { RootScope } - ast::item_ty(_, ref generics) | - ast::item_enum(_, ref generics) | - ast::item_struct(_, ref generics) | - ast::item_impl(ref generics, _, _, _) | - ast::item_trait(ref generics, _, _) => { + ast::ItemTy(_, ref generics) | + ast::ItemEnum(_, ref generics) | + ast::ItemStruct(_, ref generics) | + ast::ItemImpl(ref generics, _, _, _) | + ast::ItemTrait(ref generics, _, _) => { self.check_lifetime_names(&generics.lifetimes); ItemScope(&generics.lifetimes) } @@ -81,34 +81,29 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext { debug!("exiting scope {:?}", scope); } - fn visit_fn(&mut self, - fk: &visit::fn_kind, - fd: &ast::fn_decl, - b: &ast::Block, - s: Span, - n: ast::NodeId, + fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl, + b: &ast::Block, s: Span, n: ast::NodeId, scope: &'a ScopeChain<'a>) { match *fk { - visit::fk_item_fn(_, generics, _, _) | - visit::fk_method(_, generics, _) => { + visit::FkItemFn(_, generics, _, _) | + visit::FkMethod(_, generics, _) => { let scope1 = FnScope(n, &generics.lifetimes, scope); self.check_lifetime_names(&generics.lifetimes); debug!("pushing fn scope id={} due to item/method", n); visit::walk_fn(self, fk, fd, b, s, n, &scope1); debug!("popping fn scope id={} due to item/method", n); } - visit::fk_fn_block(..) => { + visit::FkFnBlock(..) => { visit::walk_fn(self, fk, fd, b, s, n, scope); } } } - fn visit_ty(&mut self, - ty: &ast::Ty, + fn visit_ty(&mut self, ty: &ast::Ty, scope: &'a ScopeChain<'a>) { match ty.node { - ast::ty_closure(@ast::TyClosure { lifetimes: ref lifetimes, .. }) | - ast::ty_bare_fn(@ast::TyBareFn { lifetimes: ref lifetimes, .. }) => { + ast::TyClosure(@ast::ClosureTy { lifetimes: ref lifetimes, .. }) | + ast::TyBareFn(@ast::BareFnTy { lifetimes: ref lifetimes, .. }) => { let scope1 = FnScope(ty.id, lifetimes, scope); self.check_lifetime_names(lifetimes); debug!("pushing fn scope id={} due to type", ty.id); diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 296a99423c0..36a92e55e7b 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -303,11 +303,11 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp debug!("range_to_inttype: {:?} {:?}", hint, bounds); // Lists of sizes to try. u64 is always allowed as a fallback. static choose_shortest: &'static[IntType] = &[ - attr::UnsignedInt(ast::ty_u8), attr::SignedInt(ast::ty_i8), - attr::UnsignedInt(ast::ty_u16), attr::SignedInt(ast::ty_i16), - attr::UnsignedInt(ast::ty_u32), attr::SignedInt(ast::ty_i32)]; + attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8), + attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16), + attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)]; static at_least_32: &'static[IntType] = &[ - attr::UnsignedInt(ast::ty_u32), attr::SignedInt(ast::ty_i32)]; + attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)]; let attempts; match hint { @@ -336,7 +336,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp return ity; } } - return attr::UnsignedInt(ast::ty_u64); + return attr::UnsignedInt(ast::TyU64); } pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type { diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index 974ef9cf99d..ffcbd59c9e0 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -27,7 +27,7 @@ use middle::trans::type_::Type; use syntax::ast; // Take an inline assembly expression and splat it out via LLVM -pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::inline_asm) +pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm) -> &'a Block<'a> { let mut bcx = bcx; let mut constraints = ~[]; @@ -98,8 +98,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::inline_asm) }; let dialect = match ia.dialect { - ast::asm_att => lib::llvm::AD_ATT, - ast::asm_intel => lib::llvm::AD_Intel + ast::AsmAtt => lib::llvm::AD_ATT, + ast::AsmIntel => lib::llvm::AD_Intel }; let r = ia.asm.with_c_str(|a| { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 9730d664189..aaa8d071aff 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -77,7 +77,7 @@ use std::libc::c_uint; use std::vec; use std::local_data; use syntax::ast::Name; -use syntax::ast_map::{path, path_elt_to_str, path_name, path_pretty_name}; +use syntax::ast_map::{PathName, PathPrettyName, path_elem_to_str}; use syntax::ast_util::{local_def, is_local}; use syntax::attr; use syntax::codemap::Span; @@ -1745,7 +1745,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t) // Be warned! You must call `init_function` before doing anything with the // returned function context. pub fn new_fn_ctxt_w_id(ccx: @CrateContext, - path: path, + path: ast_map::Path, llfndecl: ValueRef, id: ast::NodeId, output_type: ty::t, @@ -1841,7 +1841,7 @@ pub fn init_function<'a>( } pub fn new_fn_ctxt(ccx: @CrateContext, - path: path, + path: ast_map::Path, llfndecl: ValueRef, output_type: ty::t, sp: Option<Span>) @@ -1867,7 +1867,7 @@ pub fn new_fn_ctxt(ccx: @CrateContext, // field of the fn_ctxt with pub fn create_llargs_for_fn_args(cx: &FunctionContext, self_arg: self_arg, - args: &[ast::arg]) + args: &[ast::Arg]) -> ~[ValueRef] { let _icx = push_ctxt("create_llargs_for_fn_args"); @@ -1892,7 +1892,7 @@ pub fn create_llargs_for_fn_args(cx: &FunctionContext, pub fn copy_args_to_allocas<'a>( fcx: &FunctionContext<'a>, bcx: &'a Block<'a>, - args: &[ast::arg], + args: &[ast::Arg], raw_llargs: &[ValueRef], arg_tys: &[ty::t]) -> &'a Block<'a> { @@ -2007,8 +2007,8 @@ pub enum self_arg { impl_self(ty::t, ty::SelfMode), no_self, } // If the function closes over its environment a closure will be // returned. pub fn trans_closure(ccx: @CrateContext, - path: path, - decl: &ast::fn_decl, + path: ast_map::Path, + decl: &ast::FnDecl, body: &ast::Block, llfndecl: ValueRef, self_arg: self_arg, @@ -2085,8 +2085,8 @@ pub fn trans_closure(ccx: @CrateContext, // trans_fn: creates an LLVM function corresponding to a source language // function. pub fn trans_fn(ccx: @CrateContext, - path: path, - decl: &ast::fn_decl, + path: ast_map::Path, + decl: &ast::FnDecl, body: &ast::Block, llfndecl: ValueRef, self_arg: self_arg, @@ -2115,7 +2115,7 @@ pub fn trans_fn(ccx: @CrateContext, } fn insert_synthetic_type_entries(bcx: &Block, - fn_args: &[ast::arg], + fn_args: &[ast::Arg], arg_tys: &[ty::t]) { /*! * For tuple-like structs and enum-variants, we generate @@ -2144,8 +2144,8 @@ fn insert_synthetic_type_entries(bcx: &Block, pub fn trans_enum_variant(ccx: @CrateContext, _enum_id: ast::NodeId, - variant: &ast::variant, - args: &[ast::variant_arg], + variant: &ast::Variant, + args: &[ast::VariantArg], disr: ty::Disr, param_substs: Option<@param_substs>, llfndecl: ValueRef) { @@ -2161,7 +2161,7 @@ pub fn trans_enum_variant(ccx: @CrateContext, } pub fn trans_tuple_struct(ccx: @CrateContext, - fields: &[ast::struct_field], + fields: &[ast::StructField], ctor_id: ast::NodeId, param_substs: Option<@param_substs>, llfndecl: ValueRef) { @@ -2181,12 +2181,12 @@ trait IdAndTy { fn ty(&self) -> ast::P<ast::Ty>; } -impl IdAndTy for ast::variant_arg { +impl IdAndTy for ast::VariantArg { fn id(&self) -> ast::NodeId { self.id } fn ty(&self) -> ast::P<ast::Ty> { self.ty } } -impl IdAndTy for ast::struct_field { +impl IdAndTy for ast::StructField { fn id(&self) -> ast::NodeId { self.node.id } fn ty(&self) -> ast::P<ast::Ty> { self.node.ty } } @@ -2201,7 +2201,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>( { // Translate variant arguments to function arguments. let fn_args = args.map(|varg| { - ast::arg { + ast::Arg { ty: varg.ty(), pat: ast_util::ident_to_pat( ccx.tcx.sess.next_node_id(), @@ -2272,7 +2272,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>( finish_fn(&fcx, bcx); } -pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def, +pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::EnumDef, id: ast::NodeId, vi: @~[@ty::VariantInfo], i: &mut uint) { for &variant in enum_definition.variants.iter() { @@ -2280,15 +2280,15 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def, *i += 1; match variant.node.kind { - ast::tuple_variant_kind(ref args) if args.len() > 0 => { + ast::TupleVariantKind(ref args) if args.len() > 0 => { let llfn = get_item_val(ccx, variant.node.id); trans_enum_variant(ccx, id, variant, *args, disr_val, None, llfn); } - ast::tuple_variant_kind(_) => { + ast::TupleVariantKind(_) => { // Nothing to do. } - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { trans_struct_def(ccx, struct_def); } } @@ -2300,29 +2300,28 @@ pub struct TransItemVisitor { } impl Visitor<()> for TransItemVisitor { - fn visit_item(&mut self, i: &ast::item, _:()) { + fn visit_item(&mut self, i: &ast::Item, _:()) { trans_item(self.ccx, i); } } -pub fn trans_item(ccx: @CrateContext, item: &ast::item) { +pub fn trans_item(ccx: @CrateContext, item: &ast::Item) { let _icx = push_ctxt("trans_item"); let path = { let items = ccx.tcx.items.borrow(); match items.get().get_copy(&item.id) { - ast_map::node_item(_, p) => p, + ast_map::NodeItem(_, p) => p, // tjc: ? _ => fail!("trans_item"), } }; match item.node { - ast::item_fn(decl, purity, _abis, ref generics, body) => { - if purity == ast::extern_fn { + ast::ItemFn(decl, purity, _abis, ref generics, body) => { + if purity == ast::ExternFn { let llfndecl = get_item_val(ccx, item.id); foreign::trans_rust_fn_with_foreign_abi( ccx, - &vec::append((*path).clone(), - [path_name(item.ident)]), + &vec::append_one((*path).clone(), PathName(item.ident)), decl, body, item.attrs, @@ -2331,7 +2330,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { } else if !generics.is_type_parameterized() { let llfndecl = get_item_val(ccx, item.id); trans_fn(ccx, - vec::append((*path).clone(), [path_name(item.ident)]), + vec::append_one((*path).clone(), PathName(item.ident)), decl, body, llfndecl, @@ -2346,7 +2345,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { v.visit_block(body, ()); } } - ast::item_impl(ref generics, _, _, ref ms) => { + ast::ItemImpl(ref generics, _, _, ref ms) => { meth::trans_impl(ccx, (*path).clone(), item.ident, @@ -2354,17 +2353,17 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { generics, item.id); } - ast::item_mod(ref m) => { + ast::ItemMod(ref m) => { trans_mod(ccx, m); } - ast::item_enum(ref enum_definition, ref generics) => { + ast::ItemEnum(ref enum_definition, ref generics) => { if !generics.is_type_parameterized() { let vi = ty::enum_variants(ccx.tcx, local_def(item.id)); let mut i = 0; trans_enum_def(ccx, enum_definition, item.id, vi, &mut i); } } - ast::item_static(_, m, expr) => { + ast::ItemStatic(_, m, expr) => { consts::trans_const(ccx, m, item.id); // Do static_assert checking. It can't really be done much earlier // because we need to get the value of the bool out of LLVM @@ -2384,15 +2383,15 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { } } }, - ast::item_foreign_mod(ref foreign_mod) => { + ast::ItemForeignMod(ref foreign_mod) => { foreign::trans_foreign_mod(ccx, foreign_mod); } - ast::item_struct(struct_def, ref generics) => { + ast::ItemStruct(struct_def, ref generics) => { if !generics.is_type_parameterized() { trans_struct_def(ccx, struct_def); } } - ast::item_trait(..) => { + ast::ItemTrait(..) => { // Inside of this trait definition, we won't be actually translating any // functions, but the trait still needs to be walked. Otherwise default // methods with items will not get translated and will cause ICE's when @@ -2404,7 +2403,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { } } -pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def) { +pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::StructDef) { // If this is a tuple-like struct, translate the constructor. match struct_def.ctor_id { // We only need to translate a constructor if there are fields; @@ -2423,7 +2422,7 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def) { // separate modules in the compiled program. That's because modules exist // only as a convenience for humans working with the code, to organize names // and control visibility. -pub fn trans_mod(ccx: @CrateContext, m: &ast::_mod) { +pub fn trans_mod(ccx: @CrateContext, m: &ast::Mod) { let _icx = push_ctxt("trans_mod"); for item in m.items.iter() { trans_item(ccx, *item); @@ -2580,18 +2579,19 @@ pub fn fill_fn_pair(bcx: &Block, Store(bcx, llenvblobptr, env_cell); } -pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> path { +pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> ast_map::Path { ty::item_path(ccx.tcx, ast_util::local_def(*id)) } -fn exported_name(ccx: &CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str { +fn exported_name(ccx: &CrateContext, path: ast_map::Path, + ty: ty::t, attrs: &[ast::Attribute]) -> ~str { match attr::first_attr_value_str_by_name(attrs, "export_name") { // Use provided name Some(name) => name.to_owned(), // Don't mangle _ if attr::contains_name(attrs, "no_mangle") - => path_elt_to_str(*path.last(), token::get_ident_interner()), + => path_elem_to_str(*path.last(), token::get_ident_interner()), // Usual name mangling _ => mangle_exported_name(ccx, path, ty) @@ -2615,15 +2615,15 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { items.get().get_copy(&id) }; let val = match item { - ast_map::node_item(i, pth) => { + ast_map::NodeItem(i, pth) => { - let elt = path_pretty_name(i.ident, id as u64); + let elt = PathPrettyName(i.ident, id as u64); let my_path = vec::append_one((*pth).clone(), elt); let ty = ty::node_id_to_type(ccx.tcx, i.id); let sym = exported_name(ccx, my_path, ty, i.attrs); let v = match i.node { - ast::item_static(_, _, expr) => { + ast::ItemStatic(_, _, expr) => { // If this static came from an external crate, then // we need to get the symbol from csearch instead of // using the current crate's name/version @@ -2720,8 +2720,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { } } - ast::item_fn(_, purity, _, _, _) => { - let llfn = if purity != ast::extern_fn { + ast::ItemFn(_, purity, _, _, _) => { + let llfn = if purity != ast::ExternFn { register_fn(ccx, i.span, sym, i.id, ty) } else { foreign::register_rust_fn_with_foreign_abi(ccx, @@ -2748,33 +2748,33 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { v } - ast_map::node_trait_method(trait_method, _, pth) => { - debug!("get_item_val(): processing a node_trait_method"); + ast_map::NodeTraitMethod(trait_method, _, pth) => { + debug!("get_item_val(): processing a NodeTraitMethod"); match *trait_method { - ast::required(_) => { + ast::Required(_) => { ccx.sess.bug("unexpected variant: required trait method in \ get_item_val()"); } - ast::provided(m) => { + ast::Provided(m) => { register_method(ccx, id, pth, m) } } } - ast_map::node_method(m, _, pth) => { + ast_map::NodeMethod(m, _, pth) => { register_method(ccx, id, pth, m) } - ast_map::node_foreign_item(ni, abis, _, pth) => { + ast_map::NodeForeignItem(ni, abis, _, pth) => { let ty = ty::node_id_to_type(ccx.tcx, ni.id); foreign = true; match ni.node { - ast::foreign_item_fn(..) => { - let path = vec::append((*pth).clone(), [path_name(ni.ident)]); + ast::ForeignItemFn(..) => { + let path = vec::append_one((*pth).clone(), PathName(ni.ident)); foreign::register_foreign_item_fn(ccx, abis, &path, ni) } - ast::foreign_item_static(..) => { + ast::ForeignItemStatic(..) => { // Treat the crate map static specially in order to // a weak-linkage-like functionality where it's // dynamically resolved at runtime. If we're @@ -2813,25 +2813,25 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { } } - ast_map::node_variant(ref v, enm, pth) => { + ast_map::NodeVariant(ref v, enm, pth) => { let llfn; match v.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { assert!(args.len() != 0u); let pth = vec::append((*pth).clone(), - [path_name(enm.ident), - path_name((*v).node.name)]); + [PathName(enm.ident), + PathName((*v).node.name)]); let ty = ty::node_id_to_type(ccx.tcx, id); let sym = exported_name(ccx, pth, ty, enm.attrs); llfn = match enm.node { - ast::item_enum(_, _) => { + ast::ItemEnum(_, _) => { register_fn(ccx, (*v).span, sym, id, ty) } - _ => fail!("node_variant, shouldn't happen") + _ => fail!("NodeVariant, shouldn't happen") }; } - ast::struct_variant_kind(_) => { + ast::StructVariantKind(_) => { fail!("struct variant kind unexpected in get_item_val") } } @@ -2839,7 +2839,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { llfn } - ast_map::node_struct_ctor(struct_def, struct_item, struct_path) => { + ast_map::NodeStructCtor(struct_def, struct_item, struct_path) => { // Only register the constructor if this is a tuple-like struct. match struct_def.ctor_id { None => { @@ -2883,12 +2883,12 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { pub fn register_method(ccx: @CrateContext, id: ast::NodeId, - path: @ast_map::path, - m: @ast::method) -> ValueRef { + path: @ast_map::Path, + m: @ast::Method) -> ValueRef { let mty = ty::node_id_to_type(ccx.tcx, id); let mut path = (*path).clone(); - path.push(path_pretty_name(m.ident, token::gensym("meth") as u64)); + path.push(PathPrettyName(m.ident, token::gensym("meth") as u64)); let sym = exported_name(ccx, path, mty, m.attrs); @@ -3138,7 +3138,7 @@ pub fn create_module_map(ccx: &CrateContext) -> (ValueRef, uint) { pub fn symname(sess: session::Session, name: &str, hash: &str, vers: &str) -> ~str { - let elt = path_name(sess.ident_of(name)); + let elt = PathName(sess.ident_of(name)); link::exported_name(sess, ~[elt], hash, vers) } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 6bf1babb9e5..795ccb200a0 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -370,7 +370,7 @@ pub fn trans_fn_ref_with_vtables( || format!("local item should be in ast map")); match *map_node { - ast_map::node_foreign_item(_, abis, _, _) => { + ast_map::NodeForeignItem(_, abis, _, _) => { must_monomorphise = abis.is_intrinsic() } _ => { diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 44bce6b2a2a..5a9d7b0a283 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -26,7 +26,7 @@ use util::ppaux::ty_to_str; use std::vec; use syntax::ast; -use syntax::ast_map::path_name; +use syntax::ast_map::PathName; use syntax::ast_util; use syntax::parse::token::special_idents; @@ -358,7 +358,7 @@ pub fn load_environment(fcx: &FunctionContext, pub fn trans_expr_fn<'a>( bcx: &'a Block<'a>, sigil: ast::Sigil, - decl: &ast::fn_decl, + decl: &ast::FnDecl, body: &ast::Block, outer_id: ast::NodeId, user_id: ast::NodeId, @@ -400,7 +400,7 @@ pub fn trans_expr_fn<'a>( }; let sub_path = vec::append_one(bcx.fcx.path.clone(), - path_name(special_idents::anon)); + PathName(special_idents::anon)); // XXX: Bad copy. let s = mangle_internal_name_by_path_and_seq(ccx, sub_path.clone(), diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 4baae9279b1..dab701a0e1f 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -39,7 +39,7 @@ use std::hashmap::HashMap; use std::libc::{c_uint, c_longlong, c_ulonglong, c_char}; use std::vec; use syntax::ast::{Name, Ident}; -use syntax::ast_map::{path, path_elt, path_pretty_name}; +use syntax::ast_map::{Path, PathElem, PathPrettyName}; use syntax::codemap::Span; use syntax::parse::token; use syntax::{ast, ast_map}; @@ -79,10 +79,10 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool { } } -pub fn gensym_name(name: &str) -> (Ident, path_elt) { +pub fn gensym_name(name: &str) -> (Ident, PathElem) { let name = token::gensym(name); let ident = Ident::new(name); - (ident, path_pretty_name(ident, name as u64)) + (ident, PathPrettyName(ident, name as u64)) } pub struct tydesc_info { @@ -257,7 +257,7 @@ pub struct FunctionContext<'a> { // The source span and nesting context where this function comes from, for // error reporting and symbol generation. span: Option<Span>, - path: path, + path: Path, // The arena that blocks are allocated from. block_arena: TypedArena<Block<'a>>, @@ -1078,13 +1078,13 @@ pub fn align_to(cx: &Block, off: ValueRef, align: ValueRef) -> ValueRef { return build::And(cx, bumped, build::Not(cx, mask)); } -pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str { +pub fn path_str(sess: session::Session, p: &[PathElem]) -> ~str { let mut r = ~""; let mut first = true; for e in p.iter() { match *e { - ast_map::path_name(s) | ast_map::path_mod(s) | - ast_map::path_pretty_name(s, _) => { + ast_map::PathName(s) | ast_map::PathMod(s) | + ast_map::PathPrettyName(s, _) => { if first { first = false } else { diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 0df11b24a98..8cde68225c9 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -35,44 +35,44 @@ use std::libc::c_uint; use std::vec; use syntax::{ast, ast_util, ast_map}; -pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::lit) +pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit) -> ValueRef { let _icx = push_ctxt("trans_lit"); match lit.node { - ast::lit_char(i) => C_integral(Type::char(), i as u64, false), - ast::lit_int(i, t) => C_integral(Type::int_from_ty(cx, t), i as u64, true), - ast::lit_uint(u, t) => C_integral(Type::uint_from_ty(cx, t), u, false), - ast::lit_int_unsuffixed(i) => { - let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id); - match ty::get(lit_int_ty).sty { - ty::ty_int(t) => { - C_integral(Type::int_from_ty(cx, t), i as u64, true) - } - ty::ty_uint(t) => { - C_integral(Type::uint_from_ty(cx, t), i as u64, false) - } - _ => cx.sess.span_bug(lit.span, - format!("integer literal has type {} (expected int or uint)", - ty_to_str(cx.tcx, lit_int_ty))) + ast::LitChar(i) => C_integral(Type::char(), i as u64, false), + ast::LitInt(i, t) => C_integral(Type::int_from_ty(cx, t), i as u64, true), + ast::LitUint(u, t) => C_integral(Type::uint_from_ty(cx, t), u, false), + ast::LitIntUnsuffixed(i) => { + let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id); + match ty::get(lit_int_ty).sty { + ty::ty_int(t) => { + C_integral(Type::int_from_ty(cx, t), i as u64, true) + } + ty::ty_uint(t) => { + C_integral(Type::uint_from_ty(cx, t), i as u64, false) + } + _ => cx.sess.span_bug(lit.span, + format!("integer literal has type {} (expected int or uint)", + ty_to_str(cx.tcx, lit_int_ty))) + } } - } - ast::lit_float(fs, t) => C_floating(fs, Type::float_from_ty(t)), - ast::lit_float_unsuffixed(fs) => { - let lit_float_ty = ty::node_id_to_type(cx.tcx, e.id); - match ty::get(lit_float_ty).sty { - ty::ty_float(t) => { - C_floating(fs, Type::float_from_ty(t)) - } - _ => { - cx.sess.span_bug(lit.span, - "floating point literal doesn't have the right type"); - } + ast::LitFloat(fs, t) => C_floating(fs, Type::float_from_ty(t)), + ast::LitFloatUnsuffixed(fs) => { + let lit_float_ty = ty::node_id_to_type(cx.tcx, e.id); + match ty::get(lit_float_ty).sty { + ty::ty_float(t) => { + C_floating(fs, Type::float_from_ty(t)) + } + _ => { + cx.sess.span_bug(lit.span, + "floating point literal doesn't have the right type"); + } + } } - } - ast::lit_bool(b) => C_bool(b), - ast::lit_nil => C_nil(), - ast::lit_str(s, _) => C_estr_slice(cx, s), - ast::lit_binary(data) => C_binary_slice(cx, data), + ast::LitBool(b) => C_bool(b), + ast::LitNil => C_nil(), + ast::LitStr(s, _) => C_estr_slice(cx, s), + ast::LitBinary(data) => C_binary_slice(cx, data), } } @@ -172,8 +172,8 @@ pub fn get_const_val(cx: @CrateContext, }; match opt_item { - ast_map::node_item(@ast::item { - node: ast::item_static(_, ast::MutImmutable, _), .. + ast_map::NodeItem(@ast::Item { + node: ast::ItemStatic(_, ast::MutImmutable, _), .. }, _) => { trans_const(cx, ast::MutImmutable, def_id.node); } @@ -551,8 +551,8 @@ fn const_expr_unadjusted(cx: @CrateContext, match sub.node { ast::ExprLit(ref lit) => { match lit.node { - ast::lit_str(..) => { const_expr(cx, sub) } - _ => { cx.sess.span_bug(e.span, "bad const-slice lit") } + ast::LitStr(..) => { const_expr(cx, sub) } + _ => { cx.sess.span_bug(e.span, "bad const-slice lit") } } } ast::ExprVec(ref es, ast::MutImmutable) => { diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index dbdadb46f49..527308be0ff 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -62,7 +62,7 @@ pub struct CrateContext { // came from) external_srcs: RefCell<HashMap<ast::NodeId, ast::DefId>>, // A set of static items which cannot be inlined into other crates. This - // will pevent in ii_item() structures from being encoded into the metadata + // will pevent in IIItem() structures from being encoded into the metadata // that is generated non_inlineable_statics: RefCell<HashSet<ast::NodeId>>, // Cache instances of monomorphized functions diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 549e5d18fbe..3197084f73c 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -330,8 +330,8 @@ pub fn create_captured_var_metadata(bcx: &Block, None => { cx.sess.span_bug(span, "debuginfo::create_captured_var_metadata() - NodeId not found"); } - Some(ast_map::node_local(ident, _)) => ident, - Some(ast_map::node_arg(@ast::Pat { node: ast::PatIdent(_, ref path, _), .. })) => { + Some(ast_map::NodeLocal(ident, _)) => ident, + Some(ast_map::NodeArg(@ast::Pat { node: ast::PatIdent(_, ref path, _), .. })) => { ast_util::path_to_ident(path) } _ => { @@ -429,12 +429,12 @@ pub fn create_self_argument_metadata(bcx: &Block, items.get().get_copy(&bcx.fcx.id) }; let span = match fnitem { - ast_map::node_method(@ast::method { explicit_self: explicit_self, .. }, _, _) => { + ast_map::NodeMethod(@ast::Method { explicit_self: explicit_self, .. }, _, _) => { explicit_self.span } - ast_map::node_trait_method( - @ast::provided( - @ast::method { + ast_map::NodeTraitMethod( + @ast::Provided( + @ast::Method { explicit_self: explicit_self, .. }), @@ -494,7 +494,7 @@ pub fn create_self_argument_metadata(bcx: &Block, /// Creates debug information for the given function argument. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_argument_metadata(bcx: &Block, arg: &ast::arg) { +pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) { if fn_should_be_ignored(bcx.fcx) { return; } @@ -618,9 +618,9 @@ pub fn create_function_debug_context(cx: &CrateContext, items.get().get_copy(&fn_ast_id) }; let (ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem { - ast_map::node_item(ref item, _) => { + ast_map::NodeItem(ref item, _) => { match item.node { - ast::item_fn(fn_decl, _, _, ref generics, top_level_block) => { + ast::ItemFn(fn_decl, _, _, ref generics, top_level_block) => { (item.ident, fn_decl, generics, top_level_block, item.span, true) } _ => { @@ -629,8 +629,8 @@ pub fn create_function_debug_context(cx: &CrateContext, } } } - ast_map::node_method( - @ast::method { + ast_map::NodeMethod( + @ast::Method { decl: fn_decl, ident: ident, generics: ref generics, @@ -642,7 +642,7 @@ pub fn create_function_debug_context(cx: &CrateContext, _) => { (ident, fn_decl, generics, top_level_block, span, true) } - ast_map::node_expr(ref expr) => { + ast_map::NodeExpr(ref expr) => { match expr.node { ast::ExprFnBlock(fn_decl, top_level_block) | ast::ExprProc(fn_decl, top_level_block) => { @@ -661,9 +661,9 @@ pub fn create_function_debug_context(cx: &CrateContext, "create_function_debug_context: expected an expr_fn_block here") } } - ast_map::node_trait_method( - @ast::provided( - @ast::method { + ast_map::NodeTraitMethod( + @ast::Provided( + @ast::Method { decl: fn_decl, ident: ident, generics: ref generics, @@ -675,11 +675,8 @@ pub fn create_function_debug_context(cx: &CrateContext, _) => { (ident, fn_decl, generics, top_level_block, span, true) } - ast_map::node_foreign_item(@ast::foreign_item { .. }, _, _, _) | - ast_map::node_variant(..) | - ast_map::node_struct_ctor(..) => { - return FunctionWithoutDebugInfo; - } + ast_map::NodeForeignItem(..) | ast_map::NodeVariant(..) + | ast_map::NodeStructCtor(..) => { return FunctionWithoutDebugInfo; } _ => cx.sess.bug(format!("create_function_debug_context: \ unexpected sort of node: {:?}", fnitem)) }; @@ -705,7 +702,7 @@ pub fn create_function_debug_context(cx: &CrateContext, file_metadata, &mut function_name); - // There is no ast_map::path for ast::ExprFnBlock-type functions. For now, just don't put them + // There is no ast_map::Path for ast::ExprFnBlock-type functions. For now, just don't put them // into a namespace. In the future this could be improved somehow (storing a path in the // ast_map, or construct a path using the enclosing function). let (linkage_name, containing_scope) = if has_path { @@ -779,7 +776,7 @@ pub fn create_function_debug_context(cx: &CrateContext, fn get_function_signature(cx: &CrateContext, fn_ast_id: ast::NodeId, - fn_decl: &ast::fn_decl, + fn_decl: &ast::FnDecl, param_substs: Option<@param_substs>, error_span: Span) -> DIArray { if !cx.sess.opts.extra_debuginfo { @@ -790,7 +787,7 @@ pub fn create_function_debug_context(cx: &CrateContext, // Return type -- llvm::DIBuilder wants this at index 0 match fn_decl.output.node { - ast::ty_nil => { + ast::TyNil => { signature.push(ptr::null()); } _ => { @@ -1118,22 +1115,22 @@ fn basic_type_metadata(cx: &CrateContext, t: ty::t) -> DIType { ty::ty_bool => (~"bool", DW_ATE_boolean), ty::ty_char => (~"char", DW_ATE_unsigned_char), ty::ty_int(int_ty) => match int_ty { - ast::ty_i => (~"int", DW_ATE_signed), - ast::ty_i8 => (~"i8", DW_ATE_signed), - ast::ty_i16 => (~"i16", DW_ATE_signed), - ast::ty_i32 => (~"i32", DW_ATE_signed), - ast::ty_i64 => (~"i64", DW_ATE_signed) + ast::TyI => (~"int", DW_ATE_signed), + ast::TyI8 => (~"i8", DW_ATE_signed), + ast::TyI16 => (~"i16", DW_ATE_signed), + ast::TyI32 => (~"i32", DW_ATE_signed), + ast::TyI64 => (~"i64", DW_ATE_signed) }, ty::ty_uint(uint_ty) => match uint_ty { - ast::ty_u => (~"uint", DW_ATE_unsigned), - ast::ty_u8 => (~"u8", DW_ATE_unsigned), - ast::ty_u16 => (~"u16", DW_ATE_unsigned), - ast::ty_u32 => (~"u32", DW_ATE_unsigned), - ast::ty_u64 => (~"u64", DW_ATE_unsigned) + ast::TyU => (~"uint", DW_ATE_unsigned), + ast::TyU8 => (~"u8", DW_ATE_unsigned), + ast::TyU16 => (~"u16", DW_ATE_unsigned), + ast::TyU32 => (~"u32", DW_ATE_unsigned), + ast::TyU64 => (~"u64", DW_ATE_unsigned) }, ty::ty_float(float_ty) => match float_ty { - ast::ty_f32 => (~"f32", DW_ATE_float), - ast::ty_f64 => (~"f64", DW_ATE_float) + ast::TyF32 => (~"f32", DW_ATE_float), + ast::TyF64 => (~"f64", DW_ATE_float) }, _ => cx.sess.bug("debuginfo::basic_type_metadata - t is invalid type") }; @@ -1422,7 +1419,7 @@ fn describe_enum_variant(cx: &CrateContext, { let items = cx.tcx.items.borrow(); match items.get().find(&variant_info.id.node) { - Some(&ast_map::node_variant(ref variant, _, _)) => variant.span, + Some(&ast_map::NodeVariant(ref variant, _, _)) => variant.span, ref node => { cx.sess.span_warn(span, format!("debuginfo::enum_metadata()::\ @@ -2311,7 +2308,7 @@ fn get_namespace_and_span_for_item(cx: &CrateContext, { let items = cx.tcx.items.borrow(); let definition_span = match items.get().find(&def_id.node) { - Some(&ast_map::node_item(@ast::item { span, .. }, _)) => span, + Some(&ast_map::NodeItem(@ast::Item { span, .. }, _)) => span, ref node => { cx.sess.span_warn(warning_span, format!("debuginfo::\ @@ -2704,7 +2701,7 @@ fn populate_scope_map(cx: &CrateContext, scope_stack, scope_map, |cx, scope_stack, scope_map| { - for &ast::arg { pat: pattern, .. } in decl.inputs.iter() { + for &ast::Arg { pat: pattern, .. } in decl.inputs.iter() { walk_pattern(cx, pattern, scope_stack, scope_map); } @@ -2783,9 +2780,9 @@ fn populate_scope_map(cx: &CrateContext, } } - ast::ExprInlineAsm(ast::inline_asm { inputs: ref inputs, - outputs: ref outputs, - .. }) => { + ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs, + outputs: ref outputs, + .. }) => { // inputs, outputs: ~[(@str, @expr)] for &(_, @ref exp) in inputs.iter() { walk_expr(cx, exp, scope_stack, scope_map); @@ -2852,7 +2849,7 @@ fn namespace_for_item(cx: &CrateContext, if def_id.crate == ast::LOCAL_CRATE { // prepend crate name if not already present let crate_namespace_ident = token::str_to_ident(cx.link_meta.crateid.name); - item_path.insert(0, ast_map::path_mod(crate_namespace_ident)); + item_path.insert(0, ast_map::PathMod(crate_namespace_ident)); } item_path diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 422e7042505..970e3e4eac7 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -152,7 +152,7 @@ use std::hashmap::HashMap; use std::vec; use syntax::print::pprust::{expr_to_str}; use syntax::ast; -use syntax::ast_map::path_mod; +use syntax::ast_map::PathMod; use syntax::codemap; // Destinations @@ -748,7 +748,7 @@ fn trans_rvalue_dps_unadjusted<'a>( args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect(); return trans_adt(bcx, repr, 0, numbered_fields, None, dest); } - ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s, _), ..}) => { + ast::ExprLit(@codemap::Spanned {node: ast::LitStr(s, _), ..}) => { return tvec::trans_lit_str(bcx, expr, s, dest); } ast::ExprVstore(contents, ast::ExprVstoreSlice) | @@ -1392,7 +1392,7 @@ fn trans_adt<'a>( fn trans_immediate_lit<'a>( bcx: &'a Block<'a>, expr: &ast::Expr, - lit: ast::lit) + lit: ast::Lit) -> DatumBlock<'a> { // must not be a string constant, that is a RvalueDpsExpr let _icx = push_ctxt("trans_immediate_lit"); @@ -1916,10 +1916,10 @@ pub fn trans_log_level<'a>(bcx: &'a Block<'a>) -> DatumBlock<'a> { None => ccx.link_meta.crateid.name.to_managed(), }; }; - let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))]; + let mut modpath = ~[PathMod(ccx.sess.ident_of(srccrate))]; for e in bcx.fcx.path.iter() { match *e { - path_mod(_) => { modpath.push(*e) } + PathMod(_) => { modpath.push(*e) } _ => {} } } diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index b9d4defc5be..487aaa528ed 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -107,8 +107,8 @@ pub fn llvm_calling_convention(ccx: &CrateContext, pub fn register_foreign_item_fn(ccx: @CrateContext, abis: AbiSet, - path: &ast_map::path, - foreign_item: @ast::foreign_item) -> ValueRef { + path: &ast_map::Path, + foreign_item: @ast::ForeignItem) -> ValueRef { /*! * Registers a foreign function found in a library. * Just adds a LLVM global. @@ -352,15 +352,15 @@ pub fn trans_native_call<'a>( } pub fn trans_foreign_mod(ccx: @CrateContext, - foreign_mod: &ast::foreign_mod) { + foreign_mod: &ast::ForeignMod) { let _icx = push_ctxt("foreign::trans_foreign_mod"); for &foreign_item in foreign_mod.items.iter() { match foreign_item.node { - ast::foreign_item_fn(..) => { + ast::ForeignItemFn(..) => { let items = ccx.tcx.items.borrow(); let (abis, mut path) = match items.get().get_copy(&foreign_item.id) { - ast_map::node_foreign_item(_, abis, _, path) => { + ast_map::NodeForeignItem(_, abis, _, path) => { (abis, (*path).clone()) } _ => { @@ -369,7 +369,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext, } }; if !(abis.is_rust() || abis.is_intrinsic()) { - path.push(ast_map::path_name(foreign_item.ident)); + path.push(ast_map::PathName(foreign_item.ident)); register_foreign_item_fn(ccx, abis, &path, foreign_item); } } @@ -437,8 +437,8 @@ pub fn register_rust_fn_with_foreign_abi(ccx: @CrateContext, } pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, - path: &ast_map::path, - decl: &ast::fn_decl, + path: &ast_map::Path, + decl: &ast::FnDecl, body: &ast::Block, attrs: &[ast::Attribute], llwrapfn: ValueRef, @@ -455,8 +455,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, } fn build_rust_fn(ccx: @CrateContext, - path: &ast_map::path, - decl: &ast::fn_decl, + path: &ast_map::Path, + decl: &ast::FnDecl, body: &ast::Block, attrs: &[ast::Attribute], id: ast::NodeId) @@ -465,7 +465,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, let tcx = ccx.tcx; let t = ty::node_id_to_type(tcx, id); let ps = link::mangle_internal_name_by_path( - ccx, vec::append_one((*path).clone(), ast_map::path_name( + ccx, vec::append_one((*path).clone(), ast_map::PathName( special_idents::clownshoe_abi ))); @@ -748,7 +748,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, // This code is kind of a confused mess and needs to be reworked given // the massive simplifications that have occurred. -pub fn link_name(ccx: &CrateContext, i: @ast::foreign_item) -> @str { +pub fn link_name(ccx: &CrateContext, i: @ast::ForeignItem) -> @str { match attr::first_attr_value_str_by_name(i.attrs, "link_name") { None => ccx.sess.str_of(i.ident), Some(ln) => ln, diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index bea58929323..f571d35bb28 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -19,7 +19,7 @@ use util::ppaux::ty_to_str; use std::vec; use syntax::ast; -use syntax::ast_map::path_name; +use syntax::ast_map::PathName; use syntax::ast_util::local_def; use syntax::attr; @@ -56,7 +56,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) external.get().insert(fn_id, None); fn_id } - csearch::found(ast::ii_item(item)) => { + csearch::found(ast::IIItem(item)) => { { let mut external = ccx.external.borrow_mut(); let mut external_srcs = ccx.external_srcs.borrow_mut(); @@ -76,7 +76,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) // however, so we use the available_externally linkage which llvm // provides match item.node { - ast::item_static(..) => { + ast::ItemStatic(..) => { let g = get_item_val(ccx, item.id); // see the comment in get_item_val() as to why this check is // performed here. @@ -90,7 +90,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) local_def(item.id) } - csearch::found(ast::ii_foreign(item)) => { + csearch::found(ast::IIForeign(item)) => { { let mut external = ccx.external.borrow_mut(); let mut external_srcs = ccx.external_srcs.borrow_mut(); @@ -99,7 +99,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) } local_def(item.id) } - csearch::found_parent(parent_id, ast::ii_item(item)) => { + csearch::found_parent(parent_id, ast::IIItem(item)) => { { let mut external = ccx.external.borrow_mut(); let mut external_srcs = ccx.external_srcs.borrow_mut(); @@ -109,7 +109,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) let mut my_id = 0; match item.node { - ast::item_enum(_, _) => { + ast::ItemEnum(_, _) => { let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); let vs_there = ty::enum_variants(ccx.tcx, parent_id); for (here, there) in vs_here.iter().zip(vs_there.iter()) { @@ -118,7 +118,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) external.get().insert(there.id, Some(here.id.node)); } } - ast::item_struct(ref struct_def, _) => { + ast::ItemStruct(ref struct_def, _) => { match struct_def.ctor_id { None => {} Some(ctor_id) => { @@ -138,7 +138,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) ccx.sess.bug("maybe_get_item_ast returned a found_parent \ with a non-item parent"); } - csearch::found(ast::ii_method(impl_did, is_provided, mth)) => { + csearch::found(ast::IIMethod(impl_did, is_provided, mth)) => { { let mut external = ccx.external.borrow_mut(); let mut external_srcs = ccx.external_srcs.borrow_mut(); @@ -159,18 +159,17 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) if num_type_params == 0 { let llfn = get_item_val(ccx, mth.id); - let path = vec::append( - ty::item_path(ccx.tcx, impl_did), - [path_name(mth.ident)]); + let path = vec::append_one( + ty::item_path(ccx.tcx, impl_did), PathName(mth.ident)); let self_kind = match mth.explicit_self.node { - ast::sty_static => no_self, + ast::SelfStatic => no_self, _ => { let self_ty = ty::node_id_to_type(ccx.tcx, mth.self_id); debug!("calling inline trans_fn with self_ty {}", ty_to_str(ccx.tcx, self_ty)); match mth.explicit_self.node { - ast::sty_value(_) => impl_self(self_ty, ty::ByRef), + ast::SelfValue(_) => impl_self(self_ty, ty::ByRef), _ => impl_self(self_ty, ty::ByCopy), } } diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index fe9d227f053..b001802f165 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -31,8 +31,8 @@ use middle::trans::type_::Type; pub fn trans_intrinsic(ccx: @CrateContext, decl: ValueRef, - item: &ast::foreign_item, - path: ast_map::path, + item: &ast::ForeignItem, + path: ast_map::Path, substs: @param_substs, _attributes: &[ast::Attribute], ref_id: Option<ast::NodeId>) { @@ -348,7 +348,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, let sp = { let items = ccx.tcx.items.borrow(); match items.get().get_copy(&ref_id.unwrap()) { - ast_map::node_expr(e) => e.span, + ast_map::NodeExpr(e) => e.span, _ => fail!("transmute has non-expr arg"), } }; diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 8740aaa5cee..f526fb528c5 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -34,11 +34,9 @@ use middle::trans::type_::Type; use std::c_str::ToCStr; use std::vec; -use syntax::ast_map::{path, path_mod, path_name, path_pretty_name}; -use syntax::ast_util; -use syntax::{ast, ast_map}; +use syntax::ast_map::{Path, PathMod, PathName, PathPrettyName}; use syntax::parse::token; -use syntax::visit; +use syntax::{ast, ast_map, ast_util, visit}; /** The main "translation" pass for methods. Generates code @@ -47,9 +45,9 @@ be generated once they are invoked with specific type parameters, see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`. */ pub fn trans_impl(ccx: @CrateContext, - path: path, + path: Path, name: ast::Ident, - methods: &[@ast::method], + methods: &[@ast::Method], generics: &ast::Generics, id: ast::NodeId) { let _icx = push_ctxt("impl::trans_impl"); @@ -67,12 +65,12 @@ pub fn trans_impl(ccx: @CrateContext, } return; } - let sub_path = vec::append_one(path, path_name(name)); + let sub_path = vec::append_one(path, PathName(name)); for method in methods.iter() { if method.generics.ty_params.len() == 0u { let llfn = get_item_val(ccx, method.id); let path = vec::append_one(sub_path.clone(), - path_name(method.ident)); + PathName(method.ident)); trans_method(ccx, path, @@ -98,13 +96,13 @@ pub fn trans_impl(ccx: @CrateContext, /// /// XXX(pcwalton) Can we take `path` by reference? pub fn trans_method(ccx: @CrateContext, - path: path, - method: &ast::method, + path: Path, + method: &ast::Method, param_substs: Option<@param_substs>, llfn: ValueRef) { // figure out how self is being passed let self_arg = match method.explicit_self.node { - ast::sty_static => { + ast::SelfStatic => { no_self } _ => { @@ -120,7 +118,7 @@ pub fn trans_method(ccx: @CrateContext, debug!("calling trans_fn with self_ty {}", self_ty.repr(ccx.tcx)); match method.explicit_self.node { - ast::sty_value(_) => impl_self(self_ty, ty::ByRef), + ast::SelfValue(_) => impl_self(self_ty, ty::ByRef), _ => impl_self(self_ty, ty::ByCopy), } } @@ -252,7 +250,7 @@ pub fn trans_static_method_callee(bcx: &Block, { let items = bcx.tcx().items.borrow(); match items.get().get_copy(&method_id.node) { - ast_map::node_trait_method(trait_method, _, _) => { + ast_map::NodeTraitMethod(trait_method, _, _) => { ast_util::trait_method_to_ty_method(trait_method).ident } _ => fail!("callee is not a trait method") @@ -261,8 +259,8 @@ pub fn trans_static_method_callee(bcx: &Block, } else { let path = csearch::get_item_path(bcx.tcx(), method_id); match path[path.len()-1] { - path_pretty_name(s, _) | path_name(s) => { s } - path_mod(_) => { fail!("path doesn't have a name?") } + PathPrettyName(s, _) | PathName(s) => { s } + PathMod(_) => { fail!("path doesn't have a name?") } } }; debug!("trans_static_method_callee: method_id={:?}, callee_id={:?}, \ diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index a60ddc9d8b6..8365b541532 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -107,44 +107,44 @@ pub fn monomorphic_fn(ccx: @CrateContext, // Get the path so that we can create a symbol let (pt, name, span) = match map_node { - ast_map::node_item(i, pt) => (pt, i.ident, i.span), - ast_map::node_variant(ref v, enm, pt) => (pt, (*v).node.name, enm.span), - ast_map::node_method(m, _, pt) => (pt, m.ident, m.span), - ast_map::node_foreign_item(i, abis, _, pt) if abis.is_intrinsic() + ast_map::NodeItem(i, pt) => (pt, i.ident, i.span), + ast_map::NodeVariant(ref v, enm, pt) => (pt, (*v).node.name, enm.span), + ast_map::NodeMethod(m, _, pt) => (pt, m.ident, m.span), + ast_map::NodeForeignItem(i, abis, _, pt) if abis.is_intrinsic() => (pt, i.ident, i.span), - ast_map::node_foreign_item(..) => { + ast_map::NodeForeignItem(..) => { // Foreign externs don't have to be monomorphized. return (get_item_val(ccx, fn_id.node), true); } - ast_map::node_trait_method(@ast::provided(m), _, pt) => { + ast_map::NodeTraitMethod(@ast::Provided(m), _, pt) => { // If this is a static provided method, indicate that // and stash the number of params on the method. - if m.explicit_self.node == ast::sty_static { + if m.explicit_self.node == ast::SelfStatic { is_static_provided = Some(m.generics.ty_params.len()); } (pt, m.ident, m.span) } - ast_map::node_trait_method(@ast::required(_), _, _) => { + ast_map::NodeTraitMethod(@ast::Required(_), _, _) => { ccx.tcx.sess.bug("Can't monomorphize a required trait method") } - ast_map::node_expr(..) => { + ast_map::NodeExpr(..) => { ccx.tcx.sess.bug("Can't monomorphize an expr") } - ast_map::node_stmt(..) => { + ast_map::NodeStmt(..) => { ccx.tcx.sess.bug("Can't monomorphize a stmt") } - ast_map::node_arg(..) => ccx.tcx.sess.bug("Can't monomorphize an arg"), - ast_map::node_block(..) => { + ast_map::NodeArg(..) => ccx.tcx.sess.bug("Can't monomorphize an arg"), + ast_map::NodeBlock(..) => { ccx.tcx.sess.bug("Can't monomorphize a block") } - ast_map::node_local(..) => { + ast_map::NodeLocal(..) => { ccx.tcx.sess.bug("Can't monomorphize a local") } - ast_map::node_callee_scope(..) => { + ast_map::NodeCalleeScope(..) => { ccx.tcx.sess.bug("Can't monomorphize a callee-scope") } - ast_map::node_struct_ctor(_, i, pt) => (pt, i.ident, i.span) + ast_map::NodeStructCtor(_, i, pt) => (pt, i.ident, i.span) }; debug!("monomorphic_fn about to subst into {}", llitem_ty.repr(ccx.tcx)); @@ -219,8 +219,8 @@ pub fn monomorphic_fn(ccx: @CrateContext, }; let lldecl = match map_node { - ast_map::node_item(i@@ast::item { - node: ast::item_fn(decl, _, _, _, body), + ast_map::NodeItem(i@@ast::Item { + node: ast::ItemFn(decl, _, _, _, body), .. }, _) => { let d = mk_lldecl(); @@ -236,22 +236,22 @@ pub fn monomorphic_fn(ccx: @CrateContext, []); d } - ast_map::node_item(..) => { + ast_map::NodeItem(..) => { ccx.tcx.sess.bug("Can't monomorphize this kind of item") } - ast_map::node_foreign_item(i, _, _, _) => { + ast_map::NodeForeignItem(i, _, _, _) => { let d = mk_lldecl(); intrinsic::trans_intrinsic(ccx, d, i, pt, psubsts, i.attrs, ref_id); d } - ast_map::node_variant(v, enum_item, _) => { + ast_map::NodeVariant(v, enum_item, _) => { let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id)); let this_tv = *tvs.iter().find(|tv| { tv.id.node == fn_id.node}).unwrap(); let d = mk_lldecl(); set_inline_hint(d); match v.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { trans_enum_variant(ccx, enum_item.id, v, @@ -260,25 +260,25 @@ pub fn monomorphic_fn(ccx: @CrateContext, Some(psubsts), d); } - ast::struct_variant_kind(_) => + ast::StructVariantKind(_) => ccx.tcx.sess.bug("can't monomorphize struct variants"), } d } - ast_map::node_method(mth, _, _) => { + ast_map::NodeMethod(mth, _, _) => { // XXX: What should the self type be here? let d = mk_lldecl(); set_llvm_fn_attrs(mth.attrs, d); meth::trans_method(ccx, pt, mth, Some(psubsts), d); d } - ast_map::node_trait_method(@ast::provided(mth), _, pt) => { + ast_map::NodeTraitMethod(@ast::Provided(mth), _, pt) => { let d = mk_lldecl(); set_llvm_fn_attrs(mth.attrs, d); meth::trans_method(ccx, (*pt).clone(), mth, Some(psubsts), d); d } - ast_map::node_struct_ctor(struct_def, _, _) => { + ast_map::NodeStructCtor(struct_def, _, _) => { let d = mk_lldecl(); set_inline_hint(d); base::trans_tuple_struct(ccx, @@ -291,13 +291,13 @@ pub fn monomorphic_fn(ccx: @CrateContext, } // Ugh -- but this ensures any new variants won't be forgotten - ast_map::node_expr(..) | - ast_map::node_stmt(..) | - ast_map::node_trait_method(..) | - ast_map::node_arg(..) | - ast_map::node_block(..) | - ast_map::node_callee_scope(..) | - ast_map::node_local(..) => { + ast_map::NodeExpr(..) | + ast_map::NodeStmt(..) | + ast_map::NodeTraitMethod(..) | + ast_map::NodeArg(..) | + ast_map::NodeBlock(..) | + ast_map::NodeCalleeScope(..) | + ast_map::NodeLocal(..) => { ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", map_node)) } }; diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 181fad4f7e6..7810a99b273 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -29,7 +29,7 @@ use std::option::{Some,None}; use std::vec; use syntax::ast::DefId; use syntax::ast; -use syntax::ast_map::path_name; +use syntax::ast_map::PathName; use syntax::parse::token::special_idents; use middle::trans::type_::Type; @@ -158,18 +158,18 @@ impl<'a> Reflector<'a> { ty::ty_nil => self.leaf("nil"), ty::ty_bool => self.leaf("bool"), ty::ty_char => self.leaf("char"), - ty::ty_int(ast::ty_i) => self.leaf("int"), - ty::ty_int(ast::ty_i8) => self.leaf("i8"), - ty::ty_int(ast::ty_i16) => self.leaf("i16"), - ty::ty_int(ast::ty_i32) => self.leaf("i32"), - ty::ty_int(ast::ty_i64) => self.leaf("i64"), - ty::ty_uint(ast::ty_u) => self.leaf("uint"), - ty::ty_uint(ast::ty_u8) => self.leaf("u8"), - ty::ty_uint(ast::ty_u16) => self.leaf("u16"), - ty::ty_uint(ast::ty_u32) => self.leaf("u32"), - ty::ty_uint(ast::ty_u64) => self.leaf("u64"), - ty::ty_float(ast::ty_f32) => self.leaf("f32"), - ty::ty_float(ast::ty_f64) => self.leaf("f64"), + ty::ty_int(ast::TyI) => self.leaf("int"), + ty::ty_int(ast::TyI8) => self.leaf("i8"), + ty::ty_int(ast::TyI16) => self.leaf("i16"), + ty::ty_int(ast::TyI32) => self.leaf("i32"), + ty::ty_int(ast::TyI64) => self.leaf("i64"), + ty::ty_uint(ast::TyU) => self.leaf("uint"), + ty::ty_uint(ast::TyU8) => self.leaf("u8"), + ty::ty_uint(ast::TyU16) => self.leaf("u16"), + ty::ty_uint(ast::TyU32) => self.leaf("u32"), + ty::ty_uint(ast::TyU64) => self.leaf("u64"), + ty::ty_float(ast::TyF32) => self.leaf("f32"), + ty::ty_float(ast::TyF64) => self.leaf("f64"), ty::ty_unboxed_vec(ref mt) => { let values = self.c_mt(mt); @@ -290,7 +290,7 @@ impl<'a> Reflector<'a> { mutbl: ast::MutImmutable }); let make_get_disr = || { - let sub_path = bcx.fcx.path + &[path_name(special_idents::anon)]; + let sub_path = bcx.fcx.path + &[PathName(special_idents::anon)]; let sym = mangle_internal_name_by_path_and_seq(ccx, sub_path, "get_disr"); @@ -416,10 +416,10 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint { } } -pub fn ast_purity_constant(purity: ast::purity) -> uint { +pub fn ast_purity_constant(purity: ast::Purity) -> uint { match purity { - ast::unsafe_fn => 1u, - ast::impure_fn => 2u, - ast::extern_fn => 3u + ast::UnsafeFn => 1u, + ast::ImpureFn => 2u, + ast::ExternFn => 3u } } diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 18bfe52f643..5b8d2a0f6b5 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -225,7 +225,7 @@ pub fn trans_slice_vstore<'a>( // Handle the &"..." case: match content_expr.node { - ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s, _), span: _}) => { + ast::ExprLit(@codemap::Spanned {node: ast::LitStr(s, _), span: _}) => { return trans_lit_str(bcx, content_expr, s, dest); } _ => {} @@ -320,7 +320,7 @@ pub fn trans_uniq_or_managed_vstore<'a>( heap_exchange => { match content_expr.node { ast::ExprLit(@codemap::Spanned { - node: ast::lit_str(s, _), span + node: ast::LitStr(s, _), span }) => { let llptrval = C_cstr(bcx.ccx(), s); let llptrval = PointerCast(bcx, llptrval, Type::i8p()); @@ -382,7 +382,7 @@ pub fn write_content<'a>( let _indenter = indenter(); match content_expr.node { - ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s, _), .. }) => { + ast::ExprLit(@codemap::Spanned { node: ast::LitStr(s, _), .. }) => { match dest { Ignore => { return bcx; @@ -479,7 +479,7 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { //! Figure out the number of elements we need to store this content match content_expr.node { - ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s, _), .. }) => { + ast::ExprLit(@codemap::Spanned { node: ast::LitStr(s, _), .. }) => { s.len() }, ast::ExprVec(ref es, _) => es.len(), diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index fae677497b8..e2338c1ad81 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -117,30 +117,30 @@ impl Type { Type::f64() } - pub fn int_from_ty(ctx: &CrateContext, t: ast::int_ty) -> Type { + pub fn int_from_ty(ctx: &CrateContext, t: ast::IntTy) -> Type { match t { - ast::ty_i => ctx.int_type, - ast::ty_i8 => Type::i8(), - ast::ty_i16 => Type::i16(), - ast::ty_i32 => Type::i32(), - ast::ty_i64 => Type::i64() + ast::TyI => ctx.int_type, + ast::TyI8 => Type::i8(), + ast::TyI16 => Type::i16(), + ast::TyI32 => Type::i32(), + ast::TyI64 => Type::i64() } } - pub fn uint_from_ty(ctx: &CrateContext, t: ast::uint_ty) -> Type { + pub fn uint_from_ty(ctx: &CrateContext, t: ast::UintTy) -> Type { match t { - ast::ty_u => ctx.int_type, - ast::ty_u8 => Type::i8(), - ast::ty_u16 => Type::i16(), - ast::ty_u32 => Type::i32(), - ast::ty_u64 => Type::i64() + ast::TyU => ctx.int_type, + ast::TyU8 => Type::i8(), + ast::TyU16 => Type::i16(), + ast::TyU32 => Type::i32(), + ast::TyU64 => Type::i64() } } - pub fn float_from_ty(t: ast::float_ty) -> Type { + pub fn float_from_ty(t: ast::FloatTy) -> Type { match t { - ast::ty_f32 => Type::f32(), - ast::ty_f64 => Type::f64() + ast::TyF32 => Type::f32(), + ast::TyF64 => Type::f64() } } diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index e5f946213f3..f6fb509e317 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -267,7 +267,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_evec(ref mt, ty::vstore_slice(_)) => { let p_ty = type_of(cx, mt.ty).ptr_to(); - let u_ty = Type::uint_from_ty(cx, ast::ty_u); + let u_ty = Type::uint_from_ty(cx, ast::TyU); Type::struct_([p_ty, u_ty], false) } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index a4acc33fe96..a202b810b75 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -76,8 +76,8 @@ pub struct Method { generics: ty::Generics, transformed_self_ty: Option<ty::t>, fty: BareFnTy, - explicit_self: ast::explicit_self_, - vis: ast::visibility, + explicit_self: ast::ExplicitSelf_, + vis: ast::Visibility, def_id: ast::DefId, container: MethodContainer, @@ -90,14 +90,14 @@ impl Method { generics: ty::Generics, transformed_self_ty: Option<ty::t>, fty: BareFnTy, - explicit_self: ast::explicit_self_, - vis: ast::visibility, + explicit_self: ast::ExplicitSelf_, + vis: ast::Visibility, def_id: ast::DefId, container: MethodContainer, provided_source: Option<ast::DefId>) -> Method { // Check the invariants. - if explicit_self == ast::sty_static { + if explicit_self == ast::SelfStatic { assert!(transformed_self_ty.is_none()); } else { assert!(transformed_self_ty.is_some()); @@ -162,7 +162,7 @@ pub enum SelfMode { pub struct field_ty { name: Name, id: DefId, - vis: ast::visibility, + vis: ast::Visibility, } // Contains information needed to resolve types and (in the future) look up @@ -305,7 +305,7 @@ struct ctxt_ { /// Despite its name, `items` does not only map NodeId to an item but /// also to expr/stmt/local/arg/etc - items: ast_map::map, + items: ast_map::Map, intrinsic_defs: RefCell<HashMap<ast::DefId, t>>, freevars: RefCell<freevars::freevar_map>, tcache: type_cache, @@ -435,14 +435,14 @@ pub fn type_id(t: t) -> uint { get(t).id } #[deriving(Clone, Eq, IterBytes)] pub struct BareFnTy { - purity: ast::purity, + purity: ast::Purity, abis: AbiSet, sig: FnSig } #[deriving(Clone, Eq, IterBytes)] pub struct ClosureTy { - purity: ast::purity, + purity: ast::Purity, sigil: ast::Sigil, onceness: ast::Onceness, region: Region, @@ -596,18 +596,18 @@ mod primitives { def_prim_ty!(TY_NIL, super::ty_nil, 0) def_prim_ty!(TY_BOOL, super::ty_bool, 1) def_prim_ty!(TY_CHAR, super::ty_char, 2) - def_prim_ty!(TY_INT, super::ty_int(ast::ty_i), 3) - def_prim_ty!(TY_I8, super::ty_int(ast::ty_i8), 4) - def_prim_ty!(TY_I16, super::ty_int(ast::ty_i16), 5) - def_prim_ty!(TY_I32, super::ty_int(ast::ty_i32), 6) - def_prim_ty!(TY_I64, super::ty_int(ast::ty_i64), 7) - def_prim_ty!(TY_UINT, super::ty_uint(ast::ty_u), 8) - def_prim_ty!(TY_U8, super::ty_uint(ast::ty_u8), 9) - def_prim_ty!(TY_U16, super::ty_uint(ast::ty_u16), 10) - def_prim_ty!(TY_U32, super::ty_uint(ast::ty_u32), 11) - def_prim_ty!(TY_U64, super::ty_uint(ast::ty_u64), 12) - def_prim_ty!(TY_F32, super::ty_float(ast::ty_f32), 14) - def_prim_ty!(TY_F64, super::ty_float(ast::ty_f64), 15) + def_prim_ty!(TY_INT, super::ty_int(ast::TyI), 3) + def_prim_ty!(TY_I8, super::ty_int(ast::TyI8), 4) + def_prim_ty!(TY_I16, super::ty_int(ast::TyI16), 5) + def_prim_ty!(TY_I32, super::ty_int(ast::TyI32), 6) + def_prim_ty!(TY_I64, super::ty_int(ast::TyI64), 7) + def_prim_ty!(TY_UINT, super::ty_uint(ast::TyU), 8) + def_prim_ty!(TY_U8, super::ty_uint(ast::TyU8), 9) + def_prim_ty!(TY_U16, super::ty_uint(ast::TyU16), 10) + def_prim_ty!(TY_U32, super::ty_uint(ast::TyU32), 11) + def_prim_ty!(TY_U64, super::ty_uint(ast::TyU64), 12) + def_prim_ty!(TY_F32, super::ty_float(ast::TyF32), 14) + def_prim_ty!(TY_F64, super::ty_float(ast::TyF64), 15) pub static TY_BOT: t_box_ = t_box_ { sty: super::ty_bot, @@ -632,9 +632,9 @@ pub enum sty { ty_bot, ty_bool, ty_char, - ty_int(ast::int_ty), - ty_uint(ast::uint_ty), - ty_float(ast::float_ty), + ty_int(ast::IntTy), + ty_uint(ast::UintTy), + ty_float(ast::FloatTy), ty_estr(vstore), ty_enum(DefId, substs), ty_box(t), @@ -672,8 +672,8 @@ pub struct TraitRef { #[deriving(Clone, Eq)] pub enum IntVarValue { - IntType(ast::int_ty), - UintType(ast::uint_ty), + IntType(ast::IntTy), + UintType(ast::UintTy), } #[deriving(Clone, ToStr)] @@ -694,7 +694,7 @@ pub struct expected_found<T> { #[deriving(Clone, ToStr)] pub enum type_err { terr_mismatch, - terr_purity_mismatch(expected_found<purity>), + terr_purity_mismatch(expected_found<Purity>), terr_onceness_mismatch(expected_found<Onceness>), terr_abi_mismatch(expected_found<AbiSet>), terr_mutability, @@ -720,7 +720,7 @@ pub enum type_err { terr_sorts(expected_found<t>), terr_integer_as_char, terr_int_mismatch(expected_found<IntVarValue>), - terr_float_mismatch(expected_found<ast::float_ty>), + terr_float_mismatch(expected_found<ast::FloatTy>), terr_traits(expected_found<ast::DefId>), terr_builtin_bounds(expected_found<BuiltinBounds>), terr_variadic_mismatch(expected_found<bool>) @@ -964,7 +964,7 @@ pub type node_type_table = RefCell<HashMap<uint,t>>; pub fn mk_ctxt(s: session::Session, dm: resolve::DefMap, named_region_map: @RefCell<resolve_lifetime::NamedRegionMap>, - amap: ast_map::map, + amap: ast_map::Map, freevars: freevars::freevar_map, region_maps: middle::region::RegionMaps, lang_items: middle::lang_items::LanguageItems) @@ -1204,30 +1204,30 @@ pub fn mk_u32() -> t { mk_prim_t(&primitives::TY_U32) } #[inline] pub fn mk_u64() -> t { mk_prim_t(&primitives::TY_U64) } -pub fn mk_mach_int(tm: ast::int_ty) -> t { +pub fn mk_mach_int(tm: ast::IntTy) -> t { match tm { - ast::ty_i => mk_int(), - ast::ty_i8 => mk_i8(), - ast::ty_i16 => mk_i16(), - ast::ty_i32 => mk_i32(), - ast::ty_i64 => mk_i64(), + ast::TyI => mk_int(), + ast::TyI8 => mk_i8(), + ast::TyI16 => mk_i16(), + ast::TyI32 => mk_i32(), + ast::TyI64 => mk_i64(), } } -pub fn mk_mach_uint(tm: ast::uint_ty) -> t { +pub fn mk_mach_uint(tm: ast::UintTy) -> t { match tm { - ast::ty_u => mk_uint(), - ast::ty_u8 => mk_u8(), - ast::ty_u16 => mk_u16(), - ast::ty_u32 => mk_u32(), - ast::ty_u64 => mk_u64(), + ast::TyU => mk_uint(), + ast::TyU8 => mk_u8(), + ast::TyU16 => mk_u16(), + ast::TyU32 => mk_u32(), + ast::TyU64 => mk_u64(), } } -pub fn mk_mach_float(tm: ast::float_ty) -> t { +pub fn mk_mach_float(tm: ast::FloatTy) -> t { match tm { - ast::ty_f32 => mk_f32(), - ast::ty_f64 => mk_f64(), + ast::TyF32 => mk_f32(), + ast::TyF64 => mk_f64(), } } @@ -1306,7 +1306,7 @@ pub fn mk_ctor_fn(cx: ctxt, let input_args = input_tys.map(|t| *t); mk_bare_fn(cx, BareFnTy { - purity: ast::impure_fn, + purity: ast::ImpureFn, abis: AbiSet::Rust(), sig: FnSig { binder_id: binder_id, @@ -1550,7 +1550,7 @@ pub fn type_is_str(ty: t) -> bool { pub fn sequence_element_type(cx: ctxt, ty: t) -> t { match get(ty).sty { - ty_estr(_) => return mk_mach_uint(ast::ty_u8), + ty_estr(_) => return mk_mach_uint(ast::TyU8), ty_evec(mt, _) | ty_unboxed_vec(mt) => return mt.ty, _ => cx.sess.bug("sequence_element_type called on non-sequence value"), } @@ -2497,7 +2497,7 @@ pub fn type_is_signed(ty: t) -> bool { pub fn type_is_machine(ty: t) -> bool { match get(ty).sty { - ty_int(ast::ty_i) | ty_uint(ast::ty_u) => false, + ty_int(ast::TyI) | ty_uint(ast::TyU) => false, ty_int(..) | ty_uint(..) | ty_float(..) => true, _ => false } @@ -2735,7 +2735,7 @@ pub fn ty_closure_sigil(fty: t) -> Sigil { } } -pub fn ty_fn_purity(fty: t) -> ast::purity { +pub fn ty_fn_purity(fty: t) -> ast::Purity { match get(fty).sty { ty_bare_fn(ref f) => f.purity, ty_closure(ref f) => f.purity, @@ -3184,7 +3184,7 @@ pub fn expr_kind(tcx: ctxt, ast::ExprDoBody(..) | ast::ExprBlock(..) | ast::ExprRepeat(..) | - ast::ExprLit(@codemap::Spanned {node: lit_str(..), ..}) | + ast::ExprLit(@codemap::Spanned {node: LitStr(..), ..}) | ast::ExprVstore(_, ast::ExprVstoreSlice) | ast::ExprVstore(_, ast::ExprVstoreMutSlice) | ast::ExprVec(..) => { @@ -3232,7 +3232,7 @@ pub fn expr_kind(tcx: ctxt, ast::ExprForLoop(..) => fail!("non-desugared expr_for_loop"), ast::ExprLogLevel | - ast::ExprLit(_) | // Note: lit_str is carved out above + ast::ExprLit(_) | // Note: LitStr is carved out above ast::ExprUnary(..) | ast::ExprAddrOf(..) | ast::ExprBinary(..) | @@ -3551,8 +3551,8 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::DefId) -> ~[@Method] { { let items = cx.items.borrow(); match items.get().find(&id.node) { - Some(&ast_map::node_item(@ast::item { - node: item_trait(_, _, ref ms), + Some(&ast_map::NodeItem(@ast::Item { + node: ItemTrait(_, _, ref ms), .. }, _)) => match ast_util::split_trait_methods(*ms) { @@ -3673,8 +3673,8 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> { { let items = cx.items.borrow(); match items.get().find(&id.node) { - Some(&ast_map::node_item(@ast::item { - node: ast::item_impl(_, ref opt_trait, _, _), + Some(&ast_map::NodeItem(@ast::Item { + node: ast::ItemImpl(_, ref opt_trait, _, _), ..}, _)) => { match opt_trait { @@ -3694,7 +3694,7 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> { return ret; } -pub fn trait_ref_to_def_id(tcx: ctxt, tr: &ast::trait_ref) -> ast::DefId { +pub fn trait_ref_to_def_id(tcx: ctxt, tr: &ast::TraitRef) -> ast::DefId { let def_map = tcx.def_map.borrow(); let def = def_map.get() .find(&tr.ref_id) @@ -3732,7 +3732,7 @@ pub struct VariantInfo { name: ast::Ident, id: ast::DefId, disr_val: Disr, - vis: visibility + vis: Visibility } impl VariantInfo { @@ -3741,12 +3741,12 @@ impl VariantInfo { /// /// Does not do any caching of the value in the type context. pub fn from_ast_variant(cx: ctxt, - ast_variant: &ast::variant, + ast_variant: &ast::Variant, discriminant: Disr) -> VariantInfo { let ctor_ty = node_id_to_type(cx, ast_variant.node.id); match ast_variant.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { let arg_tys = if args.len() > 0 { ty_fn_args(ctor_ty).map(|a| *a) } else { ~[] }; return VariantInfo { @@ -3759,17 +3759,17 @@ impl VariantInfo { vis: ast_variant.node.vis }; }, - ast::struct_variant_kind(ref struct_def) => { + ast::StructVariantKind(ref struct_def) => { - let fields: &[struct_field] = struct_def.fields; + let fields: &[StructField] = struct_def.fields; assert!(fields.len() > 0); let arg_tys = ty_fn_args(ctor_ty).map(|a| *a); let arg_names = fields.map(|field| { match field.node.kind { - named_field(ident, _) => ident, - unnamed_field => cx.sess.bug( + NamedField(ident, _) => ident, + UnnamedField => cx.sess.bug( "enum_variants: all fields in struct must have a name") } }); @@ -3853,7 +3853,7 @@ pub fn has_dtor(cx: ctxt, struct_id: DefId) -> bool { ty_dtor(cx, struct_id).is_present() } -pub fn item_path(cx: ctxt, id: ast::DefId) -> ast_map::path { +pub fn item_path(cx: ctxt, id: ast::DefId) -> ast_map::Path { if id.crate != ast::LOCAL_CRATE { return csearch::get_item_path(cx, id) } @@ -3865,45 +3865,43 @@ pub fn item_path(cx: ctxt, id: ast::DefId) -> ast_map::path { // match *node { let items = cx.items.borrow(); match *items.get().get(&id.node) { - ast_map::node_item(item, path) => { - let item_elt = match item.node { - item_mod(_) | item_foreign_mod(_) => { - ast_map::path_mod(item.ident) - } - _ => { - ast_map::path_name(item.ident) - } - }; - vec::append_one((*path).clone(), item_elt) - } + ast_map::NodeItem(item, path) => { + let item_elt = match item.node { + ItemMod(_) | ItemForeignMod(_) => { + ast_map::PathMod(item.ident) + } + _ => ast_map::PathName(item.ident) + }; + vec::append_one((*path).clone(), item_elt) + } - ast_map::node_foreign_item(nitem, _, _, path) => { - vec::append_one((*path).clone(), - ast_map::path_name(nitem.ident)) - } + ast_map::NodeForeignItem(nitem, _, _, path) => { + vec::append_one((*path).clone(), + ast_map::PathName(nitem.ident)) + } - ast_map::node_method(method, _, path) => { - vec::append_one((*path).clone(), - ast_map::path_name(method.ident)) - } - ast_map::node_trait_method(trait_method, _, path) => { - let method = ast_util::trait_method_to_ty_method(&*trait_method); - vec::append_one((*path).clone(), - ast_map::path_name(method.ident)) - } + ast_map::NodeMethod(method, _, path) => { + vec::append_one((*path).clone(), + ast_map::PathName(method.ident)) + } + ast_map::NodeTraitMethod(trait_method, _, path) => { + let method = ast_util::trait_method_to_ty_method(&*trait_method); + vec::append_one((*path).clone(), + ast_map::PathName(method.ident)) + } - ast_map::node_variant(ref variant, _, path) => { - vec::append_one(path.init().to_owned(), - ast_map::path_name((*variant).node.name)) - } + ast_map::NodeVariant(ref variant, _, path) => { + vec::append_one(path.init().to_owned(), + ast_map::PathName((*variant).node.name)) + } - ast_map::node_struct_ctor(_, item, path) => { - vec::append_one((*path).clone(), ast_map::path_name(item.ident)) - } + ast_map::NodeStructCtor(_, item, path) => { + vec::append_one((*path).clone(), ast_map::PathName(item.ident)) + } - ref node => { - cx.sess.bug(format!("cannot find item_path for node {:?}", node)); - } + ref node => { + cx.sess.bug(format!("cannot find item_path for node {:?}", node)); + } } } @@ -3938,8 +3936,8 @@ pub fn enum_variants(cx: ctxt, id: ast::DefId) -> @~[@VariantInfo] { { let items = cx.items.borrow(); match items.get().get_copy(&id.node) { - ast_map::node_item(@ast::item { - node: ast::item_enum(ref enum_definition, _), + ast_map::NodeItem(@ast::Item { + node: ast::ItemEnum(ref enum_definition, _), .. }, _) => { let mut last_discriminant: Option<Disr> = None; @@ -4045,7 +4043,7 @@ pub fn each_attr(tcx: ctxt, did: DefId, f: |@MetaItem| -> bool) -> bool { { let items = tcx.items.borrow(); match items.get().find(&did.node) { - Some(&ast_map::node_item(@ast::item { + Some(&ast_map::NodeItem(@ast::Item { attrs: ref attrs, .. }, _)) => @@ -4131,17 +4129,17 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::DefId) -> ~[field_ty] { { let items = cx.items.borrow(); match items.get().find(&did.node) { - Some(&ast_map::node_item(i,_)) => { + Some(&ast_map::NodeItem(i,_)) => { match i.node { - ast::item_struct(struct_def, _) => { + ast::ItemStruct(struct_def, _) => { struct_field_tys(struct_def.fields) } _ => cx.sess.bug("struct ID bound to non-struct") } } - Some(&ast_map::node_variant(ref variant, _, _)) => { + Some(&ast_map::NodeVariant(ref variant, _, _)) => { match (*variant).node.kind { - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { struct_field_tys(struct_def.fields) } _ => { @@ -4175,22 +4173,22 @@ pub fn lookup_struct_field(cx: ctxt, } } -fn struct_field_tys(fields: &[struct_field]) -> ~[field_ty] { +fn struct_field_tys(fields: &[StructField]) -> ~[field_ty] { fields.map(|field| { match field.node.kind { - named_field(ident, visibility) => { + NamedField(ident, visibility) => { field_ty { name: ident.name, id: ast_util::local_def(field.node.id), vis: visibility, } } - unnamed_field => { + UnnamedField => { field_ty { name: syntax::parse::token::special_idents::unnamed_field.name, id: ast_util::local_def(field.node.id), - vis: ast::public, + vis: ast::Public, } } } @@ -4417,15 +4415,15 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::Expr) -> } // Determine what purity to check a nested function under -pub fn determine_inherited_purity(parent: (ast::purity, ast::NodeId), - child: (ast::purity, ast::NodeId), +pub fn determine_inherited_purity(parent: (ast::Purity, ast::NodeId), + child: (ast::Purity, ast::NodeId), child_sigil: ast::Sigil) - -> (ast::purity, ast::NodeId) { + -> (ast::Purity, ast::NodeId) { // If the closure is a stack closure and hasn't had some non-standard // purity inferred for it, then check it under its parent's purity. // Otherwise, use its own match child_sigil { - ast::BorrowedSigil if child.first() == ast::impure_fn => parent, + ast::BorrowedSigil if child.first() == ast::ImpureFn => parent, _ => child } } @@ -4674,9 +4672,9 @@ pub fn trait_id_of_impl(tcx: ctxt, None => return None }; match node { - &ast_map::node_item(item, _) => { + &ast_map::NodeItem(item, _) => { match item.node { - ast::item_impl(_, Some(ref trait_ref), _, _) => { + ast::ItemImpl(_, Some(ref trait_ref), _, _) => { Some(node_id_to_trait_ref(tcx, trait_ref.ref_id).def_id) } _ => None diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 76378d15bae..882fb46e772 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -288,7 +288,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } fn ast_mt_to_mt<AC:AstConv, RS:RegionScope>( - this: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt { + this: &AC, rscope: &RS, mt: &ast::MutTy) -> ty::mt { ty::mt {ty: ast_ty_to_ty(this, rscope, mt.ty), mutbl: mt.mutbl} } @@ -300,7 +300,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( RS:RegionScope>( this: &AC, rscope: &RS, - a_seq_ty: &ast::mt, + a_seq_ty: &ast::MutTy, vst: ty::vstore, constr: |ty::mt| -> ty::t) -> ty::t { @@ -308,7 +308,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( debug!("mk_pointer(vst={:?})", vst); match a_seq_ty.ty.node { - ast::ty_vec(ty) => { + ast::TyVec(ty) => { let mut mt = ast_ty_to_mt(this, rscope, ty); if a_seq_ty.mutbl == ast::MutMutable { mt = ty::mt { ty: mt.ty, mutbl: a_seq_ty.mutbl }; @@ -316,13 +316,13 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( debug!("&[]: vst={:?}", vst); return ty::mk_evec(tcx, mt, vst); } - ast::ty_path(ref path, ref bounds, id) => { + ast::TyPath(ref path, ref bounds, id) => { // Note that the "bounds must be empty if path is not a trait" // restriction is enforced in the below case for ty_path, which // will run after this as long as the path isn't a trait. let def_map = tcx.def_map.borrow(); match def_map.get().find(&id) { - Some(&ast::DefPrimTy(ast::ty_str)) if a_seq_ty.mutbl == ast::MutImmutable => { + Some(&ast::DefPrimTy(ast::TyStr)) if a_seq_ty.mutbl == ast::MutImmutable => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); return ty::mk_estr(tcx, vst); } @@ -400,44 +400,44 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( let typ = match ast_ty.node { - ast::ty_nil => ty::mk_nil(), - ast::ty_bot => ty::mk_bot(), - ast::ty_box(ty) => { - let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable }; + ast::TyNil => ty::mk_nil(), + ast::TyBot => ty::mk_bot(), + ast::TyBox(ty) => { + let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable }; mk_pointer(this, rscope, &mt, ty::vstore_box, |tmt| ty::mk_box(tcx, tmt.ty)) } - ast::ty_uniq(ty) => { - let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable }; + ast::TyUniq(ty) => { + let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable }; mk_pointer(this, rscope, &mt, ty::vstore_uniq, |tmt| ty::mk_uniq(tcx, tmt)) } - ast::ty_vec(ty) => { + ast::TyVec(ty) => { tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type"); // return /something/ so they can at least get more errors ty::mk_evec(tcx, ast_ty_to_mt(this, rscope, ty), ty::vstore_uniq) } - ast::ty_ptr(ref mt) => { + ast::TyPtr(ref mt) => { ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt)) } - ast::ty_rptr(ref region, ref mt) => { + ast::TyRptr(ref region, ref mt) => { let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region); debug!("ty_rptr r={}", r.repr(this.tcx())); mk_pointer(this, rscope, mt, ty::vstore_slice(r), |tmt| ty::mk_rptr(tcx, r, tmt)) } - ast::ty_tup(ref fields) => { + ast::TyTup(ref fields) => { let flds = fields.map(|&t| ast_ty_to_ty(this, rscope, t)); ty::mk_tup(tcx, flds) } - ast::ty_bare_fn(ref bf) => { + ast::TyBareFn(ref bf) => { if bf.decl.variadic && !bf.abis.is_c() { tcx.sess.span_err(ast_ty.span, "variadic function must have C calling convention"); } ty::mk_bare_fn(tcx, ty_of_bare_fn(this, ast_ty.id, bf.purity, bf.abis, bf.decl)) } - ast::ty_closure(ref f) => { + ast::TyClosure(ref f) => { if f.sigil == ast::ManagedSigil { tcx.sess.span_err(ast_ty.span, "managed closures are not supported"); @@ -463,7 +463,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( ast_ty.span); ty::mk_closure(tcx, fn_decl) } - ast::ty_path(ref path, ref bounds, id) => { + ast::TyPath(ref path, ref bounds, id) => { let def_map = tcx.def_map.borrow(); let a_def = match def_map.get().find(&id) { None => tcx.sess.span_fatal( @@ -495,27 +495,27 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } ast::DefPrimTy(nty) => { match nty { - ast::ty_bool => { + ast::TyBool => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_bool() } - ast::ty_char => { + ast::TyChar => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_char() } - ast::ty_int(it) => { + ast::TyInt(it) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_mach_int(it) } - ast::ty_uint(uit) => { + ast::TyUint(uit) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_mach_uint(uit) } - ast::ty_float(ft) => { + ast::TyFloat(ft) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_mach_float(ft) } - ast::ty_str => { + ast::TyStr => { tcx.sess.span_err(ast_ty.span, "bare `str` is not a type"); // return /something/ so they can at least get more errors @@ -547,7 +547,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } } } - ast::ty_fixed_length_vec(ty, e) => { + ast::TyFixedLengthVec(ty, e) => { match const_eval::eval_const_expr_partial(&tcx, e) { Ok(ref r) => { match *r { @@ -570,10 +570,10 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } } } - ast::ty_typeof(_e) => { + ast::TyTypeof(_e) => { tcx.sess.span_bug(ast_ty.span, "typeof is reserved but unimplemented"); } - ast::ty_infer => { + ast::TyInfer => { // ty_infer should only appear as the type of arguments or return // values in a fn_expr, or as the type of local variables. Both of // these cases are handled specially and should not descend into this @@ -593,28 +593,28 @@ pub fn ty_of_arg<AC:AstConv, RS:RegionScope>( this: &AC, rscope: &RS, - a: &ast::arg, + a: &ast::Arg, expected_ty: Option<ty::t>) -> ty::t { match a.ty.node { - ast::ty_infer if expected_ty.is_some() => expected_ty.unwrap(), - ast::ty_infer => this.ty_infer(a.ty.span), + ast::TyInfer if expected_ty.is_some() => expected_ty.unwrap(), + ast::TyInfer => this.ty_infer(a.ty.span), _ => ast_ty_to_ty(this, rscope, a.ty), } } struct SelfInfo { untransformed_self_ty: ty::t, - explicit_self: ast::explicit_self + explicit_self: ast::ExplicitSelf } pub fn ty_of_method<AC:AstConv>( this: &AC, id: ast::NodeId, - purity: ast::purity, + purity: ast::Purity, untransformed_self_ty: ty::t, - explicit_self: ast::explicit_self, - decl: &ast::fn_decl) -> (Option<ty::t>, ty::BareFnTy) + explicit_self: ast::ExplicitSelf, + decl: &ast::FnDecl) -> (Option<ty::t>, ty::BareFnTy) { let self_info = SelfInfo { untransformed_self_ty: untransformed_self_ty, @@ -628,9 +628,9 @@ pub fn ty_of_method<AC:AstConv>( pub fn ty_of_bare_fn<AC:AstConv>( this: &AC, id: ast::NodeId, - purity: ast::purity, + purity: ast::Purity, abi: AbiSet, - decl: &ast::fn_decl) -> ty::BareFnTy + decl: &ast::FnDecl) -> ty::BareFnTy { let (_, b) = ty_of_method_or_bare_fn(this, id, purity, abi, None, decl); @@ -640,10 +640,10 @@ pub fn ty_of_bare_fn<AC:AstConv>( fn ty_of_method_or_bare_fn<AC:AstConv>( this: &AC, id: ast::NodeId, - purity: ast::purity, + purity: ast::Purity, abi: AbiSet, opt_self_info: Option<&SelfInfo>, - decl: &ast::fn_decl) -> (Option<Option<ty::t>>, ty::BareFnTy) + decl: &ast::FnDecl) -> (Option<Option<ty::t>>, ty::BareFnTy) { debug!("ty_of_method_or_bare_fn"); @@ -658,7 +658,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv>( let input_tys = decl.inputs.map(|a| ty_of_arg(this, &rb, a, None)); let output_ty = match decl.output.node { - ast::ty_infer => this.ty_infer(decl.output.span), + ast::TyInfer => this.ty_infer(decl.output.span), _ => ast_ty_to_ty(this, &rb, decl.output) }; @@ -678,11 +678,11 @@ fn ty_of_method_or_bare_fn<AC:AstConv>( self_info: &SelfInfo) -> Option<ty::t> { match self_info.explicit_self.node { - ast::sty_static => None, - ast::sty_value(_) => { + ast::SelfStatic => None, + ast::SelfValue(_) => { Some(self_info.untransformed_self_ty) } - ast::sty_region(ref lifetime, mutability) => { + ast::SelfRegion(ref lifetime, mutability) => { let region = opt_ast_region_to_region(this, rscope, self_info.explicit_self.span, @@ -691,10 +691,10 @@ fn ty_of_method_or_bare_fn<AC:AstConv>( ty::mt {ty: self_info.untransformed_self_ty, mutbl: mutability})) } - ast::sty_box(_) => { + ast::SelfBox(_) => { Some(ty::mk_box(this.tcx(), self_info.untransformed_self_ty)) } - ast::sty_uniq(_) => { + ast::SelfUniq(_) => { Some(ty::mk_uniq(this.tcx(), ty::mt {ty: self_info.untransformed_self_ty, mutbl: ast::MutImmutable})) @@ -708,11 +708,11 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>( rscope: &RS, id: ast::NodeId, sigil: ast::Sigil, - purity: ast::purity, + purity: ast::Purity, onceness: ast::Onceness, bounds: ty::BuiltinBounds, opt_lifetime: &Option<ast::Lifetime>, - decl: &ast::fn_decl, + decl: &ast::FnDecl, expected_sig: Option<ty::FnSig>, span: Span) -> ty::ClosureTy @@ -755,8 +755,8 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>( let expected_ret_ty = expected_sig.map(|e| e.output); let output_ty = match decl.output.node { - ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.unwrap(), - ast::ty_infer => this.ty_infer(decl.output.span), + ast::TyInfer if expected_ret_ty.is_some() => expected_ret_ty.unwrap(), + ast::TyInfer => this.ty_infer(decl.output.span), _ => ast_ty_to_ty(this, &rb, decl.output) }; diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 9c359f238f8..4a9f7ea3624 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -100,8 +100,8 @@ use std::cell::RefCell; use std::hashmap::HashSet; use std::result; use std::vec; -use syntax::ast::{DefId, sty_value, sty_region, sty_box}; -use syntax::ast::{sty_uniq, sty_static, NodeId}; +use syntax::ast::{DefId, SelfValue, SelfRegion, SelfBox}; +use syntax::ast::{SelfUniq, SelfStatic, NodeId}; use syntax::ast::{MutMutable, MutImmutable}; use syntax::ast; use syntax::ast_map; @@ -505,7 +505,7 @@ impl<'a> LookupContext<'a> { let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id); match trait_methods.iter().position(|m| { - m.explicit_self != ast::sty_static && + m.explicit_self != ast::SelfStatic && m.ident.name == self.m_name }) { Some(pos) => { @@ -944,7 +944,7 @@ impl<'a> LookupContext<'a> { self.enforce_drop_trait_limitations(candidate); // static methods should never have gotten this far: - assert!(candidate.method_ty.explicit_self != sty_static); + assert!(candidate.method_ty.explicit_self != SelfStatic); let transformed_self_ty = match candidate.origin { method_object(..) => { @@ -1078,27 +1078,27 @@ impl<'a> LookupContext<'a> { self_ty: None, tps: rcvr_substs.tps.clone()}; match method_ty.explicit_self { - ast::sty_static => { + ast::SelfStatic => { self.bug(~"static method for object type receiver"); } - ast::sty_value(_) => { + ast::SelfValue(_) => { ty::mk_err() // error reported in `enforce_object_limitations()` } - ast::sty_region(..) | ast::sty_box(..) | ast::sty_uniq(..) => { + ast::SelfRegion(..) | ast::SelfBox(..) | ast::SelfUniq(..) => { let transformed_self_ty = method_ty.transformed_self_ty.clone().unwrap(); match ty::get(transformed_self_ty).sty { - ty::ty_rptr(r, mt) => { // must be sty_region + ty::ty_rptr(r, mt) => { // must be SelfRegion ty::mk_trait(self.tcx(), trait_def_id, substs, RegionTraitStore(r), mt.mutbl, ty::EmptyBuiltinBounds()) } - ty::ty_box(_) => { // must be sty_box + ty::ty_box(_) => { // must be SelfBox ty::mk_trait(self.tcx(), trait_def_id, substs, BoxTraitStore, ast::MutImmutable, ty::EmptyBuiltinBounds()) } - ty::ty_uniq(mt) => { // must be sty_uniq + ty::ty_uniq(mt) => { // must be SelfUniq ty::mk_trait(self.tcx(), trait_def_id, substs, UniqTraitStore, mt.mutbl, ty::EmptyBuiltinBounds()) @@ -1133,21 +1133,21 @@ impl<'a> LookupContext<'a> { } match candidate.method_ty.explicit_self { - ast::sty_static => { // reason (a) above + ast::SelfStatic => { // reason (a) above self.tcx().sess.span_err( self.expr.span, "cannot call a method without a receiver \ through an object"); } - ast::sty_value(_) => { // reason (a) above + ast::SelfValue(_) => { // reason (a) above self.tcx().sess.span_err( self.expr.span, "cannot call a method with a by-value receiver \ through an object"); } - ast::sty_region(..) | ast::sty_box(..) | ast::sty_uniq(..) => {} + ast::SelfRegion(..) | ast::SelfBox(..) | ast::SelfUniq(..) => {} } if ty::type_has_self(method_fty) { // reason (a) above @@ -1196,16 +1196,16 @@ impl<'a> LookupContext<'a> { self.ty_to_str(rcvr_ty), self.cand_to_str(candidate)); return match candidate.method_ty.explicit_self { - sty_static => { + SelfStatic => { debug!("(is relevant?) explicit self is static"); false } - sty_value(_) => { + SelfValue(_) => { rcvr_matches_ty(self.fcx, rcvr_ty, candidate) } - sty_region(_, m) => { + SelfRegion(_, m) => { debug!("(is relevant?) explicit self is a region"); match ty::get(rcvr_ty).sty { ty::ty_rptr(_, mt) => { @@ -1222,7 +1222,7 @@ impl<'a> LookupContext<'a> { } } - sty_box(m) => { + SelfBox(m) => { debug!("(is relevant?) explicit self is a box"); match ty::get(rcvr_ty).sty { ty::ty_box(typ) => { @@ -1238,7 +1238,7 @@ impl<'a> LookupContext<'a> { } } - sty_uniq(_) => { + SelfUniq(_) => { debug!("(is relevant?) explicit self is a unique pointer"); match ty::get(rcvr_ty).sty { ty::ty_uniq(mt) => { @@ -1312,10 +1312,9 @@ impl<'a> LookupContext<'a> { { let items = self.tcx().items.borrow(); match items.get().find(&did.node) { - Some(&ast_map::node_method(m, _, _)) - | Some(&ast_map::node_trait_method(@ast::provided(m), - _, - _)) => { + Some(&ast_map::NodeMethod(m, _, _)) + | Some(&ast_map::NodeTraitMethod(@ast::Provided(m), + _, _)) => { m.span } _ => fail!("report_static_candidate: bad item {:?}", did) @@ -1376,9 +1375,9 @@ impl<'a> LookupContext<'a> { } } -pub fn get_mode_from_explicit_self(explicit_self: ast::explicit_self_) -> SelfMode { +pub fn get_mode_from_explicit_self(explicit_self: ast::ExplicitSelf_) -> SelfMode { match explicit_self { - sty_value(_) => ty::ByRef, + SelfValue(_) => ty::ByRef, _ => ty::ByCopy, } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 41757b1a634..a1e360dae8c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -116,7 +116,7 @@ use std::result; use std::util::replace; use std::vec; use syntax::abi::AbiSet; -use syntax::ast::{provided, required}; +use syntax::ast::{Provided, Required}; use syntax::ast; use syntax::ast_map; use syntax::ast_util::local_def; @@ -181,12 +181,12 @@ pub enum FnKind { #[deriving(Clone)] pub struct PurityState { def: ast::NodeId, - purity: ast::purity, + purity: ast::Purity, priv from_fn: bool } impl PurityState { - pub fn function(purity: ast::purity, def: ast::NodeId) -> PurityState { + pub fn function(purity: ast::Purity, def: ast::NodeId) -> PurityState { PurityState { def: def, purity: purity, from_fn: true } } @@ -196,11 +196,11 @@ impl PurityState { // unsafe we shouldn't attribute the unsafe'ness to the block. This // way the block can be warned about instead of ignoring this // extraneous block (functions are never warned about). - ast::unsafe_fn if self.from_fn => *self, + ast::UnsafeFn if self.from_fn => *self, purity => { let (purity, def) = match blk.rules { - ast::UnsafeBlock(..) => (ast::unsafe_fn, blk.id), + ast::UnsafeBlock(..) => (ast::UnsafeFn, blk.id), ast::DefaultBlock => (purity, self.def), }; PurityState{ def: def, @@ -284,7 +284,7 @@ pub fn blank_fn_ctxt(ccx: @CrateCtxt, @FnCtxt { err_count_on_creation: ccx.tcx.sess.err_count(), ret_ty: rty, - ps: RefCell::new(PurityState::function(ast::impure_fn, 0)), + ps: RefCell::new(PurityState::function(ast::ImpureFn, 0)), region_lb: Cell::new(region_bnd), fn_kind: Vanilla, inh: @Inherited::new(ccx.tcx, param_env), @@ -305,7 +305,7 @@ impl ExprTyProvider for FnCtxt { struct CheckItemTypesVisitor { ccx: @CrateCtxt } impl Visitor<()> for CheckItemTypesVisitor { - fn visit_item(&mut self, i: &ast::item, _: ()) { + fn visit_item(&mut self, i: &ast::Item, _: ()) { check_item(self.ccx, i); visit::walk_item(self, i, ()); } @@ -317,7 +317,7 @@ pub fn check_item_types(ccx: @CrateCtxt, crate: &ast::Crate) { } pub fn check_bare_fn(ccx: @CrateCtxt, - decl: &ast::fn_decl, + decl: &ast::FnDecl, body: &ast::Block, id: ast::NodeId, self_info: Option<SelfInfo>, @@ -367,7 +367,7 @@ impl Visitor<()> for GatherLocalsVisitor { // Add explicitly-declared locals. fn visit_local(&mut self, local: &ast::Local, _: ()) { let o_ty = match local.ty.node { - ast::ty_infer => None, + ast::TyInfer => None, _ => Some(self.fcx.to_ty(local.ty)) }; self.assign(local.id, o_ty); @@ -409,17 +409,17 @@ impl Visitor<()> for GatherLocalsVisitor { } // Don't descend into fns and items - fn visit_fn(&mut self, _: &visit::fn_kind, _: &ast::fn_decl, + fn visit_fn(&mut self, _: &visit::FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId, _: ()) { } - fn visit_item(&mut self, _: &ast::item, _: ()) { } + fn visit_item(&mut self, _: &ast::Item, _: ()) { } } pub fn check_fn(ccx: @CrateCtxt, opt_self_info: Option<SelfInfo>, - purity: ast::purity, + purity: ast::Purity, fn_sig: &ty::FnSig, - decl: &ast::fn_decl, + decl: &ast::FnDecl, id: ast::NodeId, body: &ast::Block, fn_kind: FnKind, @@ -506,7 +506,7 @@ pub fn check_fn(ccx: @CrateCtxt, return fcx; fn gather_locals(fcx: @FnCtxt, - decl: &ast::fn_decl, + decl: &ast::FnDecl, body: &ast::Block, arg_tys: &[ty::t], opt_self_info: Option<SelfInfo>) { @@ -576,21 +576,21 @@ pub fn check_struct(ccx: @CrateCtxt, id: ast::NodeId, span: Span) { } } -pub fn check_item(ccx: @CrateCtxt, it: &ast::item) { +pub fn check_item(ccx: @CrateCtxt, it: &ast::Item) { debug!("check_item(it.id={}, it.ident={})", it.id, ty::item_path_str(ccx.tcx, local_def(it.id))); let _indenter = indenter(); match it.node { - ast::item_static(_, _, e) => check_const(ccx, it.span, e, it.id), - ast::item_enum(ref enum_definition, _) => { + ast::ItemStatic(_, _, e) => check_const(ccx, it.span, e, it.id), + ast::ItemEnum(ref enum_definition, _) => { check_enum_variants(ccx, it.span, enum_definition.variants, it.id); } - ast::item_fn(decl, _, _, _, body) => { + ast::ItemFn(decl, _, _, _, body) => { let fn_tpt = ty::lookup_item_type(ccx.tcx, ast_util::local_def(it.id)); // FIXME(#5121) -- won't work for lifetimes that appear in type bounds @@ -604,8 +604,8 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::item) { check_bare_fn(ccx, decl, body, it.id, None, fn_tpt.ty, param_env); } - ast::item_impl(_, ref opt_trait_ref, _, ref ms) => { - debug!("item_impl {} with id {}", ccx.tcx.sess.str_of(it.ident), it.id); + ast::ItemImpl(_, ref opt_trait_ref, _, ref ms) => { + debug!("ItemImpl {} with id {}", ccx.tcx.sess.str_of(it.ident), it.id); let impl_tpt = ty::lookup_item_type(ccx.tcx, ast_util::local_def(it.id)); for m in ms.iter() { @@ -629,29 +629,29 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::item) { } } - ast::item_trait(_, _, ref trait_methods) => { + ast::ItemTrait(_, _, ref trait_methods) => { let trait_def = ty::lookup_trait_def(ccx.tcx, local_def(it.id)); for trait_method in (*trait_methods).iter() { match *trait_method { - required(..) => { - // Nothing to do, since required methods don't have - // bodies to check. - } - provided(m) => { - check_method_body(ccx, &trait_def.generics, - Some(trait_def.trait_ref), m); - } + Required(..) => { + // Nothing to do, since required methods don't have + // bodies to check. + } + Provided(m) => { + check_method_body(ccx, &trait_def.generics, + Some(trait_def.trait_ref), m); + } } } } - ast::item_struct(..) => { + ast::ItemStruct(..) => { check_struct(ccx, it.id, it.span); } - ast::item_ty(ref t, ref generics) => { + ast::ItemTy(ref t, ref generics) => { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); check_bounds_are_used(ccx, t.span, &generics.ty_params, tpt_ty); } - ast::item_foreign_mod(ref m) => { + ast::ItemForeignMod(ref m) => { if m.abis.is_intrinsic() { for item in m.items.iter() { check_intrinsic_type(ccx, *item); @@ -664,7 +664,7 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::item) { } match item.node { - ast::foreign_item_fn(ref fn_decl, _) => { + ast::ForeignItemFn(ref fn_decl, _) => { if fn_decl.variadic && !m.abis.is_c() { ccx.tcx.sess.span_err( item.span, "variadic function must have C calling convention"); @@ -682,7 +682,7 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::item) { fn check_method_body(ccx: @CrateCtxt, item_generics: &ty::Generics, self_bound: Option<@ty::TraitRef>, - method: &ast::method) { + method: &ast::Method) { /*! * Type checks a method body. * @@ -734,9 +734,9 @@ fn check_method_body(ccx: @CrateCtxt, fn check_impl_methods_against_trait(ccx: @CrateCtxt, impl_span: Span, impl_generics: &ty::Generics, - ast_trait_ref: &ast::trait_ref, + ast_trait_ref: &ast::TraitRef, impl_trait_ref: &ty::TraitRef, - impl_methods: &[@ast::method]) { + impl_methods: &[@ast::Method]) { // Locate trait methods let tcx = ccx.tcx; let trait_methods = ty::trait_methods(tcx, impl_trait_ref.def_id); @@ -831,8 +831,8 @@ pub fn compare_impl_method(tcx: ty::ctxt, // inscrutable, particularly for cases where one method has no // self. match (&trait_m.explicit_self, &impl_m.explicit_self) { - (&ast::sty_static, &ast::sty_static) => {} - (&ast::sty_static, _) => { + (&ast::SelfStatic, &ast::SelfStatic) => {} + (&ast::SelfStatic, _) => { tcx.sess.span_err( impl_m_span, format!("method `{}` has a `{}` declaration in the impl, \ @@ -842,7 +842,7 @@ pub fn compare_impl_method(tcx: ty::ctxt, tcx.sess.intr()))); return; } - (_, &ast::sty_static) => { + (_, &ast::SelfStatic) => { tcx.sess.span_err( impl_m_span, format!("method `{}` has a `{}` declaration in the trait, \ @@ -1378,31 +1378,31 @@ pub fn do_autoderef(fcx: @FnCtxt, sp: Span, t: ty::t) -> (ty::t, uint) { } // AST fragment checking -pub fn check_lit(fcx: @FnCtxt, lit: &ast::lit) -> ty::t { +pub fn check_lit(fcx: @FnCtxt, lit: &ast::Lit) -> ty::t { let tcx = fcx.ccx.tcx; match lit.node { - ast::lit_str(..) => ty::mk_estr(tcx, ty::vstore_slice(ty::ReStatic)), - ast::lit_binary(..) => { - ty::mk_evec(tcx, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable }, - ty::vstore_slice(ty::ReStatic)) - } - ast::lit_char(_) => ty::mk_char(), - ast::lit_int(_, t) => ty::mk_mach_int(t), - ast::lit_uint(_, t) => ty::mk_mach_uint(t), - ast::lit_int_unsuffixed(_) => { - // An unsuffixed integer literal could have any integral type, - // so we create an integral type variable for it. - ty::mk_int_var(tcx, fcx.infcx().next_int_var_id()) - } - ast::lit_float(_, t) => ty::mk_mach_float(t), - ast::lit_float_unsuffixed(_) => { - // An unsuffixed floating point literal could have any floating point - // type, so we create a floating point type variable for it. - ty::mk_float_var(tcx, fcx.infcx().next_float_var_id()) - } - ast::lit_nil => ty::mk_nil(), - ast::lit_bool(_) => ty::mk_bool() + ast::LitStr(..) => ty::mk_estr(tcx, ty::vstore_slice(ty::ReStatic)), + ast::LitBinary(..) => { + ty::mk_evec(tcx, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable }, + ty::vstore_slice(ty::ReStatic)) + } + ast::LitChar(_) => ty::mk_char(), + ast::LitInt(_, t) => ty::mk_mach_int(t), + ast::LitUint(_, t) => ty::mk_mach_uint(t), + ast::LitIntUnsuffixed(_) => { + // An unsuffixed integer literal could have any integral type, + // so we create an integral type variable for it. + ty::mk_int_var(tcx, fcx.infcx().next_int_var_id()) + } + ast::LitFloat(_, t) => ty::mk_mach_float(t), + ast::LitFloatUnsuffixed(_) => { + // An unsuffixed floating point literal could have any floating point + // type, so we create a floating point type variable for it. + ty::mk_float_var(tcx, fcx.infcx().next_float_var_id()) + } + ast::LitNil => ty::mk_nil(), + ast::LitBool(_) => ty::mk_bool() } } @@ -1815,17 +1815,17 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, // in C but we just error out instead and require explicit casts. let arg_ty = structurally_resolved_type(fcx, arg.span, fcx.expr_ty(*arg)); match ty::get(arg_ty).sty { - ty::ty_float(ast::ty_f32) => { + ty::ty_float(ast::TyF32) => { fcx.type_error_message(arg.span, |t| format!("can't pass an {} to variadic function, \ cast to c_double", t), arg_ty, None); } - ty::ty_int(ast::ty_i8) | ty::ty_int(ast::ty_i16) | ty::ty_bool => { + ty::ty_int(ast::TyI8) | ty::ty_int(ast::TyI16) | ty::ty_bool => { fcx.type_error_message(arg.span, |t| format!("can't pass {} to variadic function, cast to c_int", t), arg_ty, None); } - ty::ty_uint(ast::ty_u8) | ty::ty_uint(ast::ty_u16) => { + ty::ty_uint(ast::TyU8) | ty::ty_uint(ast::TyU16) => { fcx.type_error_message(arg.span, |t| format!("can't pass {} to variadic function, cast to c_uint", t), arg_ty, None); @@ -2250,7 +2250,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, fn check_expr_fn(fcx: @FnCtxt, expr: &ast::Expr, ast_sigil_opt: Option<ast::Sigil>, - decl: &ast::fn_decl, + decl: &ast::FnDecl, body: ast::P<ast::Block>, fn_kind: FnKind, expected: Option<ty::t>) { @@ -2295,7 +2295,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, } _ => () } - (None, ast::impure_fn, sigil, + (None, ast::ImpureFn, sigil, onceness, bounds) } } @@ -2304,7 +2304,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, // If the proto is specified, use that, otherwise select a // proto based on inference. let (sigil, purity) = match ast_sigil_opt { - Some(p) => (p, ast::impure_fn), + Some(p) => (p, ast::ImpureFn), None => (expected_sigil, expected_purity) }; @@ -2622,7 +2622,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, match expr.node { ast::ExprVstore(ev, vst) => { let typ = match ev.node { - ast::ExprLit(@codemap::Spanned { node: ast::lit_str(..), .. }) => { + ast::ExprLit(@codemap::Spanned { node: ast::LitStr(..), .. }) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); ty::mk_estr(tcx, tt) } @@ -3081,7 +3081,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, if type_is_c_like_enum(fcx, expr.span, t_e) && t_1_is_trivial { // casts from C-like enums are allowed } else if t_1_is_char { - if ty::get(te).sty != ty::ty_uint(ast::ty_u8) { + if ty::get(te).sty != ty::ty_uint(ast::TyU8) { fcx.type_error_message(expr.span, |actual| { format!("only `u8` can be cast as `char`, not `{}`", actual) }, t_e, None); @@ -3541,28 +3541,28 @@ pub fn check_simd(tcx: ty::ctxt, sp: Span, id: ast::NodeId) { pub fn check_enum_variants(ccx: @CrateCtxt, sp: Span, - vs: &[ast::P<ast::variant>], + vs: &[ast::P<ast::Variant>], id: ast::NodeId) { fn disr_in_range(ccx: @CrateCtxt, ty: attr::IntType, disr: ty::Disr) -> bool { - fn uint_in_range(ccx: @CrateCtxt, ty: ast::uint_ty, disr: ty::Disr) -> bool { + fn uint_in_range(ccx: @CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool { match ty { - ast::ty_u8 => disr as u8 as Disr == disr, - ast::ty_u16 => disr as u16 as Disr == disr, - ast::ty_u32 => disr as u32 as Disr == disr, - ast::ty_u64 => disr as u64 as Disr == disr, - ast::ty_u => uint_in_range(ccx, ccx.tcx.sess.targ_cfg.uint_type, disr) + ast::TyU8 => disr as u8 as Disr == disr, + ast::TyU16 => disr as u16 as Disr == disr, + ast::TyU32 => disr as u32 as Disr == disr, + ast::TyU64 => disr as u64 as Disr == disr, + ast::TyU => uint_in_range(ccx, ccx.tcx.sess.targ_cfg.uint_type, disr) } } - fn int_in_range(ccx: @CrateCtxt, ty: ast::int_ty, disr: ty::Disr) -> bool { + fn int_in_range(ccx: @CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool { match ty { - ast::ty_i8 => disr as i8 as Disr == disr, - ast::ty_i16 => disr as i16 as Disr == disr, - ast::ty_i32 => disr as i32 as Disr == disr, - ast::ty_i64 => disr as i64 as Disr == disr, - ast::ty_i => int_in_range(ccx, ccx.tcx.sess.targ_cfg.int_type, disr) + ast::TyI8 => disr as i8 as Disr == disr, + ast::TyI16 => disr as i16 as Disr == disr, + ast::TyI32 => disr as i32 as Disr == disr, + ast::TyI64 => disr as i64 as Disr == disr, + ast::TyI => int_in_range(ccx, ccx.tcx.sess.targ_cfg.int_type, disr) } } match ty { @@ -3572,7 +3572,7 @@ pub fn check_enum_variants(ccx: @CrateCtxt, } fn do_check(ccx: @CrateCtxt, - vs: &[ast::P<ast::variant>], + vs: &[ast::P<ast::Variant>], id: ast::NodeId, hint: attr::ReprAttr) -> ~[@ty::VariantInfo] { @@ -3975,7 +3975,7 @@ pub fn check_bounds_are_used(ccx: @CrateCtxt, } } -pub fn check_intrinsic_type(ccx: @CrateCtxt, it: &ast::foreign_item) { +pub fn check_intrinsic_type(ccx: @CrateCtxt, it: &ast::ForeignItem) { fn param(ccx: @CrateCtxt, n: uint) -> ty::t { ty::mk_param(ccx.tcx, n, local_def(0)) } @@ -4277,7 +4277,7 @@ pub fn check_intrinsic_type(ccx: @CrateCtxt, it: &ast::foreign_item) { } }; let fty = ty::mk_bare_fn(tcx, ty::BareFnTy { - purity: ast::unsafe_fn, + purity: ast::UnsafeFn, abis: AbiSet::Intrinsic(), sig: FnSig {binder_id: it.id, inputs: inputs, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 2670a5d59a1..668163881a9 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -175,7 +175,7 @@ impl Visitor<()> for Rcx { // hierarchy, and in particular the relationships between free // regions, until regionck, as described in #3238. - fn visit_item(&mut self, i: &ast::item, _: ()) { visit_item(self, i); } + fn visit_item(&mut self, i: &ast::Item, _: ()) { visit_item(self, i); } fn visit_expr(&mut self, ex: &ast::Expr, _: ()) { visit_expr(self, ex); } @@ -188,7 +188,7 @@ impl Visitor<()> for Rcx { fn visit_block(&mut self, b: &ast::Block, _: ()) { visit_block(self, b); } } -fn visit_item(_rcx: &mut Rcx, _item: &ast::item) { +fn visit_item(_rcx: &mut Rcx, _item: &ast::Item) { // Ignore items } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 208ba615d23..d66e53ec8f4 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -552,7 +552,7 @@ pub fn location_info_for_expr(expr: &ast::Expr) -> LocationInfo { id: expr.id } } -pub fn location_info_for_item(item: &ast::item) -> LocationInfo { +pub fn location_info_for_item(item: &ast::Item) -> LocationInfo { LocationInfo { span: item.span, id: item.id @@ -760,7 +760,7 @@ fn resolve_expr(fcx: @FnCtxt, ex: &ast::Expr) { } pub fn resolve_impl(ccx: @CrateCtxt, - impl_item: &ast::item, + impl_item: &ast::Item, impl_generics: &ty::Generics, impl_trait_ref: &ty::TraitRef) { let param_env = ty::construct_parameter_environment( @@ -819,7 +819,7 @@ impl visit::Visitor<()> for @FnCtxt { fn visit_expr(&mut self, ex: &ast::Expr, _: ()) { resolve_expr(*self, ex); } - fn visit_item(&mut self, _: &ast::item, _: ()) { + fn visit_item(&mut self, _: &ast::Item, _: ()) { // no-op } } diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 9305ddcc5d1..ef0a595f9b6 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -343,12 +343,12 @@ fn visit_local(l: &ast::Local, wbcx: &mut WbCtxt) { } visit::walk_local(wbcx, l, ()); } -fn visit_item(_item: &ast::item, _wbcx: &mut WbCtxt) { +fn visit_item(_item: &ast::Item, _wbcx: &mut WbCtxt) { // Ignore items } impl Visitor<()> for WbCtxt { - fn visit_item(&mut self, i: &ast::item, _: ()) { visit_item(i, self); } + fn visit_item(&mut self, i: &ast::Item, _: ()) { visit_item(i, self); } fn visit_stmt(&mut self, s: &ast::Stmt, _: ()) { visit_stmt(s, self); } fn visit_expr(&mut self, ex:&ast::Expr, _: ()) { visit_expr(ex, self); } fn visit_block(&mut self, b: &ast::Block, _: ()) { visit_block(b, self); } @@ -366,7 +366,7 @@ pub fn resolve_type_vars_in_expr(fcx: @FnCtxt, e: &ast::Expr) -> bool { } pub fn resolve_type_vars_in_fn(fcx: @FnCtxt, - decl: &ast::fn_decl, + decl: &ast::FnDecl, blk: &ast::Block, self_info: Option<SelfInfo>) -> bool { let mut wbcx = WbCtxt { fcx: fcx, success: true }; diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 177b8d9fafc..9466792c62e 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -36,10 +36,10 @@ use middle::typeck::infer::{new_infer_ctxt, resolve_ivar, resolve_type}; use middle::typeck::infer; use util::ppaux::Repr; use syntax::ast::{Crate, DefId, DefStruct, DefTy}; -use syntax::ast::{item, item_enum, item_impl, item_mod, item_struct}; -use syntax::ast::{LOCAL_CRATE, trait_ref, ty_path}; +use syntax::ast::{Item, ItemEnum, ItemImpl, ItemMod, ItemStruct}; +use syntax::ast::{LOCAL_CRATE, TraitRef, TyPath}; use syntax::ast; -use syntax::ast_map::node_item; +use syntax::ast_map::NodeItem; use syntax::ast_map; use syntax::ast_util::{def_id_of_def, local_def}; use syntax::codemap::Span; @@ -159,13 +159,13 @@ pub struct CoherenceChecker { struct CoherenceCheckVisitor { cc: CoherenceChecker } impl visit::Visitor<()> for CoherenceCheckVisitor { - fn visit_item(&mut self, item: &item, _: ()) { + fn visit_item(&mut self, item: &Item, _: ()) { // debug!("(checking coherence) item '{}'", // self.cc.crate_context.tcx.sess.str_of(item.ident)); match item.node { - item_impl(_, ref opt_trait, _, _) => { + ItemImpl(_, ref opt_trait, _, _) => { match opt_trait.clone() { Some(opt_trait) => { self.cc.check_implementation(item, [opt_trait]); @@ -185,14 +185,14 @@ impl visit::Visitor<()> for CoherenceCheckVisitor { struct PrivilegedScopeVisitor { cc: CoherenceChecker } impl visit::Visitor<()> for PrivilegedScopeVisitor { - fn visit_item(&mut self, item: &item, _: ()) { + fn visit_item(&mut self, item: &Item, _: ()) { match item.node { - item_mod(ref module_) => { + ItemMod(ref module_) => { // Then visit the module items. visit::walk_mod(self, module_, ()); } - item_impl(_, None, ast_ty, _) => { + ItemImpl(_, None, ast_ty, _) => { if !self.cc.ast_type_is_defined_in_local_crate(ast_ty) { // This is an error. let session = self.cc.crate_context.tcx.sess; @@ -202,7 +202,7 @@ impl visit::Visitor<()> for PrivilegedScopeVisitor { a trait or new type instead"); } } - item_impl(_, Some(ref trait_ref), _, _) => { + ItemImpl(_, Some(ref trait_ref), _, _) => { // `for_ty` is `Type` in `impl Trait for Type` let for_ty = ty::node_id_to_type(self.cc.crate_context.tcx, @@ -259,8 +259,8 @@ impl CoherenceChecker { } pub fn check_implementation(&self, - item: &item, - associated_traits: &[trait_ref]) { + item: &Item, + associated_traits: &[TraitRef]) { let tcx = self.crate_context.tcx; let self_type = ty::lookup_item_type(tcx, local_def(item.id)); @@ -546,7 +546,7 @@ impl CoherenceChecker { visit::walk_crate(&mut visitor, crate, ()); } - pub fn trait_ref_to_trait_def_id(&self, trait_ref: &trait_ref) -> DefId { + pub fn trait_ref_to_trait_def_id(&self, trait_ref: &TraitRef) -> DefId { let def_map = self.crate_context.tcx.def_map; let def_map = def_map.borrow(); let trait_def = def_map.get().get_copy(&trait_ref.ref_id); @@ -560,7 +560,7 @@ impl CoherenceChecker { pub fn ast_type_is_defined_in_local_crate(&self, original_type: &ast::Ty) -> bool { match original_type.node { - ty_path(_, _, path_id) => { + TyPath(_, _, path_id) => { let def_map = self.crate_context.tcx.def_map.borrow(); match def_map.get().get_copy(&path_id) { DefTy(def_id) | DefStruct(def_id) => { @@ -577,9 +577,9 @@ impl CoherenceChecker { original_type.span, "resolve didn't resolve this type?!"); } - Some(&node_item(item, _)) => { + Some(&NodeItem(item, _)) => { match item.node { - item_struct(..) | item_enum(..) => true, + ItemStruct(..) | ItemEnum(..) => true, _ => false, } } @@ -594,10 +594,10 @@ impl CoherenceChecker { } // Converts an implementation in the AST to an Impl structure. - pub fn create_impl_from_item(&self, item: &item) -> @Impl { + pub fn create_impl_from_item(&self, item: &Item) -> @Impl { let tcx = self.crate_context.tcx; match item.node { - item_impl(_, ref trait_refs, _, ref ast_methods) => { + ItemImpl(_, ref trait_refs, _, ref ast_methods) => { let mut methods = ~[]; for ast_method in ast_methods.iter() { methods.push(ty::method(tcx, local_def(ast_method.id))); @@ -630,7 +630,7 @@ impl CoherenceChecker { assert_eq!(implementation.did.crate, LOCAL_CRATE); let items = self.crate_context.tcx.items.borrow(); match items.get().find(&implementation.did.node) { - Some(&node_item(item, _)) => { + Some(&NodeItem(item, _)) => { return item.span; } _ => { @@ -736,7 +736,7 @@ impl CoherenceChecker { { let items = tcx.items.borrow(); match items.get().find(&impl_info.did.node) { - Some(&ast_map::node_item(@ref item, _)) => { + Some(&ast_map::NodeItem(@ref item, _)) => { tcx.sess.span_err((*item).span, "the Drop trait may \ only be implemented \ diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index a713ada3706..c5499ffb241 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -62,11 +62,11 @@ struct CollectItemTypesVisitor { } impl visit::Visitor<()> for CollectItemTypesVisitor { - fn visit_item(&mut self, i: &ast::item, _: ()) { + fn visit_item(&mut self, i: &ast::Item, _: ()) { convert(self.ccx, i); visit::walk_item(self, i, ()); } - fn visit_foreign_item(&mut self, i: &ast::foreign_item, _: ()) { + fn visit_foreign_item(&mut self, i: &ast::ForeignItem, _: ()) { convert_foreign(self.ccx, i); visit::walk_foreign_item(self, i, ()); } @@ -112,8 +112,8 @@ impl AstConv for CrateCtxt { let items = self.tcx.items.borrow(); match items.get().find(&id.node) { - Some(&ast_map::node_item(item, _)) => ty_of_item(self, item), - Some(&ast_map::node_foreign_item(foreign_item, abis, _, _)) => { + Some(&ast_map::NodeItem(item, _)) => ty_of_item(self, item), + Some(&ast_map::NodeForeignItem(foreign_item, abis, _, _)) => { ty_of_foreign_item(self, foreign_item, abis) } ref x => { @@ -135,7 +135,7 @@ impl AstConv for CrateCtxt { pub fn get_enum_variant_types(ccx: &CrateCtxt, enum_ty: ty::t, - variants: &[ast::P<ast::variant>], + variants: &[ast::P<ast::Variant>], generics: &ast::Generics) { let tcx = ccx.tcx; @@ -145,17 +145,17 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt, // constructors get turned into functions. let scope = variant.node.id; let result_ty = match variant.node.kind { - ast::tuple_variant_kind(ref args) if args.len() > 0 => { + ast::TupleVariantKind(ref args) if args.len() > 0 => { let rs = ExplicitRscope; let input_tys = args.map(|va| ccx.to_ty(&rs, va.ty)); ty::mk_ctor_fn(tcx, scope, input_tys, enum_ty) } - ast::tuple_variant_kind(_) => { + ast::TupleVariantKind(_) => { enum_ty } - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { let tpt = ty_param_bounds_and_ty { generics: ty_generics(ccx, generics, 0), ty: enum_ty @@ -189,8 +189,8 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, let tcx = ccx.tcx; let items = tcx.items.borrow(); match items.get().get_copy(&trait_id) { - ast_map::node_item(@ast::item { - node: ast::item_trait(ref generics, _, ref ms), + ast_map::NodeItem(@ast::Item { + node: ast::ItemTrait(ref generics, _, ref ms), .. }, _) => { let trait_ty_generics = @@ -200,14 +200,14 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, // store it into the `tcx.methods` table: for m in ms.iter() { let ty_method = @match m { - &ast::required(ref m) => { + &ast::Required(ref m) => { ty_method_of_trait_method( ccx, trait_id, &trait_ty_generics, &m.id, &m.ident, &m.explicit_self, &m.generics, &m.purity, m.decl) } - &ast::provided(ref m) => { + &ast::Provided(ref m) => { ty_method_of_trait_method( ccx, trait_id, &trait_ty_generics, &m.id, &m.ident, &m.explicit_self, @@ -215,7 +215,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, } }; - if ty_method.explicit_self == ast::sty_static { + if ty_method.explicit_self == ast::SelfStatic { make_static_method_ty(ccx, trait_id, ty_method, &trait_ty_generics); } @@ -227,8 +227,8 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, // Add an entry mapping let method_def_ids = @ms.map(|m| { match m { - &ast::required(ref ty_method) => local_def(ty_method.id), - &ast::provided(ref method) => local_def(method.id) + &ast::Required(ref ty_method) => local_def(ty_method.id), + &ast::Provided(ref method) => local_def(method.id) } }); @@ -372,10 +372,10 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_generics: &ty::Generics, m_id: &ast::NodeId, m_ident: &ast::Ident, - m_explicit_self: &ast::explicit_self, + m_explicit_self: &ast::ExplicitSelf, m_generics: &ast::Generics, - m_purity: &ast::purity, - m_decl: &ast::fn_decl) -> ty::Method + m_purity: &ast::Purity, + m_decl: &ast::FnDecl) -> ty::Method { let trait_self_ty = ty::mk_self(this.tcx, local_def(trait_id)); let (transformed_self_ty, fty) = @@ -390,7 +390,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, fty, m_explicit_self.node, // assume public, because this is only invoked on trait methods - ast::public, + ast::Public, local_def(*m_id), TraitContainer(local_def(trait_id)), None @@ -401,7 +401,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, pub fn ensure_supertraits(ccx: &CrateCtxt, id: ast::NodeId, sp: codemap::Span, - ast_trait_refs: &[ast::trait_ref]) + ast_trait_refs: &[ast::TraitRef]) -> ty::BuiltinBounds { let tcx = ccx.tcx; @@ -443,7 +443,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, pub fn convert_field(ccx: &CrateCtxt, struct_generics: &ty::Generics, - v: &ast::struct_field) { + v: &ast::StructField) { let tt = ccx.to_ty(&ExplicitRscope, v.node.ty); write_ty_to_tcx(ccx.tcx, v.node.id, tt); /* add the field to the tcache */ @@ -457,11 +457,11 @@ pub fn convert_field(ccx: &CrateCtxt, fn convert_methods(ccx: &CrateCtxt, container: MethodContainer, - ms: &[@ast::method], + ms: &[@ast::Method], untransformed_rcvr_ty: ty::t, rcvr_ty_generics: &ty::Generics, rcvr_ast_generics: &ast::Generics, - rcvr_visibility: ast::visibility) + rcvr_visibility: ast::Visibility) { let tcx = ccx.tcx; for m in ms.iter() { @@ -505,10 +505,10 @@ fn convert_methods(ccx: &CrateCtxt, fn ty_of_method(ccx: &CrateCtxt, container: MethodContainer, - m: &ast::method, + m: &ast::Method, untransformed_rcvr_ty: ty::t, rcvr_generics: &ast::Generics, - rcvr_visibility: ast::visibility) -> ty::Method + rcvr_visibility: ast::Visibility) -> ty::Method { let (transformed_self_ty, fty) = astconv::ty_of_method(ccx, m.id, m.purity, @@ -551,13 +551,13 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt, } } -pub fn convert(ccx: &CrateCtxt, it: &ast::item) { +pub fn convert(ccx: &CrateCtxt, it: &ast::Item) { let tcx = ccx.tcx; debug!("convert: item {} with id {}", tcx.sess.str_of(it.ident), it.id); match it.node { // These don't define types. - ast::item_foreign_mod(_) | ast::item_mod(_) => {} - ast::item_enum(ref enum_definition, ref generics) => { + ast::ItemForeignMod(_) | ast::ItemMod(_) => {} + ast::ItemEnum(ref enum_definition, ref generics) => { ensure_no_ty_param_bounds(ccx, it.span, generics, "enumeration"); let tpt = ty_of_item(ccx, it); write_ty_to_tcx(tcx, it.id, tpt.ty); @@ -566,7 +566,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { enum_definition.variants, generics); } - ast::item_impl(ref generics, ref opt_trait_ref, selfty, ref ms) => { + ast::ItemImpl(ref generics, ref opt_trait_ref, selfty, ref ms) => { let i_ty_generics = ty_generics(ccx, generics, 0); let selfty = ccx.to_ty(&ExplicitRscope, selfty); write_ty_to_tcx(tcx, it.id, selfty); @@ -585,7 +585,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { // from the trait, not the impl. Forcing the visibility to be public // makes things sorta work. let parent_visibility = if opt_trait_ref.is_some() { - ast::public + ast::Public } else { it.vis }; @@ -609,7 +609,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { } } } - ast::item_trait(ref generics, _, ref trait_methods) => { + ast::ItemTrait(ref generics, _, ref trait_methods) => { let trait_def = trait_def_of_item(ccx, it); // Run convert_methods on the provided methods. @@ -629,7 +629,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { // static trait methods. This is somewhat unfortunate. ensure_trait_methods(ccx, it.id); } - ast::item_struct(struct_def, ref generics) => { + ast::ItemStruct(struct_def, ref generics) => { ensure_no_ty_param_bounds(ccx, it.span, generics, "structure"); // Write the class type @@ -643,7 +643,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { convert_struct(ccx, struct_def, tpt, it.id); } - ast::item_ty(_, ref generics) => { + ast::ItemTy(_, ref generics) => { ensure_no_ty_param_bounds(ccx, it.span, generics, "type"); let tpt = ty_of_item(ccx, it); write_ty_to_tcx(tcx, it.id, tpt.ty); @@ -659,7 +659,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { } pub fn convert_struct(ccx: &CrateCtxt, - struct_def: &ast::struct_def, + struct_def: &ast::StructDef, tpt: ty::ty_param_bounds_and_ty, id: ast::NodeId) { let tcx = ccx.tcx; @@ -684,7 +684,7 @@ pub fn convert_struct(ccx: &CrateCtxt, let mut tcache = tcx.tcache.borrow_mut(); tcache.get().insert(local_def(ctor_id), tpt); } - } else if struct_def.fields[0].node.kind == ast::unnamed_field { + } else if struct_def.fields[0].node.kind == ast::UnnamedField { // Tuple-like. let inputs = { let tcache = tcx.tcache.borrow(); @@ -707,7 +707,7 @@ pub fn convert_struct(ccx: &CrateCtxt, } } -pub fn convert_foreign(ccx: &CrateCtxt, i: &ast::foreign_item) { +pub fn convert_foreign(ccx: &CrateCtxt, i: &ast::ForeignItem) { // As above, this call populates the type table with the converted // type of the foreign item. We simply write it into the node type // table. @@ -718,7 +718,7 @@ pub fn convert_foreign(ccx: &CrateCtxt, i: &ast::foreign_item) { // convenient way to extract the ABI. - ndm let items = ccx.tcx.items.borrow(); let abis = match items.get().find(&i.id) { - Some(&ast_map::node_foreign_item(_, abis, _, _)) => abis, + Some(&ast_map::NodeForeignItem(_, abis, _, _)) => abis, ref x => { ccx.tcx.sess.bug(format!("unexpected sort of item \ in get_item_ty(): {:?}", (*x))); @@ -733,7 +733,7 @@ pub fn convert_foreign(ccx: &CrateCtxt, i: &ast::foreign_item) { } pub fn instantiate_trait_ref(ccx: &CrateCtxt, - ast_trait_ref: &ast::trait_ref, + ast_trait_ref: &ast::TraitRef, self_ty: ty::t) -> @ty::TraitRef { /*! @@ -772,13 +772,13 @@ fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> @ty::TraitDef { let items = ccx.tcx.items.borrow(); match items.get().get(&trait_id.node) { - &ast_map::node_item(item, _) => trait_def_of_item(ccx, item), + &ast_map::NodeItem(item, _) => trait_def_of_item(ccx, item), _ => ccx.tcx.sess.bug(format!("get_trait_def({}): not an item", trait_id.node)) } } -pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef { +pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> @ty::TraitDef { let def_id = local_def(it.id); let tcx = ccx.tcx; { @@ -790,7 +790,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef { } match it.node { - ast::item_trait(ref generics, ref supertraits, _) => { + ast::ItemTrait(ref generics, ref supertraits, _) => { let self_ty = ty::mk_self(tcx, def_id); let ty_generics = ty_generics(ccx, generics, 0); let substs = mk_item_substs(ccx, &ty_generics, Some(self_ty)); @@ -812,7 +812,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef { } } -pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) +pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item) -> ty::ty_param_bounds_and_ty { let def_id = local_def(it.id); let tcx = ccx.tcx; @@ -824,7 +824,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) } } match it.node { - ast::item_static(t, _, _) => { + ast::ItemStatic(t, _, _) => { let typ = ccx.to_ty(&ExplicitRscope, t); let tpt = no_params(typ); @@ -832,7 +832,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) tcache.get().insert(local_def(it.id), tpt); return tpt; } - ast::item_fn(decl, purity, abi, ref generics, _) => { + ast::ItemFn(decl, purity, abi, ref generics, _) => { let ty_generics = ty_generics(ccx, generics, 0); let tofd = astconv::ty_of_bare_fn(ccx, it.id, @@ -855,7 +855,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) tcache.get().insert(local_def(it.id), tpt); return tpt; } - ast::item_ty(t, ref generics) => { + ast::ItemTy(t, ref generics) => { { let mut tcache = tcx.tcache.borrow_mut(); match tcache.get().find(&local_def(it.id)) { @@ -876,7 +876,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) tcache.get().insert(local_def(it.id), tpt); return tpt; } - ast::item_enum(_, ref generics) => { + ast::ItemEnum(_, ref generics) => { // Create a new generic polytype. let ty_generics = ty_generics(ccx, generics, 0); let substs = mk_item_substs(ccx, &ty_generics, None); @@ -890,12 +890,12 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) tcache.get().insert(local_def(it.id), tpt); return tpt; } - ast::item_trait(..) => { + ast::ItemTrait(..) => { tcx.sess.span_bug( it.span, format!("Invoked ty_of_item on trait")); } - ast::item_struct(_, ref generics) => { + ast::ItemStruct(_, ref generics) => { let ty_generics = ty_generics(ccx, generics, 0); let substs = mk_item_substs(ccx, &ty_generics, None); let t = ty::mk_struct(tcx, local_def(it.id), substs); @@ -908,25 +908,25 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) tcache.get().insert(local_def(it.id), tpt); return tpt; } - ast::item_impl(..) | ast::item_mod(_) | - ast::item_foreign_mod(_) => fail!(), - ast::item_mac(..) => fail!("item macros unimplemented") + ast::ItemImpl(..) | ast::ItemMod(_) | + ast::ItemForeignMod(_) => fail!(), + ast::ItemMac(..) => fail!("item macros unimplemented") } } pub fn ty_of_foreign_item(ccx: &CrateCtxt, - it: &ast::foreign_item, + it: &ast::ForeignItem, abis: AbiSet) -> ty::ty_param_bounds_and_ty { match it.node { - ast::foreign_item_fn(fn_decl, ref generics) => { + ast::ForeignItemFn(fn_decl, ref generics) => { ty_of_foreign_fn_decl(ccx, fn_decl, local_def(it.id), generics, abis) } - ast::foreign_item_static(t, _) => { + ast::ForeignItemStatic(t, _) => { ty::ty_param_bounds_and_ty { generics: ty::Generics { type_param_defs: @~[], @@ -1016,7 +1016,7 @@ pub fn ty_generics(ccx: &CrateCtxt, } pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, - decl: &ast::fn_decl, + decl: &ast::FnDecl, def_id: ast::DefId, ast_generics: &ast::Generics, abis: AbiSet) @@ -1030,7 +1030,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, ccx.tcx, ty::BareFnTy { abis: abis, - purity: ast::unsafe_fn, + purity: ast::UnsafeFn, sig: ty::FnSig {binder_id: def_id.node, inputs: input_tys, output: output_ty, diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 7c232c8168f..2b2115173ae 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -63,7 +63,7 @@ use util::common::indent; use util::ppaux::Repr; use std::result; -use syntax::ast::{Onceness, purity}; +use syntax::ast::{Onceness, Purity}; use syntax::ast; use syntax::opt_vec; use syntax::abi::AbiSet; @@ -245,7 +245,7 @@ pub trait Combine { } } - fn purities(&self, a: purity, b: purity) -> cres<purity>; + fn purities(&self, a: Purity, b: Purity) -> cres<Purity>; fn abis(&self, a: AbiSet, b: AbiSet) -> cres<AbiSet> { if a == b { @@ -591,7 +591,7 @@ pub fn super_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> cres<ty::t> { this: &C, vid_is_expected: bool, vid: ty::FloatVid, - val: ast::float_ty) -> cres<ty::t> + val: ast::FloatTy) -> cres<ty::t> { if_ok!(this.infcx().simple_var_t(vid_is_expected, vid, val)); Ok(ty::mk_mach_float(val)) diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 137ba657ad5..075a45e1613 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -21,9 +21,9 @@ use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::infer::{TypeTrace, Subtype}; use middle::typeck::infer::fold_regions_in_sig; -use syntax::ast::{Many, Once, extern_fn, impure_fn, MutImmutable, MutMutable}; -use syntax::ast::{unsafe_fn, NodeId}; -use syntax::ast::{Onceness, purity}; +use syntax::ast::{Many, Once, MutImmutable, MutMutable}; +use syntax::ast::{ExternFn, ImpureFn, UnsafeFn, NodeId}; +use syntax::ast::{Onceness, Purity}; use std::hashmap::HashMap; use util::common::{indenter}; use util::ppaux::mt_to_str; @@ -81,11 +81,11 @@ impl Combine for Glb { Lub(*self.get_ref()).tys(a, b) } - fn purities(&self, a: purity, b: purity) -> cres<purity> { + fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { match (a, b) { - (extern_fn, _) | (_, extern_fn) => Ok(extern_fn), - (impure_fn, _) | (_, impure_fn) => Ok(impure_fn), - (unsafe_fn, unsafe_fn) => Ok(unsafe_fn) + (ExternFn, _) | (_, ExternFn) => Ok(ExternFn), + (ImpureFn, _) | (_, ImpureFn) => Ok(ImpureFn), + (UnsafeFn, UnsafeFn) => Ok(UnsafeFn) } } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 0cb16c8fbfb..23bd0600383 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -22,9 +22,9 @@ use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::infer::fold_regions_in_sig; use middle::typeck::infer::{TypeTrace, Subtype}; use std::hashmap::HashMap; -use syntax::ast::{Many, Once, extern_fn, impure_fn, NodeId}; -use syntax::ast::{unsafe_fn}; -use syntax::ast::{Onceness, purity}; +use syntax::ast::{Many, Once, NodeId}; +use syntax::ast::{ExternFn, ImpureFn, UnsafeFn}; +use syntax::ast::{Onceness, Purity}; use util::ppaux::mt_to_str; pub struct Lub(CombineFields); // least-upper-bound: common supertype @@ -79,11 +79,11 @@ impl Combine for Lub { Glb(*self.get_ref()).tys(a, b) } - fn purities(&self, a: purity, b: purity) -> cres<purity> { + fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { match (a, b) { - (unsafe_fn, _) | (_, unsafe_fn) => Ok(unsafe_fn), - (impure_fn, _) | (_, impure_fn) => Ok(impure_fn), - (extern_fn, extern_fn) => Ok(extern_fn), + (UnsafeFn, _) | (_, UnsafeFn) => Ok(UnsafeFn), + (ImpureFn, _) | (_, ImpureFn) => Ok(ImpureFn), + (ExternFn, ExternFn) => Ok(ExternFn), } } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index f859d3b2add..cb714399c16 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -89,7 +89,7 @@ pub struct InferCtxt { // Map from floating variable to the kind of float it represents float_var_bindings: RefCell<ValsAndBindings<ty::FloatVid, - Option<ast::float_ty>>>, + Option<ast::FloatTy>>>, float_var_counter: Cell<uint>, // For region variables. diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 93ac3d8c254..498f4707f92 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -260,8 +260,7 @@ impl ResolveState { if self.should(force_ivar) { // As a last resort, default to int. let ty = ty::mk_int(); - self.infcx.set(vid, - Root(Some(IntType(ast::ty_i)), node.rank)); + self.infcx.set(vid, Root(Some(IntType(ast::TyI)), node.rank)); ty } else { ty::mk_int_var(self.infcx.tcx, vid) @@ -282,7 +281,7 @@ impl ResolveState { if self.should(force_fvar) { // As a last resort, default to f64. let ty = ty::mk_f64(); - self.infcx.set(vid, Root(Some(ast::ty_f64), node.rank)); + self.infcx.set(vid, Root(Some(ast::TyF64), node.rank)); ty } else { ty::mk_float_var(self.infcx.tcx, vid) diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 81faec297a1..6e370a85096 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -25,7 +25,7 @@ use middle::typeck::infer::{TypeTrace, Subtype}; use util::common::{indenter}; use util::ppaux::bound_region_to_str; -use syntax::ast::{Onceness, purity}; +use syntax::ast::{Onceness, Purity}; pub struct Sub(CombineFields); // "subtype", "subregion" etc @@ -87,7 +87,7 @@ impl Combine for Sub { } } - fn purities(&self, a: purity, b: purity) -> cres<purity> { + fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { self.lub().purities(a, b).compare(b, || { ty::terr_purity_mismatch(expected_found(self, a, b)) }) diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index f2ea3a320ee..dc8e090596d 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -105,7 +105,7 @@ impl Env { }; fn search_mod(self: &Env, - m: &ast::_mod, + m: &ast::Mod, idx: uint, names: &[~str]) -> Option<ast::node_id> { assert!(idx < names.len()); @@ -118,7 +118,7 @@ impl Env { } fn search(self: &Env, - it: @ast::item, + it: @ast::Item, idx: uint, names: &[~str]) -> Option<ast::node_id> { if idx == names.len() { @@ -126,18 +126,18 @@ impl Env { } return match it.node { - ast::item_const(..) | ast::item_fn(..) | - ast::item_foreign_mod(..) | ast::item_ty(..) => { + ast::ItemConst(..) | ast::ItemFn(..) | + ast::ItemForeignMod(..) | ast::ItemTy(..) => { None } - ast::item_enum(..) | ast::item_struct(..) | - ast::item_trait(..) | ast::item_impl(..) | - ast::item_mac(..) => { + ast::ItemEnum(..) | ast::ItemStruct(..) | + ast::ItemTrait(..) | ast::ItemImpl(..) | + ast::ItemMac(..) => { None } - ast::item_mod(ref m) => { + ast::ItemMod(ref m) => { search_mod(self, m, idx, names) } }; @@ -185,7 +185,7 @@ impl Env { let inputs = input_tys.map(|t| {mode: ast::expl(ast::by_copy), ty: *t}); ty::mk_fn(self.tcx, FnTyBase { - meta: FnMeta {purity: ast::impure_fn, + meta: FnMeta {purity: ast::ImpureFn, proto: ast::ProtoBare, onceness: ast::Many, region: ty::ReStatic, diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs index 2bb7a994593..d604d68dd54 100644 --- a/src/librustc/middle/typeck/infer/to_str.rs +++ b/src/librustc/middle/typeck/infer/to_str.rs @@ -82,7 +82,7 @@ impl InferStr for IntVarValue { } } -impl InferStr for ast::float_ty { +impl InferStr for ast::FloatTy { fn inf_str(&self, _cx: &InferCtxt) -> ~str { self.to_str() } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 1ec9b49ba4b..e34947930fa 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -296,16 +296,15 @@ impl SimplyUnifiable for IntVarValue { } } -impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid { +impl UnifyVid<Option<ast::FloatTy>> for ty::FloatVid { fn appropriate_vals_and_bindings<'v>(infcx: &'v InferCtxt) - -> &'v RefCell<ValsAndBindings<ty::FloatVid, - Option<ast::float_ty>>> { + -> &'v RefCell<ValsAndBindings<ty::FloatVid, Option<ast::FloatTy>>> { return &infcx.float_var_bindings; } } -impl SimplyUnifiable for ast::float_ty { - fn to_type_err(err: expected_found<ast::float_ty>) -> ty::type_err { +impl SimplyUnifiable for ast::FloatTy { + fn to_type_err(err: expected_found<ast::FloatTy>) -> ty::type_err { return ty::terr_float_mismatch(err); } } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 982e2ca0685..d3f075774c5 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -152,7 +152,7 @@ pub struct method_map_entry { self_mode: ty::SelfMode, // the type of explicit self on the method - explicit_self: ast::explicit_self_, + explicit_self: ast::ExplicitSelf_, // method details being invoked origin: method_origin, @@ -352,9 +352,9 @@ fn check_main_fn_ty(ccx: &CrateCtxt, ty::ty_bare_fn(..) => { let items = tcx.items.borrow(); match items.get().find(&main_id) { - Some(&ast_map::node_item(it,_)) => { + Some(&ast_map::NodeItem(it,_)) => { match it.node { - ast::item_fn(_, _, _, ref ps, _) + ast::ItemFn(_, _, _, ref ps, _) if ps.is_parameterized() => { tcx.sess.span_err( main_span, @@ -367,7 +367,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt, _ => () } let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy { - purity: ast::impure_fn, + purity: ast::ImpureFn, abis: abi::AbiSet::Rust(), sig: ty::FnSig { binder_id: main_id, @@ -398,9 +398,9 @@ fn check_start_fn_ty(ccx: &CrateCtxt, ty::ty_bare_fn(_) => { let items = tcx.items.borrow(); match items.get().find(&start_id) { - Some(&ast_map::node_item(it,_)) => { + Some(&ast_map::NodeItem(it,_)) => { match it.node { - ast::item_fn(_,_,_,ref ps,_) + ast::ItemFn(_,_,_,ref ps,_) if ps.is_parameterized() => { tcx.sess.span_err( start_span, @@ -414,7 +414,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, } let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy { - purity: ast::impure_fn, + purity: ast::ImpureFn, abis: abi::AbiSet::Rust(), sig: ty::FnSig { binder_id: start_id, diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 6ddb023066e..b5e5bdfd65b 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -328,7 +328,7 @@ impl<'a> TermsContext<'a> { } impl<'a> Visitor<()> for TermsContext<'a> { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { debug!("add_inferreds for item {}", item.repr(self.tcx)); let inferreds_on_entry = self.num_inferred(); @@ -337,16 +337,16 @@ impl<'a> Visitor<()> for TermsContext<'a> { // tcx, we rely on the fact that all inferreds for a particular // item are assigned continuous indices. match item.node { - ast::item_trait(..) => { + ast::ItemTrait(..) => { self.add_inferred(item.id, SelfParam, 0, item.id); } _ => { } } match item.node { - ast::item_enum(_, ref generics) | - ast::item_struct(_, ref generics) | - ast::item_trait(ref generics, _, _) => { + ast::ItemEnum(_, ref generics) | + ast::ItemStruct(_, ref generics) | + ast::ItemTrait(ref generics, _, _) => { for (i, p) in generics.lifetimes.iter().enumerate() { self.add_inferred(item.id, RegionParam, i, p.id); } @@ -374,13 +374,13 @@ impl<'a> Visitor<()> for TermsContext<'a> { visit::walk_item(self, item, ()); } - ast::item_impl(..) | - ast::item_static(..) | - ast::item_fn(..) | - ast::item_mod(..) | - ast::item_foreign_mod(..) | - ast::item_ty(..) | - ast::item_mac(..) => { + ast::ItemImpl(..) | + ast::ItemStatic(..) | + ast::ItemFn(..) | + ast::ItemMod(..) | + ast::ItemForeignMod(..) | + ast::ItemTy(..) | + ast::ItemMac(..) => { visit::walk_item(self, item, ()); } } @@ -433,12 +433,12 @@ fn add_constraints_from_crate<'a>(terms_cx: TermsContext<'a>, } impl<'a> Visitor<()> for ConstraintContext<'a> { - fn visit_item(&mut self, item: &ast::item, _: ()) { + fn visit_item(&mut self, item: &ast::Item, _: ()) { let did = ast_util::local_def(item.id); let tcx = self.terms_cx.tcx; match item.node { - ast::item_enum(ref enum_definition, _) => { + ast::ItemEnum(ref enum_definition, _) => { // Hack: If we directly call `ty::enum_variants`, it // annoyingly takes it upon itself to run off and // evaluate the discriminants eagerly (*grumpy* that's @@ -460,7 +460,7 @@ impl<'a> Visitor<()> for ConstraintContext<'a> { } } - ast::item_struct(..) => { + ast::ItemStruct(..) => { let struct_fields = ty::lookup_struct_fields(tcx, did); for field_info in struct_fields.iter() { assert_eq!(field_info.id.crate, ast::LOCAL_CRATE); @@ -469,7 +469,7 @@ impl<'a> Visitor<()> for ConstraintContext<'a> { } } - ast::item_trait(..) => { + ast::ItemTrait(..) => { let methods = ty::trait_methods(tcx, did); for method in methods.iter() { match method.transformed_self_ty { @@ -493,13 +493,13 @@ impl<'a> Visitor<()> for ConstraintContext<'a> { } } - ast::item_static(..) | - ast::item_fn(..) | - ast::item_mod(..) | - ast::item_foreign_mod(..) | - ast::item_ty(..) | - ast::item_impl(..) | - ast::item_mac(..) => { + ast::ItemStatic(..) | + ast::ItemFn(..) | + ast::ItemMod(..) | + ast::ItemForeignMod(..) | + ast::ItemTy(..) | + ast::ItemImpl(..) | + ast::ItemMac(..) => { visit::walk_item(self, item, ()); } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 6a346eac425..6ef00fa9d00 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -74,13 +74,13 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) ReScope(node_id) => { let items = cx.items.borrow(); match items.get().find(&node_id) { - Some(&ast_map::node_block(ref blk)) => { + Some(&ast_map::NodeBlock(ref blk)) => { explain_span(cx, "block", blk.span) } - Some(&ast_map::node_callee_scope(expr)) => { + Some(&ast_map::NodeCalleeScope(expr)) => { explain_span(cx, "callee", expr.span) } - Some(&ast_map::node_expr(expr)) => { + Some(&ast_map::NodeExpr(expr)) => { match expr.node { ast::ExprCall(..) => explain_span(cx, "call", expr.span), ast::ExprMethodCall(..) => { @@ -90,11 +90,11 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) _ => explain_span(cx, "expression", expr.span) } } - Some(&ast_map::node_stmt(stmt)) => { + Some(&ast_map::NodeStmt(stmt)) => { explain_span(cx, "statement", stmt.span) } - Some(&ast_map::node_item(it, _)) if (match it.node { - ast::item_fn(..) => true, _ => false}) => { + Some(&ast_map::NodeItem(it, _)) if (match it.node { + ast::ItemFn(..) => true, _ => false}) => { explain_span(cx, "function body", it.span) } Some(_) | None => { @@ -116,12 +116,12 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) let items = cx.items.borrow(); match items.get().find(&fr.scope_id) { - Some(&ast_map::node_block(ref blk)) => { + Some(&ast_map::NodeBlock(ref blk)) => { let (msg, opt_span) = explain_span(cx, "block", blk.span); (format!("{} {}", prefix, msg), opt_span) } - Some(&ast_map::node_item(it, _)) if match it.node { - ast::item_impl(..) => true, _ => false} => { + Some(&ast_map::NodeItem(it, _)) if match it.node { + ast::ItemImpl(..) => true, _ => false} => { let (msg, opt_span) = explain_span(cx, "impl", it.span); (format!("{} {}", prefix, msg), opt_span) } @@ -176,11 +176,11 @@ pub fn bound_region_to_str(cx: ctxt, pub fn ReScope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str { let items = cx.items.borrow(); match items.get().find(&node_id) { - Some(&ast_map::node_block(ref blk)) => { + Some(&ast_map::NodeBlock(ref blk)) => { format!("<block at {}>", cx.sess.codemap.span_to_str(blk.span)) } - Some(&ast_map::node_expr(expr)) => { + Some(&ast_map::NodeExpr(expr)) => { match expr.node { ast::ExprCall(..) => { format!("<call at {}>", @@ -314,7 +314,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_to_str(cx, input) } fn bare_fn_to_str(cx: ctxt, - purity: ast::purity, + purity: ast::Purity, abis: AbiSet, ident: Option<ast::Ident>, sig: &ty::FnSig) @@ -326,7 +326,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { }; match purity { - ast::impure_fn => {} + ast::ImpureFn => {} _ => { s.push_str(purity.to_str()); s.push_char(' '); @@ -368,7 +368,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { } match cty.purity { - ast::impure_fn => {} + ast::ImpureFn => {} _ => { s.push_str(cty.purity.to_str()); s.push_char(' '); @@ -449,9 +449,9 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_bot => ~"!", ty_bool => ~"bool", ty_char => ~"char", - ty_int(ast::ty_i) => ~"int", + ty_int(ast::TyI) => ~"int", ty_int(t) => ast_util::int_ty_to_str(t), - ty_uint(ast::ty_u) => ~"uint", + ty_uint(ast::TyU) => ~"uint", ty_uint(t) => ast_util::uint_ty_to_str(t), ty_float(t) => ast_util::float_ty_to_str(t), ty_box(typ) => ~"@" + ty_to_str(cx, typ), @@ -665,7 +665,7 @@ impl Repr for ast::Expr { } } -impl Repr for ast::item { +impl Repr for ast::Item { fn repr(&self, tcx: ctxt) -> ~str { format!("item({})", ast_map::node_id_to_str(tcx.items, @@ -746,12 +746,12 @@ impl Repr for ast::DefId { { let items = tcx.items.borrow(); match items.get().find(&self.node) { - Some(&ast_map::node_item(..)) | - Some(&ast_map::node_foreign_item(..)) | - Some(&ast_map::node_method(..)) | - Some(&ast_map::node_trait_method(..)) | - Some(&ast_map::node_variant(..)) | - Some(&ast_map::node_struct_ctor(..)) => { + Some(&ast_map::NodeItem(..)) | + Some(&ast_map::NodeForeignItem(..)) | + Some(&ast_map::NodeMethod(..)) | + Some(&ast_map::NodeTraitMethod(..)) | + Some(&ast_map::NodeVariant(..)) | + Some(&ast_map::NodeStructCtor(..)) => { return format!("{:?}:{}", *self, ty::item_path_str(tcx, *self)); @@ -815,13 +815,13 @@ impl Repr for ast::Ident { } } -impl Repr for ast::explicit_self_ { +impl Repr for ast::ExplicitSelf_ { fn repr(&self, _tcx: ctxt) -> ~str { format!("{:?}", *self) } } -impl Repr for ast::visibility { +impl Repr for ast::Visibility { fn repr(&self, _tcx: ctxt) -> ~str { format!("{:?}", *self) } @@ -911,12 +911,12 @@ impl Repr for ty::vstore { } } -impl Repr for ast_map::path_elt { +impl Repr for ast_map::PathElem { fn repr(&self, tcx: ctxt) -> ~str { match *self { - ast_map::path_mod(id) => id.repr(tcx), - ast_map::path_name(id) => id.repr(tcx), - ast_map::path_pretty_name(id, _) => id.repr(tcx), + ast_map::PathMod(id) => id.repr(tcx), + ast_map::PathName(id) => id.repr(tcx), + ast_map::PathPrettyName(id, _) => id.repr(tcx), } } } diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 8e63dca57b0..3de2c67032e 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -324,11 +324,11 @@ impl Clean<Generics> for ast::Generics { pub struct Method { generics: Generics, self_: SelfTy, - purity: ast::purity, + purity: ast::Purity, decl: FnDecl, } -impl Clean<Item> for ast::method { +impl Clean<Item> for ast::Method { fn clean(&self) -> Item { Item { name: Some(self.ident.clean()), @@ -348,7 +348,7 @@ impl Clean<Item> for ast::method { #[deriving(Clone, Encodable, Decodable)] pub struct TyMethod { - purity: ast::purity, + purity: ast::Purity, decl: FnDecl, generics: Generics, self_: SelfTy, @@ -381,14 +381,14 @@ pub enum SelfTy { SelfOwned, } -impl Clean<SelfTy> for ast::explicit_self { +impl Clean<SelfTy> for ast::ExplicitSelf { fn clean(&self) -> SelfTy { match self.node { - ast::sty_static => SelfStatic, - ast::sty_value(_) => SelfValue, - ast::sty_uniq(_) => SelfOwned, - ast::sty_region(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()), - ast::sty_box(mt) => SelfManaged(mt.clean()), + ast::SelfStatic => SelfStatic, + ast::SelfValue(_) => SelfValue, + ast::SelfUniq(_) => SelfOwned, + ast::SelfRegion(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()), + ast::SelfBox(mt) => SelfManaged(mt.clean()), } } } @@ -397,7 +397,7 @@ impl Clean<SelfTy> for ast::explicit_self { pub struct Function { decl: FnDecl, generics: Generics, - purity: ast::purity, + purity: ast::Purity, } impl Clean<Item> for doctree::Function { @@ -424,11 +424,11 @@ pub struct ClosureDecl { lifetimes: ~[Lifetime], decl: FnDecl, onceness: ast::Onceness, - purity: ast::purity, + purity: ast::Purity, bounds: ~[TyParamBound] } -impl Clean<ClosureDecl> for ast::TyClosure { +impl Clean<ClosureDecl> for ast::ClosureTy { fn clean(&self) -> ClosureDecl { ClosureDecl { sigil: self.sigil, @@ -453,7 +453,7 @@ pub struct FnDecl { attrs: ~[Attribute] } -impl Clean<FnDecl> for ast::fn_decl { +impl Clean<FnDecl> for ast::FnDecl { fn clean(&self) -> FnDecl { FnDecl { inputs: self.inputs.iter().map(|x| x.clean()).collect(), @@ -471,7 +471,7 @@ pub struct Argument { id: ast::NodeId } -impl Clean<Argument> for ast::arg { +impl Clean<Argument> for ast::Arg { fn clean(&self) -> Argument { Argument { name: name_from_pat(self.pat), @@ -487,11 +487,11 @@ pub enum RetStyle { Return } -impl Clean<RetStyle> for ast::ret_style { +impl Clean<RetStyle> for ast::RetStyle { fn clean(&self) -> RetStyle { match *self { - ast::return_val => Return, - ast::noreturn => NoReturn + ast::Return => Return, + ast::NoReturn => NoReturn } } } @@ -520,7 +520,7 @@ impl Clean<Item> for doctree::Trait { } } -impl Clean<Type> for ast::trait_ref { +impl Clean<Type> for ast::TraitRef { fn clean(&self) -> Type { resolve_type(self.path.clean(), None, self.ref_id) } @@ -553,11 +553,11 @@ impl TraitMethod { } } -impl Clean<TraitMethod> for ast::trait_method { +impl Clean<TraitMethod> for ast::TraitMethod { fn clean(&self) -> TraitMethod { match self { - &ast::required(ref t) => Required(t.clean()), - &ast::provided(ref t) => Provided(t.clean()), + &ast::Required(ref t) => Required(t.clean()), + &ast::Provided(ref t) => Provided(t.clean()), } } } @@ -567,7 +567,7 @@ impl Clean<TraitMethod> for ast::trait_method { /// it does not preserve mutability or boxes. #[deriving(Clone, Encodable, Decodable)] pub enum Type { - /// structs/enums/traits (anything that'd be an ast::ty_path) + /// structs/enums/traits (anything that'd be an ast::TyPath) ResolvedPath { path: Path, typarams: Option<~[TyParamBound]>, @@ -589,7 +589,7 @@ pub enum Type { /// For references to self Self(ast::NodeId), /// Primitives are just the fixed-size numeric types (plus int/uint/float), and char. - Primitive(ast::prim_ty), + Primitive(ast::PrimTy), Closure(~ClosureDecl), /// extern "ABI" fn BareFunction(~BareFunctionDecl), @@ -650,10 +650,10 @@ pub struct StructField { type_: Type, } -impl Clean<Item> for ast::struct_field { +impl Clean<Item> for ast::StructField { fn clean(&self) -> Item { let (name, vis) = match self.node.kind { - ast::named_field(id, vis) => (Some(id), Some(vis)), + ast::NamedField(id, vis) => (Some(id), Some(vis)), _ => (None, None) }; Item { @@ -669,9 +669,9 @@ impl Clean<Item> for ast::struct_field { } } -pub type Visibility = ast::visibility; +pub type Visibility = ast::Visibility; -impl Clean<Option<Visibility>> for ast::visibility { +impl Clean<Option<Visibility>> for ast::Visibility { fn clean(&self) -> Option<Visibility> { Some(*self) } @@ -713,7 +713,7 @@ pub struct VariantStruct { fields_stripped: bool, } -impl Clean<VariantStruct> for syntax::ast::struct_def { +impl Clean<VariantStruct> for syntax::ast::StructDef { fn clean(&self) -> VariantStruct { VariantStruct { struct_type: doctree::struct_type_from_def(self), @@ -774,17 +774,17 @@ pub enum VariantKind { StructVariant(VariantStruct), } -impl Clean<VariantKind> for ast::variant_kind { +impl Clean<VariantKind> for ast::VariantKind { fn clean(&self) -> VariantKind { match self { - &ast::tuple_variant_kind(ref args) => { + &ast::TupleVariantKind(ref args) => { if args.len() == 0 { CLikeVariant } else { TupleVariant(args.iter().map(|x| x.ty.clean()).collect()) } }, - &ast::struct_variant_kind(ref sd) => StructVariant(sd.clean()), + &ast::StructVariantKind(ref sd) => StructVariant(sd.clean()), } } } @@ -892,13 +892,13 @@ impl Clean<Item> for doctree::Typedef { #[deriving(Clone, Encodable, Decodable)] pub struct BareFunctionDecl { - purity: ast::purity, + purity: ast::Purity, generics: Generics, decl: FnDecl, abi: ~str } -impl Clean<BareFunctionDecl> for ast::TyBareFn { +impl Clean<BareFunctionDecl> for ast::BareFnTy { fn clean(&self) -> BareFunctionDecl { BareFunctionDecl { purity: self.purity, @@ -986,7 +986,7 @@ pub struct ViewItem { inner: ViewItemInner } -impl Clean<Item> for ast::view_item { +impl Clean<Item> for ast::ViewItem { fn clean(&self) -> Item { Item { name: None, @@ -1007,12 +1007,12 @@ pub enum ViewItemInner { Import(~[ViewPath]) } -impl Clean<ViewItemInner> for ast::view_item_ { +impl Clean<ViewItemInner> for ast::ViewItem_ { fn clean(&self) -> ViewItemInner { match self { - &ast::view_item_extern_mod(ref i, ref p, ref id) => + &ast::ViewItemExternMod(ref i, ref p, ref id) => ExternMod(i.clean(), p.map(|(ref x, _)| x.to_owned()), *id), - &ast::view_item_use(ref vp) => Import(vp.clean()) + &ast::ViewItemUse(ref vp) => Import(vp.clean()) } } } @@ -1033,14 +1033,14 @@ pub struct ImportSource { did: Option<ast::DefId>, } -impl Clean<ViewPath> for ast::view_path { +impl Clean<ViewPath> for ast::ViewPath { fn clean(&self) -> ViewPath { match self.node { - ast::view_path_simple(ref i, ref p, id) => + ast::ViewPathSimple(ref i, ref p, id) => SimpleImport(i.clean(), resolve_use_source(p.clean(), id)), - ast::view_path_glob(ref p, id) => + ast::ViewPathGlob(ref p, id) => GlobImport(resolve_use_source(p.clean(), id)), - ast::view_path_list(ref p, ref pl, id) => + ast::ViewPathList(ref p, ref pl, id) => ImportList(resolve_use_source(p.clean(), id), pl.clean()), } } @@ -1052,7 +1052,7 @@ pub struct ViewListIdent { source: Option<ast::DefId>, } -impl Clean<ViewListIdent> for ast::path_list_ident { +impl Clean<ViewListIdent> for ast::PathListIdent { fn clean(&self) -> ViewListIdent { ViewListIdent { name: self.node.name.clean(), @@ -1061,23 +1061,23 @@ impl Clean<ViewListIdent> for ast::path_list_ident { } } -impl Clean<~[Item]> for ast::foreign_mod { +impl Clean<~[Item]> for ast::ForeignMod { fn clean(&self) -> ~[Item] { self.items.clean() } } -impl Clean<Item> for ast::foreign_item { +impl Clean<Item> for ast::ForeignItem { fn clean(&self) -> Item { let inner = match self.node { - ast::foreign_item_fn(ref decl, ref generics) => { + ast::ForeignItemFn(ref decl, ref generics) => { ForeignFunctionItem(Function { decl: decl.clean(), generics: generics.clean(), - purity: ast::extern_fn, + purity: ast::ExternFn, }) } - ast::foreign_item_static(ref ty, mutbl) => { + ast::ForeignItemStatic(ref ty, mutbl) => { ForeignStaticItem(Static { type_: ty.clean(), mutability: if mutbl {Mutable} else {Immutable}, @@ -1115,18 +1115,18 @@ impl ToSource for syntax::codemap::Span { } } -fn lit_to_str(lit: &ast::lit) -> ~str { +fn lit_to_str(lit: &ast::Lit) -> ~str { match lit.node { - ast::lit_str(st, _) => st.to_owned(), - ast::lit_binary(data) => format!("{:?}", data.as_slice()), - ast::lit_char(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'", - ast::lit_int(i, _t) => i.to_str(), - ast::lit_uint(u, _t) => u.to_str(), - ast::lit_int_unsuffixed(i) => i.to_str(), - ast::lit_float(f, _t) => f.to_str(), - ast::lit_float_unsuffixed(f) => f.to_str(), - ast::lit_bool(b) => b.to_str(), - ast::lit_nil => ~"", + ast::LitStr(st, _) => st.to_owned(), + ast::LitBinary(data) => format!("{:?}", data.as_slice()), + ast::LitChar(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'", + ast::LitInt(i, _t) => i.to_str(), + ast::LitUint(u, _t) => u.to_str(), + ast::LitIntUnsuffixed(i) => i.to_str(), + ast::LitFloat(f, _t) => f.to_str(), + ast::LitFloatUnsuffixed(f) => f.to_str(), + ast::LitBool(b) => b.to_str(), + ast::LitNil => ~"", } } @@ -1186,8 +1186,8 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>, (i, TypeTrait) }, ast::DefPrimTy(p) => match p { - ast::ty_str => return String, - ast::ty_bool => return Bool, + ast::TyStr => return String, + ast::TyBool => return Bool, _ => return Primitive(p) }, ast::DefTyParam(i, _) => return Generic(i.node), diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 3bec7359760..38252658a48 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -28,10 +28,10 @@ pub struct Module { typedefs: ~[Typedef], statics: ~[Static], traits: ~[Trait], - vis: ast::visibility, + vis: ast::Visibility, impls: ~[Impl], - foreigns: ~[ast::foreign_mod], - view_items: ~[ast::view_item], + foreigns: ~[ast::ForeignMod], + view_items: ~[ast::ViewItem], } impl Module { @@ -70,22 +70,22 @@ pub enum StructType { pub enum TypeBound { RegionBound, - TraitBound(ast::trait_ref) + TraitBound(ast::TraitRef) } pub struct Struct { - vis: ast::visibility, + vis: ast::Visibility, id: NodeId, struct_type: StructType, name: Ident, generics: ast::Generics, attrs: ~[ast::Attribute], - fields: ~[ast::struct_field], + fields: ~[ast::StructField], where: Span, } pub struct Enum { - vis: ast::visibility, + vis: ast::Visibility, variants: ~[Variant], generics: ast::Generics, attrs: ~[ast::Attribute], @@ -97,19 +97,19 @@ pub struct Enum { pub struct Variant { name: Ident, attrs: ~[ast::Attribute], - kind: ast::variant_kind, + kind: ast::VariantKind, id: ast::NodeId, - vis: ast::visibility, + vis: ast::Visibility, where: Span, } pub struct Function { - decl: ast::fn_decl, + decl: ast::FnDecl, attrs: ~[ast::Attribute], id: NodeId, name: Ident, - vis: ast::visibility, - purity: ast::purity, + vis: ast::Visibility, + purity: ast::Purity, where: Span, generics: ast::Generics, } @@ -121,7 +121,7 @@ pub struct Typedef { id: ast::NodeId, attrs: ~[ast::Attribute], where: Span, - vis: ast::visibility, + vis: ast::Visibility, } pub struct Static { @@ -130,34 +130,34 @@ pub struct Static { expr: @ast::Expr, name: Ident, attrs: ~[ast::Attribute], - vis: ast::visibility, + vis: ast::Visibility, id: ast::NodeId, where: Span, } pub struct Trait { name: Ident, - methods: ~[ast::trait_method], //should be TraitMethod + methods: ~[ast::TraitMethod], //should be TraitMethod generics: ast::Generics, - parents: ~[ast::trait_ref], + parents: ~[ast::TraitRef], attrs: ~[ast::Attribute], id: ast::NodeId, where: Span, - vis: ast::visibility, + vis: ast::Visibility, } pub struct Impl { generics: ast::Generics, - trait_: Option<ast::trait_ref>, + trait_: Option<ast::TraitRef>, for_: ast::P<ast::Ty>, - methods: ~[@ast::method], + methods: ~[@ast::Method], attrs: ~[ast::Attribute], where: Span, - vis: ast::visibility, + vis: ast::Visibility, id: ast::NodeId, } -pub fn struct_type_from_def(sd: &ast::struct_def) -> StructType { +pub fn struct_type_from_def(sd: &ast::StructDef) -> StructType { if sd.ctor_id.is_some() { // We are in a tuple-struct match sd.fields.len() { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index edc47fd2d69..0838085b9cb 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -28,21 +28,21 @@ use html::render::{cache_key, current_location_key}; /// Helper to render an optional visibility with a space after it (if the /// visibility is preset) -pub struct VisSpace(Option<ast::visibility>); +pub struct VisSpace(Option<ast::Visibility>); /// Similarly to VisSpace, this structure is used to render a purity with a /// space after it. -pub struct PuritySpace(ast::purity); +pub struct PuritySpace(ast::Purity); /// Wrapper struct for properly emitting a method declaration. pub struct Method<'a>(&'a clean::SelfTy, &'a clean::FnDecl); impl VisSpace { - pub fn get(&self) -> Option<ast::visibility> { + pub fn get(&self) -> Option<ast::Visibility> { let VisSpace(v) = *self; v } } impl PuritySpace { - pub fn get(&self) -> ast::purity { + pub fn get(&self) -> ast::Purity { let PuritySpace(v) = *self; v } } @@ -290,21 +290,21 @@ impl fmt::Default for clean::Type { clean::Self(..) => f.buf.write("Self".as_bytes()), clean::Primitive(prim) => { let s = match prim { - ast::ty_int(ast::ty_i) => "int", - ast::ty_int(ast::ty_i8) => "i8", - ast::ty_int(ast::ty_i16) => "i16", - ast::ty_int(ast::ty_i32) => "i32", - ast::ty_int(ast::ty_i64) => "i64", - ast::ty_uint(ast::ty_u) => "uint", - ast::ty_uint(ast::ty_u8) => "u8", - ast::ty_uint(ast::ty_u16) => "u16", - ast::ty_uint(ast::ty_u32) => "u32", - ast::ty_uint(ast::ty_u64) => "u64", - ast::ty_float(ast::ty_f32) => "f32", - ast::ty_float(ast::ty_f64) => "f64", - ast::ty_str => "str", - ast::ty_bool => "bool", - ast::ty_char => "char", + ast::TyInt(ast::TyI) => "int", + ast::TyInt(ast::TyI8) => "i8", + ast::TyInt(ast::TyI16) => "i16", + ast::TyInt(ast::TyI32) => "i32", + ast::TyInt(ast::TyI64) => "i64", + ast::TyUint(ast::TyU) => "uint", + ast::TyUint(ast::TyU8) => "u8", + ast::TyUint(ast::TyU16) => "u16", + ast::TyUint(ast::TyU32) => "u32", + ast::TyUint(ast::TyU64) => "u64", + ast::TyFloat(ast::TyF32) => "f32", + ast::TyFloat(ast::TyF64) => "f64", + ast::TyStr => "str", + ast::TyBool => "bool", + ast::TyChar => "char", }; f.buf.write(s.as_bytes()); } @@ -437,9 +437,9 @@ impl<'a> fmt::Default for Method<'a> { impl fmt::Default for VisSpace { fn fmt(v: &VisSpace, f: &mut fmt::Formatter) { match v.get() { - Some(ast::public) => { write!(f.buf, "pub "); } - Some(ast::private) => { write!(f.buf, "priv "); } - Some(ast::inherited) | None => {} + Some(ast::Public) => { write!(f.buf, "pub "); } + Some(ast::Private) => { write!(f.buf, "priv "); } + Some(ast::Inherited) | None => {} } } } @@ -447,9 +447,9 @@ impl fmt::Default for VisSpace { impl fmt::Default for PuritySpace { fn fmt(p: &PuritySpace, f: &mut fmt::Formatter) { match p.get() { - ast::unsafe_fn => write!(f.buf, "unsafe "), - ast::extern_fn => write!(f.buf, "extern "), - ast::impure_fn => {} + ast::UnsafeFn => write!(f.buf, "unsafe "), + ast::ExternFn => write!(f.buf, "extern "), + ast::ImpureFn => {} } } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index a74b457fbd1..35eb9e88a4a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1149,7 +1149,7 @@ fn item_trait(w: &mut Writer, it: &clean::Item, t: &clean::Trait) { } fn render_method(w: &mut Writer, meth: &clean::Item, withlink: bool) { - fn fun(w: &mut Writer, it: &clean::Item, purity: ast::purity, + fn fun(w: &mut Writer, it: &clean::Item, purity: ast::Purity, g: &clean::Generics, selfty: &clean::SelfTy, d: &clean::FnDecl, withlink: bool) { write!(w, "{}fn {withlink, select, @@ -1158,7 +1158,7 @@ fn render_method(w: &mut Writer, meth: &clean::Item, withlink: bool) { other{<span class='fnname'>{name}</span>} }{generics}{decl}", match purity { - ast::unsafe_fn => "unsafe ", + ast::UnsafeFn => "unsafe ", _ => "", }, ty = shortty(it), diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 2740e75b3fc..f333c98789c 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -96,13 +96,13 @@ impl<'a> fold::DocFolder for Stripper<'a> { } clean::ViewItemItem(..) => { - if i.visibility != Some(ast::public) { + if i.visibility != Some(ast::Public) { return None } } clean::StructFieldItem(..) => { - if i.visibility == Some(ast::private) { + if i.visibility == Some(ast::Private) { return None; } } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 60df2402e9e..c96502c55b3 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -42,13 +42,12 @@ impl<'a> RustdocVisitor<'a> { self.attrs = crate.attrs.clone(); self.module = self.visit_mod_contents(crate.span, crate.attrs.clone(), - ast::public, ast::CRATE_NODE_ID, + ast::Public, ast::CRATE_NODE_ID, &crate.module, None); } - pub fn visit_struct_def(&mut self, item: &ast::item, sd: @ast::struct_def, - - generics: &ast::Generics) -> Struct { + pub fn visit_struct_def(&mut self, item: &ast::Item, sd: @ast::StructDef, + generics: &ast::Generics) -> Struct { debug!("Visiting struct"); let struct_type = struct_type_from_def(sd); Struct { @@ -63,8 +62,8 @@ impl<'a> RustdocVisitor<'a> { } } - pub fn visit_enum_def(&mut self, it: &ast::item, def: &ast::enum_def, - params: &ast::Generics) -> Enum { + pub fn visit_enum_def(&mut self, it: &ast::Item, def: &ast::EnumDef, + params: &ast::Generics) -> Enum { debug!("Visiting enum"); let mut vars: ~[Variant] = ~[]; for x in def.variants.iter() { @@ -88,8 +87,8 @@ impl<'a> RustdocVisitor<'a> { } } - pub fn visit_fn(&mut self, item: &ast::item, fd: &ast::fn_decl, - purity: &ast::purity, _abi: &AbiSet, + pub fn visit_fn(&mut self, item: &ast::Item, fd: &ast::FnDecl, + purity: &ast::Purity, _abi: &AbiSet, gen: &ast::Generics) -> Function { debug!("Visiting fn"); Function { @@ -105,8 +104,8 @@ impl<'a> RustdocVisitor<'a> { } pub fn visit_mod_contents(&mut self, span: Span, attrs: ~[ast::Attribute], - vis: ast::visibility, id: ast::NodeId, - m: &ast::_mod, + vis: ast::Visibility, id: ast::NodeId, + m: &ast::Mod, name: Option<ast::Ident>) -> Module { let mut om = Module::new(name); for item in m.view_items.iter() { @@ -194,10 +193,10 @@ impl<'a> RustdocVisitor<'a> { *items.get().get(&def.node) }; match item { - ast_map::node_item(it, _) => { + ast_map::NodeItem(it, _) => { if glob { match it.node { - ast::item_mod(ref m) => { + ast::ItemMod(ref m) => { for vi in m.view_items.iter() { self.visit_view_item(vi, om); } @@ -216,21 +215,21 @@ impl<'a> RustdocVisitor<'a> { } } - pub fn visit_item(&mut self, item: &ast::item, om: &mut Module) { + pub fn visit_item(&mut self, item: &ast::Item, om: &mut Module) { debug!("Visiting item {:?}", item); match item.node { - ast::item_mod(ref m) => { + ast::ItemMod(ref m) => { om.mods.push(self.visit_mod_contents(item.span, item.attrs.clone(), item.vis, item.id, m, Some(item.ident))); }, - ast::item_enum(ref ed, ref gen) => + ast::ItemEnum(ref ed, ref gen) => om.enums.push(self.visit_enum_def(item, ed, gen)), - ast::item_struct(sd, ref gen) => + ast::ItemStruct(sd, ref gen) => om.structs.push(self.visit_struct_def(item, sd, gen)), - ast::item_fn(fd, ref pur, ref abi, ref gen, _) => + ast::ItemFn(fd, ref pur, ref abi, ref gen, _) => om.fns.push(self.visit_fn(item, fd, pur, abi, gen)), - ast::item_ty(ty, ref gen) => { + ast::ItemTy(ty, ref gen) => { let t = Typedef { ty: ty, gen: gen.clone(), @@ -242,7 +241,7 @@ impl<'a> RustdocVisitor<'a> { }; om.typedefs.push(t); }, - ast::item_static(ty, ref mut_, ref exp) => { + ast::ItemStatic(ty, ref mut_, ref exp) => { let s = Static { type_: ty, mutability: mut_.clone(), @@ -255,7 +254,7 @@ impl<'a> RustdocVisitor<'a> { }; om.statics.push(s); }, - ast::item_trait(ref gen, ref tr, ref met) => { + ast::ItemTrait(ref gen, ref tr, ref met) => { let t = Trait { name: item.ident, methods: met.clone(), @@ -268,7 +267,7 @@ impl<'a> RustdocVisitor<'a> { }; om.traits.push(t); }, - ast::item_impl(ref gen, ref tr, ty, ref meths) => { + ast::ItemImpl(ref gen, ref tr, ty, ref meths) => { let i = Impl { generics: gen.clone(), trait_: tr.clone(), @@ -281,7 +280,7 @@ impl<'a> RustdocVisitor<'a> { }; om.impls.push(i); }, - ast::item_foreign_mod(ref fm) => { + ast::ItemForeignMod(ref fm) => { om.foreigns.push(fm.clone()); } _ => (), diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 8111c8a805d..73356078eac 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -23,7 +23,7 @@ use syntax::codemap::{DUMMY_SP, Spanned}; use syntax::ext::base::ExtCtxt; use syntax::{ast, attr, codemap, diagnostic, fold, visit}; use syntax::attr::AttrMetaMethods; -use syntax::fold::ast_fold; +use syntax::fold::Folder; use syntax::visit::Visitor; use syntax::util::small_vector::SmallVector; use rustc::back::link::output_type_exe; @@ -70,9 +70,9 @@ struct ReadyCtx { fns: ~[ListenerFn] } -fn fold_mod(m: &ast::_mod, fold: &mut CrateSetup) -> ast::_mod { - fn strip_main(item: @ast::item) -> @ast::item { - @ast::item { +fn fold_mod(m: &ast::Mod, fold: &mut CrateSetup) -> ast::Mod { + fn strip_main(item: @ast::Item) -> @ast::Item { + @ast::Item { attrs: item.attrs.iter().filter_map(|attr| { if "main" != attr.name() { Some(*attr) @@ -84,14 +84,14 @@ fn fold_mod(m: &ast::_mod, fold: &mut CrateSetup) -> ast::_mod { } } - fold::noop_fold_mod(&ast::_mod { + fold::noop_fold_mod(&ast::Mod { items: m.items.map(|item| strip_main(*item)), .. (*m).clone() }, fold) } -fn fold_item(item: @ast::item, fold: &mut CrateSetup) - -> SmallVector<@ast::item> { +fn fold_item(item: @ast::Item, fold: &mut CrateSetup) + -> SmallVector<@ast::Item> { fold.ctx.path.push(item.ident); let mut cmds = ~[]; @@ -133,11 +133,11 @@ struct CrateSetup<'a> { ctx: &'a mut ReadyCtx, } -impl<'a> fold::ast_fold for CrateSetup<'a> { - fn fold_item(&mut self, item: @ast::item) -> SmallVector<@ast::item> { +impl<'a> fold::Folder for CrateSetup<'a> { + fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> { fold_item(item, self) } - fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod { + fn fold_mod(&mut self, module: &ast::Mod) -> ast::Mod { fold_mod(module, self) } } @@ -350,7 +350,7 @@ pub fn compile_crate_from_input(input: &Path, // Returns None if one of the flags that suppresses compilation output was // given crate: ast::Crate, - ast_map: syntax::ast_map::map, + ast_map: syntax::ast_map::Map, what: OutputType) -> Option<Path> { debug!("Calling build_output_filenames with {}, building library? {:?}", out_dir.display(), sess.building_library); @@ -447,12 +447,12 @@ struct ViewItemVisitor<'a> { } impl<'a> Visitor<()> for ViewItemVisitor<'a> { - fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) { + fn visit_view_item(&mut self, vi: &ast::ViewItem, env: ()) { use conditions::nonexistent_package::cond; match vi.node { // ignore metadata, I guess - ast::view_item_extern_mod(lib_ident, path_opt, _) => { + ast::ViewItemExternMod(lib_ident, path_opt, _) => { let lib_name = match path_opt { Some((p, _)) => p, None => self.sess.str_of(lib_ident) @@ -619,9 +619,9 @@ pub fn find_and_install_dependencies(context: &BuildContext, visit::walk_crate(&mut visitor, c, ()) } -pub fn mk_string_lit(s: @str) -> ast::lit { +pub fn mk_string_lit(s: @str) -> ast::Lit { Spanned { - node: ast::lit_str(s, ast::CookedStr), + node: ast::LitStr(s, ast::CookedStr), span: DUMMY_SP } } diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 9f69379f3c5..9194acfcdec 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -32,6 +32,7 @@ pub enum Abi { RustIntrinsic, } +#[allow(non_camel_case_types)] #[deriving(Eq)] pub enum Architecture { // NB. You cannot change the ordering of these diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 8864c678b95..2458577aa86 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -197,7 +197,7 @@ pub static DUMMY_NODE_ID: NodeId = -1; // detects Copy, Send, Send, and Freeze. #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum TyParamBound { - TraitTyParamBound(trait_ref), + TraitTyParamBound(TraitRef), RegionTyParamBound } @@ -234,8 +234,8 @@ pub enum MethodProvenance { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum Def { - DefFn(DefId, purity), - DefStaticMethod(/* method */ DefId, MethodProvenance, purity), + DefFn(DefId, Purity), + DefStaticMethod(/* method */ DefId, MethodProvenance, Purity), DefSelf(NodeId, bool /* is_mutbl */), DefSelfTy(/* trait id */ NodeId), DefMod(DefId), @@ -246,7 +246,7 @@ pub enum Def { DefVariant(DefId /* enum */, DefId /* variant */, bool /* is_structure */), DefTy(DefId), DefTrait(DefId), - DefPrimTy(prim_ty), + DefPrimTy(PrimTy), DefTyParam(DefId, uint), DefBinding(NodeId, BindingMode), DefUse(DefId), @@ -256,13 +256,13 @@ pub enum Def { NodeId), // id for the block/body of the closure expr /// Note that if it's a tuple struct's definition, the node id of the DefId - /// may either refer to the item definition's id or the struct_def.ctor_id. + /// may either refer to the item definition's id or the StructDef.ctor_id. /// /// The cases that I have encountered so far are (this is not exhaustive): /// - If it's a ty_path referring to some tuple struct, then DefMap maps /// it to a def whose id is the item definition's id. /// - If it's an ExprPath referring to some tuple struct, then DefMap maps - /// it to a def whose id is the struct_def.ctor_id. + /// it to a def whose id is the StructDef.ctor_id. DefStruct(DefId), DefTyParamBinder(NodeId), /* struct, impl or trait with ty params */ DefRegion(NodeId), @@ -284,7 +284,7 @@ pub type CrateConfig = ~[@MetaItem]; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Crate { - module: _mod, + module: Mod, attrs: ~[Attribute], config: CrateConfig, span: Span, @@ -296,7 +296,7 @@ pub type MetaItem = Spanned<MetaItem_>; pub enum MetaItem_ { MetaWord(@str), MetaList(@str, ~[@MetaItem]), - MetaNameValue(@str, lit), + MetaNameValue(@str, Lit), } // can't be derived because the MetaList requires an unordered comparison @@ -326,7 +326,7 @@ impl Eq for MetaItem_ { #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] pub struct Block { - view_items: ~[view_item], + view_items: ~[ViewItem], stmts: ~[@Stmt], expr: Option<@Expr>, id: NodeId, @@ -464,7 +464,7 @@ pub enum Stmt_ { StmtSemi(@Expr, NodeId), // bool: is there a trailing sem-colon? - StmtMac(mac, bool), + StmtMac(Mac, bool), } // FIXME (pending discussion of #1697, #2178...): local should really be @@ -486,7 +486,7 @@ pub enum Decl_ { // a local (let) binding: DeclLocal(@Local), // an item binding: - DeclItem(@item), + DeclItem(@Item), } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -553,7 +553,7 @@ pub enum Expr_ { ExprTup(~[@Expr]), ExprBinary(NodeId, BinOp, @Expr, @Expr), ExprUnary(NodeId, UnOp, @Expr), - ExprLit(@lit), + ExprLit(@Lit), ExprCast(@Expr, P<Ty>), ExprIf(@Expr, P<Block>, Option<@Expr>), ExprWhile(@Expr, P<Block>), @@ -563,8 +563,8 @@ pub enum Expr_ { // FIXME #6993: change to Option<Name> ExprLoop(P<Block>, Option<Ident>), ExprMatch(@Expr, ~[Arm]), - ExprFnBlock(P<fn_decl>, P<Block>), - ExprProc(P<fn_decl>, P<Block>), + ExprFnBlock(P<FnDecl>, P<Block>), + ExprProc(P<FnDecl>, P<Block>), ExprDoBody(@Expr), ExprBlock(P<Block>), @@ -588,9 +588,9 @@ pub enum Expr_ { /// Gets the log level for the enclosing module ExprLogLevel, - ExprInlineAsm(inline_asm), + ExprInlineAsm(InlineAsm), - ExprMac(mac), + ExprMac(Mac), // A struct literal expression. ExprStruct(Path, ~[Field], Option<@Expr> /* base */), @@ -610,31 +610,38 @@ pub enum Expr_ { // If the syntax extension is an MBE macro, it will attempt to match its // LHS "matchers" against the provided token tree, and if it finds a // match, will transcribe the RHS token tree, splicing in any captured -// macro_parser::matched_nonterminals into the tt_nonterminals it finds. +// macro_parser::matched_nonterminals into the TTNonterminals it finds. // -// The RHS of an MBE macro is the only place a tt_nonterminal or tt_seq +// The RHS of an MBE macro is the only place a TTNonterminal or TTSeq // makes any real sense. You could write them elsewhere but nothing // else knows what to do with them, so you'll probably get a syntax // error. // #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[doc="For macro invocations; parsing is delegated to the macro"] -pub enum token_tree { +pub enum TokenTree { // a single token - tt_tok(Span, ::parse::token::Token), + TTTok(Span, ::parse::token::Token), // a delimited sequence (the delimiters appear as the first // and last elements of the vector) - tt_delim(@~[token_tree]), + TTDelim(@~[TokenTree]), // These only make sense for right-hand-sides of MBE macros: - // a kleene-style repetition sequence with a span, a tt_forest, + // a kleene-style repetition sequence with a span, a TTForest, // an optional separator, and a boolean where true indicates // zero or more (..), and false indicates one or more (+). - tt_seq(Span, @~[token_tree], Option<::parse::token::Token>, bool), + TTSeq(Span, @~[TokenTree], Option<::parse::token::Token>, bool), // a syntactic variable that will be filled in by macro expansion. - tt_nonterminal(Span, Ident) + TTNonterminal(Span, Ident) +} + +// NOTE remove after next snapshot +// Required for ext::quote macros. +#[cfg(stage0)] +pub fn tt_tok(span: Span, tok: ::parse::token::Token) -> TokenTree { + TTTok(span, tok) } // @@ -646,15 +653,15 @@ pub enum token_tree { // token-trees, and are thus primarily used by the macro-defining extension // itself. // -// match_tok -// --------- +// MatchTok +// -------- // // A matcher that matches a single token, denoted by the token itself. So // long as there's no $ involved. // // -// match_seq -// --------- +// MatchSeq +// -------- // // A matcher that matches a sequence of sub-matchers, denoted various // possible ways: @@ -665,7 +672,7 @@ pub enum token_tree { // $(A B C);* zero or more semi-separated 'A B C' seqs // // -// match_nonterminal +// MatchNonterminal // ----------------- // // A matcher that matches one of a few interesting named rust @@ -682,35 +689,35 @@ pub enum token_tree { // // As a final, horrifying aside, note that macro-by-example's input is // also matched by one of these matchers. Holy self-referential! It is matched -// by an match_seq, specifically this one: +// by an MatchSeq, specifically this one: // // $( $lhs:matchers => $rhs:tt );+ // // If you understand that, you have closed to loop and understand the whole // macro system. Congratulations. // -pub type matcher = Spanned<matcher_>; +pub type Matcher = Spanned<Matcher_>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum matcher_ { +pub enum Matcher_ { // match one token - match_tok(::parse::token::Token), + MatchTok(::parse::token::Token), // match repetitions of a sequence: body, separator, zero ok?, // lo, hi position-in-match-array used: - match_seq(~[matcher], Option<::parse::token::Token>, bool, uint, uint), + MatchSeq(~[Matcher], Option<::parse::token::Token>, bool, uint, uint), // parse a Rust NT: name to bind, name of NT, position in match array: - match_nonterminal(Ident, Ident, uint) + MatchNonterminal(Ident, Ident, uint) } -pub type mac = Spanned<mac_>; +pub type Mac = Spanned<Mac_>; // represents a macro invocation. The Path indicates which macro // is being invoked, and the vector of token-trees contains the source // of the macro invocation. // There's only one flavor, now, so this could presumably be simplified. #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum mac_ { - mac_invoc_tt(Path,~[token_tree],SyntaxContext), // new macro-invocation +pub enum Mac_ { + MacInvocTT(Path, ~[TokenTree], SyntaxContext), // new macro-invocation } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -719,26 +726,26 @@ pub enum StrStyle { RawStr(uint) } -pub type lit = Spanned<lit_>; +pub type Lit = Spanned<Lit_>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum lit_ { - lit_str(@str, StrStyle), - lit_binary(@[u8]), - lit_char(u32), - lit_int(i64, int_ty), - lit_uint(u64, uint_ty), - lit_int_unsuffixed(i64), - lit_float(@str, float_ty), - lit_float_unsuffixed(@str), - lit_nil, - lit_bool(bool), +pub enum Lit_ { + LitStr(@str, StrStyle), + LitBinary(@[u8]), + LitChar(u32), + LitInt(i64, IntTy), + LitUint(u64, UintTy), + LitIntUnsuffixed(i64), + LitFloat(@str, FloatTy), + LitFloatUnsuffixed(@str), + LitNil, + LitBool(bool), } // NB: If you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct mt { +pub struct MutTy { ty: P<Ty>, mutbl: Mutability, } @@ -746,7 +753,7 @@ pub struct mt { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct TypeField { ident: Ident, - mt: mt, + mt: MutTy, span: Span, } @@ -754,10 +761,10 @@ pub struct TypeField { pub struct TypeMethod { ident: Ident, attrs: ~[Attribute], - purity: purity, - decl: P<fn_decl>, + purity: Purity, + decl: P<FnDecl>, generics: Generics, - explicit_self: explicit_self, + explicit_self: ExplicitSelf, id: NodeId, span: Span, } @@ -766,48 +773,48 @@ pub struct TypeMethod { // implementation, just a signature) or provided (meaning it has a default // implementation). #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum trait_method { - required(TypeMethod), - provided(@method), +pub enum TraitMethod { + Required(TypeMethod), + Provided(@Method), } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum int_ty { - ty_i, - ty_i8, - ty_i16, - ty_i32, - ty_i64, +pub enum IntTy { + TyI, + TyI8, + TyI16, + TyI32, + TyI64, } -impl ToStr for int_ty { +impl ToStr for IntTy { fn to_str(&self) -> ~str { ::ast_util::int_ty_to_str(*self) } } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum uint_ty { - ty_u, - ty_u8, - ty_u16, - ty_u32, - ty_u64, +pub enum UintTy { + TyU, + TyU8, + TyU16, + TyU32, + TyU64, } -impl ToStr for uint_ty { +impl ToStr for UintTy { fn to_str(&self) -> ~str { ::ast_util::uint_ty_to_str(*self) } } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum float_ty { - ty_f32, - ty_f64, +pub enum FloatTy { + TyF32, + TyF64, } -impl ToStr for float_ty { +impl ToStr for FloatTy { fn to_str(&self) -> ~str { ::ast_util::float_ty_to_str(*self) } @@ -817,19 +824,19 @@ impl ToStr for float_ty { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Ty { id: NodeId, - node: ty_, + node: Ty_, span: Span, } // Not represented directly in the AST, referred to by name through a ty_path. #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum prim_ty { - ty_int(int_ty), - ty_uint(uint_ty), - ty_float(float_ty), - ty_str, - ty_bool, - ty_char +pub enum PrimTy { + TyInt(IntTy), + TyUint(UintTy), + TyFloat(FloatTy), + TyStr, + TyBool, + TyChar } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -848,13 +855,13 @@ impl ToStr for Onceness { } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct TyClosure { +pub struct ClosureTy { sigil: Sigil, region: Option<Lifetime>, lifetimes: OptVec<Lifetime>, - purity: purity, + purity: Purity, onceness: Onceness, - decl: P<fn_decl>, + decl: P<FnDecl>, // Optional optvec distinguishes between "fn()" and "fn:()" so we can // implement issue #7264. None means "fn()", which means infer a default // bound based on pointer sigil during typeck. Some(Empty) means "fn:()", @@ -863,42 +870,42 @@ pub struct TyClosure { } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct TyBareFn { - purity: purity, +pub struct BareFnTy { + purity: Purity, abis: AbiSet, lifetimes: OptVec<Lifetime>, - decl: P<fn_decl> + decl: P<FnDecl> } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum ty_ { - ty_nil, - ty_bot, /* bottom type */ - ty_box(P<Ty>), - ty_uniq(P<Ty>), - ty_vec(P<Ty>), - ty_fixed_length_vec(P<Ty>, @Expr), - ty_ptr(mt), - ty_rptr(Option<Lifetime>, mt), - ty_closure(@TyClosure), - ty_bare_fn(@TyBareFn), - ty_tup(~[P<Ty>]), - ty_path(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above - ty_typeof(@Expr), +pub enum Ty_ { + TyNil, + TyBot, /* bottom type */ + TyBox(P<Ty>), + TyUniq(P<Ty>), + TyVec(P<Ty>), + TyFixedLengthVec(P<Ty>, @Expr), + TyPtr(MutTy), + TyRptr(Option<Lifetime>, MutTy), + TyClosure(@ClosureTy), + TyBareFn(@BareFnTy), + TyTup(~[P<Ty>]), + TyPath(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above + TyTypeof(@Expr), // ty_infer means the type should be inferred instead of it having been // specified. This should only appear at the "top level" of a type and not // nested in one. - ty_infer, + TyInfer, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum asm_dialect { - asm_att, - asm_intel +pub enum AsmDialect { + AsmAtt, + AsmIntel } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct inline_asm { +pub struct InlineAsm { asm: @str, asm_str_style: StrStyle, clobbers: @str, @@ -906,159 +913,159 @@ pub struct inline_asm { outputs: ~[(@str, @Expr)], volatile: bool, alignstack: bool, - dialect: asm_dialect + dialect: AsmDialect } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct arg { +pub struct Arg { ty: P<Ty>, pat: @Pat, id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct fn_decl { - inputs: ~[arg], +pub struct FnDecl { + inputs: ~[Arg], output: P<Ty>, - cf: ret_style, + cf: RetStyle, variadic: bool } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum purity { - unsafe_fn, // declared with "unsafe fn" - impure_fn, // declared with "fn" - extern_fn, // declared with "extern fn" +pub enum Purity { + UnsafeFn, // declared with "unsafe fn" + ImpureFn, // declared with "fn" + ExternFn, // declared with "extern fn" } -impl ToStr for purity { +impl ToStr for Purity { fn to_str(&self) -> ~str { match *self { - impure_fn => ~"impure", - unsafe_fn => ~"unsafe", - extern_fn => ~"extern" + ImpureFn => ~"impure", + UnsafeFn => ~"unsafe", + ExternFn => ~"extern" } } } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum ret_style { - noreturn, // functions with return type _|_ that always +pub enum RetStyle { + NoReturn, // functions with return type _|_ that always // raise an error or exit (i.e. never return to the caller) - return_val, // everything else + Return, // everything else } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum explicit_self_ { - sty_static, // no self - sty_value(Mutability), // `self` - sty_region(Option<Lifetime>, Mutability), // `&'lt self` - sty_box(Mutability), // `@self` - sty_uniq(Mutability) // `~self` +pub enum ExplicitSelf_ { + SelfStatic, // no self + SelfValue(Mutability), // `self` + SelfRegion(Option<Lifetime>, Mutability), // `&'lt self` + SelfBox(Mutability), // `@self` + SelfUniq(Mutability) // `~self` } -pub type explicit_self = Spanned<explicit_self_>; +pub type ExplicitSelf = Spanned<ExplicitSelf_>; #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct method { +pub struct Method { ident: Ident, attrs: ~[Attribute], generics: Generics, - explicit_self: explicit_self, - purity: purity, - decl: P<fn_decl>, + explicit_self: ExplicitSelf, + purity: Purity, + decl: P<FnDecl>, body: P<Block>, id: NodeId, span: Span, self_id: NodeId, - vis: visibility, + vis: Visibility, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct _mod { - view_items: ~[view_item], - items: ~[@item], +pub struct Mod { + view_items: ~[ViewItem], + items: ~[@Item], } #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] -pub struct foreign_mod { +pub struct ForeignMod { abis: AbiSet, - view_items: ~[view_item], - items: ~[@foreign_item], + view_items: ~[ViewItem], + items: ~[@ForeignItem], } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct variant_arg { +pub struct VariantArg { ty: P<Ty>, id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum variant_kind { - tuple_variant_kind(~[variant_arg]), - struct_variant_kind(@struct_def), +pub enum VariantKind { + TupleVariantKind(~[VariantArg]), + StructVariantKind(@StructDef), } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct enum_def { - variants: ~[P<variant>], +pub struct EnumDef { + variants: ~[P<Variant>], } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct variant_ { +pub struct Variant_ { name: Ident, attrs: ~[Attribute], - kind: variant_kind, + kind: VariantKind, id: NodeId, disr_expr: Option<@Expr>, - vis: visibility, + vis: Visibility, } -pub type variant = Spanned<variant_>; +pub type Variant = Spanned<Variant_>; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct path_list_ident_ { +pub struct PathListIdent_ { name: Ident, id: NodeId, } -pub type path_list_ident = Spanned<path_list_ident_>; +pub type PathListIdent = Spanned<PathListIdent_>; -pub type view_path = Spanned<view_path_>; +pub type ViewPath = Spanned<ViewPath_>; #[deriving(Eq, Encodable, Decodable, IterBytes)] -pub enum view_path_ { +pub enum ViewPath_ { // quux = foo::bar::baz // // or just // // foo::bar::baz (with 'baz =' implicitly on the left) - view_path_simple(Ident, Path, NodeId), + ViewPathSimple(Ident, Path, NodeId), // foo::bar::* - view_path_glob(Path, NodeId), + ViewPathGlob(Path, NodeId), // foo::bar::{a,b,c} - view_path_list(Path, ~[path_list_ident], NodeId) + ViewPathList(Path, ~[PathListIdent], NodeId) } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct view_item { - node: view_item_, +pub struct ViewItem { + node: ViewItem_, attrs: ~[Attribute], - vis: visibility, + vis: Visibility, span: Span, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum view_item_ { +pub enum ViewItem_ { // ident: name used to refer to this crate in the code // optional @str: if present, this is a location (containing // arbitrary characters) from which to fetch the crate sources // For example, extern mod whatever = "github.com/mozilla/rust" - view_item_extern_mod(Ident, Option<(@str, StrStyle)>, NodeId), - view_item_use(~[@view_path]), + ViewItemExternMod(Ident, Option<(@str, StrStyle)>, NodeId), + ViewItemUse(~[@ViewPath]), } // Meta-data associated with an item @@ -1082,53 +1089,53 @@ pub struct Attribute_ { } /* - trait_refs appear in impls. - resolve maps each trait_ref's ref_id to its defining trait; that's all + TraitRef's appear in impls. + resolve maps each TraitRef's ref_id to its defining trait; that's all that the ref_id is for. The impl_id maps to the "self type" of this impl. - If this impl is an item_impl, the impl_id is redundant (it could be the + If this impl is an ItemImpl, the impl_id is redundant (it could be the same as the impl's node id). */ #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] -pub struct trait_ref { +pub struct TraitRef { path: Path, ref_id: NodeId, } #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] -pub enum visibility { - public, - private, - inherited, +pub enum Visibility { + Public, + Private, + Inherited, } -impl visibility { - pub fn inherit_from(&self, parent_visibility: visibility) -> visibility { +impl Visibility { + pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility { match self { - &inherited => parent_visibility, - &public | &private => *self + &Inherited => parent_visibility, + &Public | &Private => *self } } } #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] -pub struct struct_field_ { - kind: struct_field_kind, +pub struct StructField_ { + kind: StructFieldKind, id: NodeId, ty: P<Ty>, attrs: ~[Attribute], } -pub type struct_field = Spanned<struct_field_>; +pub type StructField = Spanned<StructField_>; #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] -pub enum struct_field_kind { - named_field(Ident, visibility), - unnamed_field // element of a tuple-like struct +pub enum StructFieldKind { + NamedField(Ident, Visibility), + UnnamedField // element of a tuple-like struct } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct struct_def { - fields: ~[struct_field], /* fields, not including ctor */ +pub struct StructDef { + fields: ~[StructField], /* fields, not including ctor */ /* ID of the constructor. This is only used for tuple- or enum-like * structs. */ ctor_id: Option<NodeId> @@ -1139,57 +1146,57 @@ pub struct struct_def { we just use dummy names for anon items. */ #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct item { +pub struct Item { ident: Ident, attrs: ~[Attribute], id: NodeId, - node: item_, - vis: visibility, + node: Item_, + vis: Visibility, span: Span, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum item_ { - item_static(P<Ty>, Mutability, @Expr), - item_fn(P<fn_decl>, purity, AbiSet, Generics, P<Block>), - item_mod(_mod), - item_foreign_mod(foreign_mod), - item_ty(P<Ty>, Generics), - item_enum(enum_def, Generics), - item_struct(@struct_def, Generics), - item_trait(Generics, ~[trait_ref], ~[trait_method]), - item_impl(Generics, - Option<trait_ref>, // (optional) trait this impl implements - P<Ty>, // self - ~[@method]), +pub enum Item_ { + ItemStatic(P<Ty>, Mutability, @Expr), + ItemFn(P<FnDecl>, Purity, AbiSet, Generics, P<Block>), + ItemMod(Mod), + ItemForeignMod(ForeignMod), + ItemTy(P<Ty>, Generics), + ItemEnum(EnumDef, Generics), + ItemStruct(@StructDef, Generics), + ItemTrait(Generics, ~[TraitRef], ~[TraitMethod]), + ItemImpl(Generics, + Option<TraitRef>, // (optional) trait this impl implements + P<Ty>, // self + ~[@Method]), // a macro invocation (which includes macro definition) - item_mac(mac), + ItemMac(Mac), } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct foreign_item { +pub struct ForeignItem { ident: Ident, attrs: ~[Attribute], - node: foreign_item_, + node: ForeignItem_, id: NodeId, span: Span, - vis: visibility, + vis: Visibility, } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub enum foreign_item_ { - foreign_item_fn(P<fn_decl>, Generics), - foreign_item_static(P<Ty>, /* is_mutbl */ bool), +pub enum ForeignItem_ { + ForeignItemFn(P<FnDecl>, Generics), + ForeignItemStatic(P<Ty>, /* is_mutbl */ bool), } // The data we save and restore about an inlined item or method. This is not // part of the AST that we parse from a file, but it becomes part of the tree // that we trans. #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub enum inlined_item { - ii_item(@item), - ii_method(DefId /* impl id */, bool /* is provided */, @method), - ii_foreign(@foreign_item), +pub enum InlinedItem { + IIItem(@Item), + IIMethod(DefId /* impl id */, bool /* is provided */, @Method), + IIForeign(@ForeignItem), } #[cfg(test)] @@ -1200,7 +1207,7 @@ mod test { // Assert that the AST remains Freeze (#10693). #[test] fn ast_is_freeze() { - is_freeze::<item>(); + is_freeze::<Item>(); } } @@ -1292,7 +1299,7 @@ mod test { let e : crate = spanned{ node: crate_{ - module: _mod {view_items: ~[], items: ~[]}, + module: Mod {view_items: ~[], items: ~[]}, attrs: ~[], config: ~[] }, diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a19b930be3e..0f5737d775e 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -14,10 +14,9 @@ use ast; use ast_util; use codemap::Span; use diagnostic::SpanHandler; -use fold::ast_fold; +use fold::Folder; use fold; -use parse::token::get_ident_interner; -use parse::token::ident_interner; +use parse::token::{get_ident_interner, IdentInterner}; use parse::token::special_idents; use print::pprust; use util::small_vector::SmallVector; @@ -26,34 +25,34 @@ use std::cell::RefCell; use std::hashmap::HashMap; #[deriving(Clone, Eq)] -pub enum path_elt { - path_mod(Ident), - path_name(Ident), +pub enum PathElem { + PathMod(Ident), + PathName(Ident), // A pretty name can come from an `impl` block. We attempt to select a // reasonable name for debuggers to see, but to guarantee uniqueness with // other paths the hash should also be taken into account during symbol // generation. - path_pretty_name(Ident, u64), + PathPrettyName(Ident, u64), } -impl path_elt { +impl PathElem { pub fn ident(&self) -> Ident { match *self { - path_mod(ident) | - path_name(ident) | - path_pretty_name(ident, _) => ident + PathMod(ident) | + PathName(ident) | + PathPrettyName(ident, _) => ident } } } -pub type path = ~[path_elt]; +pub type Path = ~[PathElem]; -pub fn path_to_str_with_sep(p: &[path_elt], sep: &str, itr: @ident_interner) - -> ~str { +pub fn path_to_str_with_sep(p: &[PathElem], sep: &str, itr: @IdentInterner) + -> ~str { let strs = p.map(|e| { match *e { - path_mod(s) | path_name(s) | path_pretty_name(s, _) => { + PathMod(s) | PathName(s) | PathPrettyName(s, _) => { itr.get(s.name) } } @@ -61,7 +60,7 @@ pub fn path_to_str_with_sep(p: &[path_elt], sep: &str, itr: @ident_interner) strs.connect(sep) } -pub fn path_ident_to_str(p: &path, i: Ident, itr: @ident_interner) -> ~str { +pub fn path_ident_to_str(p: &Path, i: Ident, itr: @IdentInterner) -> ~str { if p.is_empty() { itr.get(i.name).to_owned() } else { @@ -69,13 +68,13 @@ pub fn path_ident_to_str(p: &path, i: Ident, itr: @ident_interner) -> ~str { } } -pub fn path_to_str(p: &[path_elt], itr: @ident_interner) -> ~str { +pub fn path_to_str(p: &[PathElem], itr: @IdentInterner) -> ~str { path_to_str_with_sep(p, "::", itr) } -pub fn path_elt_to_str(pe: path_elt, itr: @ident_interner) -> ~str { +pub fn path_elem_to_str(pe: PathElem, itr: @IdentInterner) -> ~str { match pe { - path_mod(s) | path_name(s) | path_pretty_name(s, _) => { + PathMod(s) | PathName(s) | PathPrettyName(s, _) => { itr.get(s.name).to_owned() } } @@ -90,26 +89,26 @@ pub fn path_elt_to_str(pe: path_elt, itr: @ident_interner) -> ~str { // relic of $ being one of the very few valid symbol names on // unix. These kinds of details shouldn't be exposed way up here // in the ast. -fn pretty_ty(ty: &Ty, itr: @ident_interner, out: &mut ~str) { +fn pretty_ty(ty: &Ty, itr: @IdentInterner, out: &mut ~str) { let (prefix, subty) = match ty.node { - ty_uniq(ty) => ("$UP$", &*ty), - ty_box(ty) => ("$SP$", &*ty), - ty_ptr(mt { ty, mutbl }) => (if mutbl == MutMutable {"$RPmut$"} else {"$RP$"}, - &*ty), - ty_rptr(_, mt { ty, mutbl }) => (if mutbl == MutMutable {"$BPmut$"} else {"$BP$"}, - &*ty), + TyUniq(ty) => ("$UP$", &*ty), + TyBox(ty) => ("$SP$", &*ty), + TyPtr(MutTy { ty, mutbl }) => (if mutbl == MutMutable {"$RPmut$"} else {"$RP$"}, + &*ty), + TyRptr(_, MutTy { ty, mutbl }) => (if mutbl == MutMutable {"$BPmut$"} else {"$BP$"}, + &*ty), - ty_vec(ty) => ("$VEC$", &*ty), - ty_fixed_length_vec(ty, _) => ("$FIXEDVEC$", &*ty), + TyVec(ty) => ("$VEC$", &*ty), + TyFixedLengthVec(ty, _) => ("$FIXEDVEC$", &*ty), // these can't be represented as <prefix><contained ty>, so // need custom handling. - ty_nil => { out.push_str("$NIL$"); return } - ty_path(ref path, _, _) => { - out.push_str(itr.get(path.segments.last().identifier.name)); - return - } - ty_tup(ref tys) => { + TyNil => { out.push_str("$NIL$"); return } + TyPath(ref path, _, _) => { + out.push_str(itr.get(path.segments.last().identifier.name)); + return + } + TyTup(ref tys) => { out.push_str(format!("$TUP_{}$", tys.len())); for subty in tys.iter() { pretty_ty(*subty, itr, out); @@ -119,11 +118,11 @@ fn pretty_ty(ty: &Ty, itr: @ident_interner, out: &mut ~str) { } // meh, better than nothing. - ty_bot => { out.push_str("$BOT$"); return } - ty_closure(..) => { out.push_str("$CLOSURE$"); return } - ty_bare_fn(..) => { out.push_str("$FN$"); return } - ty_typeof(..) => { out.push_str("$TYPEOF$"); return } - ty_infer(..) => { out.push_str("$INFER$"); return } + TyBot => { out.push_str("$BOT$"); return } + TyClosure(..) => { out.push_str("$CLOSURE$"); return } + TyBareFn(..) => { out.push_str("$FN$"); return } + TyTypeof(..) => { out.push_str("$TYPEOF$"); return } + TyInfer(..) => { out.push_str("$INFER$"); return } }; @@ -131,7 +130,7 @@ fn pretty_ty(ty: &Ty, itr: @ident_interner, out: &mut ~str) { pretty_ty(subty, itr, out); } -pub fn impl_pretty_name(trait_ref: &Option<trait_ref>, ty: &Ty) -> path_elt { +pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: &Ty) -> PathElem { let itr = get_ident_interner(); let hash = (trait_ref, ty).hash(); @@ -145,56 +144,56 @@ pub fn impl_pretty_name(trait_ref: &Option<trait_ref>, ty: &Ty) -> path_elt { }; pretty_ty(ty, itr, &mut pretty); - path_pretty_name(Ident::new(itr.gensym(pretty)), hash) + PathPrettyName(Ident::new(itr.gensym(pretty)), hash) } #[deriving(Clone)] -pub enum ast_node { - node_item(@item, @path), - node_foreign_item(@foreign_item, AbiSet, visibility, @path), - node_trait_method(@trait_method, DefId /* trait did */, - @path /* path to the trait */), - node_method(@method, DefId /* impl did */, @path /* path to the impl */), - - /// node_variant represents a variant of an enum, e.g., for - /// `enum A { B, C, D }`, there would be a node_item for `A`, and a - /// node_variant item for each of `B`, `C`, and `D`. - node_variant(P<variant>, @item, @path), - node_expr(@Expr), - node_stmt(@Stmt), - node_arg(@Pat), +pub enum Node { + NodeItem(@Item, @Path), + NodeForeignItem(@ForeignItem, AbiSet, Visibility, @Path), + NodeTraitMethod(@TraitMethod, DefId /* trait did */, + @Path /* path to the trait */), + NodeMethod(@Method, DefId /* impl did */, @Path /* path to the impl */), + + /// NodeVariant represents a variant of an enum, e.g., for + /// `enum A { B, C, D }`, there would be a NodeItem for `A`, and a + /// NodeVariant item for each of `B`, `C`, and `D`. + NodeVariant(P<Variant>, @Item, @Path), + NodeExpr(@Expr), + NodeStmt(@Stmt), + NodeArg(@Pat), // HACK(eddyb) should always be a pattern, but `self` is not, and thus it // is identified only by an ident and no span is available. In all other // cases, node_span will return the proper span (required by borrowck). - node_local(Ident, Option<@Pat>), - node_block(P<Block>), + NodeLocal(Ident, Option<@Pat>), + NodeBlock(P<Block>), - /// node_struct_ctor represents a tuple struct. - node_struct_ctor(@struct_def, @item, @path), - node_callee_scope(@Expr) + /// NodeStructCtor represents a tuple struct. + NodeStructCtor(@StructDef, @Item, @Path), + NodeCalleeScope(@Expr) } -impl ast_node { +impl Node { pub fn with_attrs<T>(&self, f: |Option<&[Attribute]>| -> T) -> T { let attrs = match *self { - node_item(i, _) => Some(i.attrs.as_slice()), - node_foreign_item(fi, _, _, _) => Some(fi.attrs.as_slice()), - node_trait_method(tm, _, _) => match *tm { - required(ref type_m) => Some(type_m.attrs.as_slice()), - provided(m) => Some(m.attrs.as_slice()) + NodeItem(i, _) => Some(i.attrs.as_slice()), + NodeForeignItem(fi, _, _, _) => Some(fi.attrs.as_slice()), + NodeTraitMethod(tm, _, _) => match *tm { + Required(ref type_m) => Some(type_m.attrs.as_slice()), + Provided(m) => Some(m.attrs.as_slice()) }, - node_method(m, _, _) => Some(m.attrs.as_slice()), - node_variant(ref v, _, _) => Some(v.node.attrs.as_slice()), + NodeMethod(m, _, _) => Some(m.attrs.as_slice()), + NodeVariant(ref v, _, _) => Some(v.node.attrs.as_slice()), // unit/tuple structs take the attributes straight from // the struct definition. - node_struct_ctor(_, strct, _) => Some(strct.attrs.as_slice()), + NodeStructCtor(_, strct, _) => Some(strct.attrs.as_slice()), _ => None }; f(attrs) } } -pub type map = @RefCell<HashMap<NodeId, ast_node>>; +pub type Map = @RefCell<HashMap<NodeId, Node>>; pub trait FoldOps { fn new_id(&self, id: ast::NodeId) -> ast::NodeId { @@ -206,24 +205,24 @@ pub trait FoldOps { } pub struct Ctx<F> { - map: map, - path: path, + map: Map, + path: Path, diag: @SpanHandler, fold_ops: F } impl<F> Ctx<F> { - fn insert(&self, id: ast::NodeId, node: ast_node) { + fn insert(&self, id: ast::NodeId, node: Node) { let mut map = self.map.borrow_mut(); map.get().insert(id, node); } - fn map_self(&self, m: @method) { - self.insert(m.self_id, node_local(special_idents::self_, None)); + fn map_self(&self, m: @Method) { + self.insert(m.self_id, NodeLocal(special_idents::self_, None)); } } -impl<F: FoldOps> ast_fold for Ctx<F> { +impl<F: FoldOps> Folder for Ctx<F> { fn new_id(&mut self, id: ast::NodeId) -> ast::NodeId { self.fold_ops.new_id(id) } @@ -232,69 +231,65 @@ impl<F: FoldOps> ast_fold for Ctx<F> { self.fold_ops.new_span(span) } - fn fold_item(&mut self, i: @item) -> SmallVector<@item> { + fn fold_item(&mut self, i: @Item) -> SmallVector<@Item> { // clone is FIXME #2543 let item_path = @self.path.clone(); self.path.push(match i.node { - item_impl(_, ref maybe_trait, ty, _) => { + ItemImpl(_, ref maybe_trait, ty, _) => { // Right now the ident on impls is __extensions__ which isn't // very pretty when debugging, so attempt to select a better // name to use. impl_pretty_name(maybe_trait, ty) } - item_mod(_) | item_foreign_mod(_) => path_mod(i.ident), - _ => path_name(i.ident) + ItemMod(_) | ItemForeignMod(_) => PathMod(i.ident), + _ => PathName(i.ident) }); let i = fold::noop_fold_item(i, self).expect_one("expected one item"); - self.insert(i.id, node_item(i, item_path)); + self.insert(i.id, NodeItem(i, item_path)); match i.node { - item_impl(_, _, _, ref ms) => { + ItemImpl(_, _, _, ref ms) => { // clone is FIXME #2543 let p = @self.path.clone(); let impl_did = ast_util::local_def(i.id); for &m in ms.iter() { - self.insert(m.id, node_method(m, impl_did, p)); + self.insert(m.id, NodeMethod(m, impl_did, p)); self.map_self(m); } } - item_enum(ref enum_definition, _) => { + ItemEnum(ref enum_definition, _) => { // clone is FIXME #2543 let p = @self.path.clone(); for &v in enum_definition.variants.iter() { - self.insert(v.node.id, node_variant(v, i, p)); + self.insert(v.node.id, NodeVariant(v, i, p)); } } - item_foreign_mod(ref nm) => { + ItemForeignMod(ref nm) => { for nitem in nm.items.iter() { // Compute the visibility for this native item. - let visibility = match nitem.vis { - public => public, - private => private, - inherited => i.vis - }; + let visibility = nitem.vis.inherit_from(i.vis); self.insert(nitem.id, // Anonymous extern mods go in the parent scope. - node_foreign_item(*nitem, nm.abis, visibility, item_path)); + NodeForeignItem(*nitem, nm.abis, visibility, item_path)); } } - item_struct(struct_def, _) => { + ItemStruct(struct_def, _) => { // If this is a tuple-like struct, register the constructor. match struct_def.ctor_id { None => {} Some(ctor_id) => { // clone is FIXME #2543 let p = @self.path.clone(); - self.insert(ctor_id, node_struct_ctor(struct_def, i, p)); + self.insert(ctor_id, NodeStructCtor(struct_def, i, p)); } } } - item_trait(_, ref traits, ref methods) => { + ItemTrait(_, ref traits, ref methods) => { for t in traits.iter() { - self.insert(t.ref_id, node_item(i, item_path)); + self.insert(t.ref_id, NodeItem(i, item_path)); } // clone is FIXME #2543 @@ -302,11 +297,11 @@ impl<F: FoldOps> ast_fold for Ctx<F> { for tm in methods.iter() { let d_id = ast_util::local_def(i.id); match *tm { - required(ref m) => { - self.insert(m.id, node_trait_method(@(*tm).clone(), d_id, p)); + Required(ref m) => { + self.insert(m.id, NodeTraitMethod(@(*tm).clone(), d_id, p)); } - provided(m) => { - self.insert(m.id, node_trait_method(@provided(m), d_id, p)); + Provided(m) => { + self.insert(m.id, NodeTraitMethod(@Provided(m), d_id, p)); self.map_self(m); } } @@ -325,7 +320,7 @@ impl<F: FoldOps> ast_fold for Ctx<F> { match pat.node { PatIdent(_, ref path, _) => { // Note: this is at least *potentially* a pattern... - self.insert(pat.id, node_local(ast_util::path_to_ident(path), Some(pat))); + self.insert(pat.id, NodeLocal(ast_util::path_to_ident(path), Some(pat))); } _ => {} } @@ -336,13 +331,13 @@ impl<F: FoldOps> ast_fold for Ctx<F> { fn fold_expr(&mut self, expr: @Expr) -> @Expr { let expr = fold::noop_fold_expr(expr, self); - self.insert(expr.id, node_expr(expr)); + self.insert(expr.id, NodeExpr(expr)); // Expressions which are or might be calls: { let r = expr.get_callee_id(); for callee_id in r.iter() { - self.insert(*callee_id, node_callee_scope(expr)); + self.insert(*callee_id, NodeCalleeScope(expr)); } } @@ -351,34 +346,34 @@ impl<F: FoldOps> ast_fold for Ctx<F> { fn fold_stmt(&mut self, stmt: &Stmt) -> SmallVector<@Stmt> { let stmt = fold::noop_fold_stmt(stmt, self).expect_one("expected one statement"); - self.insert(ast_util::stmt_id(stmt), node_stmt(stmt)); + self.insert(ast_util::stmt_id(stmt), NodeStmt(stmt)); SmallVector::one(stmt) } - fn fold_method(&mut self, m: @method) -> @method { - self.path.push(path_name(m.ident)); + fn fold_method(&mut self, m: @Method) -> @Method { + self.path.push(PathName(m.ident)); let m = fold::noop_fold_method(m, self); self.path.pop(); m } - fn fold_fn_decl(&mut self, decl: &fn_decl) -> P<fn_decl> { + fn fold_fn_decl(&mut self, decl: &FnDecl) -> P<FnDecl> { let decl = fold::noop_fold_fn_decl(decl, self); for a in decl.inputs.iter() { - self.insert(a.id, node_arg(a.pat)); + self.insert(a.id, NodeArg(a.pat)); } decl } fn fold_block(&mut self, block: P<Block>) -> P<Block> { let block = fold::noop_fold_block(block, self); - self.insert(block.id, node_block(block)); + self.insert(block.id, NodeBlock(block)); block } } pub fn map_crate<F: 'static + FoldOps>(diag: @SpanHandler, c: Crate, - fold_ops: F) -> (Crate, map) { + fold_ops: F) -> (Crate, Map) { let mut cx = Ctx { map: @RefCell::new(HashMap::new()), path: ~[], @@ -392,11 +387,11 @@ pub fn map_crate<F: 'static + FoldOps>(diag: @SpanHandler, c: Crate, // crate. The `path` should be the path to the item but should not include // the item itself. pub fn map_decoded_item<F: 'static + FoldOps>(diag: @SpanHandler, - map: map, - path: path, + map: Map, + path: Path, fold_ops: F, - fold_ii: |&mut Ctx<F>| -> inlined_item) - -> inlined_item { + fold_ii: |&mut Ctx<F>| -> InlinedItem) + -> InlinedItem { // I believe it is ok for the local IDs of inlined items from other crates // to overlap with the local ids from this crate, so just generate the ids // starting from 0. @@ -413,18 +408,18 @@ pub fn map_decoded_item<F: 'static + FoldOps>(diag: @SpanHandler, // don't decode and instantiate the impl, but just the method, we have to // add it to the table now. Likewise with foreign items. match ii { - ii_item(..) => {} // fallthrough - ii_foreign(i) => { - cx.insert(i.id, node_foreign_item(i, - AbiSet::Intrinsic(), - i.vis, // Wrong but OK - @path)); + IIItem(..) => {} // fallthrough + IIForeign(i) => { + cx.insert(i.id, NodeForeignItem(i, + AbiSet::Intrinsic(), + i.vis, // Wrong but OK + @path)); } - ii_method(impl_did, is_provided, m) => { + IIMethod(impl_did, is_provided, m) => { let entry = if is_provided { - node_trait_method(@provided(m), impl_did, @path) + NodeTraitMethod(@Provided(m), impl_did, @path) } else { - node_method(m, impl_did, @path) + NodeMethod(m, impl_did, @path) }; cx.insert(m.id, entry); cx.map_self(m); @@ -434,100 +429,98 @@ pub fn map_decoded_item<F: 'static + FoldOps>(diag: @SpanHandler, ii } -pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str { +pub fn node_id_to_str(map: Map, id: NodeId, itr: @IdentInterner) -> ~str { let map = map.borrow(); match map.get().find(&id) { None => { format!("unknown node (id={})", id) } - Some(&node_item(item, path)) => { + Some(&NodeItem(item, path)) => { let path_str = path_ident_to_str(path, item.ident, itr); let item_str = match item.node { - item_static(..) => ~"static", - item_fn(..) => ~"fn", - item_mod(..) => ~"mod", - item_foreign_mod(..) => ~"foreign mod", - item_ty(..) => ~"ty", - item_enum(..) => ~"enum", - item_struct(..) => ~"struct", - item_trait(..) => ~"trait", - item_impl(..) => ~"impl", - item_mac(..) => ~"macro" + ItemStatic(..) => ~"static", + ItemFn(..) => ~"fn", + ItemMod(..) => ~"mod", + ItemForeignMod(..) => ~"foreign mod", + ItemTy(..) => ~"ty", + ItemEnum(..) => ~"enum", + ItemStruct(..) => ~"struct", + ItemTrait(..) => ~"trait", + ItemImpl(..) => ~"impl", + ItemMac(..) => ~"macro" }; format!("{} {} (id={})", item_str, path_str, id) } - Some(&node_foreign_item(item, abi, _, path)) => { + Some(&NodeForeignItem(item, abi, _, path)) => { format!("foreign item {} with abi {:?} (id={})", path_ident_to_str(path, item.ident, itr), abi, id) } - Some(&node_method(m, _, path)) => { + Some(&NodeMethod(m, _, path)) => { format!("method {} in {} (id={})", itr.get(m.ident.name), path_to_str(*path, itr), id) } - Some(&node_trait_method(ref tm, _, path)) => { + Some(&NodeTraitMethod(ref tm, _, path)) => { let m = ast_util::trait_method_to_ty_method(&**tm); format!("method {} in {} (id={})", itr.get(m.ident.name), path_to_str(*path, itr), id) } - Some(&node_variant(ref variant, _, path)) => { + Some(&NodeVariant(ref variant, _, path)) => { format!("variant {} in {} (id={})", itr.get(variant.node.name.name), path_to_str(*path, itr), id) } - Some(&node_expr(expr)) => { + Some(&NodeExpr(expr)) => { format!("expr {} (id={})", pprust::expr_to_str(expr, itr), id) } - Some(&node_callee_scope(expr)) => { + Some(&NodeCalleeScope(expr)) => { format!("callee_scope {} (id={})", pprust::expr_to_str(expr, itr), id) } - Some(&node_stmt(stmt)) => { + Some(&NodeStmt(stmt)) => { format!("stmt {} (id={})", pprust::stmt_to_str(stmt, itr), id) } - Some(&node_arg(pat)) => { + Some(&NodeArg(pat)) => { format!("arg {} (id={})", pprust::pat_to_str(pat, itr), id) } - Some(&node_local(ident, _)) => { + Some(&NodeLocal(ident, _)) => { format!("local (id={}, name={})", id, itr.get(ident.name)) } - Some(&node_block(block)) => { + Some(&NodeBlock(block)) => { format!("block {} (id={})", pprust::block_to_str(block, itr), id) } - Some(&node_struct_ctor(_, _, path)) => { + Some(&NodeStructCtor(_, _, path)) => { format!("struct_ctor {} (id={})", path_to_str(*path, itr), id) } } } -pub fn node_item_query<Result>(items: map, id: NodeId, query: |@item| -> Result, error_msg: ~str) +pub fn node_item_query<Result>(items: Map, id: NodeId, query: |@Item| -> Result, error_msg: ~str) -> Result { let items = items.borrow(); match items.get().find(&id) { - Some(&node_item(it, _)) => query(it), + Some(&NodeItem(it, _)) => query(it), _ => fail!("{}", error_msg) } } -pub fn node_span(items: map, - id: ast::NodeId) - -> Span { +pub fn node_span(items: Map, id: ast::NodeId) -> Span { let items = items.borrow(); match items.get().find(&id) { - Some(&node_item(item, _)) => item.span, - Some(&node_foreign_item(foreign_item, _, _, _)) => foreign_item.span, - Some(&node_trait_method(@required(ref type_method), _, _)) => type_method.span, - Some(&node_trait_method(@provided(ref method), _, _)) => method.span, - Some(&node_method(method, _, _)) => method.span, - Some(&node_variant(variant, _, _)) => variant.span, - Some(&node_expr(expr)) => expr.span, - Some(&node_stmt(stmt)) => stmt.span, - Some(&node_arg(pat)) => pat.span, - Some(&node_local(_, pat)) => match pat { + Some(&NodeItem(item, _)) => item.span, + Some(&NodeForeignItem(foreign_item, _, _, _)) => foreign_item.span, + Some(&NodeTraitMethod(@Required(ref type_method), _, _)) => type_method.span, + Some(&NodeTraitMethod(@Provided(ref method), _, _)) => method.span, + Some(&NodeMethod(method, _, _)) => method.span, + Some(&NodeVariant(variant, _, _)) => variant.span, + Some(&NodeExpr(expr)) => expr.span, + Some(&NodeStmt(stmt)) => stmt.span, + Some(&NodeArg(pat)) => pat.span, + Some(&NodeLocal(_, pat)) => match pat { Some(pat) => pat.span, - None => fail!("node_span: cannot get span from node_local (likely `self`)") + None => fail!("node_span: cannot get span from NodeLocal (likely `self`)") }, - Some(&node_block(block)) => block.span, - Some(&node_struct_ctor(_, item, _)) => item.span, - Some(&node_callee_scope(expr)) => expr.span, + Some(&NodeBlock(block)) => block.span, + Some(&NodeStructCtor(_, item, _)) => item.span, + Some(&NodeCalleeScope(expr)) => expr.span, None => fail!("node_span: could not find id {}", id), } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 973d7f5aa9e..bcac69c188a 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -151,46 +151,46 @@ pub fn is_path(e: @Expr) -> bool { return match e.node { ExprPath(_) => true, _ => false }; } -pub fn int_ty_to_str(t: int_ty) -> ~str { +pub fn int_ty_to_str(t: IntTy) -> ~str { match t { - ty_i => ~"", - ty_i8 => ~"i8", - ty_i16 => ~"i16", - ty_i32 => ~"i32", - ty_i64 => ~"i64" + TyI => ~"", + TyI8 => ~"i8", + TyI16 => ~"i16", + TyI32 => ~"i32", + TyI64 => ~"i64" } } -pub fn int_ty_max(t: int_ty) -> u64 { +pub fn int_ty_max(t: IntTy) -> u64 { match t { - ty_i8 => 0x80u64, - ty_i16 => 0x8000u64, - ty_i | ty_i32 => 0x80000000u64, // actually ni about ty_i - ty_i64 => 0x8000000000000000u64 + TyI8 => 0x80u64, + TyI16 => 0x8000u64, + TyI | TyI32 => 0x80000000u64, // actually ni about TyI + TyI64 => 0x8000000000000000u64 } } -pub fn uint_ty_to_str(t: uint_ty) -> ~str { +pub fn uint_ty_to_str(t: UintTy) -> ~str { match t { - ty_u => ~"u", - ty_u8 => ~"u8", - ty_u16 => ~"u16", - ty_u32 => ~"u32", - ty_u64 => ~"u64" + TyU => ~"u", + TyU8 => ~"u8", + TyU16 => ~"u16", + TyU32 => ~"u32", + TyU64 => ~"u64" } } -pub fn uint_ty_max(t: uint_ty) -> u64 { +pub fn uint_ty_max(t: UintTy) -> u64 { match t { - ty_u8 => 0xffu64, - ty_u16 => 0xffffu64, - ty_u | ty_u32 => 0xffffffffu64, // actually ni about ty_u - ty_u64 => 0xffffffffffffffffu64 + TyU8 => 0xffu64, + TyU16 => 0xffffu64, + TyU | TyU32 => 0xffffffffu64, // actually ni about TyU + TyU64 => 0xffffffffffffffffu64 } } -pub fn float_ty_to_str(t: float_ty) -> ~str { - match t { ty_f32 => ~"f32", ty_f64 => ~"f64" } +pub fn float_ty_to_str(t: FloatTy) -> ~str { + match t { TyF32 => ~"f32", TyF64 => ~"f64" } } pub fn is_call_expr(e: @Expr) -> bool { @@ -243,21 +243,21 @@ pub fn unguarded_pat(a: &Arm) -> Option<~[@Pat]> { } } -pub fn public_methods(ms: ~[@method]) -> ~[@method] { +pub fn public_methods(ms: ~[@Method]) -> ~[@Method] { ms.move_iter().filter(|m| { match m.vis { - public => true, + Public => true, _ => false } }).collect() } -// extract a TypeMethod from a trait_method. if the trait_method is +// extract a TypeMethod from a TraitMethod. if the TraitMethod is // a default, pull out the useful fields to make a TypeMethod -pub fn trait_method_to_ty_method(method: &trait_method) -> TypeMethod { +pub fn trait_method_to_ty_method(method: &TraitMethod) -> TypeMethod { match *method { - required(ref m) => (*m).clone(), - provided(ref m) => { + Required(ref m) => (*m).clone(), + Provided(ref m) => { TypeMethod { ident: m.ident, attrs: m.attrs.clone(), @@ -272,23 +272,23 @@ pub fn trait_method_to_ty_method(method: &trait_method) -> TypeMethod { } } -pub fn split_trait_methods(trait_methods: &[trait_method]) - -> (~[TypeMethod], ~[@method]) { +pub fn split_trait_methods(trait_methods: &[TraitMethod]) + -> (~[TypeMethod], ~[@Method]) { let mut reqd = ~[]; let mut provd = ~[]; for trt_method in trait_methods.iter() { match *trt_method { - required(ref tm) => reqd.push((*tm).clone()), - provided(m) => provd.push(m) + Required(ref tm) => reqd.push((*tm).clone()), + Provided(m) => provd.push(m) } }; (reqd, provd) } -pub fn struct_field_visibility(field: ast::struct_field) -> visibility { +pub fn struct_field_visibility(field: ast::StructField) -> Visibility { match field.node.kind { - ast::named_field(_, visibility) => visibility, - ast::unnamed_field => ast::public + ast::NamedField(_, visibility) => visibility, + ast::UnnamedField => ast::Public } } @@ -332,14 +332,14 @@ pub fn empty_generics() -> Generics { // Enumerating the IDs which appear in an AST #[deriving(Encodable, Decodable)] -pub struct id_range { +pub struct IdRange { min: NodeId, max: NodeId, } -impl id_range { - pub fn max() -> id_range { - id_range { +impl IdRange { + pub fn max() -> IdRange { + IdRange { min: u32::max_value, max: u32::min_value, } @@ -378,7 +378,7 @@ impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> { impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { fn visit_mod(&mut self, - module: &_mod, + module: &Mod, _: Span, node_id: NodeId, env: ()) { @@ -386,19 +386,19 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { visit::walk_mod(self, module, env) } - fn visit_view_item(&mut self, view_item: &view_item, env: ()) { + fn visit_view_item(&mut self, view_item: &ViewItem, env: ()) { match view_item.node { - view_item_extern_mod(_, _, node_id) => { + ViewItemExternMod(_, _, node_id) => { self.operation.visit_id(node_id) } - view_item_use(ref view_paths) => { + ViewItemUse(ref view_paths) => { for view_path in view_paths.iter() { match view_path.node { - view_path_simple(_, _, node_id) | - view_path_glob(_, node_id) => { + ViewPathSimple(_, _, node_id) | + ViewPathGlob(_, node_id) => { self.operation.visit_id(node_id) } - view_path_list(_, ref paths, node_id) => { + ViewPathList(_, ref paths, node_id) => { self.operation.visit_id(node_id); for path in paths.iter() { self.operation.visit_id(path.node.id) @@ -411,12 +411,12 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { visit::walk_view_item(self, view_item, env) } - fn visit_foreign_item(&mut self, foreign_item: &foreign_item, env: ()) { + fn visit_foreign_item(&mut self, foreign_item: &ForeignItem, env: ()) { self.operation.visit_id(foreign_item.id); visit::walk_foreign_item(self, foreign_item, env) } - fn visit_item(&mut self, item: &item, env: ()) { + fn visit_item(&mut self, item: &Item, env: ()) { if !self.pass_through_items { if self.visited_outermost { return @@ -427,7 +427,7 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { self.operation.visit_id(item.id); match item.node { - item_enum(ref enum_definition, _) => { + ItemEnum(ref enum_definition, _) => { for variant in enum_definition.variants.iter() { self.operation.visit_id(variant.node.id) } @@ -475,7 +475,7 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { fn visit_ty(&mut self, typ: &Ty, env: ()) { self.operation.visit_id(typ.id); match typ.node { - ty_path(_, _, id) => self.operation.visit_id(id), + TyPath(_, _, id) => self.operation.visit_id(id), _ => {} } visit::walk_ty(self, typ, env) @@ -487,16 +487,16 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { } fn visit_fn(&mut self, - function_kind: &visit::fn_kind, - function_declaration: &fn_decl, + function_kind: &visit::FnKind, + function_declaration: &FnDecl, block: &Block, span: Span, node_id: NodeId, env: ()) { if !self.pass_through_items { match *function_kind { - visit::fk_method(..) if self.visited_outermost => return, - visit::fk_method(..) => self.visited_outermost = true, + visit::FkMethod(..) if self.visited_outermost => return, + visit::FkMethod(..) => self.visited_outermost = true, _ => {} } } @@ -504,14 +504,14 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { self.operation.visit_id(node_id); match *function_kind { - visit::fk_item_fn(_, generics, _, _) => { + visit::FkItemFn(_, generics, _, _) => { self.visit_generics_helper(generics) } - visit::fk_method(_, generics, method) => { + visit::FkMethod(_, generics, method) => { self.operation.visit_id(method.self_id); self.visit_generics_helper(generics) } - visit::fk_fn_block => {} + visit::FkFnBlock => {} } for argument in function_declaration.inputs.iter() { @@ -528,19 +528,19 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { if !self.pass_through_items { match *function_kind { - visit::fk_method(..) => self.visited_outermost = false, + visit::FkMethod(..) => self.visited_outermost = false, _ => {} } } } - fn visit_struct_field(&mut self, struct_field: &struct_field, env: ()) { + fn visit_struct_field(&mut self, struct_field: &StructField, env: ()) { self.operation.visit_id(struct_field.node.id); visit::walk_struct_field(self, struct_field, env) } fn visit_struct_def(&mut self, - struct_def: &struct_def, + struct_def: &StructDef, ident: ast::Ident, generics: &ast::Generics, id: NodeId, @@ -550,16 +550,16 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { visit::walk_struct_def(self, struct_def, ident, generics, id, ()); } - fn visit_trait_method(&mut self, tm: &ast::trait_method, _: ()) { + fn visit_trait_method(&mut self, tm: &ast::TraitMethod, _: ()) { match *tm { - ast::required(ref m) => self.operation.visit_id(m.id), - ast::provided(ref m) => self.operation.visit_id(m.id), + ast::Required(ref m) => self.operation.visit_id(m.id), + ast::Provided(ref m) => self.operation.visit_id(m.id), } visit::walk_trait_method(self, tm, ()); } } -pub fn visit_ids_for_inlined_item<O: IdVisitingOperation>(item: &inlined_item, +pub fn visit_ids_for_inlined_item<O: IdVisitingOperation>(item: &InlinedItem, operation: &O) { let mut id_visitor = IdVisitor { operation: operation, @@ -568,14 +568,14 @@ pub fn visit_ids_for_inlined_item<O: IdVisitingOperation>(item: &inlined_item, }; match *item { - ii_item(i) => id_visitor.visit_item(i, ()), - ii_foreign(i) => id_visitor.visit_foreign_item(i, ()), - ii_method(_, _, m) => visit::walk_method_helper(&mut id_visitor, m, ()), + IIItem(i) => id_visitor.visit_item(i, ()), + IIForeign(i) => id_visitor.visit_foreign_item(i, ()), + IIMethod(_, _, m) => visit::walk_method_helper(&mut id_visitor, m, ()), } } struct IdRangeComputingVisitor { - result: Cell<id_range>, + result: Cell<IdRange>, } impl IdVisitingOperation for IdRangeComputingVisitor { @@ -586,18 +586,18 @@ impl IdVisitingOperation for IdRangeComputingVisitor { } } -pub fn compute_id_range_for_inlined_item(item: &inlined_item) -> id_range { +pub fn compute_id_range_for_inlined_item(item: &InlinedItem) -> IdRange { let visitor = IdRangeComputingVisitor { - result: Cell::new(id_range::max()) + result: Cell::new(IdRange::max()) }; visit_ids_for_inlined_item(item, &visitor); visitor.result.get() } -pub fn is_item_impl(item: @ast::item) -> bool { +pub fn is_item_impl(item: @ast::Item) -> bool { match item.node { - item_impl(..) => true, - _ => false + ItemImpl(..) => true, + _ => false } } @@ -630,21 +630,21 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool { } pub trait EachViewItem { - fn each_view_item(&self, f: |&ast::view_item| -> bool) -> bool; + fn each_view_item(&self, f: |&ast::ViewItem| -> bool) -> bool; } struct EachViewItemData<'a> { - callback: 'a |&ast::view_item| -> bool, + callback: 'a |&ast::ViewItem| -> bool, } impl<'a> Visitor<()> for EachViewItemData<'a> { - fn visit_view_item(&mut self, view_item: &ast::view_item, _: ()) { + fn visit_view_item(&mut self, view_item: &ast::ViewItem, _: ()) { let _ = (self.callback)(view_item); } } impl EachViewItem for ast::Crate { - fn each_view_item(&self, f: |&ast::view_item| -> bool) -> bool { + fn each_view_item(&self, f: |&ast::ViewItem| -> bool) -> bool { let mut visit = EachViewItemData { callback: f, }; @@ -653,17 +653,16 @@ impl EachViewItem for ast::Crate { } } -pub fn view_path_id(p: &view_path) -> NodeId { +pub fn view_path_id(p: &ViewPath) -> NodeId { match p.node { - view_path_simple(_, _, id) | - view_path_glob(_, id) | - view_path_list(_, _, id) => id + ViewPathSimple(_, _, id) | ViewPathGlob(_, id) + | ViewPathList(_, _, id) => id } } /// Returns true if the given struct def is tuple-like; i.e. that its fields /// are unnamed. -pub fn struct_def_is_tuple_like(struct_def: &ast::struct_def) -> bool { +pub fn struct_def_is_tuple_like(struct_def: &ast::StructDef) -> bool { struct_def.ctor_id.is_some() } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index df8b45dbcf5..c44861bd7d7 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -66,7 +66,7 @@ impl AttrMetaMethods for MetaItem { match self.node { MetaNameValue(_, ref v) => { match v.node { - ast::lit_str(s, _) => Some(s), + ast::LitStr(s, _) => Some(s), _ => None, } }, @@ -126,11 +126,11 @@ impl AttributeMethods for Attribute { /* Constructors */ pub fn mk_name_value_item_str(name: @str, value: @str) -> @MetaItem { - let value_lit = dummy_spanned(ast::lit_str(value, ast::CookedStr)); + let value_lit = dummy_spanned(ast::LitStr(value, ast::CookedStr)); mk_name_value_item(name, value_lit) } -pub fn mk_name_value_item(name: @str, value: ast::lit) -> @MetaItem { +pub fn mk_name_value_item(name: @str, value: ast::Lit) -> @MetaItem { @dummy_spanned(MetaNameValue(name, value)) } @@ -152,7 +152,7 @@ pub fn mk_attr(item: @MetaItem) -> Attribute { pub fn mk_sugared_doc_attr(text: @str, lo: BytePos, hi: BytePos) -> Attribute { let style = doc_comment_style(text); - let lit = spanned(lo, hi, ast::lit_str(text, ast::CookedStr)); + let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr)); let attr = Attribute_ { style: style, value: @spanned(lo, hi, MetaNameValue(@"doc", lit)), @@ -423,16 +423,16 @@ pub fn find_repr_attr(diagnostic: @SpanHandler, attr: @ast::MetaItem, acc: ReprA fn int_type_of_word(s: &str) -> Option<IntType> { match s { - "i8" => Some(SignedInt(ast::ty_i8)), - "u8" => Some(UnsignedInt(ast::ty_u8)), - "i16" => Some(SignedInt(ast::ty_i16)), - "u16" => Some(UnsignedInt(ast::ty_u16)), - "i32" => Some(SignedInt(ast::ty_i32)), - "u32" => Some(UnsignedInt(ast::ty_u32)), - "i64" => Some(SignedInt(ast::ty_i64)), - "u64" => Some(UnsignedInt(ast::ty_u64)), - "int" => Some(SignedInt(ast::ty_i)), - "uint" => Some(UnsignedInt(ast::ty_u)), + "i8" => Some(SignedInt(ast::TyI8)), + "u8" => Some(UnsignedInt(ast::TyU8)), + "i16" => Some(SignedInt(ast::TyI16)), + "u16" => Some(UnsignedInt(ast::TyU16)), + "i32" => Some(SignedInt(ast::TyI32)), + "u32" => Some(UnsignedInt(ast::TyU32)), + "i64" => Some(SignedInt(ast::TyI64)), + "u64" => Some(UnsignedInt(ast::TyU64)), + "int" => Some(SignedInt(ast::TyI)), + "uint" => Some(UnsignedInt(ast::TyU)), _ => None } } @@ -456,8 +456,8 @@ impl ReprAttr { #[deriving(Eq)] pub enum IntType { - SignedInt(ast::int_ty), - UnsignedInt(ast::uint_ty) + SignedInt(ast::IntTy), + UnsignedInt(ast::UintTy) } impl IntType { @@ -470,10 +470,10 @@ impl IntType { } fn is_ffi_safe(self) -> bool { match self { - SignedInt(ast::ty_i8) | UnsignedInt(ast::ty_u8) | - SignedInt(ast::ty_i16) | UnsignedInt(ast::ty_u16) | - SignedInt(ast::ty_i32) | UnsignedInt(ast::ty_u32) | - SignedInt(ast::ty_i64) | UnsignedInt(ast::ty_u64) => true, + SignedInt(ast::TyI8) | UnsignedInt(ast::TyU8) | + SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) | + SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) | + SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true, _ => false } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index af3f0488d96..18479d4ef41 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -24,7 +24,7 @@ pub trait Emitter { fn emit(&self, cmsp: Option<(&codemap::CodeMap, Span)>, msg: &str, - lvl: level); + lvl: Level); } // a span-handler is like a handler but also @@ -37,18 +37,18 @@ pub struct SpanHandler { impl SpanHandler { pub fn span_fatal(@self, sp: Span, msg: &str) -> ! { - self.handler.emit(Some((&*self.cm, sp)), msg, fatal); + self.handler.emit(Some((&*self.cm, sp)), msg, Fatal); fail!(); } pub fn span_err(@self, sp: Span, msg: &str) { - self.handler.emit(Some((&*self.cm, sp)), msg, error); + self.handler.emit(Some((&*self.cm, sp)), msg, Error); self.handler.bump_err_count(); } pub fn span_warn(@self, sp: Span, msg: &str) { - self.handler.emit(Some((&*self.cm, sp)), msg, warning); + self.handler.emit(Some((&*self.cm, sp)), msg, Warning); } pub fn span_note(@self, sp: Span, msg: &str) { - self.handler.emit(Some((&*self.cm, sp)), msg, note); + self.handler.emit(Some((&*self.cm, sp)), msg, Note); } pub fn span_bug(@self, sp: Span, msg: &str) -> ! { self.span_fatal(sp, ice_msg(msg)); @@ -71,11 +71,11 @@ pub struct Handler { impl Handler { pub fn fatal(@self, msg: &str) -> ! { - self.emit.emit(None, msg, fatal); + self.emit.emit(None, msg, Fatal); fail!(); } pub fn err(@self, msg: &str) { - self.emit.emit(None, msg, error); + self.emit.emit(None, msg, Error); self.bump_err_count(); } pub fn bump_err_count(@self) { @@ -100,10 +100,10 @@ impl Handler { self.fatal(s); } pub fn warn(@self, msg: &str) { - self.emit.emit(None, msg, warning); + self.emit.emit(None, msg, Warning); } pub fn note(@self, msg: &str) { - self.emit.emit(None, msg, note); + self.emit.emit(None, msg, Note); } pub fn bug(@self, msg: &str) -> ! { self.fatal(ice_msg(msg)); @@ -114,7 +114,7 @@ impl Handler { pub fn emit(@self, cmsp: Option<(&codemap::CodeMap, Span)>, msg: &str, - lvl: level) { + lvl: Level) { self.emit.emit(cmsp, msg, lvl); } } @@ -145,28 +145,30 @@ pub fn mk_handler(emitter: Option<@Emitter>) -> @Handler { } #[deriving(Eq)] -pub enum level { - fatal, - error, - warning, - note, +pub enum Level { + Fatal, + Error, + Warning, + Note, } -fn diagnosticstr(lvl: level) -> ~str { - match lvl { - fatal => ~"error", - error => ~"error", - warning => ~"warning", - note => ~"note" +impl ToStr for Level { + fn to_str(&self) -> ~str { + match *self { + Fatal | Error => ~"error", + Warning => ~"warning", + Note => ~"note" + } } } -fn diagnosticcolor(lvl: level) -> term::color::Color { - match lvl { - fatal => term::color::BRIGHT_RED, - error => term::color::BRIGHT_RED, - warning => term::color::BRIGHT_YELLOW, - note => term::color::BRIGHT_GREEN +impl Level { + fn color(self) -> term::color::Color { + match self { + Fatal | Error => term::color::BRIGHT_RED, + Warning => term::color::BRIGHT_YELLOW, + Note => term::color::BRIGHT_GREEN + } } } @@ -212,15 +214,15 @@ fn print_maybe_styled(msg: &str, color: term::attr::Attr) { } } -fn print_diagnostic(topic: &str, lvl: level, msg: &str) { +fn print_diagnostic(topic: &str, lvl: Level, msg: &str) { let mut stderr = io::stderr(); if !topic.is_empty() { write!(&mut stderr as &mut io::Writer, "{} ", topic); } - print_maybe_styled(format!("{}: ", diagnosticstr(lvl)), - term::attr::ForegroundColor(diagnosticcolor(lvl))); + print_maybe_styled(format!("{}: ", lvl.to_str()), + term::attr::ForegroundColor(lvl.color())); print_maybe_styled(format!("{}\n", msg), term::attr::Bold); } @@ -230,7 +232,7 @@ impl Emitter for DefaultEmitter { fn emit(&self, cmsp: Option<(&codemap::CodeMap, Span)>, msg: &str, - lvl: level) { + lvl: Level) { match cmsp { Some((cm, sp)) => { let sp = cm.adjust_span(sp); @@ -247,7 +249,7 @@ impl Emitter for DefaultEmitter { fn highlight_lines(cm: &codemap::CodeMap, sp: Span, - lvl: level, + lvl: Level, lines: &codemap::FileLines) { let fm = lines.file; let mut err = io::stderr(); @@ -308,7 +310,7 @@ fn highlight_lines(cm: &codemap::CodeMap, let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u; num_squigglies.times(|| s.push_char('~')); } - print_maybe_styled(s + "\n", term::attr::ForegroundColor(diagnosticcolor(lvl))); + print_maybe_styled(s + "\n", term::attr::ForegroundColor(lvl.color())); } } @@ -319,10 +321,10 @@ fn print_macro_backtrace(cm: &codemap::CodeMap, sp: Span) { codemap::MacroAttribute => ("#[", "]"), codemap::MacroBang => ("", "!") }; - print_diagnostic(ss, note, + print_diagnostic(ss, Note, format!("in expansion of {}{}{}", pre, ei.callee.name, post)); let ss = cm.span_to_str(ei.call_site); - print_diagnostic(ss, note, "expansion site"); + print_diagnostic(ss, Note, "expansion site"); print_macro_backtrace(cm, ei.call_site); } } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 0d78acadcae..e5145d37278 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -37,7 +37,7 @@ fn next_state(s: State) -> Option<State> { } } -pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let mut p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), @@ -50,7 +50,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) let mut cons = ~""; let mut volatile = false; let mut alignstack = false; - let mut dialect = ast::asm_att; + let mut dialect = ast::AsmAtt; let mut state = Asm; @@ -139,7 +139,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } else if "alignstack" == option { alignstack = true; } else if "intel" == option { - dialect = ast::asm_intel; + dialect = ast::AsmIntel; } if p.token == token::COMMA { @@ -187,7 +187,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) MRExpr(@ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprInlineAsm(ast::inline_asm { + node: ast::ExprInlineAsm(ast::InlineAsm { asm: asm, asm_str_style: asm_str_style.unwrap(), clobbers: cons.to_managed(), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index cbd7e7ca0ee..76135f31e31 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -25,9 +25,9 @@ use std::hashmap::HashMap; // // MacResult, NormalTT, IdentTT // -// also note that ast::mac used to have a bunch of extraneous cases and +// also note that ast::Mac used to have a bunch of extraneous cases and // is now probably a redundant AST node, can be merged with -// ast::mac_invoc_tt. +// ast::MacInvocTT. pub struct MacroDef { name: @str, @@ -35,7 +35,7 @@ pub struct MacroDef { } pub type ItemDecorator = - fn(&ExtCtxt, Span, @ast::MetaItem, ~[@ast::item]) -> ~[@ast::item]; + fn(&ExtCtxt, Span, @ast::MetaItem, ~[@ast::Item]) -> ~[@ast::Item]; pub struct SyntaxExpanderTT { expander: SyntaxExpanderTTExpander, @@ -46,13 +46,13 @@ pub trait SyntaxExpanderTTTrait { fn expand(&self, ecx: &mut ExtCtxt, span: Span, - token_tree: &[ast::token_tree], + token_tree: &[ast::TokenTree], context: ast::SyntaxContext) -> MacResult; } pub type SyntaxExpanderTTFunNoCtxt = - fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::token_tree]) + fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::TokenTree]) -> MacResult; enum SyntaxExpanderTTExpander { @@ -63,7 +63,7 @@ impl SyntaxExpanderTTTrait for SyntaxExpanderTT { fn expand(&self, ecx: &mut ExtCtxt, span: Span, - token_tree: &[ast::token_tree], + token_tree: &[ast::TokenTree], _: ast::SyntaxContext) -> MacResult { match self.expander { @@ -89,7 +89,7 @@ pub trait SyntaxExpanderTTItemTrait { cx: &mut ExtCtxt, sp: Span, ident: ast::Ident, - token_tree: ~[ast::token_tree], + token_tree: ~[ast::TokenTree], context: ast::SyntaxContext) -> MacResult; } @@ -99,7 +99,7 @@ impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem { cx: &mut ExtCtxt, sp: Span, ident: ast::Ident, - token_tree: ~[ast::token_tree], + token_tree: ~[ast::TokenTree], context: ast::SyntaxContext) -> MacResult { match self.expander { @@ -114,21 +114,21 @@ impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem { } pub type SyntaxExpanderTTItemFun = - fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::token_tree], ast::SyntaxContext) + fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::TokenTree], ast::SyntaxContext) -> MacResult; pub type SyntaxExpanderTTItemFunNoCtxt = - fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::token_tree]) -> MacResult; + fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::TokenTree]) -> MacResult; pub trait AnyMacro { fn make_expr(&self) -> @ast::Expr; - fn make_items(&self) -> SmallVector<@ast::item>; + fn make_items(&self) -> SmallVector<@ast::Item>; fn make_stmt(&self) -> @ast::Stmt; } pub enum MacResult { MRExpr(@ast::Expr), - MRItem(@ast::item), + MRItem(@ast::Item), MRAny(@AnyMacro), MRDef(MacroDef), } @@ -393,15 +393,15 @@ impl ExtCtxt { pub fn expr_to_str(cx: &ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast::StrStyle) { match expr.node { - ast::ExprLit(l) => match l.node { - ast::lit_str(s, style) => (s, style), - _ => cx.span_fatal(l.span, err_msg) - }, - _ => cx.span_fatal(expr.span, err_msg) + ast::ExprLit(l) => match l.node { + ast::LitStr(s, style) => (s, style), + _ => cx.span_fatal(l.span, err_msg) + }, + _ => cx.span_fatal(expr.span, err_msg) } } -pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree], +pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree], name: &str) { if tts.len() != 0 { cx.span_fatal(sp, format!("{} takes no arguments", name)); @@ -410,7 +410,7 @@ pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree], pub fn get_single_str_from_tts(cx: &ExtCtxt, sp: Span, - tts: &[ast::token_tree], + tts: &[ast::TokenTree], name: &str) -> @str { if tts.len() != 1 { @@ -418,15 +418,15 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt, } match tts[0] { - ast::tt_tok(_, token::LIT_STR(ident)) - | ast::tt_tok(_, token::LIT_STR_RAW(ident, _)) => cx.str_of(ident), + ast::TTTok(_, token::LIT_STR(ident)) + | ast::TTTok(_, token::LIT_STR_RAW(ident, _)) => cx.str_of(ident), _ => cx.span_fatal(sp, format!("{} requires a string.", name)), } } pub fn get_exprs_from_tts(cx: &ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> ~[@ast::Expr] { + tts: &[ast::TokenTree]) -> ~[@ast::Expr] { let mut p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned()); diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 481472e8f0b..85cda0bd1ae 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -15,7 +15,7 @@ use ast_util; use codemap::{Span, respan, DUMMY_SP}; use ext::base::ExtCtxt; use ext::quote::rt::*; -use fold::ast_fold; +use fold::Folder; use opt_vec; use opt_vec::OptVec; @@ -43,9 +43,9 @@ pub trait AstBuilder { -> ast::Path; // types - fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::mt; + fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy; - fn ty(&self, span: Span, ty: ast::ty_) -> P<ast::Ty>; + fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>; fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> P<ast::Ty>; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>; @@ -67,7 +67,7 @@ pub trait AstBuilder { fn typaram(&self, id: ast::Ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam; - fn trait_ref(&self, path: ast::Path) -> ast::trait_ref; + fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; fn typarambound(&self, path: ast::Path) -> ast::TyParamBound; fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime; @@ -86,7 +86,7 @@ pub trait AstBuilder { fn block(&self, span: Span, stmts: ~[@ast::Stmt], expr: Option<@ast::Expr>) -> P<ast::Block>; fn block_expr(&self, expr: @ast::Expr) -> P<ast::Block>; fn block_all(&self, span: Span, - view_items: ~[ast::view_item], + view_items: ~[ast::ViewItem], stmts: ~[@ast::Stmt], expr: Option<@ast::Expr>) -> P<ast::Block>; @@ -119,7 +119,7 @@ pub trait AstBuilder { fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::Expr; fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: ~[ast::Field]) -> @ast::Expr; - fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::Expr; + fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> @ast::Expr; fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr; fn expr_int(&self, sp: Span, i: int) -> @ast::Expr; @@ -160,7 +160,7 @@ pub trait AstBuilder { cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr; fn lambda_fn_decl(&self, span: Span, - fn_decl: P<ast::fn_decl>, blk: P<ast::Block>) -> @ast::Expr; + fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> @ast::Expr; fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: P<ast::Block>) -> @ast::Expr; fn lambda0(&self, span: Span, blk: P<ast::Block>) -> @ast::Expr; @@ -176,64 +176,64 @@ pub trait AstBuilder { // items fn item(&self, span: Span, - name: Ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item; + name: Ident, attrs: ~[ast::Attribute], node: ast::Item_) -> @ast::Item; - fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::arg; + fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg; // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: P<ast::Ty>) -> P<ast::fn_decl>; + fn fn_decl(&self, inputs: ~[ast::Arg], output: P<ast::Ty>) -> P<ast::FnDecl>; fn item_fn_poly(&self, span: Span, name: Ident, - inputs: ~[ast::arg], + inputs: ~[ast::Arg], output: P<ast::Ty>, generics: Generics, - body: P<ast::Block>) -> @ast::item; + body: P<ast::Block>) -> @ast::Item; fn item_fn(&self, span: Span, name: Ident, - inputs: ~[ast::arg], + inputs: ~[ast::Arg], output: P<ast::Ty>, - body: P<ast::Block>) -> @ast::item; + body: P<ast::Block>) -> @ast::Item; - fn variant(&self, span: Span, name: Ident, tys: ~[P<ast::Ty>]) -> ast::variant; + fn variant(&self, span: Span, name: Ident, tys: ~[P<ast::Ty>]) -> ast::Variant; fn item_enum_poly(&self, span: Span, name: Ident, - enum_definition: ast::enum_def, - generics: Generics) -> @ast::item; - fn item_enum(&self, span: Span, name: Ident, enum_def: ast::enum_def) -> @ast::item; + enum_definition: ast::EnumDef, + generics: Generics) -> @ast::Item; + fn item_enum(&self, span: Span, name: Ident, enum_def: ast::EnumDef) -> @ast::Item; fn item_struct_poly(&self, span: Span, name: Ident, - struct_def: ast::struct_def, - generics: Generics) -> @ast::item; - fn item_struct(&self, span: Span, name: Ident, struct_def: ast::struct_def) -> @ast::item; + struct_def: ast::StructDef, + generics: Generics) -> @ast::Item; + fn item_struct(&self, span: Span, name: Ident, struct_def: ast::StructDef) -> @ast::Item; fn item_mod(&self, span: Span, name: Ident, attrs: ~[ast::Attribute], - vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item; + vi: ~[ast::ViewItem], items: ~[@ast::Item]) -> @ast::Item; fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>, - generics: Generics) -> @ast::item; - fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::item; + generics: Generics) -> @ast::Item; + fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::Item; fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute; fn meta_word(&self, sp: Span, w: @str) -> @ast::MetaItem; fn meta_list(&self, sp: Span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem; - fn meta_name_value(&self, sp: Span, name: @str, value: ast::lit_) -> @ast::MetaItem; + fn meta_name_value(&self, sp: Span, name: @str, value: ast::Lit_) -> @ast::MetaItem; fn view_use(&self, sp: Span, - vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item; - fn view_use_list(&self, sp: Span, vis: ast::visibility, - path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::view_item; + vis: ast::Visibility, vp: ~[@ast::ViewPath]) -> ast::ViewItem; + fn view_use_list(&self, sp: Span, vis: ast::Visibility, + path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem; fn view_use_glob(&self, sp: Span, - vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item; + vis: ast::Visibility, path: ~[ast::Ident]) -> ast::ViewItem; } impl AstBuilder for ExtCtxt { @@ -274,14 +274,14 @@ impl AstBuilder for ExtCtxt { } } - fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::mt { - ast::mt { + fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy { + ast::MutTy { ty: ty, mutbl: mutbl } } - fn ty(&self, span: Span, ty: ast::ty_) -> P<ast::Ty> { + fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> { P(ast::Ty { id: ast::DUMMY_NODE_ID, span: span, @@ -292,7 +292,7 @@ impl AstBuilder for ExtCtxt { fn ty_path(&self, path: ast::Path, bounds: Option<OptVec<ast::TyParamBound>>) -> P<ast::Ty> { self.ty(path.span, - ast::ty_path(path, bounds, ast::DUMMY_NODE_ID)) + ast::TyPath(path, bounds, ast::DUMMY_NODE_ID)) } // Might need to take bounds as an argument in the future, if you ever want @@ -309,15 +309,15 @@ impl AstBuilder for ExtCtxt { mutbl: ast::Mutability) -> P<ast::Ty> { self.ty(span, - ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl))) + ast::TyRptr(lifetime, self.ty_mt(ty, mutbl))) } fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { - self.ty(span, ast::ty_uniq(ty)) + self.ty(span, ast::TyUniq(ty)) } fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { - self.ty(span, ast::ty_box(ty)) + self.ty(span, ast::TyBox(ty)) } fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { @@ -336,19 +336,19 @@ impl AstBuilder for ExtCtxt { fn ty_field_imm(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::TypeField { ast::TypeField { ident: name, - mt: ast::mt { ty: ty, mutbl: ast::MutImmutable }, + mt: ast::MutTy { ty: ty, mutbl: ast::MutImmutable }, span: span, } } fn ty_infer(&self, span: Span) -> P<ast::Ty> { - self.ty(span, ast::ty_infer) + self.ty(span, ast::TyInfer) } fn ty_nil(&self) -> P<ast::Ty> { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::ty_nil, + node: ast::TyNil, span: DUMMY_SP, }) } @@ -381,8 +381,8 @@ impl AstBuilder for ExtCtxt { } } - fn trait_ref(&self, path: ast::Path) -> ast::trait_ref { - ast::trait_ref { + fn trait_ref(&self, path: ast::Path) -> ast::TraitRef { + ast::TraitRef { path: path, ref_id: ast::DUMMY_NODE_ID } @@ -449,7 +449,7 @@ impl AstBuilder for ExtCtxt { } fn block_all(&self, span: Span, - view_items: ~[ast::view_item], + view_items: ~[ast::ViewItem], stmts: ~[@ast::Stmt], expr: Option<@ast::Expr>) -> P<ast::Block> { P(ast::Block { @@ -541,20 +541,20 @@ impl AstBuilder for ExtCtxt { self.expr_struct(span, self.path_ident(span, id), fields) } - fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::Expr { + fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> @ast::Expr { self.expr(sp, ast::ExprLit(@respan(sp, lit))) } fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr { - self.expr_lit(span, ast::lit_uint(i as u64, ast::ty_u)) + self.expr_lit(span, ast::LitUint(i as u64, ast::TyU)) } fn expr_int(&self, sp: Span, i: int) -> @ast::Expr { - self.expr_lit(sp, ast::lit_int(i as i64, ast::ty_i)) + self.expr_lit(sp, ast::LitInt(i as i64, ast::TyI)) } fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr { - self.expr_lit(sp, ast::lit_uint(u as u64, ast::ty_u8)) + self.expr_lit(sp, ast::LitUint(u as u64, ast::TyU8)) } fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr { - self.expr_lit(sp, ast::lit_bool(value)) + self.expr_lit(sp, ast::LitBool(value)) } fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr { @@ -570,7 +570,7 @@ impl AstBuilder for ExtCtxt { self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreSlice) } fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr { - self.expr_lit(sp, ast::lit_str(s, ast::CookedStr)) + self.expr_lit(sp, ast::LitStr(s, ast::CookedStr)) } fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr { self.expr_vstore(sp, self.expr_str(sp, s), ast::ExprVstoreUniq) @@ -675,7 +675,7 @@ impl AstBuilder for ExtCtxt { } fn lambda_fn_decl(&self, span: Span, - fn_decl: P<ast::fn_decl>, blk: P<ast::Block>) -> @ast::Expr { + fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> @ast::Expr { self.expr(span, ast::ExprFnBlock(fn_decl, blk)) } fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: P<ast::Block>) -> @ast::Expr { @@ -715,9 +715,9 @@ impl AstBuilder for ExtCtxt { self.lambda1(span, self.block(span, stmts, None), ident) } - fn arg(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::arg { + fn arg(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Arg { let arg_pat = self.pat_ident(span, ident); - ast::arg { + ast::Arg { ty: ty, pat: arg_pat, id: ast::DUMMY_NODE_ID @@ -725,51 +725,51 @@ impl AstBuilder for ExtCtxt { } // XXX unused self - fn fn_decl(&self, inputs: ~[ast::arg], output: P<ast::Ty>) -> P<ast::fn_decl> { - P(ast::fn_decl { + fn fn_decl(&self, inputs: ~[ast::Arg], output: P<ast::Ty>) -> P<ast::FnDecl> { + P(ast::FnDecl { inputs: inputs, output: output, - cf: ast::return_val, + cf: ast::Return, variadic: false }) } fn item(&self, span: Span, - name: Ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item { + name: Ident, attrs: ~[ast::Attribute], node: ast::Item_) -> @ast::Item { // XXX: Would be nice if our generated code didn't violate // Rust coding conventions - @ast::item { ident: name, + @ast::Item { ident: name, attrs: attrs, id: ast::DUMMY_NODE_ID, node: node, - vis: ast::inherited, + vis: ast::Inherited, span: span } } fn item_fn_poly(&self, span: Span, name: Ident, - inputs: ~[ast::arg], + inputs: ~[ast::Arg], output: P<ast::Ty>, generics: Generics, - body: P<ast::Block>) -> @ast::item { + body: P<ast::Block>) -> @ast::Item { self.item(span, name, ~[], - ast::item_fn(self.fn_decl(inputs, output), - ast::impure_fn, - AbiSet::Rust(), - generics, - body)) + ast::ItemFn(self.fn_decl(inputs, output), + ast::ImpureFn, + AbiSet::Rust(), + generics, + body)) } fn item_fn(&self, span: Span, name: Ident, - inputs: ~[ast::arg], + inputs: ~[ast::Arg], output: P<ast::Ty>, body: P<ast::Block> - ) -> @ast::item { + ) -> @ast::Item { self.item_fn_poly( span, name, @@ -779,40 +779,36 @@ impl AstBuilder for ExtCtxt { body) } - fn variant(&self, span: Span, name: Ident, tys: ~[P<ast::Ty>]) -> ast::variant { + fn variant(&self, span: Span, name: Ident, tys: ~[P<ast::Ty>]) -> ast::Variant { let args = tys.move_iter().map(|ty| { - ast::variant_arg { ty: ty, id: ast::DUMMY_NODE_ID } + ast::VariantArg { ty: ty, id: ast::DUMMY_NODE_ID } }).collect(); respan(span, - ast::variant_ { + ast::Variant_ { name: name, attrs: ~[], - kind: ast::tuple_variant_kind(args), + kind: ast::TupleVariantKind(args), id: ast::DUMMY_NODE_ID, disr_expr: None, - vis: ast::public + vis: ast::Public }) } fn item_enum_poly(&self, span: Span, name: Ident, - enum_definition: ast::enum_def, - generics: Generics) -> @ast::item { - self.item(span, name, ~[], ast::item_enum(enum_definition, generics)) + enum_definition: ast::EnumDef, + generics: Generics) -> @ast::Item { + self.item(span, name, ~[], ast::ItemEnum(enum_definition, generics)) } fn item_enum(&self, span: Span, name: Ident, - enum_definition: ast::enum_def) -> @ast::item { + enum_definition: ast::EnumDef) -> @ast::Item { self.item_enum_poly(span, name, enum_definition, ast_util::empty_generics()) } - fn item_struct( - &self, - span: Span, - name: Ident, - struct_def: ast::struct_def - ) -> @ast::item { + fn item_struct(&self, span: Span, name: Ident, + struct_def: ast::StructDef) -> @ast::Item { self.item_struct_poly( span, name, @@ -821,25 +817,20 @@ impl AstBuilder for ExtCtxt { ) } - fn item_struct_poly( - &self, - span: Span, - name: Ident, - struct_def: ast::struct_def, - generics: Generics - ) -> @ast::item { - self.item(span, name, ~[], ast::item_struct(@struct_def, generics)) + fn item_struct_poly(&self, span: Span, name: Ident, + struct_def: ast::StructDef, generics: Generics) -> @ast::Item { + self.item(span, name, ~[], ast::ItemStruct(@struct_def, generics)) } fn item_mod(&self, span: Span, name: Ident, attrs: ~[ast::Attribute], - vi: ~[ast::view_item], - items: ~[@ast::item]) -> @ast::item { + vi: ~[ast::ViewItem], + items: ~[@ast::Item]) -> @ast::Item { self.item( span, name, attrs, - ast::item_mod(ast::_mod { + ast::ItemMod(ast::Mod { view_items: vi, items: items, }) @@ -847,11 +838,11 @@ impl AstBuilder for ExtCtxt { } fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>, - generics: Generics) -> @ast::item { - self.item(span, name, ~[], ast::item_ty(ty, generics)) + generics: Generics) -> @ast::Item { + self.item(span, name, ~[], ast::ItemTy(ty, generics)) } - fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::item { + fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::Item { self.item_ty_poly(span, name, ty, ast_util::empty_generics()) } @@ -869,38 +860,38 @@ impl AstBuilder for ExtCtxt { fn meta_list(&self, sp: Span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem { @respan(sp, ast::MetaList(name, mis)) } - fn meta_name_value(&self, sp: Span, name: @str, value: ast::lit_) -> @ast::MetaItem { + fn meta_name_value(&self, sp: Span, name: @str, value: ast::Lit_) -> @ast::MetaItem { @respan(sp, ast::MetaNameValue(name, respan(sp, value))) } fn view_use(&self, sp: Span, - vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item { - ast::view_item { - node: ast::view_item_use(vp), + vis: ast::Visibility, vp: ~[@ast::ViewPath]) -> ast::ViewItem { + ast::ViewItem { + node: ast::ViewItemUse(vp), attrs: ~[], vis: vis, span: sp } } - fn view_use_list(&self, sp: Span, vis: ast::visibility, - path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::view_item { + fn view_use_list(&self, sp: Span, vis: ast::Visibility, + path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem { let imports = imports.map(|id| { - respan(sp, ast::path_list_ident_ { name: *id, id: ast::DUMMY_NODE_ID }) + respan(sp, ast::PathListIdent_ { name: *id, id: ast::DUMMY_NODE_ID }) }); self.view_use(sp, vis, ~[@respan(sp, - ast::view_path_list(self.path(sp, path), - imports, - ast::DUMMY_NODE_ID))]) + ast::ViewPathList(self.path(sp, path), + imports, + ast::DUMMY_NODE_ID))]) } fn view_use_glob(&self, sp: Span, - vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item { + vis: ast::Visibility, path: ~[ast::Ident]) -> ast::ViewItem { self.view_use(sp, vis, ~[@respan(sp, - ast::view_path_glob(self.path(sp, path), ast::DUMMY_NODE_ID))]) + ast::ViewPathGlob(self.path(sp, path), ast::DUMMY_NODE_ID))]) } } @@ -908,7 +899,7 @@ struct Duplicator<'a> { cx: &'a ExtCtxt, } -impl<'a> ast_fold for Duplicator<'a> { +impl<'a> Folder for Duplicator<'a> { fn new_id(&mut self, _: NodeId) -> NodeId { ast::DUMMY_NODE_ID } diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 1878f6f3c3c..945e7c0d666 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -18,7 +18,7 @@ use ext::build::AstBuilder; use std::char; -pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { +pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { // Gather all argument expressions let exprs = get_exprs_from_tts(cx, sp, tts); let mut bytes = ~[]; @@ -28,14 +28,14 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> // expression is a literal ast::ExprLit(lit) => match lit.node { // string literal, push each byte to vector expression - ast::lit_str(s, _) => { + ast::LitStr(s, _) => { for byte in s.bytes() { bytes.push(cx.expr_u8(expr.span, byte)); } } // u8 literal, push to vector expression - ast::lit_uint(v, ast::ty_u8) => { + ast::LitUint(v, ast::TyU8) => { if v > 0xFF { cx.span_err(expr.span, "Too large u8 literal in bytes!") } else { @@ -44,7 +44,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> } // integer literal, push to vector expression - ast::lit_int_unsuffixed(v) => { + ast::LitIntUnsuffixed(v) => { if v > 0xFF { cx.span_err(expr.span, "Too large integer literal in bytes!") } else if v < 0 { @@ -55,7 +55,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> } // char literal, push to vector expression - ast::lit_char(v) => { + ast::LitChar(v) => { if char::from_u32(v).unwrap().is_ascii() { bytes.push(cx.expr_u8(expr.span, v as u8)); } else { diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index f3f44f4fa3f..9af295c0b11 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -23,9 +23,9 @@ use attr; use attr::*; use parse; use parse::token; -use parse::attr::parser_attr; +use parse::attr::ParserAttr; -pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { +pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let mut p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned()); diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index d8be7dedef2..251492141c8 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -17,7 +17,7 @@ use ext::build::AstBuilder; pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, sp: codemap::Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let es = base::get_exprs_from_tts(cx, sp, tts); let mut accumulator = ~""; for e in es.move_iter() { @@ -25,26 +25,24 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, match e.node { ast::ExprLit(lit) => { match lit.node { - ast::lit_str(s, _) | - ast::lit_float(s, _) | - ast::lit_float_unsuffixed(s) => { + ast::LitStr(s, _) | ast::LitFloat(s, _) + | ast::LitFloatUnsuffixed(s) => { accumulator.push_str(s); } - ast::lit_char(c) => { + ast::LitChar(c) => { accumulator.push_char(char::from_u32(c).unwrap()); } - ast::lit_int(i, _) | - ast::lit_int_unsuffixed(i) => { + ast::LitInt(i, _) | ast::LitIntUnsuffixed(i) => { accumulator.push_str(format!("{}", i)); } - ast::lit_uint(u, _) => { + ast::LitUint(u, _) => { accumulator.push_str(format!("{}", u)); } - ast::lit_nil => {} - ast::lit_bool(b) => { + ast::LitNil => {} + ast::LitBool(b) => { accumulator.push_str(format!("{}", b)); } - ast::lit_binary(..) => { + ast::LitBinary(..) => { cx.span_err(e.span, "cannot concatenate a binary literal"); } } diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 0cb3e781c26..0d053bb1d12 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -16,18 +16,18 @@ use opt_vec; use parse::token; use parse::token::{str_to_ident}; -pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let mut res_str = ~""; for (i, e) in tts.iter().enumerate() { if i & 1 == 1 { match *e { - ast::tt_tok(_, token::COMMA) => (), + ast::TTTok(_, token::COMMA) => (), _ => cx.span_fatal(sp, "concat_idents! expecting comma.") } } else { match *e { - ast::tt_tok(_, token::IDENT(ident,_)) => res_str.push_str(cx.str_of(ident)), + ast::TTTok(_, token::IDENT(ident,_)) => res_str.push_str(cx.str_of(ident)), _ => cx.span_fatal(sp, "concat_idents! requires ident args.") } } diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index c3c57082684..aa8dcc3981b 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -17,8 +17,8 @@ use ext::deriving::generic::*; pub fn expand_deriving_clone(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, @@ -45,8 +45,8 @@ pub fn expand_deriving_clone(cx: &ExtCtxt, pub fn expand_deriving_deep_clone(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index f7b249fc8d8..99b5163214a 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -17,7 +17,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_eq(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { // structures are equal if all fields are equal, and non equal, if // any fields are not equal or if the enum variants are different fn cs_eq(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index c1e4e1e2b64..8a2b11b798c 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -18,7 +18,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_ord(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { macro_rules! md ( ($name:expr, $op:expr, $equal:expr) => { MethodDef { diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 0b4d2659fd1..6a1aaeb2f9e 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -17,7 +17,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_totaleq(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 3c58bfa01a9..f1e360f20ba 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -19,7 +19,7 @@ use std::cmp::{Ordering, Equal, Less, Greater}; pub fn expand_deriving_totalord(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index de995af9ae3..9272152e8d5 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -13,7 +13,7 @@ The compiler code necessary for #[deriving(Decodable)]. See encodable.rs for more. */ -use ast::{MetaItem, item, Expr, MutMutable, Ident}; +use ast::{MetaItem, Item, Expr, MutMutable, Ident}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -22,7 +22,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_decodable(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index ba2df120796..0ae3c6f4593 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -17,8 +17,8 @@ use ext::deriving::generic::*; pub fn expand_deriving_default(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index a6cba59aea5..285bf86916e 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -75,7 +75,7 @@ would yield functions like: } */ -use ast::{MetaItem, item, Expr, MutImmutable, MutMutable}; +use ast::{MetaItem, Item, Expr, MutImmutable, MutMutable}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -84,7 +84,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_encodable(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 234551ccb01..826d5381d47 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -126,7 +126,7 @@ When generating the `expr` for a call with `self == C0(a)` and `other == C0(b)`, the SubstructureFields is ~~~ -EnumMatching(0, <ast::variant for C0>, +EnumMatching(0, <ast::Variant for C0>, ~[FieldInfo { span: <span of int> name: None, @@ -138,7 +138,7 @@ EnumMatching(0, <ast::variant for C0>, For `C1 {x}` and `C1 {x}`, ~~~ -EnumMatching(1, <ast::variant for C1>, +EnumMatching(1, <ast::Variant for C1>, ~[FieldInfo { span: <span of x> name: Some(<ident of x>), @@ -150,9 +150,9 @@ EnumMatching(1, <ast::variant for C1>, For `C0(a)` and `C1 {x}` , ~~~ -EnumNonMatching(~[(0, <ast::variant for B0>, +EnumNonMatching(~[(0, <ast::Variant for B0>, ~[(<span of int>, None, <expr for &a>)]), - (1, <ast::variant for B1>, + (1, <ast::Variant for B1>, ~[(<span of x>, Some(<ident of x>), <expr for &other.x>)])]) ~~~ @@ -164,18 +164,18 @@ EnumNonMatching(~[(0, <ast::variant for B0>, A static method on the above would result in, ~~~~ -StaticStruct(<ast::struct_def of A>, Named(~[(<ident of x>, <span of x>)])) +StaticStruct(<ast::StructDef of A>, Named(~[(<ident of x>, <span of x>)])) -StaticStruct(<ast::struct_def of B>, Unnamed(~[<span of x>])) +StaticStruct(<ast::StructDef of B>, Unnamed(~[<span of x>])) -StaticEnum(<ast::enum_def of C>, ~[(<ident of C0>, Unnamed(~[<span of int>])), - (<ident of C1>, Named(~[(<ident of x>, <span of x>)]))]) +StaticEnum(<ast::EnumDef of C>, ~[(<ident of C0>, Unnamed(~[<span of int>])), + (<ident of C1>, Named(~[(<ident of x>, <span of x>)]))]) ~~~ */ use ast; -use ast::{P, enum_def, Expr, Ident, Generics, struct_def}; +use ast::{P, EnumDef, Expr, Ident, Generics, StructDef}; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -274,23 +274,23 @@ pub enum StaticFields { pub enum SubstructureFields<'a> { Struct(~[FieldInfo]), /** - Matching variants of the enum: variant index, ast::variant, + Matching variants of the enum: variant index, ast::Variant, fields: the field name is only non-`None` in the case of a struct variant. */ - EnumMatching(uint, &'a ast::variant, ~[FieldInfo]), + EnumMatching(uint, &'a ast::Variant, ~[FieldInfo]), /** - non-matching variants of the enum, [(variant index, ast::variant, + non-matching variants of the enum, [(variant index, ast::Variant, [field span, field ident, fields])] (i.e. all fields for self are in the first tuple, for other1 are in the second tuple, etc.) */ - EnumNonMatching(&'a [(uint, P<ast::variant>, ~[(Span, Option<Ident>, @Expr)])]), + EnumNonMatching(&'a [(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])]), /// A static method where Self is a struct. - StaticStruct(&'a ast::struct_def, StaticFields), + StaticStruct(&'a ast::StructDef, StaticFields), /// A static method where Self is an enum. - StaticEnum(&'a ast::enum_def, ~[(Ident, StaticFields)]) + StaticEnum(&'a ast::EnumDef, ~[(Ident, StaticFields)]) } @@ -304,13 +304,13 @@ pub type CombineSubstructureFunc<'a> = /** Deal with non-matching enum variants, the arguments are a list -representing each variant: (variant index, ast::variant instance, +representing each variant: (variant index, ast::Variant instance, [variant fields]), and a list of the nonself args of the type */ pub type EnumNonMatchFunc<'a> = 'a |&ExtCtxt, Span, - &[(uint, P<ast::variant>, ~[(Span, Option<Ident>, @Expr)])], + &[(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])], &[@Expr]| -> @Expr; @@ -318,17 +318,17 @@ pub type EnumNonMatchFunc<'a> = impl<'a> TraitDef<'a> { pub fn expand(&self, _mitem: @ast::MetaItem, - in_items: ~[@ast::item]) -> ~[@ast::item] { + in_items: ~[@ast::Item]) -> ~[@ast::Item] { let mut result = ~[]; for item in in_items.iter() { result.push(*item); match item.node { - ast::item_struct(struct_def, ref generics) => { + ast::ItemStruct(struct_def, ref generics) => { result.push(self.expand_struct_def(struct_def, item.ident, generics)); } - ast::item_enum(ref enum_def, ref generics) => { + ast::ItemEnum(ref enum_def, ref generics) => { result.push(self.expand_enum_def(enum_def, item.ident, generics)); @@ -351,7 +351,7 @@ impl<'a> TraitDef<'a> { */ fn create_derived_impl(&self, type_ident: Ident, generics: &Generics, - methods: ~[@ast::method]) -> @ast::item { + methods: ~[@ast::Method]) -> @ast::Item { let cx = self.cx; let trait_path = self.path.to_path(cx, self.span, type_ident, generics); @@ -395,21 +395,19 @@ impl<'a> TraitDef<'a> { self.span, cx.meta_name_value(self.span, @"doc", - ast::lit_str(@"Automatically derived.", ast::CookedStr))); + ast::LitStr(@"Automatically derived.", ast::CookedStr))); cx.item( self.span, ::parse::token::special_idents::clownshoes_extensions, ~[doc_attr], - ast::item_impl(trait_generics, - Some(trait_ref), - self_type, - methods.map(|x| *x))) + ast::ItemImpl(trait_generics, Some(trait_ref), + self_type, methods.map(|x| *x))) } fn expand_struct_def(&self, - struct_def: &struct_def, + struct_def: &StructDef, type_ident: Ident, - generics: &Generics) -> @ast::item { + generics: &Generics) -> @ast::Item { let methods = self.methods.map(|method_def| { let (explicit_self, self_args, nonself_args, tys) = method_def.split_self_nonself_args(self, type_ident, generics); @@ -437,9 +435,9 @@ impl<'a> TraitDef<'a> { } fn expand_enum_def(&self, - enum_def: &enum_def, + enum_def: &EnumDef, type_ident: Ident, - generics: &Generics) -> @ast::item { + generics: &Generics) -> @ast::Item { let methods = self.methods.map(|method_def| { let (explicit_self, self_args, nonself_args, tys) = method_def.split_self_nonself_args(self, type_ident, generics); @@ -497,7 +495,7 @@ impl<'a> MethodDef<'a> { fn split_self_nonself_args(&self, trait_: &TraitDef, type_ident: Ident, generics: &Generics) - -> (ast::explicit_self, ~[@Expr], ~[@Expr], ~[(Ident, P<ast::Ty>)]) { + -> (ast::ExplicitSelf, ~[@Expr], ~[@Expr], ~[(Ident, P<ast::Ty>)]) { let mut self_args = ~[]; let mut nonself_args = ~[]; @@ -514,7 +512,7 @@ impl<'a> MethodDef<'a> { explicit_self } - None => codemap::respan(trait_.span, ast::sty_static), + None => codemap::respan(trait_.span, ast::SelfStatic), }; for (i, ty) in self.args.iter().enumerate() { @@ -545,9 +543,9 @@ impl<'a> MethodDef<'a> { fn create_method(&self, trait_: &TraitDef, type_ident: Ident, generics: &Generics, - explicit_self: ast::explicit_self, + explicit_self: ast::ExplicitSelf, arg_types: ~[(Ident, P<ast::Ty>)], - body: @Expr) -> @ast::method { + body: @Expr) -> @ast::Method { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(trait_.cx, trait_.span, type_ident, generics); @@ -568,18 +566,18 @@ impl<'a> MethodDef<'a> { }; // Create the method. - @ast::method { + @ast::Method { ident: method_ident, attrs: attrs, generics: fn_generics, explicit_self: explicit_self, - purity: ast::impure_fn, + purity: ast::ImpureFn, decl: fn_decl, body: body_block, id: ast::DUMMY_NODE_ID, span: trait_.span, self_id: ast::DUMMY_NODE_ID, - vis: ast::inherited, + vis: ast::Inherited, } } @@ -606,7 +604,7 @@ impl<'a> MethodDef<'a> { */ fn expand_struct_method_body(&self, trait_: &TraitDef, - struct_def: &struct_def, + struct_def: &StructDef, type_ident: Ident, self_args: &[@Expr], nonself_args: &[@Expr]) @@ -665,7 +663,7 @@ impl<'a> MethodDef<'a> { fn expand_static_struct_method_body(&self, trait_: &TraitDef, - struct_def: &struct_def, + struct_def: &StructDef, type_ident: Ident, self_args: &[@Expr], nonself_args: &[@Expr]) @@ -706,7 +704,7 @@ impl<'a> MethodDef<'a> { */ fn expand_enum_method_body(&self, trait_: &TraitDef, - enum_def: &enum_def, + enum_def: &EnumDef, type_ident: Ident, self_args: &[@Expr], nonself_args: &[@Expr]) @@ -741,12 +739,12 @@ impl<'a> MethodDef<'a> { */ fn build_enum_match(&self, trait_: &TraitDef, - enum_def: &enum_def, + enum_def: &EnumDef, type_ident: Ident, self_args: &[@Expr], nonself_args: &[@Expr], matching: Option<uint>, - matches_so_far: &mut ~[(uint, P<ast::variant>, + matches_so_far: &mut ~[(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])], match_count: uint) -> @Expr { let cx = trait_.cx; @@ -891,7 +889,7 @@ impl<'a> MethodDef<'a> { fn expand_static_enum_method_body(&self, trait_: &TraitDef, - enum_def: &enum_def, + enum_def: &EnumDef, type_ident: Ident, self_args: &[@Expr], nonself_args: &[@Expr]) @@ -899,10 +897,10 @@ impl<'a> MethodDef<'a> { let summary = enum_def.variants.map(|v| { let ident = v.node.name; let summary = match v.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { Unnamed(args.map(|va| trait_.set_expn_info(va.ty.span))) } - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { trait_.summarise_struct(struct_def) } }; @@ -937,14 +935,14 @@ impl<'a> TraitDef<'a> { to_set } - fn summarise_struct(&self, struct_def: &struct_def) -> StaticFields { + fn summarise_struct(&self, struct_def: &StructDef) -> StaticFields { let mut named_idents = ~[]; let mut just_spans = ~[]; for field in struct_def.fields.iter(){ let sp = self.set_expn_info(field.span); match field.node.kind { - ast::named_field(ident, _) => named_idents.push((ident, sp)), - ast::unnamed_field => just_spans.push(sp), + ast::NamedField(ident, _) => named_idents.push((ident, sp)), + ast::UnnamedField => just_spans.push(sp), } } @@ -971,7 +969,7 @@ impl<'a> TraitDef<'a> { fn create_struct_pattern(&self, struct_ident: Ident, - struct_def: &struct_def, + struct_def: &StructDef, prefix: &str, mutbl: ast::Mutability) -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) { @@ -993,13 +991,13 @@ impl<'a> TraitDef<'a> { for (i, struct_field) in struct_def.fields.iter().enumerate() { let sp = self.set_expn_info(struct_field.span); let opt_id = match struct_field.node.kind { - ast::named_field(ident, _) if (struct_type == Unknown || - struct_type == Record) => { + ast::NamedField(ident, _) if (struct_type == Unknown || + struct_type == Record) => { struct_type = Record; Some(ident) } - ast::unnamed_field if (struct_type == Unknown || - struct_type == Tuple) => { + ast::UnnamedField if (struct_type == Unknown || + struct_type == Tuple) => { struct_type = Tuple; None } @@ -1030,14 +1028,14 @@ impl<'a> TraitDef<'a> { } fn create_enum_variant_pattern(&self, - variant: &ast::variant, + variant: &ast::Variant, prefix: &str, mutbl: ast::Mutability) -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) { let cx = self.cx; let variant_ident = variant.node.name; match variant.node.kind { - ast::tuple_variant_kind(ref variant_args) => { + ast::TupleVariantKind(ref variant_args) => { if variant_args.is_empty() { return (cx.pat_ident_binding_mode(variant.span, variant_ident, ast::BindByValue(ast::MutImmutable)), @@ -1061,7 +1059,7 @@ impl<'a> TraitDef<'a> { (cx.pat_enum(variant.span, matching_path, subpats), ident_expr) } - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { self.create_struct_pattern(variant_ident, struct_def, prefix, mutbl) } diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 8b2ad95e45c..2bf69e34674 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr, BiAnd}; +use ast::{MetaItem, Item, Expr, BiAnd}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -18,7 +18,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_iter_bytes(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 1529fbae7e1..652f5ebe6c7 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -18,7 +18,7 @@ library. */ -use ast::{enum_def, Ident, item, Generics, struct_def}; +use ast::{EnumDef, Ident, Item, Generics, StructDef}; use ast::{MetaItem, MetaList, MetaNameValue, MetaWord}; use ext::base::ExtCtxt; use codemap::Span; @@ -47,22 +47,22 @@ pub mod generic; pub type ExpandDerivingStructDefFn<'a> = 'a |&ExtCtxt, Span, - x: &struct_def, + x: &StructDef, Ident, y: &Generics| - -> @item; + -> @Item; pub type ExpandDerivingEnumDefFn<'a> = 'a |&ExtCtxt, Span, - x: &enum_def, + x: &EnumDef, Ident, y: &Generics| - -> @item; + -> @Item; pub fn expand_meta_deriving(cx: &ExtCtxt, _span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { match mitem.node { MetaNameValue(_, ref l) => { cx.span_err(l.span, "unexpected value in `deriving`"); diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index ba2d85f357a..f621ad854aa 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use ast; use codemap::Span; use ext::base::ExtCtxt; @@ -18,7 +18,7 @@ use ext::deriving::generic::*; pub fn expand_deriving_from_primitive(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) -> ~[@item] { + in_items: ~[@Item]) -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, @@ -85,7 +85,7 @@ fn cs_from(name: &str, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr for variant in enum_def.variants.iter() { match variant.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { if !args.is_empty() { cx.span_err(span, "`FromPrimitive` cannot be derived for \ enum variants with arguments"); @@ -110,7 +110,7 @@ fn cs_from(name: &str, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr arms.push(arm); } - ast::struct_variant_kind(_) => { + ast::StructVariantKind(_) => { cx.span_err(span, "`FromPrimitive` cannot be derived for enums \ with struct variants"); return cx.expr_fail(span, @""); diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 1491797c808..f065340bdc2 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use ast::{MetaItem, item, Expr, Ident}; +use ast::{MetaItem, Item, Expr, Ident}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::{AstBuilder}; @@ -19,8 +19,8 @@ use opt_vec; pub fn expand_deriving_rand(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index 25700f93a33..81453a5a10b 100644 --- a/src/libsyntax/ext/deriving/to_str.rs +++ b/src/libsyntax/ext/deriving/to_str.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast; -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -18,8 +18,8 @@ use ext::deriving::generic::*; pub fn expand_deriving_to_str(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, @@ -98,9 +98,9 @@ fn to_str_substructure(cx: &ExtCtxt, span: Span, EnumMatching(_, variant, ref fields) => { match variant.node.kind { - ast::tuple_variant_kind(..) => + ast::TupleVariantKind(..) => doit("(", @")", variant.node.name, *fields), - ast::struct_variant_kind(..) => + ast::StructVariantKind(..) => doit("{", @"}", variant.node.name, *fields), } } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 89bed626c1e..a2e69cd377a 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -153,9 +153,9 @@ impl<'a> Ty<'a> { } Tuple(ref fields) => { let ty = if fields.is_empty() { - ast::ty_nil + ast::TyNil } else { - ast::ty_tup(fields.map(|f| f.to_ty(cx, span, self_ty, self_generics))) + ast::TyTup(fields.map(|f| f.to_ty(cx, span, self_ty, self_generics))) }; cx.ty(span, ty) @@ -240,21 +240,21 @@ impl<'a> LifetimeBounds<'a> { pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) - -> (@Expr, ast::explicit_self) { + -> (@Expr, ast::ExplicitSelf) { let self_path = cx.expr_self(span); match *self_ptr { None => { - (self_path, respan(span, ast::sty_value(ast::MutImmutable))) + (self_path, respan(span, ast::SelfValue(ast::MutImmutable))) } Some(ref ptr) => { let self_ty = respan( span, match *ptr { - Send => ast::sty_uniq(ast::MutImmutable), - Managed => ast::sty_box(ast::MutImmutable), + Send => ast::SelfUniq(ast::MutImmutable), + Managed => ast::SelfBox(ast::MutImmutable), Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s))); - ast::sty_region(lt, mutbl) + ast::SelfRegion(lt, mutbl) } }); let self_expr = cx.expr_deref(span, self_path); diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index c406dbf0d01..034a7970515 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, item, Expr}; +use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -17,8 +17,8 @@ use ext::deriving::generic::*; pub fn expand_deriving_zero(cx: &ExtCtxt, span: Span, mitem: @MetaItem, - in_items: ~[@item]) - -> ~[@item] { + in_items: ~[@Item]) + -> ~[@Item] { let trait_def = TraitDef { cx: cx, span: span, diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index cebd7aac4e3..be5560adca8 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -22,7 +22,7 @@ use ext::build::AstBuilder; use std::os; -pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let var = get_single_str_from_tts(cx, sp, tts, "option_env!"); @@ -33,7 +33,7 @@ pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) MRExpr(e) } -pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let exprs = get_exprs_from_tts(cx, sp, tts); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 5d497dd541f..75c0371f625 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -9,9 +9,9 @@ // except according to those terms. use ast::{P, Block, Crate, DeclLocal, ExprMac, SyntaxContext}; -use ast::{Local, Ident, mac_invoc_tt}; -use ast::{item_mac, Mrk, Stmt, StmtDecl, StmtMac, StmtExpr, StmtSemi}; -use ast::{token_tree}; +use ast::{Local, Ident, MacInvocTT}; +use ast::{ItemMac, Mrk, Stmt, StmtDecl, StmtMac, StmtExpr, StmtSemi}; +use ast::{TokenTree}; use ast; use ast_util::{mtwt_outer_mark, new_rename, new_mark}; use ext::build::AstBuilder; @@ -43,7 +43,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { // for the other three macro invocation chunks of code // in this file. // Token-tree macros: - mac_invoc_tt(ref pth, ref tts, ctxt) => { + MacInvocTT(ref pth, ref tts, ctxt) => { if (pth.segments.len() > 1u) { fld.cx.span_fatal( pth.span, @@ -210,7 +210,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { // // NB: there is some redundancy between this and expand_item, below, and // they might benefit from some amount of semantic and language-UI merger. -pub fn expand_mod_items(module_: &ast::_mod, fld: &mut MacroExpander) -> ast::_mod { +pub fn expand_mod_items(module_: &ast::Mod, fld: &mut MacroExpander) -> ast::Mod { // Fold the contents first: let module_ = noop_fold_mod(module_, fld); @@ -240,7 +240,7 @@ pub fn expand_mod_items(module_: &ast::_mod, fld: &mut MacroExpander) -> ast::_m }) }); - ast::_mod { + ast::Mod { items: new_items, ..module_ } @@ -258,11 +258,11 @@ macro_rules! with_exts_frame ( ) // When we enter a module, record it, for the sake of `module!` -pub fn expand_item(it: @ast::item, fld: &mut MacroExpander) - -> SmallVector<@ast::item> { +pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander) + -> SmallVector<@ast::Item> { match it.node { - ast::item_mac(..) => expand_item_mac(it, fld), - ast::item_mod(_) | ast::item_foreign_mod(_) => { + ast::ItemMac(..) => expand_item_mac(it, fld), + ast::ItemMod(_) | ast::ItemForeignMod(_) => { fld.cx.mod_push(it.ident); let macro_escape = contains_macro_escape(it.attrs); let result = with_exts_frame!(fld.extsbox, @@ -282,11 +282,11 @@ pub fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool { // Support for item-position macro invocations, exactly the same // logic as for expression-position macro invocations. -pub fn expand_item_mac(it: @ast::item, fld: &mut MacroExpander) - -> SmallVector<@ast::item> { +pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander) + -> SmallVector<@ast::Item> { let (pth, tts, ctxt) = match it.node { - item_mac(codemap::Spanned { - node: mac_invoc_tt(ref pth, ref tts, ctxt), + ItemMac(codemap::Spanned { + node: MacInvocTT(ref pth, ref tts, ctxt), .. }) => { (pth, (*tts).clone(), ctxt) @@ -379,7 +379,7 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> { let (pth, tts, semi, ctxt) = match s.node { StmtMac(ref mac, semi) => { match mac.node { - mac_invoc_tt(ref pth, ref tts, ctxt) => { + MacInvocTT(ref pth, ref tts, ctxt) => { (pth, (*tts).clone(), semi, ctxt) } } @@ -631,7 +631,7 @@ struct IdentRenamer<'a> { renames: &'a mut RenameList, } -impl<'a> ast_fold for IdentRenamer<'a> { +impl<'a> Folder for IdentRenamer<'a> { fn fold_ident(&mut self, id: ast::Ident) -> ast::Ident { let new_ctxt = self.renames.iter().fold(id.ctxt, |ctxt, &(from, to)| { new_rename(from, to, ctxt) @@ -837,15 +837,15 @@ pub fn std_macros() -> @str { } struct Injector { - sm: @ast::item, + sm: @ast::Item, } -impl ast_fold for Injector { - fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod { +impl Folder for Injector { + fn fold_mod(&mut self, module: &ast::Mod) -> ast::Mod { // Just inject the standard macros at the start of the first module // in the crate: that is, at the start of the crate file itself. let items = vec::append(~[ self.sm ], module.items); - ast::_mod { + ast::Mod { items: items, ..(*module).clone() // FIXME #2543: Bad copy. } @@ -878,16 +878,16 @@ pub struct MacroExpander<'a> { cx: &'a mut ExtCtxt, } -impl<'a> ast_fold for MacroExpander<'a> { +impl<'a> Folder for MacroExpander<'a> { fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr { expand_expr(expr, self) } - fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod { + fn fold_mod(&mut self, module: &ast::Mod) -> ast::Mod { expand_mod_items(module, self) } - fn fold_item(&mut self, item: @ast::item) -> SmallVector<@ast::item> { + fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> { expand_item(item, self) } @@ -968,7 +968,7 @@ pub struct ContextWrapper { context_function: @CtxtFn, } -impl ast_fold for ContextWrapper { +impl Folder for ContextWrapper { fn fold_ident(&mut self, id: ast::Ident) -> ast::Ident { let ast::Ident { name, @@ -979,12 +979,12 @@ impl ast_fold for ContextWrapper { ctxt: self.context_function.f(ctxt), } } - fn fold_mac(&mut self, m: &ast::mac) -> ast::mac { + fn fold_mac(&mut self, m: &ast::Mac) -> ast::Mac { let macro = match m.node { - mac_invoc_tt(ref path, ref tts, ctxt) => { - mac_invoc_tt(self.fold_path(path), - fold_tts(*tts, self), - self.context_function.f(ctxt)) + MacInvocTT(ref path, ref tts, ctxt) => { + MacInvocTT(self.fold_path(path), + fold_tts(*tts, self), + self.context_function.f(ctxt)) } }; Spanned { @@ -995,7 +995,7 @@ impl ast_fold for ContextWrapper { } // given a function from ctxts to ctxts, produce -// an ast_fold that applies that function to all ctxts: +// a Folder that applies that function to all ctxts: pub fn fun_to_ctxt_folder<T : 'static + CtxtFn>(cf: @T) -> ContextWrapper { ContextWrapper { context_function: cf as @CtxtFn, @@ -1012,7 +1012,7 @@ pub fn new_rename_folder(from: ast::Ident, to: ast::Name) -> ContextWrapper { } // apply a given mark to the given token trees. Used prior to expansion of a macro. -fn mark_tts(tts : &[token_tree], m : Mrk) -> ~[token_tree] { +fn mark_tts(tts : &[TokenTree], m : Mrk) -> ~[TokenTree] { fold_tts(tts, &mut new_mark_folder(m)) } @@ -1028,7 +1028,7 @@ fn mark_stmt(expr : &ast::Stmt, m : Mrk) -> @ast::Stmt { } // apply a given mark to the given item. Used following the expansion of a macro. -fn mark_item(expr : @ast::item, m : Mrk) -> SmallVector<@ast::item> { +fn mark_item(expr : @ast::Item, m : Mrk) -> SmallVector<@ast::Item> { new_mark_folder(m).fold_item(expr) } @@ -1041,8 +1041,8 @@ pub fn replace_ctxts(expr : @ast::Expr, ctxt : SyntaxContext) -> @ast::Expr { // take the mark from the given ctxt (that has a mark at the outside), // and apply it to everything in the token trees, thereby cancelling // that mark. -pub fn mtwt_cancel_outer_mark(tts: &[ast::token_tree], ctxt: ast::SyntaxContext) - -> ~[ast::token_tree] { +pub fn mtwt_cancel_outer_mark(tts: &[ast::TokenTree], ctxt: ast::SyntaxContext) + -> ~[ast::TokenTree] { let outer_mark = mtwt_outer_mark(ctxt); mark_tts(tts,outer_mark) } @@ -1221,14 +1221,14 @@ mod test { assert_eq!(marked_once.len(),1); let marked_once_ctxt = match marked_once[0] { - ast::tt_tok(_,token::IDENT(id,_)) => id.ctxt, + ast::TTTok(_,token::IDENT(id,_)) => id.ctxt, _ => fail!(format!("unexpected shape for marked tts: {:?}",marked_once[0])) }; assert_eq!(mtwt_marksof(marked_once_ctxt,invalid_name),~[fm]); let remarked = mtwt_cancel_outer_mark(marked_once,marked_once_ctxt); assert_eq!(remarked.len(),1); match remarked[0] { - ast::tt_tok(_,token::IDENT(id,_)) => + ast::TTTok(_,token::IDENT(id,_)) => assert_eq!(mtwt_marksof(id.ctxt,invalid_name),~[]), _ => fail!(format!("unexpected shape for marked tts: {:?}",remarked[0])) } @@ -1315,11 +1315,11 @@ mod test { // in principle, you might want to control this boolean on a per-varref basis, // but that would make things even harder to understand, and might not be // necessary for thorough testing. - type renaming_test = (&'static str, ~[~[uint]], bool); + type RenamingTest = (&'static str, ~[~[uint]], bool); #[test] fn automatic_renaming () { - let tests : ~[renaming_test] = + let tests : ~[RenamingTest] = ~[// b & c should get new names throughout, in the expr too: ("fn a() -> int { let b = 13; let c = b; b+c }", ~[~[0,1],~[2]], false), @@ -1363,7 +1363,7 @@ mod test { } // run one of the renaming tests - fn run_renaming_test(t : &renaming_test, test_idx: uint) { + fn run_renaming_test(t: &RenamingTest, test_idx: uint) { let invalid_name = token::special_idents::invalid.name; let (teststr, bound_connections, bound_ident_check) = match *t { (ref str,ref conns, bic) => (str.to_managed(), conns.clone(), bic) diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 34a8236905b..411bf921dd2 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -16,7 +16,7 @@ use ext::base; use ext::build::AstBuilder; pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt, sp: Span, - _tts: &[ast::token_tree]) -> base::MacResult { + _tts: &[ast::TokenTree]) -> base::MacResult { ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead"); ecx.parse_sess.span_diagnostic.span_note(sp, "see http://static.rust-lang.org/doc/master/std/fmt/index.html \ diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index d04e2e91d64..a4b8dd78403 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -48,7 +48,7 @@ struct Context<'a> { // Collection of the compiled `rt::Piece` structures pieces: ~[@ast::Expr], name_positions: HashMap<@str, uint>, - method_statics: ~[@ast::item], + method_statics: ~[@ast::Item], // Updated as arguments are consumed or methods are entered nest_level: uint, @@ -58,7 +58,7 @@ struct Context<'a> { impl<'a> Context<'a> { /// Parses the arguments from the given list of tokens, returning None if /// there's a parse error so we can continue parsing other format! expressions. - fn parse_args(&mut self, sp: Span, tts: &[ast::token_tree]) + fn parse_args(&mut self, sp: Span, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<@ast::Expr>) { let mut p = rsparse::new_parser_from_tts(self.ecx.parse_sess(), self.ecx.cfg(), @@ -476,7 +476,7 @@ impl<'a> Context<'a> { opt_vec::with(life), ~[] ), None); - let st = ast::item_static(ty, ast::MutImmutable, method); + let st = ast::ItemStatic(ty, ast::MutImmutable, method); let static_name = self.ecx.ident_of(format!("__STATIC_METHOD_{}", self.method_statics.len())); let item = self.ecx.item(sp, static_name, self.static_attrs(), st); @@ -490,7 +490,7 @@ impl<'a> Context<'a> { ~[self.ecx.expr_str(sp, s.to_managed())]) } parse::CurrentArgument => { - let nil = self.ecx.expr_lit(sp, ast::lit_nil); + let nil = self.ecx.expr_lit(sp, ast::LitNil); self.ecx.expr_call_global(sp, rtpath("CurrentArgument"), ~[nil]) } parse::Argument(ref arg) => { @@ -522,7 +522,7 @@ impl<'a> Context<'a> { // Translate the format let fill = match arg.format.fill { Some(c) => c, None => ' ' }; - let fill = self.ecx.expr_lit(sp, ast::lit_char(fill as u32)); + let fill = self.ecx.expr_lit(sp, ast::LitChar(fill as u32)); let align = match arg.format.align { parse::AlignLeft => { self.ecx.path_global(sp, parsepath("AlignLeft")) @@ -595,12 +595,12 @@ impl<'a> Context<'a> { self.ecx.lifetime(self.fmtsp, self.ecx.ident_of("static"))), ~[] ), None); - let ty = ast::ty_fixed_length_vec( + let ty = ast::TyFixedLengthVec( piece_ty, self.ecx.expr_uint(self.fmtsp, self.pieces.len()) ); let ty = self.ecx.ty(self.fmtsp, ty); - let st = ast::item_static(ty, ast::MutImmutable, fmt); + let st = ast::ItemStatic(ty, ast::MutImmutable, fmt); let static_name = self.ecx.ident_of("__STATIC_FMTSTR"); let item = self.ecx.item(self.fmtsp, static_name, self.static_attrs(), st); @@ -726,7 +726,7 @@ impl<'a> Context<'a> { } pub fn expand_args(ecx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let mut cx = Context { ecx: ecx, args: ~[], diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 22b04501cfb..74032095840 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -17,20 +17,20 @@ use parse::token::{get_ident_interner}; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: codemap::Span, - tt: &[ast::token_tree]) + tt: &[ast::TokenTree]) -> base::MacResult { cx.print_backtrace(); println( print::pprust::tt_to_str( - &ast::tt_delim(@tt.to_owned()), + &ast::TTDelim(@tt.to_owned()), get_ident_interner())); //trivial expression MRExpr(@ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprLit(@codemap::Spanned { - node: ast::lit_nil, + node: ast::LitNil, span: sp }), span: sp, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 0f0793e03b7..e66e394d639 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -23,7 +23,7 @@ use parse; * * This is registered as a set of expression syntax extension called quote! * that lifts its argument token-tree to an AST representing the -* construction of the same token tree, with ast::tt_nonterminal nodes +* construction of the same token tree, with ast::TTNonterminal nodes * interpreted as antiquotes (splices). * */ @@ -40,11 +40,11 @@ pub mod rt { pub use codemap::{BytePos, Span, dummy_spanned}; pub trait ToTokens { - fn to_tokens(&self, _cx: &ExtCtxt) -> ~[token_tree]; + fn to_tokens(&self, _cx: &ExtCtxt) -> ~[TokenTree]; } - impl ToTokens for ~[token_tree] { - fn to_tokens(&self, _cx: &ExtCtxt) -> ~[token_tree] { + impl ToTokens for ~[TokenTree] { + fn to_tokens(&self, _cx: &ExtCtxt) -> ~[TokenTree] { (*self).clone() } } @@ -56,7 +56,7 @@ pub mod rt { pub fn to_source() -> ~str; // If you can make source, you can definitely make tokens. - pub fn to_tokens(cx: &ExtCtxt) -> ~[token_tree] { + pub fn to_tokens(cx: &ExtCtxt) -> ~[TokenTree] { cx.parse_tts(self.to_source()) } } @@ -74,13 +74,13 @@ pub mod rt { } } - impl ToSource for @ast::item { + impl ToSource for @ast::Item { fn to_source(&self) -> @str { pprust::item_to_str(*self, get_ident_interner()).to_managed() } } - impl<'a> ToSource for &'a [@ast::item] { + impl<'a> ToSource for &'a [@ast::Item] { fn to_source(&self) -> @str { self.map(|i| i.to_source()).connect("\n\n").to_managed() } @@ -118,28 +118,28 @@ pub mod rt { impl<'a> ToSource for &'a str { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_str(self.to_managed(), ast::CookedStr)); + let lit = dummy_spanned(ast::LitStr(self.to_managed(), ast::CookedStr)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for int { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i)); + let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for i8 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i8)); + let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI8)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for i16 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i16)); + let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI16)); pprust::lit_to_str(&lit).to_managed() } } @@ -147,49 +147,49 @@ pub mod rt { impl ToSource for i32 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i32)); + let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI32)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for i64 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i64)); + let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI64)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for uint { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u)); + let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for u8 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u8)); + let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU8)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for u16 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u16)); + let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU16)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for u32 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u32)); + let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU32)); pprust::lit_to_str(&lit).to_managed() } } impl ToSource for u64 { fn to_source(&self) -> @str { - let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u64)); + let lit = dummy_spanned(ast::LitUint(*self as u64, ast::TyU64)); pprust::lit_to_str(&lit).to_managed() } } @@ -199,7 +199,7 @@ pub mod rt { macro_rules! impl_to_tokens( ($t:ty) => ( impl ToTokens for $t { - fn to_tokens(&self, cx: &ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] { cx.parse_tts(self.to_source()) } } @@ -209,7 +209,7 @@ pub mod rt { macro_rules! impl_to_tokens_self( ($t:ty) => ( impl<'a> ToTokens for $t { - fn to_tokens(&self, cx: &ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] { cx.parse_tts(self.to_source()) } } @@ -217,8 +217,8 @@ pub mod rt { ) impl_to_tokens!(ast::Ident) - impl_to_tokens!(@ast::item) - impl_to_tokens_self!(&'a [@ast::item]) + impl_to_tokens!(@ast::Item) + impl_to_tokens_self!(&'a [@ast::Item]) impl_to_tokens!(ast::Ty) impl_to_tokens_self!(&'a [ast::Ty]) impl_to_tokens!(Generics) @@ -237,15 +237,15 @@ pub mod rt { impl_to_tokens!(u64) pub trait ExtParseUtils { - fn parse_item(&self, s: @str) -> @ast::item; + fn parse_item(&self, s: @str) -> @ast::Item; fn parse_expr(&self, s: @str) -> @ast::Expr; fn parse_stmt(&self, s: @str) -> @ast::Stmt; - fn parse_tts(&self, s: @str) -> ~[ast::token_tree]; + fn parse_tts(&self, s: @str) -> ~[ast::TokenTree]; } impl ExtParseUtils for ExtCtxt { - fn parse_item(&self, s: @str) -> @ast::item { + fn parse_item(&self, s: @str) -> @ast::Item { let res = parse::parse_item_from_source_str( @"<quote expansion>", s, @@ -278,7 +278,7 @@ pub mod rt { self.parse_sess()) } - fn parse_tts(&self, s: @str) -> ~[ast::token_tree] { + fn parse_tts(&self, s: @str) -> ~[ast::TokenTree] { parse::parse_tts_from_source_str( @"<quote expansion>", s, @@ -291,7 +291,7 @@ pub mod rt { pub fn expand_quote_tokens(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let (cx_expr, expr) = expand_tts(cx, sp, tts); let expanded = expand_wrapper(cx, sp, cx_expr, expr); base::MRExpr(expanded) @@ -299,14 +299,14 @@ pub fn expand_quote_tokens(cx: &mut ExtCtxt, pub fn expand_quote_expr(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let expanded = expand_parse_call(cx, sp, "parse_expr", ~[], tts); base::MRExpr(expanded) } pub fn expand_quote_item(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let e_attrs = cx.expr_vec_uniq(sp, ~[]); let expanded = expand_parse_call(cx, sp, "parse_item", ~[e_attrs], tts); @@ -315,8 +315,8 @@ pub fn expand_quote_item(cx: &mut ExtCtxt, pub fn expand_quote_pat(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { - let e_refutable = cx.expr_lit(sp, ast::lit_bool(true)); + tts: &[ast::TokenTree]) -> base::MacResult { + let e_refutable = cx.expr_lit(sp, ast::LitBool(true)); let expanded = expand_parse_call(cx, sp, "parse_pat", ~[e_refutable], tts); base::MRExpr(expanded) @@ -324,8 +324,8 @@ pub fn expand_quote_pat(cx: &mut ExtCtxt, pub fn expand_quote_ty(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { - let e_param_colons = cx.expr_lit(sp, ast::lit_bool(false)); + tts: &[ast::TokenTree]) -> base::MacResult { + let e_param_colons = cx.expr_lit(sp, ast::LitBool(false)); let expanded = expand_parse_call(cx, sp, "parse_ty", ~[e_param_colons], tts); base::MRExpr(expanded) @@ -333,7 +333,7 @@ pub fn expand_quote_ty(cx: &mut ExtCtxt, pub fn expand_quote_stmt(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> base::MacResult { + tts: &[ast::TokenTree]) -> base::MacResult { let e_attrs = cx.expr_vec_uniq(sp, ~[]); let expanded = expand_parse_call(cx, sp, "parse_stmt", ~[e_attrs], tts); @@ -357,7 +357,7 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { ~[e_str]) } -fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr { +fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> @ast::Expr { let name = match bop { PLUS => "PLUS", MINUS => "MINUS", @@ -388,25 +388,22 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { } LIT_CHAR(i) => { - let s_ity = ~"ty_char"; - let e_ity = cx.expr_ident(sp, id_ext(s_ity)); - - let e_char = cx.expr_lit(sp, ast::lit_char(i)); + let e_char = cx.expr_lit(sp, ast::LitChar(i)); - return cx.expr_call_ident(sp, id_ext("LIT_CHAR"), ~[e_char, e_ity]); + return cx.expr_call_ident(sp, id_ext("LIT_CHAR"), ~[e_char]); } LIT_INT(i, ity) => { let s_ity = match ity { - ast::ty_i => ~"ty_i", - ast::ty_i8 => ~"ty_i8", - ast::ty_i16 => ~"ty_i16", - ast::ty_i32 => ~"ty_i32", - ast::ty_i64 => ~"ty_i64" + ast::TyI => ~"TyI", + ast::TyI8 => ~"TyI8", + ast::TyI16 => ~"TyI16", + ast::TyI32 => ~"TyI32", + ast::TyI64 => ~"TyI64" }; let e_ity = cx.expr_ident(sp, id_ext(s_ity)); - let e_i64 = cx.expr_lit(sp, ast::lit_int(i, ast::ty_i64)); + let e_i64 = cx.expr_lit(sp, ast::LitInt(i, ast::TyI64)); return cx.expr_call_ident(sp, id_ext("LIT_INT"), @@ -415,15 +412,15 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { LIT_UINT(u, uty) => { let s_uty = match uty { - ast::ty_u => ~"ty_u", - ast::ty_u8 => ~"ty_u8", - ast::ty_u16 => ~"ty_u16", - ast::ty_u32 => ~"ty_u32", - ast::ty_u64 => ~"ty_u64" + ast::TyU => ~"TyU", + ast::TyU8 => ~"TyU8", + ast::TyU16 => ~"TyU16", + ast::TyU32 => ~"TyU32", + ast::TyU64 => ~"TyU64" }; let e_uty = cx.expr_ident(sp, id_ext(s_uty)); - let e_u64 = cx.expr_lit(sp, ast::lit_uint(u, ast::ty_u64)); + let e_u64 = cx.expr_lit(sp, ast::LitUint(u, ast::TyU64)); return cx.expr_call_ident(sp, id_ext("LIT_UINT"), @@ -431,7 +428,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { } LIT_INT_UNSUFFIXED(i) => { - let e_i64 = cx.expr_lit(sp, ast::lit_int(i, ast::ty_i64)); + let e_i64 = cx.expr_lit(sp, ast::LitInt(i, ast::TyI64)); return cx.expr_call_ident(sp, id_ext("LIT_INT_UNSUFFIXED"), @@ -440,8 +437,8 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { LIT_FLOAT(fident, fty) => { let s_fty = match fty { - ast::ty_f32 => ~"ty_f32", - ast::ty_f64 => ~"ty_f64" + ast::TyF32 => ~"TyF32", + ast::TyF64 => ~"TyF64" }; let e_fty = cx.expr_ident(sp, id_ext(s_fty)); @@ -528,15 +525,14 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { } -fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::token_tree) - -> ~[@ast::Stmt] { +fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> ~[@ast::Stmt] { match *tt { - ast::tt_tok(sp, ref tok) => { + ast::TTTok(sp, ref tok) => { let e_sp = cx.expr_ident(sp, id_ext("sp")); let e_tok = cx.expr_call_ident(sp, - id_ext("tt_tok"), + id_ext("TTTok"), ~[e_sp, mk_token(cx, sp, tok)]); let e_push = cx.expr_method_call(sp, @@ -546,10 +542,10 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::token_tree) ~[cx.stmt_expr(e_push)] } - ast::tt_delim(ref tts) => mk_tts(cx, sp, **tts), - ast::tt_seq(..) => fail!("tt_seq in quote!"), + ast::TTDelim(ref tts) => mk_tts(cx, sp, **tts), + ast::TTSeq(..) => fail!("TTSeq in quote!"), - ast::tt_nonterminal(sp, ident) => { + ast::TTNonterminal(sp, ident) => { // tt.push_all_move($ident.to_tokens(ext_cx)) @@ -570,7 +566,7 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::token_tree) } } -fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) +fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> ~[@ast::Stmt] { let mut ss = ~[]; for tt in tts.iter() { @@ -579,10 +575,10 @@ fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) ss } -fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) +fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> (@ast::Expr, @ast::Expr) { // NB: It appears that the main parser loses its mind if we consider - // $foo as a tt_nonterminal during the main parse, so we have to re-parse + // $foo as a TTNonterminal during the main parse, so we have to re-parse // under quote_depth > 0. This is silly and should go away; the _guess_ is // it has to do with transition away from supporting old-style macros, so // try removing it when enough of them are gone. @@ -652,7 +648,7 @@ fn expand_wrapper(cx: &ExtCtxt, sp: Span, cx_expr: @ast::Expr, expr: @ast::Expr) -> @ast::Expr { - let uses = ~[ cx.view_use_glob(sp, ast::public, + let uses = ~[ cx.view_use_glob(sp, ast::Public, ids_ext(~[~"syntax", ~"ext", ~"quote", @@ -667,7 +663,7 @@ fn expand_parse_call(cx: &ExtCtxt, sp: Span, parse_method: &str, arg_exprs: ~[@ast::Expr], - tts: &[ast::token_tree]) -> @ast::Expr { + tts: &[ast::TokenTree]) -> @ast::Expr { let (cx_expr, tts_expr) = expand_tts(cx, sp, tts); let cfg_call = || cx.expr_method_call( diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index fae3f013f91..3e781451b08 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -28,7 +28,7 @@ use std::str; // a given file into the current one. /* line!(): expands to the current line number */ -pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); @@ -39,7 +39,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } /* col!(): expands to the current column number */ -pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); @@ -51,7 +51,7 @@ pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) /* file!(): expands to the current filename */ /* The filemap (`loc.file`) contains a bunch more information we could spit * out if we wanted. */ -pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); @@ -61,13 +61,13 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) base::MRExpr(cx.expr_str(topmost.call_site, filename)) } -pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let s = pprust::tts_to_str(tts, get_ident_interner()); base::MRExpr(cx.expr_str(sp, s.to_managed())) } -pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "module_path!"); base::MRExpr(cx.expr_str(sp, @@ -77,7 +77,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) // include! : parse the given file as an expr // This is generally a bad idea because it's going to behave // unhygienically. -pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include!"); // The file will be added to the code map by the parser @@ -92,7 +92,7 @@ pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } // include_str! : read the given file, insert it as a literal string expr -pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); let file = res_rel_file(cx, sp, &Path::new(file)); @@ -119,7 +119,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } } -pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { use std::at_vec; @@ -133,7 +133,7 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree]) } Ok(bytes) => { let bytes = at_vec::to_managed_move(bytes); - base::MRExpr(cx.expr_lit(sp, ast::lit_binary(bytes))) + base::MRExpr(cx.expr_lit(sp, ast::LitBinary(bytes))) } } } diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index a7d1d8fb366..679e9a5098e 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -12,20 +12,20 @@ use ast; use codemap::Span; use ext::base::ExtCtxt; use ext::base; -use parse::lexer::{new_tt_reader, reader}; +use parse::lexer::{new_tt_reader, Reader}; use parse::parser::Parser; use parse::token::keywords; pub fn expand_trace_macros(cx: &mut ExtCtxt, sp: Span, - tt: &[ast::token_tree]) + tt: &[ast::TokenTree]) -> base::MacResult { let sess = cx.parse_sess(); let cfg = cx.cfg(); let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic, None, tt.to_owned()); - let rdr = tt_rdr as @reader; + let rdr = tt_rdr as @Reader; let mut rust_parser = Parser(sess, cfg.clone(), rdr.dup()); if rust_parser.is_keyword(keywords::True) { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 8b22e32262b..22074a73a8b 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -11,14 +11,14 @@ // Earley-like parser for macros. use ast; -use ast::{matcher, match_tok, match_seq, match_nonterminal, Ident}; +use ast::{Matcher, MatchTok, MatchSeq, MatchNonterminal, Ident}; use codemap::{BytePos, mk_sp}; use codemap; use parse::lexer::*; //resolve bug? use parse::ParseSess; -use parse::attr::parser_attr; +use parse::attr::ParserAttr; use parse::parser::{LifetimeAndTypesWithoutColons, Parser}; -use parse::token::{Token, EOF, to_str, nonterminal, get_ident_interner, ident_to_str}; +use parse::token::{Token, EOF, to_str, Nonterminal, get_ident_interner, ident_to_str}; use parse::token; use std::hashmap::HashMap; @@ -33,7 +33,7 @@ ones. Instead of NTs, we have a special case for Kleene star. The big-O, in pathological cases, is worse than traditional Earley parsing, but it's an easier fit for Macro-by-Example-style rules, and I think the overhead is lower. (In order to prevent the pathological case, we'd need to lazily -construct the resulting `named_match`es at the very end. It'd be a pain, +construct the resulting `NamedMatch`es at the very end. It'd be a pain, and require more memory to keep around old items, but it would also save overhead)*/ @@ -93,60 +93,42 @@ eof: [a $( a )* a b ·] */ -/* to avoid costly uniqueness checks, we require that `match_seq` always has a +/* to avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body. */ -#[deriving(Clone)] -pub enum matcher_pos_up { /* to break a circularity */ - matcher_pos_up(Option<~MatcherPos>) -} - -pub fn is_some(mpu: &matcher_pos_up) -> bool { - match *mpu { - matcher_pos_up(None) => false, - _ => true - } -} #[deriving(Clone)] pub struct MatcherPos { - elts: ~[ast::matcher], // maybe should be <'>? Need to understand regions. + elts: ~[ast::Matcher], // maybe should be <'>? Need to understand regions. sep: Option<Token>, idx: uint, - up: matcher_pos_up, // mutable for swapping only - matches: ~[~[@named_match]], + up: Option<~MatcherPos>, + matches: ~[~[@NamedMatch]], match_lo: uint, match_hi: uint, sp_lo: BytePos, } -pub fn copy_up(mpu: &matcher_pos_up) -> ~MatcherPos { - match *mpu { - matcher_pos_up(Some(ref mp)) => (*mp).clone(), - _ => fail!() - } -} - -pub fn count_names(ms: &[matcher]) -> uint { +pub fn count_names(ms: &[Matcher]) -> uint { ms.iter().fold(0, |ct, m| { ct + match m.node { - match_tok(_) => 0u, - match_seq(ref more_ms, _, _, _, _) => count_names((*more_ms)), - match_nonterminal(_,_,_) => 1u + MatchTok(_) => 0u, + MatchSeq(ref more_ms, _, _, _, _) => count_names((*more_ms)), + MatchNonterminal(_, _, _) => 1u }}) } -pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) +pub fn initial_matcher_pos(ms: ~[Matcher], sep: Option<Token>, lo: BytePos) -> ~MatcherPos { let mut match_idx_hi = 0u; for elt in ms.iter() { match elt.node { - match_tok(_) => (), - match_seq(_,_,_,_,hi) => { - match_idx_hi = hi; // it is monotonic... - } - match_nonterminal(_,_,pos) => { - match_idx_hi = pos+1u; // ...so latest is highest - } + MatchTok(_) => (), + MatchSeq(_,_,_,_,hi) => { + match_idx_hi = hi; // it is monotonic... + } + MatchNonterminal(_,_,pos) => { + match_idx_hi = pos+1u; // ...so latest is highest + } } } let matches = vec::from_fn(count_names(ms), |_i| ~[]); @@ -154,7 +136,7 @@ pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) elts: ms, sep: sep, idx: 0u, - up: matcher_pos_up(None), + up: None, matches: matches, match_lo: 0u, match_hi: match_idx_hi, @@ -162,45 +144,43 @@ pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) } } -// named_match is a pattern-match result for a single ast::match_nonterminal: +// NamedMatch is a pattern-match result for a single ast::MatchNonterminal: // so it is associated with a single ident in a parse, and all -// matched_nonterminals in the named_match have the same nonterminal type -// (expr, item, etc). All the leaves in a single named_match correspond to a -// single matcher_nonterminal in the ast::matcher that produced it. +// MatchedNonterminal's in the NamedMatch have the same nonterminal type +// (expr, item, etc). All the leaves in a single NamedMatch correspond to a +// single matcher_nonterminal in the ast::Matcher that produced it. // // It should probably be renamed, it has more or less exact correspondence to -// ast::match nodes, and the in-memory structure of a particular named_match +// ast::match nodes, and the in-memory structure of a particular NamedMatch // represents the match that occurred when a particular subset of an -// ast::match -- those ast::matcher nodes leading to a single -// match_nonterminal -- was applied to a particular token tree. +// ast::match -- those ast::Matcher nodes leading to a single +// MatchNonterminal -- was applied to a particular token tree. // -// The width of each matched_seq in the named_match, and the identity of the -// matched_nonterminals, will depend on the token tree it was applied to: each -// matched_seq corresponds to a single match_seq in the originating -// ast::matcher. The depth of the named_match structure will therefore depend -// only on the nesting depth of ast::match_seqs in the originating -// ast::matcher it was derived from. - -pub enum named_match { - matched_seq(~[@named_match], codemap::Span), - matched_nonterminal(nonterminal) +// The width of each MatchedSeq in the NamedMatch, and the identity of the +// MatchedNonterminal's, will depend on the token tree it was applied to: each +// MatchedSeq corresponds to a single MatchSeq in the originating +// ast::Matcher. The depth of the NamedMatch structure will therefore depend +// only on the nesting depth of ast::MatchSeq's in the originating +// ast::Matcher it was derived from. + +pub enum NamedMatch { + MatchedSeq(~[@NamedMatch], codemap::Span), + MatchedNonterminal(Nonterminal) } -pub type earley_item = ~MatcherPos; - -pub fn nameize(p_s: @ParseSess, ms: &[matcher], res: &[@named_match]) - -> HashMap<Ident,@named_match> { - fn n_rec(p_s: @ParseSess, m: &matcher, res: &[@named_match], - ret_val: &mut HashMap<Ident, @named_match>) { +pub fn nameize(p_s: @ParseSess, ms: &[Matcher], res: &[@NamedMatch]) + -> HashMap<Ident, @NamedMatch> { + fn n_rec(p_s: @ParseSess, m: &Matcher, res: &[@NamedMatch], + ret_val: &mut HashMap<Ident, @NamedMatch>) { match *m { - codemap::Spanned {node: match_tok(_), .. } => (), - codemap::Spanned {node: match_seq(ref more_ms, _, _, _, _), .. } => { + codemap::Spanned {node: MatchTok(_), .. } => (), + codemap::Spanned {node: MatchSeq(ref more_ms, _, _, _, _), .. } => { for next_m in more_ms.iter() { n_rec(p_s, next_m, res, ret_val) }; } codemap::Spanned { - node: match_nonterminal(ref bind_name, _, idx), span: sp + node: MatchNonterminal(ref bind_name, _, idx), span: sp } => { if ret_val.contains_key(bind_name) { p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+ @@ -215,21 +195,21 @@ pub fn nameize(p_s: @ParseSess, ms: &[matcher], res: &[@named_match]) ret_val } -pub enum parse_result { - success(HashMap<Ident, @named_match>), - failure(codemap::Span, ~str), - error(codemap::Span, ~str) +pub enum ParseResult { + Success(HashMap<Ident, @NamedMatch>), + Failure(codemap::Span, ~str), + Error(codemap::Span, ~str) } pub fn parse_or_else(sess: @ParseSess, cfg: ast::CrateConfig, - rdr: @reader, - ms: ~[matcher]) - -> HashMap<Ident, @named_match> { + rdr: @Reader, + ms: ~[Matcher]) + -> HashMap<Ident, @NamedMatch> { match parse(sess, cfg, rdr, ms) { - success(m) => m, - failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str), - error(sp, str) => sess.span_diagnostic.span_fatal(sp, str) + Success(m) => m, + Failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str), + Error(sp, str) => sess.span_diagnostic.span_fatal(sp, str) } } @@ -244,9 +224,9 @@ pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { pub fn parse(sess: @ParseSess, cfg: ast::CrateConfig, - rdr: @reader, - ms: &[matcher]) - -> parse_result { + rdr: @Reader, + ms: &[Matcher]) + -> ParseResult { let mut cur_eis = ~[]; cur_eis.push(initial_matcher_pos(ms.to_owned(), None, rdr.peek().sp.lo)); @@ -267,7 +247,7 @@ pub fn parse(sess: @ParseSess, /* at end of sequence */ if idx >= len { // can't move out of `match`es, so: - if is_some(&ei.up) { + if ei.up.is_some() { // hack: a matcher sequence is repeating iff it has a // parent (the top level is just a container) @@ -277,7 +257,7 @@ pub fn parse(sess: @ParseSess, if idx == len { // pop from the matcher position - let mut new_pos = copy_up(&ei.up); + let mut new_pos = ei.up.clone().unwrap(); // update matches (the MBE "parse tree") by appending // each tree as a subtree. @@ -290,9 +270,8 @@ pub fn parse(sess: @ParseSess, for idx in range(ei.match_lo, ei.match_hi) { let sub = ei.matches[idx].clone(); new_pos.matches[idx] - .push(@matched_seq(sub, - mk_sp(ei.sp_lo, - sp.hi))); + .push(@MatchedSeq(sub, mk_sp(ei.sp_lo, + sp.hi))); } new_pos.idx += 1; @@ -325,14 +304,14 @@ pub fn parse(sess: @ParseSess, } else { match ei.elts[idx].node.clone() { /* need to descend into sequence */ - match_seq(ref matchers, ref sep, zero_ok, - match_idx_lo, match_idx_hi) => { + MatchSeq(ref matchers, ref sep, zero_ok, + match_idx_lo, match_idx_hi) => { if zero_ok { let mut new_ei = ei.clone(); new_ei.idx += 1u; //we specifically matched zero repeats. for idx in range(match_idx_lo, match_idx_hi) { - new_ei.matches[idx].push(@matched_seq(~[], sp)); + new_ei.matches[idx].push(@MatchedSeq(~[], sp)); } cur_eis.push(new_ei); @@ -344,14 +323,14 @@ pub fn parse(sess: @ParseSess, elts: (*matchers).clone(), sep: (*sep).clone(), idx: 0u, - up: matcher_pos_up(Some(ei_t)), + up: Some(ei_t), matches: matches, match_lo: match_idx_lo, match_hi: match_idx_hi, sp_lo: sp.lo }); } - match_nonterminal(_,_,_) => { bb_eis.push(ei) } - match_tok(ref t) => { + MatchNonterminal(_,_,_) => { bb_eis.push(ei) } + MatchTok(ref t) => { let mut ei_t = ei.clone(); //if (token_name_eq(t,&tok)) { if (token::mtwt_token_eq(t,&tok)) { @@ -370,29 +349,29 @@ pub fn parse(sess: @ParseSess, for dv in eof_eis[0u].matches.mut_iter() { v.push(dv.pop()); } - return success(nameize(sess, ms, v)); + return Success(nameize(sess, ms, v)); } else if eof_eis.len() > 1u { - return error(sp, ~"Ambiguity: multiple successful parses"); + return Error(sp, ~"Ambiguity: multiple successful parses"); } else { - return failure(sp, ~"Unexpected end of macro invocation"); + return Failure(sp, ~"Unexpected end of macro invocation"); } } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { let nts = bb_eis.map(|ei| { match ei.elts[ei.idx].node { - match_nonterminal(ref bind,ref name,_) => { + MatchNonterminal(ref bind,ref name,_) => { format!("{} ('{}')", ident_to_str(name), ident_to_str(bind)) } _ => fail!() } }).connect(" or "); - return error(sp, format!( + return Error(sp, format!( "Local ambiguity: multiple parsing options: \ built-in NTs {} or {} other options.", nts, next_eis.len())); } else if (bb_eis.len() == 0u && next_eis.len() == 0u) { - return failure(sp, ~"No rules expected the token: " + return Failure(sp, ~"No rules expected the token: " + to_str(get_ident_interner(), &tok)); } else if (next_eis.len() > 0u) { /* Now process the next token */ @@ -405,8 +384,8 @@ pub fn parse(sess: @ParseSess, let mut ei = bb_eis.pop(); match ei.elts[ei.idx].node { - match_nonterminal(_, ref name, idx) => { - ei.matches[idx].push(@matched_nonterminal( + MatchNonterminal(_, ref name, idx) => { + ei.matches[idx].push(@MatchedNonterminal( parse_nt(&mut rust_parser, ident_to_str(name)))); ei.idx += 1u; } @@ -424,36 +403,36 @@ pub fn parse(sess: @ParseSess, } } -pub fn parse_nt(p: &mut Parser, name: &str) -> nonterminal { +pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { match name { "item" => match p.parse_item(~[]) { - Some(i) => token::nt_item(i), + Some(i) => token::NtItem(i), None => p.fatal("expected an item keyword") }, - "block" => token::nt_block(p.parse_block()), - "stmt" => token::nt_stmt(p.parse_stmt(~[])), - "pat" => token::nt_pat(p.parse_pat()), - "expr" => token::nt_expr(p.parse_expr()), - "ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), + "block" => token::NtBlock(p.parse_block()), + "stmt" => token::NtStmt(p.parse_stmt(~[])), + "pat" => token::NtPat(p.parse_pat()), + "expr" => token::NtExpr(p.parse_expr()), + "ty" => token::NtTy(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one "ident" => match p.token { - token::IDENT(sn,b) => { p.bump(); token::nt_ident(~sn,b) } + token::IDENT(sn,b) => { p.bump(); token::NtIdent(~sn,b) } _ => { let token_str = token::to_str(get_ident_interner(), &p.token); p.fatal(~"expected ident, found " + token_str) } }, "path" => { - token::nt_path(~p.parse_path(LifetimeAndTypesWithoutColons).path) + token::NtPath(~p.parse_path(LifetimeAndTypesWithoutColons).path) } - "attr" => token::nt_attr(@p.parse_attribute(false)), + "attr" => token::NtAttr(@p.parse_attribute(false)), "tt" => { p.quote_depth += 1u; //but in theory, non-quoted tts might be useful - let res = token::nt_tt(@p.parse_token_tree()); + let res = token::NtTT(@p.parse_token_tree()); p.quote_depth -= 1u; res } - "matchers" => token::nt_matchers(p.parse_matchers()), + "matchers" => token::NtMatchers(p.parse_matchers()), _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name) } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index a2f218325b4..dc5eb0e9537 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -8,21 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{Ident, matcher_, matcher, match_tok, match_nonterminal, match_seq}; -use ast::{tt_delim}; +use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq}; +use ast::{TTDelim}; use ast; use codemap::{Span, Spanned, DUMMY_SP}; use ext::base::{AnyMacro, ExtCtxt, MacResult, MRAny, MRDef, MacroDef}; use ext::base::{NormalTT, SyntaxExpanderTTTrait}; use ext::base; -use ext::tt::macro_parser::{error}; -use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; -use ext::tt::macro_parser::{parse, parse_or_else, success, failure}; -use parse::lexer::{new_tt_reader, reader}; +use ext::tt::macro_parser::{Success, Error, Failure}; +use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; +use ext::tt::macro_parser::{parse, parse_or_else}; +use parse::lexer::{new_tt_reader, Reader}; use parse::parser::Parser; -use parse::attr::parser_attr; +use parse::attr::ParserAttr; use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_str}; -use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt, EOF}; +use parse::token::{FAT_ARROW, SEMI, NtMatchers, NtTT, EOF}; use print; use std::cell::RefCell; use util::small_vector::SmallVector; @@ -63,7 +63,7 @@ impl AnyMacro for ParserAnyMacro { self.ensure_complete_parse(true); ret } - fn make_items(&self) -> SmallVector<@ast::item> { + fn make_items(&self) -> SmallVector<@ast::Item> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); @@ -89,15 +89,15 @@ impl AnyMacro for ParserAnyMacro { struct MacroRulesSyntaxExpanderTTFun { name: Ident, - lhses: @~[@named_match], - rhses: @~[@named_match], + lhses: @~[@NamedMatch], + rhses: @~[@NamedMatch], } impl SyntaxExpanderTTTrait for MacroRulesSyntaxExpanderTTFun { fn expand(&self, cx: &mut ExtCtxt, sp: Span, - arg: &[ast::token_tree], + arg: &[ast::TokenTree], _: ast::SyntaxContext) -> MacResult { generic_extension(cx, sp, self.name, arg, *self.lhses, *self.rhses) @@ -108,16 +108,15 @@ impl SyntaxExpanderTTTrait for MacroRulesSyntaxExpanderTTFun { fn generic_extension(cx: &ExtCtxt, sp: Span, name: Ident, - arg: &[ast::token_tree], - lhses: &[@named_match], - rhses: &[@named_match]) + arg: &[ast::TokenTree], + lhses: &[@NamedMatch], + rhses: &[@NamedMatch]) -> MacResult { if cx.trace_macros() { println!("{}! \\{ {} \\}", cx.str_of(name), - print::pprust::tt_to_str( - &ast::tt_delim(@arg.to_owned()), - get_ident_interner())); + print::pprust::tt_to_str(&TTDelim(@arg.to_owned()), + get_ident_interner())); } // Which arm's failure should we report? (the one furthest along) @@ -128,17 +127,17 @@ fn generic_extension(cx: &ExtCtxt, for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers match *lhs { - @matched_nonterminal(nt_matchers(ref mtcs)) => { + @MatchedNonterminal(NtMatchers(ref mtcs)) => { // `none` is because we're not interpolating - let arg_rdr = new_tt_reader(s_d, None, arg.to_owned()) as @reader; + let arg_rdr = new_tt_reader(s_d, None, arg.to_owned()) as @Reader; match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) { - success(named_matches) => { + Success(named_matches) => { let rhs = match rhses[i] { // okay, what's your transcriber? - @matched_nonterminal(nt_tt(@ref tt)) => { + @MatchedNonterminal(NtTT(@ref tt)) => { match (*tt) { // cut off delimiters; don't parse 'em - tt_delim(ref tts) => { + TTDelim(ref tts) => { (*tts).slice(1u,(*tts).len()-1u).to_owned() } _ => cx.span_fatal( @@ -150,18 +149,18 @@ fn generic_extension(cx: &ExtCtxt, // rhs has holes ( `$id` and `$(...)` that need filled) let trncbr = new_tt_reader(s_d, Some(named_matches), rhs); - let p = Parser(cx.parse_sess(), cx.cfg(), trncbr as @reader); + let p = Parser(cx.parse_sess(), cx.cfg(), trncbr as @Reader); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. return MRAny(@ParserAnyMacro { parser: RefCell::new(p), } as @AnyMacro) } - failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { + Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { best_fail_spot = sp; best_fail_msg = (*msg).clone(); }, - error(sp, ref msg) => cx.span_fatal(sp, (*msg)) + Error(sp, ref msg) => cx.span_fatal(sp, (*msg)) } } _ => cx.bug("non-matcher found in parsed lhses") @@ -176,11 +175,11 @@ fn generic_extension(cx: &ExtCtxt, pub fn add_new_extension(cx: &mut ExtCtxt, sp: Span, name: Ident, - arg: ~[ast::token_tree], + arg: ~[ast::TokenTree], _: ast::SyntaxContext) -> base::MacResult { // these spans won't matter, anyways - fn ms(m: matcher_) -> matcher { + fn ms(m: Matcher_) -> Matcher { Spanned { node: m.clone(), span: DUMMY_SP @@ -195,14 +194,14 @@ pub fn add_new_extension(cx: &mut ExtCtxt, // $( $lhs:mtcs => $rhs:tt );+ // ...quasiquoting this would be nice. let argument_gram = ~[ - ms(match_seq(~[ - ms(match_nonterminal(lhs_nm, special_idents::matchers, 0u)), - ms(match_tok(FAT_ARROW)), - ms(match_nonterminal(rhs_nm, special_idents::tt, 1u)), + ms(MatchSeq(~[ + ms(MatchNonterminal(lhs_nm, special_idents::matchers, 0u)), + ms(MatchTok(FAT_ARROW)), + ms(MatchNonterminal(rhs_nm, special_idents::tt, 1u)), ], Some(SEMI), false, 0u, 2u)), //to phase into semicolon-termination instead of //semicolon-separation - ms(match_seq(~[ms(match_tok(SEMI))], None, true, 2u, 2u))]; + ms(MatchSeq(~[ms(MatchTok(SEMI))], None, true, 2u, 2u))]; // Parse the macro_rules! invocation (`none` is for no interpolations): @@ -211,18 +210,18 @@ pub fn add_new_extension(cx: &mut ExtCtxt, arg.clone()); let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(), - arg_reader as @reader, + arg_reader as @Reader, argument_gram); // Extract the arguments: let lhses = match *argument_map.get(&lhs_nm) { - @matched_seq(ref s, _) => /* FIXME (#2543) */ @(*s).clone(), + @MatchedSeq(ref s, _) => /* FIXME (#2543) */ @(*s).clone(), _ => cx.span_bug(sp, "wrong-structured lhs") }; let rhses = match *argument_map.get(&rhs_nm) { - @matched_seq(ref s, _) => /* FIXME (#2543) */ @(*s).clone(), - _ => cx.span_bug(sp, "wrong-structured rhs") + @MatchedSeq(ref s, _) => /* FIXME (#2543) */ @(*s).clone(), + _ => cx.span_bug(sp, "wrong-structured rhs") }; let exp = ~MacroRulesSyntaxExpanderTTFun { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 060f6b8a8b9..2b90f4221a8 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -9,11 +9,11 @@ // except according to those terms. use ast; -use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,Ident}; +use ast::{TokenTree, TTDelim, TTTok, TTSeq, TTNonterminal, Ident}; use codemap::{Span, DUMMY_SP}; use diagnostic::SpanHandler; -use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; -use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident}; +use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; +use parse::token::{EOF, INTERPOLATED, IDENT, Token, NtIdent}; use parse::token::{ident_to_str}; use parse::lexer::TokenAndSpan; @@ -21,9 +21,9 @@ use std::cell::{Cell, RefCell}; use std::hashmap::HashMap; use std::option; -///an unzipping of `token_tree`s +///an unzipping of `TokenTree`s struct TtFrame { - forest: @~[ast::token_tree], + forest: @~[ast::TokenTree], idx: Cell<uint>, dotdotdoted: bool, sep: Option<Token>, @@ -35,7 +35,7 @@ pub struct TtReader { // the unzipped tree: priv stack: RefCell<@TtFrame>, /* for MBE-style macro transcription */ - priv interpolations: RefCell<HashMap<Ident, @named_match>>, + priv interpolations: RefCell<HashMap<Ident, @NamedMatch>>, priv repeat_idx: RefCell<~[uint]>, priv repeat_len: RefCell<~[uint]>, /* cached: */ @@ -44,11 +44,11 @@ pub struct TtReader { } /** This can do Macro-By-Example transcription. On the other hand, if - * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and + * `src` contains no `TTSeq`s and `TTNonterminal`s, `interp` can (and * should) be none. */ pub fn new_tt_reader(sp_diag: @SpanHandler, - interp: Option<HashMap<Ident,@named_match>>, - src: ~[ast::token_tree]) + interp: Option<HashMap<Ident, @NamedMatch>>, + src: ~[ast::TokenTree]) -> @TtReader { let r = @TtReader { sp_diag: sp_diag, @@ -99,22 +99,22 @@ pub fn dup_tt_reader(r: @TtReader) -> @TtReader { } -fn lookup_cur_matched_by_matched(r: &TtReader, start: @named_match) - -> @named_match { - fn red(ad: @named_match, idx: &uint) -> @named_match { +fn lookup_cur_matched_by_matched(r: &TtReader, start: @NamedMatch) + -> @NamedMatch { + fn red(ad: @NamedMatch, idx: &uint) -> @NamedMatch { match *ad { - matched_nonterminal(_) => { - // end of the line; duplicate henceforth - ad - } - matched_seq(ref ads, _) => ads[*idx] + MatchedNonterminal(_) => { + // end of the line; duplicate henceforth + ad + } + MatchedSeq(ref ads, _) => ads[*idx] } } let repeat_idx = r.repeat_idx.borrow(); repeat_idx.get().iter().fold(start, red) } -fn lookup_cur_matched(r: &TtReader, name: Ident) -> @named_match { +fn lookup_cur_matched(r: &TtReader, name: Ident) -> @NamedMatch { let matched_opt = { let interpolations = r.interpolations.borrow(); interpolations.get().find_copy(&name) @@ -130,43 +130,43 @@ fn lookup_cur_matched(r: &TtReader, name: Ident) -> @named_match { } #[deriving(Clone)] -enum lis { - lis_unconstrained, - lis_constraint(uint, Ident), - lis_contradiction(~str), +enum LockstepIterSize { + LisUnconstrained, + LisConstraint(uint, Ident), + LisContradiction(~str), } -fn lockstep_iter_size(t: &token_tree, r: &TtReader) -> lis { - fn lis_merge(lhs: lis, rhs: lis) -> lis { - match lhs { - lis_unconstrained => rhs.clone(), - lis_contradiction(_) => lhs.clone(), - lis_constraint(l_len, ref l_id) => match rhs { - lis_unconstrained => lhs.clone(), - lis_contradiction(_) => rhs.clone(), - lis_constraint(r_len, _) if l_len == r_len => lhs.clone(), - lis_constraint(r_len, ref r_id) => { +fn lis_merge(lhs: LockstepIterSize, rhs: LockstepIterSize) -> LockstepIterSize { + match lhs { + LisUnconstrained => rhs.clone(), + LisContradiction(_) => lhs.clone(), + LisConstraint(l_len, ref l_id) => match rhs { + LisUnconstrained => lhs.clone(), + LisContradiction(_) => rhs.clone(), + LisConstraint(r_len, _) if l_len == r_len => lhs.clone(), + LisConstraint(r_len, ref r_id) => { let l_n = ident_to_str(l_id); let r_n = ident_to_str(r_id); - lis_contradiction(format!("Inconsistent lockstep iteration: \ - '{}' has {} items, but '{}' has {}", - l_n, l_len, r_n, r_len)) + LisContradiction(format!("Inconsistent lockstep iteration: \ + '{}' has {} items, but '{}' has {}", + l_n, l_len, r_n, r_len)) } - } } } +} + +fn lockstep_iter_size(t: &TokenTree, r: &TtReader) -> LockstepIterSize { match *t { - tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => { - tts.iter().fold(lis_unconstrained, |lis, tt| { - let lis2 = lockstep_iter_size(tt, r); - lis_merge(lis, lis2) - }) - } - tt_tok(..) => lis_unconstrained, - tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { - matched_nonterminal(_) => lis_unconstrained, - matched_seq(ref ads, _) => lis_constraint(ads.len(), name) - } + TTDelim(ref tts) | TTSeq(_, ref tts, _, _) => { + tts.iter().fold(LisUnconstrained, |lis, tt| { + lis_merge(lis, lockstep_iter_size(tt, r)) + }) + } + TTTok(..) => LisUnconstrained, + TTNonterminal(_, name) => match *lookup_cur_matched(r, name) { + MatchedNonterminal(_) => LisUnconstrained, + MatchedSeq(ref ads, _) => LisConstraint(ads.len(), name) + } } } @@ -228,11 +228,11 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan { } } } - loop { /* because it's easiest, this handles `tt_delim` not starting - with a `tt_tok`, even though it won't happen */ + loop { /* because it's easiest, this handles `TTDelim` not starting + with a `TTTok`, even though it won't happen */ // XXX(pcwalton): Bad copy. match r.stack.get().forest[r.stack.get().idx.get()].clone() { - tt_delim(tts) => { + TTDelim(tts) => { r.stack.set(@TtFrame { forest: tts, idx: Cell::new(0u), @@ -242,28 +242,28 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan { }); // if this could be 0-length, we'd need to potentially recur here } - tt_tok(sp, tok) => { + TTTok(sp, tok) => { r.cur_span.set(sp); r.cur_tok.set(tok); r.stack.get().idx.set(r.stack.get().idx.get() + 1u); return ret_val; } - tt_seq(sp, tts, sep, zerok) => { + TTSeq(sp, tts, sep, zerok) => { // XXX(pcwalton): Bad copy. - let t = tt_seq(sp, tts, sep.clone(), zerok); + let t = TTSeq(sp, tts, sep.clone(), zerok); match lockstep_iter_size(&t, r) { - lis_unconstrained => { + LisUnconstrained => { r.sp_diag.span_fatal( sp, /* blame macro writer */ "attempted to repeat an expression \ containing no syntax \ variables matched as repeating at this depth"); } - lis_contradiction(ref msg) => { + LisContradiction(ref msg) => { /* FIXME #2887 blame macro invoker instead*/ r.sp_diag.span_fatal(sp, (*msg)); } - lis_constraint(len, _) => { + LisConstraint(len, _) => { if len == 0 { if !zerok { r.sp_diag.span_fatal(sp, /* FIXME #2887 blame invoker @@ -293,25 +293,25 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan { } } // FIXME #2887: think about span stuff here - tt_nonterminal(sp, ident) => { + TTNonterminal(sp, ident) => { match *lookup_cur_matched(r, ident) { /* sidestep the interpolation tricks for ident because (a) idents can be in lots of places, so it'd be a pain (b) we actually can, since it's a token. */ - matched_nonterminal(nt_ident(~sn,b)) => { + MatchedNonterminal(NtIdent(~sn,b)) => { r.cur_span.set(sp); r.cur_tok.set(IDENT(sn,b)); r.stack.get().idx.set(r.stack.get().idx.get() + 1u); return ret_val; } - matched_nonterminal(ref other_whole_nt) => { + MatchedNonterminal(ref other_whole_nt) => { // XXX(pcwalton): Bad copy. r.cur_span.set(sp); r.cur_tok.set(INTERPOLATED((*other_whole_nt).clone())); r.stack.get().idx.set(r.stack.get().idx.get() + 1u); return ret_val; } - matched_seq(..) => { + MatchedSeq(..) => { r.sp_diag.span_fatal( r.cur_span.get(), /* blame the macro writer */ format!("variable '{}' is still repeating at this depth", diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8fab2df7a5d..c73edb0bfcf 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -16,7 +16,7 @@ use opt_vec::OptVec; use util::small_vector::SmallVector; // We may eventually want to be able to fold over type parameters, too. -pub trait ast_fold { +pub trait Folder { fn fold_crate(&mut self, c: Crate) -> Crate { noop_fold_crate(c, self) } @@ -25,24 +25,24 @@ pub trait ast_fold { meta_items.map(|x| fold_meta_item_(*x, self)) } - fn fold_view_paths(&mut self, view_paths: &[@view_path]) -> ~[@view_path] { + fn fold_view_paths(&mut self, view_paths: &[@ViewPath]) -> ~[@ViewPath] { view_paths.map(|view_path| { let inner_view_path = match view_path.node { - view_path_simple(ref ident, ref path, node_id) => { - view_path_simple(ident.clone(), - self.fold_path(path), - self.new_id(node_id)) + ViewPathSimple(ref ident, ref path, node_id) => { + ViewPathSimple(ident.clone(), + self.fold_path(path), + self.new_id(node_id)) } - view_path_glob(ref path, node_id) => { - view_path_glob(self.fold_path(path), self.new_id(node_id)) + ViewPathGlob(ref path, node_id) => { + ViewPathGlob(self.fold_path(path), self.new_id(node_id)) } - view_path_list(ref path, ref path_list_idents, node_id) => { - view_path_list(self.fold_path(path), - path_list_idents.map(|path_list_ident| { + ViewPathList(ref path, ref path_list_idents, node_id) => { + ViewPathList(self.fold_path(path), + path_list_idents.map(|path_list_ident| { let id = self.new_id(path_list_ident.node .id); Spanned { - node: path_list_ident_ { + node: PathListIdent_ { name: path_list_ident.node .name .clone(), @@ -50,9 +50,9 @@ pub trait ast_fold { }, span: self.new_span( path_list_ident.span) - } - }), - self.new_id(node_id)) + } + }), + self.new_id(node_id)) } }; @Spanned { @@ -62,20 +62,16 @@ pub trait ast_fold { }) } - fn fold_view_item(&mut self, vi: &view_item) -> view_item { + fn fold_view_item(&mut self, vi: &ViewItem) -> ViewItem { let inner_view_item = match vi.node { - view_item_extern_mod(ref ident, - string, - node_id) => { - view_item_extern_mod(ident.clone(), - string, - self.new_id(node_id)) + ViewItemExternMod(ref ident, string, node_id) => { + ViewItemExternMod(ident.clone(), string, self.new_id(node_id)) } - view_item_use(ref view_paths) => { - view_item_use(self.fold_view_paths(*view_paths)) + ViewItemUse(ref view_paths) => { + ViewItemUse(self.fold_view_paths(*view_paths)) } }; - view_item { + ViewItem { node: inner_view_item, attrs: vi.attrs.map(|a| fold_attribute_(*a, self)), vis: vi.vis, @@ -83,19 +79,19 @@ pub trait ast_fold { } } - fn fold_foreign_item(&mut self, ni: @foreign_item) -> @foreign_item { + fn fold_foreign_item(&mut self, ni: @ForeignItem) -> @ForeignItem { noop_fold_foreign_item(ni, self) } - fn fold_item(&mut self, i: @item) -> SmallVector<@item> { + fn fold_item(&mut self, i: @Item) -> SmallVector<@Item> { noop_fold_item(i, self) } - fn fold_struct_field(&mut self, sf: &struct_field) -> struct_field { + fn fold_struct_field(&mut self, sf: &StructField) -> StructField { let fold_attribute = |x| fold_attribute_(x, self); Spanned { - node: ast::struct_field_ { + node: ast::StructField_ { kind: sf.node.kind, id: self.new_id(sf.node.id), ty: self.fold_ty(sf.node.ty), @@ -105,11 +101,11 @@ pub trait ast_fold { } } - fn fold_item_underscore(&mut self, i: &item_) -> item_ { + fn fold_item_underscore(&mut self, i: &Item_) -> Item_ { noop_fold_item_underscore(i, self) } - fn fold_fn_decl(&mut self, d: &fn_decl) -> P<fn_decl> { + fn fold_fn_decl(&mut self, d: &FnDecl) -> P<FnDecl> { noop_fold_fn_decl(d, self) } @@ -117,7 +113,7 @@ pub trait ast_fold { noop_fold_type_method(m, self) } - fn fold_method(&mut self, m: @method) -> @method { + fn fold_method(&mut self, m: @Method) -> @Method { noop_fold_method(m, self) } @@ -163,16 +159,16 @@ pub trait ast_fold { fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> { let node = match t.node { - ty_nil | ty_bot | ty_infer => t.node.clone(), - ty_box(ty) => ty_box(self.fold_ty(ty)), - ty_uniq(ty) => ty_uniq(self.fold_ty(ty)), - ty_vec(ty) => ty_vec(self.fold_ty(ty)), - ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)), - ty_rptr(ref region, ref mt) => { - ty_rptr(fold_opt_lifetime(region, self), fold_mt(mt, self)) + TyNil | TyBot | TyInfer => t.node.clone(), + TyBox(ty) => TyBox(self.fold_ty(ty)), + TyUniq(ty) => TyUniq(self.fold_ty(ty)), + TyVec(ty) => TyVec(self.fold_ty(ty)), + TyPtr(ref mt) => TyPtr(fold_mt(mt, self)), + TyRptr(ref region, ref mt) => { + TyRptr(fold_opt_lifetime(region, self), fold_mt(mt, self)) } - ty_closure(ref f) => { - ty_closure(@TyClosure { + TyClosure(ref f) => { + TyClosure(@ClosureTy { sigil: f.sigil, purity: f.purity, region: fold_opt_lifetime(&f.region, self), @@ -182,24 +178,24 @@ pub trait ast_fold { lifetimes: f.lifetimes.map(|l| fold_lifetime(l, self)), }) } - ty_bare_fn(ref f) => { - ty_bare_fn(@TyBareFn { + TyBareFn(ref f) => { + TyBareFn(@BareFnTy { lifetimes: f.lifetimes.map(|l| fold_lifetime(l, self)), purity: f.purity, abis: f.abis, decl: self.fold_fn_decl(f.decl) }) } - ty_tup(ref tys) => ty_tup(tys.map(|&ty| self.fold_ty(ty))), - ty_path(ref path, ref bounds, id) => { - ty_path(self.fold_path(path), - fold_opt_bounds(bounds, self), - self.new_id(id)) + TyTup(ref tys) => TyTup(tys.map(|&ty| self.fold_ty(ty))), + TyPath(ref path, ref bounds, id) => { + TyPath(self.fold_path(path), + fold_opt_bounds(bounds, self), + self.new_id(id)) } - ty_fixed_length_vec(ty, e) => { - ty_fixed_length_vec(self.fold_ty(ty), self.fold_expr(e)) + TyFixedLengthVec(ty, e) => { + TyFixedLengthVec(self.fold_ty(ty), self.fold_expr(e)) } - ty_typeof(expr) => ty_typeof(self.fold_expr(expr)), + TyTypeof(expr) => TyTypeof(self.fold_expr(expr)), }; P(Ty { id: self.new_id(t.id), @@ -208,12 +204,12 @@ pub trait ast_fold { }) } - fn fold_mod(&mut self, m: &_mod) -> _mod { + fn fold_mod(&mut self, m: &Mod) -> Mod { noop_fold_mod(m, self) } - fn fold_foreign_mod(&mut self, nm: &foreign_mod) -> foreign_mod { - ast::foreign_mod { + fn fold_foreign_mod(&mut self, nm: &ForeignMod) -> ForeignMod { + ast::ForeignMod { abis: nm.abis, view_items: nm.view_items .iter() @@ -226,15 +222,15 @@ pub trait ast_fold { } } - fn fold_variant(&mut self, v: &variant) -> P<variant> { + fn fold_variant(&mut self, v: &Variant) -> P<Variant> { let kind; match v.node.kind { - tuple_variant_kind(ref variant_args) => { - kind = tuple_variant_kind(variant_args.map(|x| + TupleVariantKind(ref variant_args) => { + kind = TupleVariantKind(variant_args.map(|x| fold_variant_arg_(x, self))) } - struct_variant_kind(ref struct_def) => { - kind = struct_variant_kind(@ast::struct_def { + StructVariantKind(ref struct_def) => { + kind = StructVariantKind(@ast::StructDef { fields: struct_def.fields.iter() .map(|f| self.fold_struct_field(f)).collect(), ctor_id: struct_def.ctor_id.map(|c| self.new_id(c)) @@ -249,7 +245,7 @@ pub trait ast_fold { Some(e) => Some(self.fold_expr(e)), None => None }; - let node = ast::variant_ { + let node = ast::Variant_ { name: v.node.name, attrs: attrs, kind: kind, @@ -289,13 +285,13 @@ pub trait ast_fold { } } - fn fold_mac(&mut self, macro: &mac) -> mac { + fn fold_mac(&mut self, macro: &Mac) -> Mac { Spanned { node: match macro.node { - mac_invoc_tt(ref p, ref tts, ctxt) => { - mac_invoc_tt(self.fold_path(p), - fold_tts(*tts, self), - ctxt) + MacInvocTT(ref p, ref tts, ctxt) => { + MacInvocTT(self.fold_path(p), + fold_tts(*tts, self), + ctxt) } }, span: self.new_span(macro.span) @@ -314,29 +310,29 @@ pub trait ast_fold { sp } - fn fold_explicit_self(&mut self, es: &explicit_self) -> explicit_self { + fn fold_explicit_self(&mut self, es: &ExplicitSelf) -> ExplicitSelf { Spanned { span: self.new_span(es.span), node: self.fold_explicit_self_(&es.node) } } - fn fold_explicit_self_(&mut self, es: &explicit_self_) -> explicit_self_ { + fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ { match *es { - sty_static | sty_value(_) | sty_uniq(_) | sty_box(_) => { + SelfStatic | SelfValue(_) | SelfUniq(_) | SelfBox(_) => { *es } - sty_region(ref lifetime, m) => { - sty_region(fold_opt_lifetime(lifetime, self), m) + SelfRegion(ref lifetime, m) => { + SelfRegion(fold_opt_lifetime(lifetime, self), m) } } } } -/* some little folds that probably aren't useful to have in ast_fold itself*/ +/* some little folds that probably aren't useful to have in Folder itself*/ //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive -fn fold_meta_item_<T: ast_fold>(mi: @MetaItem, fld: &mut T) -> @MetaItem { +fn fold_meta_item_<T: Folder>(mi: @MetaItem, fld: &mut T) -> @MetaItem { @Spanned { node: match mi.node { @@ -354,7 +350,7 @@ fn fold_meta_item_<T: ast_fold>(mi: @MetaItem, fld: &mut T) -> @MetaItem { } //used in noop_fold_item and noop_fold_crate -fn fold_attribute_<T: ast_fold>(at: Attribute, fld: &mut T) -> Attribute { +fn fold_attribute_<T: Folder>(at: Attribute, fld: &mut T) -> Attribute { Spanned { span: fld.new_span(at.span), node: ast::Attribute_ { @@ -366,35 +362,35 @@ fn fold_attribute_<T: ast_fold>(at: Attribute, fld: &mut T) -> Attribute { } //used in noop_fold_foreign_item and noop_fold_fn_decl -fn fold_arg_<T: ast_fold>(a: &arg, fld: &mut T) -> arg { - ast::arg { +fn fold_arg_<T: Folder>(a: &Arg, fld: &mut T) -> Arg { + Arg { ty: fld.fold_ty(a.ty), pat: fld.fold_pat(a.pat), id: fld.new_id(a.id), } } -// build a new vector of tts by appling the ast_fold's fold_ident to +// build a new vector of tts by appling the Folder's fold_ident to // all of the identifiers in the token trees. -pub fn fold_tts<T: ast_fold>(tts: &[token_tree], fld: &mut T) -> ~[token_tree] { +pub fn fold_tts<T: Folder>(tts: &[TokenTree], fld: &mut T) -> ~[TokenTree] { tts.map(|tt| { match *tt { - tt_tok(span, ref tok) => - tt_tok(span,maybe_fold_ident(tok,fld)), - tt_delim(tts) => tt_delim(@fold_tts(*tts, fld)), - tt_seq(span, pattern, ref sep, is_optional) => - tt_seq(span, - @fold_tts(*pattern, fld), - sep.as_ref().map(|tok|maybe_fold_ident(tok,fld)), - is_optional), - tt_nonterminal(sp,ref ident) => - tt_nonterminal(sp,fld.fold_ident(*ident)) + TTTok(span, ref tok) => + TTTok(span,maybe_fold_ident(tok,fld)), + TTDelim(tts) => TTDelim(@fold_tts(*tts, fld)), + TTSeq(span, pattern, ref sep, is_optional) => + TTSeq(span, + @fold_tts(*pattern, fld), + sep.as_ref().map(|tok|maybe_fold_ident(tok,fld)), + is_optional), + TTNonterminal(sp,ref ident) => + TTNonterminal(sp,fld.fold_ident(*ident)) } }) } // apply ident folder if it's an ident, otherwise leave it alone -fn maybe_fold_ident<T: ast_fold>(t: &token::Token, fld: &mut T) -> token::Token { +fn maybe_fold_ident<T: Folder>(t: &token::Token, fld: &mut T) -> token::Token { match *t { token::IDENT(id, followed_by_colons) => { token::IDENT(fld.fold_ident(id), followed_by_colons) @@ -403,9 +399,8 @@ fn maybe_fold_ident<T: ast_fold>(t: &token::Token, fld: &mut T) -> token::Token } } -pub fn noop_fold_fn_decl<T: ast_fold>(decl: &fn_decl, fld: &mut T) - -> P<fn_decl> { - P(fn_decl { +pub fn noop_fold_fn_decl<T: Folder>(decl: &FnDecl, fld: &mut T) -> P<FnDecl> { + P(FnDecl { inputs: decl.inputs.map(|x| fold_arg_(x, fld)), // bad copy output: fld.fold_ty(decl.output), cf: decl.cf, @@ -413,7 +408,7 @@ pub fn noop_fold_fn_decl<T: ast_fold>(decl: &fn_decl, fld: &mut T) }) } -fn fold_ty_param_bound<T: ast_fold>(tpb: &TyParamBound, fld: &mut T) +fn fold_ty_param_bound<T: Folder>(tpb: &TyParamBound, fld: &mut T) -> TyParamBound { match *tpb { TraitTyParamBound(ref ty) => TraitTyParamBound(fold_trait_ref(ty, fld)), @@ -421,7 +416,7 @@ fn fold_ty_param_bound<T: ast_fold>(tpb: &TyParamBound, fld: &mut T) } } -pub fn fold_ty_param<T: ast_fold>(tp: &TyParam, fld: &mut T) -> TyParam { +pub fn fold_ty_param<T: Folder>(tp: &TyParam, fld: &mut T) -> TyParam { TyParam { ident: tp.ident, id: fld.new_id(tp.id), @@ -429,12 +424,12 @@ pub fn fold_ty_param<T: ast_fold>(tp: &TyParam, fld: &mut T) -> TyParam { } } -pub fn fold_ty_params<T: ast_fold>(tps: &OptVec<TyParam>, fld: &mut T) +pub fn fold_ty_params<T: Folder>(tps: &OptVec<TyParam>, fld: &mut T) -> OptVec<TyParam> { tps.map(|tp| fold_ty_param(tp, fld)) } -pub fn fold_lifetime<T: ast_fold>(l: &Lifetime, fld: &mut T) -> Lifetime { +pub fn fold_lifetime<T: Folder>(l: &Lifetime, fld: &mut T) -> Lifetime { Lifetime { id: fld.new_id(l.id), span: fld.new_span(l.span), @@ -442,38 +437,38 @@ pub fn fold_lifetime<T: ast_fold>(l: &Lifetime, fld: &mut T) -> Lifetime { } } -pub fn fold_lifetimes<T: ast_fold>(lts: &OptVec<Lifetime>, fld: &mut T) +pub fn fold_lifetimes<T: Folder>(lts: &OptVec<Lifetime>, fld: &mut T) -> OptVec<Lifetime> { lts.map(|l| fold_lifetime(l, fld)) } -pub fn fold_opt_lifetime<T: ast_fold>(o_lt: &Option<Lifetime>, fld: &mut T) +pub fn fold_opt_lifetime<T: Folder>(o_lt: &Option<Lifetime>, fld: &mut T) -> Option<Lifetime> { o_lt.as_ref().map(|lt| fold_lifetime(lt, fld)) } -pub fn fold_generics<T: ast_fold>(generics: &Generics, fld: &mut T) -> Generics { +pub fn fold_generics<T: Folder>(generics: &Generics, fld: &mut T) -> Generics { Generics {ty_params: fold_ty_params(&generics.ty_params, fld), lifetimes: fold_lifetimes(&generics.lifetimes, fld)} } -fn fold_struct_def<T: ast_fold>(struct_def: @struct_def, fld: &mut T) -> @struct_def { - @ast::struct_def { +fn fold_struct_def<T: Folder>(struct_def: @StructDef, fld: &mut T) -> @StructDef { + @ast::StructDef { fields: struct_def.fields.map(|f| fold_struct_field(f, fld)), ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(cid)), } } -fn fold_trait_ref<T: ast_fold>(p: &trait_ref, fld: &mut T) -> trait_ref { - ast::trait_ref { +fn fold_trait_ref<T: Folder>(p: &TraitRef, fld: &mut T) -> TraitRef { + ast::TraitRef { path: fld.fold_path(&p.path), ref_id: fld.new_id(p.ref_id), } } -fn fold_struct_field<T: ast_fold>(f: &struct_field, fld: &mut T) -> struct_field { +fn fold_struct_field<T: Folder>(f: &StructField, fld: &mut T) -> StructField { Spanned { - node: ast::struct_field_ { + node: ast::StructField_ { kind: f.node.kind, id: fld.new_id(f.node.id), ty: fld.fold_ty(f.node.ty), @@ -483,7 +478,7 @@ fn fold_struct_field<T: ast_fold>(f: &struct_field, fld: &mut T) -> struct_field } } -fn fold_field_<T: ast_fold>(field: Field, folder: &mut T) -> Field { +fn fold_field_<T: Folder>(field: Field, folder: &mut T) -> Field { ast::Field { ident: respan(field.ident.span, folder.fold_ident(field.ident.node)), expr: folder.fold_expr(field.expr), @@ -491,15 +486,15 @@ fn fold_field_<T: ast_fold>(field: Field, folder: &mut T) -> Field { } } -fn fold_mt<T: ast_fold>(mt: &mt, folder: &mut T) -> mt { - mt { +fn fold_mt<T: Folder>(mt: &MutTy, folder: &mut T) -> MutTy { + MutTy { ty: folder.fold_ty(mt.ty), mutbl: mt.mutbl, } } -fn fold_opt_bounds<T: ast_fold>(b: &Option<OptVec<TyParamBound>>, folder: &mut T) - -> Option<OptVec<TyParamBound>> { +fn fold_opt_bounds<T: Folder>(b: &Option<OptVec<TyParamBound>>, folder: &mut T) + -> Option<OptVec<TyParamBound>> { b.as_ref().map(|bounds| { bounds.map(|bound| { fold_ty_param_bound(bound, folder) @@ -507,14 +502,14 @@ fn fold_opt_bounds<T: ast_fold>(b: &Option<OptVec<TyParamBound>>, folder: &mut T }) } -fn fold_variant_arg_<T: ast_fold>(va: &variant_arg, folder: &mut T) -> variant_arg { - ast::variant_arg { +fn fold_variant_arg_<T: Folder>(va: &VariantArg, folder: &mut T) -> VariantArg { + ast::VariantArg { ty: folder.fold_ty(va.ty), id: folder.new_id(va.id) } } -pub fn noop_fold_block<T: ast_fold>(b: P<Block>, folder: &mut T) -> P<Block> { +pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> { let view_items = b.view_items.map(|x| folder.fold_view_item(x)); let stmts = b.stmts.iter().flat_map(|s| folder.fold_stmt(*s).move_iter()).collect(); P(Block { @@ -527,13 +522,13 @@ pub fn noop_fold_block<T: ast_fold>(b: P<Block>, folder: &mut T) -> P<Block> { }) } -pub fn noop_fold_item_underscore<T: ast_fold>(i: &item_, folder: &mut T) -> item_ { +pub fn noop_fold_item_underscore<T: Folder>(i: &Item_, folder: &mut T) -> Item_ { match *i { - item_static(t, m, e) => { - item_static(folder.fold_ty(t), m, folder.fold_expr(e)) + ItemStatic(t, m, e) => { + ItemStatic(folder.fold_ty(t), m, folder.fold_expr(e)) } - item_fn(decl, purity, abi, ref generics, body) => { - item_fn( + ItemFn(decl, purity, abi, ref generics, body) => { + ItemFn( folder.fold_fn_decl(decl), purity, abi, @@ -541,50 +536,47 @@ pub fn noop_fold_item_underscore<T: ast_fold>(i: &item_, folder: &mut T) -> item folder.fold_block(body) ) } - item_mod(ref m) => item_mod(folder.fold_mod(m)), - item_foreign_mod(ref nm) => { - item_foreign_mod(folder.fold_foreign_mod(nm)) + ItemMod(ref m) => ItemMod(folder.fold_mod(m)), + ItemForeignMod(ref nm) => ItemForeignMod(folder.fold_foreign_mod(nm)), + ItemTy(t, ref generics) => { + ItemTy(folder.fold_ty(t), fold_generics(generics, folder)) } - item_ty(t, ref generics) => { - item_ty(folder.fold_ty(t), - fold_generics(generics, folder)) - } - item_enum(ref enum_definition, ref generics) => { - item_enum( - ast::enum_def { + ItemEnum(ref enum_definition, ref generics) => { + ItemEnum( + ast::EnumDef { variants: enum_definition.variants.map(|&x| { folder.fold_variant(x) }), }, fold_generics(generics, folder)) } - item_struct(ref struct_def, ref generics) => { + ItemStruct(ref struct_def, ref generics) => { let struct_def = fold_struct_def(*struct_def, folder); - item_struct(struct_def, fold_generics(generics, folder)) + ItemStruct(struct_def, fold_generics(generics, folder)) } - item_impl(ref generics, ref ifce, ty, ref methods) => { - item_impl(fold_generics(generics, folder), - ifce.as_ref().map(|p| fold_trait_ref(p, folder)), - folder.fold_ty(ty), - methods.map(|x| folder.fold_method(*x)) + ItemImpl(ref generics, ref ifce, ty, ref methods) => { + ItemImpl(fold_generics(generics, folder), + ifce.as_ref().map(|p| fold_trait_ref(p, folder)), + folder.fold_ty(ty), + methods.map(|x| folder.fold_method(*x)) ) } - item_trait(ref generics, ref traits, ref methods) => { + ItemTrait(ref generics, ref traits, ref methods) => { let methods = methods.map(|method| { match *method { - required(ref m) => required(folder.fold_type_method(m)), - provided(method) => provided(folder.fold_method(method)) + Required(ref m) => Required(folder.fold_type_method(m)), + Provided(method) => Provided(folder.fold_method(method)) } }); - item_trait(fold_generics(generics, folder), - traits.map(|p| fold_trait_ref(p, folder)), - methods) + ItemTrait(fold_generics(generics, folder), + traits.map(|p| fold_trait_ref(p, folder)), + methods) } - item_mac(ref m) => item_mac(folder.fold_mac(m)), + ItemMac(ref m) => ItemMac(folder.fold_mac(m)), } } -pub fn noop_fold_type_method<T: ast_fold>(m: &TypeMethod, fld: &mut T) -> TypeMethod { +pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMethod { TypeMethod { ident: fld.fold_ident(m.ident), attrs: m.attrs.map(|a| fold_attribute_(*a, fld)), @@ -597,8 +589,8 @@ pub fn noop_fold_type_method<T: ast_fold>(m: &TypeMethod, fld: &mut T) -> TypeMe } } -pub fn noop_fold_mod<T: ast_fold>(m: &_mod, folder: &mut T) -> _mod { - ast::_mod { +pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod { + ast::Mod { view_items: m.view_items .iter() .map(|x| folder.fold_view_item(x)).collect(), @@ -606,7 +598,7 @@ pub fn noop_fold_mod<T: ast_fold>(m: &_mod, folder: &mut T) -> _mod { } } -pub fn noop_fold_crate<T: ast_fold>(c: Crate, folder: &mut T) -> Crate { +pub fn noop_fold_crate<T: Folder>(c: Crate, folder: &mut T) -> Crate { let fold_meta_item = |x| fold_meta_item_(x, folder); let fold_attribute = |x| fold_attribute_(x, folder); @@ -618,11 +610,10 @@ pub fn noop_fold_crate<T: ast_fold>(c: Crate, folder: &mut T) -> Crate { } } -pub fn noop_fold_item<T: ast_fold>(i: &item, folder: &mut T) - -> SmallVector<@item> { +pub fn noop_fold_item<T: Folder>(i: &Item, folder: &mut T) -> SmallVector<@Item> { let fold_attribute = |x| fold_attribute_(x, folder); - SmallVector::one(@item { + SmallVector::one(@Item { ident: folder.fold_ident(i.ident), attrs: i.attrs.map(|e| fold_attribute(*e)), id: folder.new_id(i.id), @@ -632,22 +623,21 @@ pub fn noop_fold_item<T: ast_fold>(i: &item, folder: &mut T) }) } -pub fn noop_fold_foreign_item<T: ast_fold>(ni: &foreign_item, folder: &mut T) - -> @foreign_item { - @foreign_item { +pub fn noop_fold_foreign_item<T: Folder>(ni: &ForeignItem, folder: &mut T) -> @ForeignItem { + @ForeignItem { ident: folder.fold_ident(ni.ident), attrs: ni.attrs.map(|x| fold_attribute_(*x, folder)), node: match ni.node { - foreign_item_fn(ref fdec, ref generics) => { - foreign_item_fn(P(fn_decl { + ForeignItemFn(ref fdec, ref generics) => { + ForeignItemFn(P(FnDecl { inputs: fdec.inputs.map(|a| fold_arg_(a, folder)), output: folder.fold_ty(fdec.output), cf: fdec.cf, variadic: fdec.variadic }), fold_generics(generics, folder)) } - foreign_item_static(t, m) => { - foreign_item_static(folder.fold_ty(t), m) + ForeignItemStatic(t, m) => { + ForeignItemStatic(folder.fold_ty(t), m) } }, id: folder.new_id(ni.id), @@ -656,8 +646,8 @@ pub fn noop_fold_foreign_item<T: ast_fold>(ni: &foreign_item, folder: &mut T) } } -pub fn noop_fold_method<T: ast_fold>(m: &method, folder: &mut T) -> @method { - @method { +pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> @Method { + @Method { ident: folder.fold_ident(m.ident), attrs: m.attrs.map(|a| fold_attribute_(*a, folder)), generics: fold_generics(&m.generics, folder), @@ -672,7 +662,7 @@ pub fn noop_fold_method<T: ast_fold>(m: &method, folder: &mut T) -> @method { } } -pub fn noop_fold_pat<T: ast_fold>(p: @Pat, folder: &mut T) -> @Pat { +pub fn noop_fold_pat<T: Folder>(p: @Pat, folder: &mut T) -> @Pat { let node = match p.node { PatWild => PatWild, PatWildMulti => PatWildMulti, @@ -717,7 +707,7 @@ pub fn noop_fold_pat<T: ast_fold>(p: @Pat, folder: &mut T) -> @Pat { } } -pub fn noop_fold_expr<T: ast_fold>(e: @Expr, folder: &mut T) -> @Expr { +pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { let fold_field = |x| fold_field_(x, folder); let node = match e.node { @@ -818,7 +808,7 @@ pub fn noop_fold_expr<T: ast_fold>(e: @Expr, folder: &mut T) -> @Expr { ExprRet(e.map(|x| folder.fold_expr(x))) } ExprInlineAsm(ref a) => { - ExprInlineAsm(inline_asm { + ExprInlineAsm(InlineAsm { inputs: a.inputs.map(|&(c, input)| (c, folder.fold_expr(input))), outputs: a.outputs.map(|&(c, out)| (c, folder.fold_expr(out))), .. (*a).clone() @@ -840,7 +830,7 @@ pub fn noop_fold_expr<T: ast_fold>(e: @Expr, folder: &mut T) -> @Expr { } } -pub fn noop_fold_stmt<T: ast_fold>(s: &Stmt, folder: &mut T) -> SmallVector<@Stmt> { +pub fn noop_fold_stmt<T: Folder>(s: &Stmt, folder: &mut T) -> SmallVector<@Stmt> { let nodes = match s.node { StmtDecl(d, nid) => { folder.fold_decl(d).move_iter() @@ -871,14 +861,14 @@ mod test { use super::*; // this version doesn't care about getting comments or docstrings in. - fn fake_print_crate(s: &mut pprust::ps, crate: &ast::Crate) { + fn fake_print_crate(s: &mut pprust::State, crate: &ast::Crate) { pprust::print_mod(s, &crate.module, crate.attrs); } // change every identifier to "zz" struct ToZzIdentFolder; - impl ast_fold for ToZzIdentFolder { + impl Folder for ToZzIdentFolder { fn fold_ident(&mut self, _: ast::Ident) -> ast::Ident { token::str_to_ident("zz") } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5128cdd54cc..0fd4c5c193c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -28,6 +28,8 @@ This API is completely unstable and subject to change. #[feature(macro_rules, globs, managed_boxes)]; +#[deny(non_camel_case_types)]; + extern mod extra; pub mod util { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index c8ebc803604..e7630a66855 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -16,7 +16,7 @@ use parse::parser::Parser; use parse::token::INTERPOLATED; // a parser that can parse attributes. -pub trait parser_attr { +pub trait ParserAttr { fn parse_outer_attributes(&mut self) -> ~[ast::Attribute]; fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute; fn parse_inner_attrs_and_next(&mut self) @@ -26,7 +26,7 @@ pub trait parser_attr { fn parse_optional_meta(&mut self) -> ~[@ast::MetaItem]; } -impl parser_attr for Parser { +impl ParserAttr for Parser { // Parse attributes that appear before an item fn parse_outer_attributes(&mut self) -> ~[ast::Attribute] { let mut attrs: ~[ast::Attribute] = ~[]; @@ -34,7 +34,7 @@ impl parser_attr for Parser { debug!("parse_outer_attributes: self.token={:?}", self.token); match self.token { - token::INTERPOLATED(token::nt_attr(..)) => { + token::INTERPOLATED(token::NtAttr(..)) => { attrs.push(self.parse_attribute(false)); } token::POUND => { @@ -69,7 +69,7 @@ impl parser_attr for Parser { debug!("parse_attributes: permit_inner={:?} self.token={:?}", permit_inner, self.token); let (span, value) = match self.token { - INTERPOLATED(token::nt_attr(attr)) => { + INTERPOLATED(token::NtAttr(attr)) => { assert!(attr.node.style == ast::AttrOuter); self.bump(); (attr.span, attr.node.value) @@ -121,7 +121,7 @@ impl parser_attr for Parser { let mut next_outer_attrs: ~[ast::Attribute] = ~[]; loop { let attr = match self.token { - token::INTERPOLATED(token::nt_attr(..)) => { + token::INTERPOLATED(token::NtAttr(..)) => { self.parse_attribute(true) } token::POUND => { @@ -165,7 +165,7 @@ impl parser_attr for Parser { // FIXME #623 Non-string meta items are not serialized correctly; // just forbid them for now match lit.node { - ast::lit_str(..) => (), + ast::LitStr(..) => {} _ => { self.span_err( lit.span, diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index e0ab7f1535d..86ab2e099d0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -11,7 +11,7 @@ use ast; use codemap::{BytePos, CharPos, CodeMap, Pos}; use diagnostic; -use parse::lexer::{is_whitespace, with_str_from, reader}; +use parse::lexer::{is_whitespace, with_str_from, Reader}; use parse::lexer::{StringReader, bump, is_eof, nextch, TokenAndSpan}; use parse::lexer::{is_line_non_doc_comment, is_block_non_doc_comment}; use parse::lexer; @@ -23,16 +23,16 @@ use std::str; use std::uint; #[deriving(Clone, Eq)] -pub enum cmnt_style { - isolated, // No code on either side of each line of the comment - trailing, // Code exists to the left of the comment - mixed, // Code before /* foo */ and after the comment - blank_line, // Just a manual blank line "\n\n", for layout +pub enum CommentStyle { + Isolated, // No code on either side of each line of the comment + Trailing, // Code exists to the left of the comment + Mixed, // Code before /* foo */ and after the comment + BlankLine, // Just a manual blank line "\n\n", for layout } #[deriving(Clone)] -pub struct cmnt { - style: cmnt_style, +pub struct Comment { + style: CommentStyle, lines: ~[~str], pos: BytePos } @@ -159,18 +159,18 @@ fn consume_non_eol_whitespace(rdr: @StringReader) { } } -fn push_blank_line_comment(rdr: @StringReader, comments: &mut ~[cmnt]) { +fn push_blank_line_comment(rdr: @StringReader, comments: &mut ~[Comment]) { debug!(">>> blank-line comment"); let v: ~[~str] = ~[]; - comments.push(cmnt { - style: blank_line, + comments.push(Comment { + style: BlankLine, lines: v, pos: rdr.last_pos.get(), }); } fn consume_whitespace_counting_blank_lines(rdr: @StringReader, - comments: &mut ~[cmnt]) { + comments: &mut ~[Comment]) { while is_whitespace(rdr.curr.get()) && !is_eof(rdr) { if rdr.col.get() == CharPos(0u) && rdr.curr.get() == '\n' { push_blank_line_comment(rdr, &mut *comments); @@ -181,19 +181,19 @@ fn consume_whitespace_counting_blank_lines(rdr: @StringReader, fn read_shebang_comment(rdr: @StringReader, code_to_the_left: bool, - comments: &mut ~[cmnt]) { + comments: &mut ~[Comment]) { debug!(">>> shebang comment"); let p = rdr.last_pos.get(); debug!("<<< shebang comment"); - comments.push(cmnt { - style: if code_to_the_left { trailing } else { isolated }, + comments.push(Comment { + style: if code_to_the_left { Trailing } else { Isolated }, lines: ~[read_one_line_comment(rdr)], pos: p }); } fn read_line_comments(rdr: @StringReader, code_to_the_left: bool, - comments: &mut ~[cmnt]) { + comments: &mut ~[Comment]) { debug!(">>> line comments"); let p = rdr.last_pos.get(); let mut lines: ~[~str] = ~[]; @@ -208,8 +208,8 @@ fn read_line_comments(rdr: @StringReader, code_to_the_left: bool, } debug!("<<< line comments"); if !lines.is_empty() { - comments.push(cmnt { - style: if code_to_the_left { trailing } else { isolated }, + comments.push(Comment { + style: if code_to_the_left { Trailing } else { Isolated }, lines: lines, pos: p }); @@ -251,7 +251,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str], fn read_block_comment(rdr: @StringReader, code_to_the_left: bool, - comments: &mut ~[cmnt]) { + comments: &mut ~[Comment]) { debug!(">>> block comment"); let p = rdr.last_pos.get(); let mut lines: ~[~str] = ~[]; @@ -280,7 +280,7 @@ fn read_block_comment(rdr: @StringReader, while level > 0 { debug!("=== block comment level {}", level); if is_eof(rdr) { - (rdr as @reader).fatal(~"unterminated block comment"); + (rdr as @Reader).fatal(~"unterminated block comment"); } if rdr.curr.get() == '\n' { trim_whitespace_prefix_and_push_line(&mut lines, curr_line, @@ -309,13 +309,13 @@ fn read_block_comment(rdr: @StringReader, } } - let mut style = if code_to_the_left { trailing } else { isolated }; + let mut style = if code_to_the_left { Trailing } else { Isolated }; consume_non_eol_whitespace(rdr); if !is_eof(rdr) && rdr.curr.get() != '\n' && lines.len() == 1u { - style = mixed; + style = Mixed; } debug!("<<< block comment"); - comments.push(cmnt {style: style, lines: lines, pos: p}); + comments.push(Comment {style: style, lines: lines, pos: p}); } fn peeking_at_comment(rdr: @StringReader) -> bool { @@ -326,7 +326,7 @@ fn peeking_at_comment(rdr: @StringReader) -> bool { fn consume_comment(rdr: @StringReader, code_to_the_left: bool, - comments: &mut ~[cmnt]) { + comments: &mut ~[Comment]) { debug!(">>> consume comment"); if rdr.curr.get() == '/' && nextch(rdr) == '/' { read_line_comments(rdr, code_to_the_left, comments); @@ -339,7 +339,7 @@ fn consume_comment(rdr: @StringReader, } #[deriving(Clone)] -pub struct lit { +pub struct Literal { lit: ~str, pos: BytePos } @@ -350,14 +350,14 @@ pub fn gather_comments_and_literals(span_diagnostic: @diagnostic::SpanHandler, path: @str, srdr: &mut io::Reader) - -> (~[cmnt], ~[lit]) { + -> (~[Comment], ~[Literal]) { let src = str::from_utf8_owned(srdr.read_to_end()).to_managed(); let cm = CodeMap::new(); let filemap = cm.new_filemap(path, src); let rdr = lexer::new_low_level_string_reader(span_diagnostic, filemap); - let mut comments: ~[cmnt] = ~[]; - let mut literals: ~[lit] = ~[]; + let mut comments: ~[Comment] = ~[]; + let mut literals: ~[Literal] = ~[]; let mut first_read: bool = true; while !is_eof(rdr) { loop { @@ -382,7 +382,7 @@ pub fn gather_comments_and_literals(span_diagnostic: if token::is_lit(&tok) { with_str_from(rdr, bstart, |s| { debug!("tok lit: {}", s); - literals.push(lit {lit: s.to_owned(), pos: sp.lo}); + literals.push(Literal {lit: s.to_owned(), pos: sp.lo}); }) } else { debug!("tok: {}", token::to_str(get_ident_interner(), &tok)); diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 3b81b09112b..9304b842294 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -25,13 +25,13 @@ use std::util; pub use ext::tt::transcribe::{TtReader, new_tt_reader}; -pub trait reader { +pub trait Reader { fn is_eof(@self) -> bool; fn next_token(@self) -> TokenAndSpan; fn fatal(@self, ~str) -> !; fn span_diag(@self) -> @SpanHandler; fn peek(@self) -> TokenAndSpan; - fn dup(@self) -> @reader; + fn dup(@self) -> @Reader; } #[deriving(Clone, Eq)] @@ -104,7 +104,7 @@ fn dup_string_reader(r: @StringReader) -> @StringReader { } } -impl reader for StringReader { +impl Reader for StringReader { fn is_eof(@self) -> bool { is_eof(self) } // return the next token. EFFECT: advances the string_reader. fn next_token(@self) -> TokenAndSpan { @@ -129,10 +129,10 @@ impl reader for StringReader { sp: self.peek_span.get(), } } - fn dup(@self) -> @reader { dup_string_reader(self) as @reader } + fn dup(@self) -> @Reader { dup_string_reader(self) as @Reader } } -impl reader for TtReader { +impl Reader for TtReader { fn is_eof(@self) -> bool { let cur_tok = self.cur_tok.borrow(); *cur_tok.get() == token::EOF @@ -152,7 +152,7 @@ impl reader for TtReader { sp: self.cur_span.get(), } } - fn dup(@self) -> @reader { dup_tt_reader(self) as @reader } + fn dup(@self) -> @Reader { dup_tt_reader(self) as @Reader } } // report a lexical error spanning [`from_pos`, `to_pos`) @@ -486,35 +486,35 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { c = rdr.curr.get(); nextch(rdr); if c == 'u' || c == 'i' { - enum Result { Signed(ast::int_ty), Unsigned(ast::uint_ty) } + enum Result { Signed(ast::IntTy), Unsigned(ast::UintTy) } let signed = c == 'i'; let mut tp = { - if signed { Signed(ast::ty_i) } - else { Unsigned(ast::ty_u) } + if signed { Signed(ast::TyI) } + else { Unsigned(ast::TyU) } }; bump(rdr); c = rdr.curr.get(); if c == '8' { bump(rdr); - tp = if signed { Signed(ast::ty_i8) } - else { Unsigned(ast::ty_u8) }; + tp = if signed { Signed(ast::TyI8) } + else { Unsigned(ast::TyU8) }; } n = nextch(rdr); if c == '1' && n == '6' { bump(rdr); bump(rdr); - tp = if signed { Signed(ast::ty_i16) } - else { Unsigned(ast::ty_u16) }; + tp = if signed { Signed(ast::TyI16) } + else { Unsigned(ast::TyU16) }; } else if c == '3' && n == '2' { bump(rdr); bump(rdr); - tp = if signed { Signed(ast::ty_i32) } - else { Unsigned(ast::ty_u32) }; + tp = if signed { Signed(ast::TyI32) } + else { Unsigned(ast::TyU32) }; } else if c == '6' && n == '4' { bump(rdr); bump(rdr); - tp = if signed { Signed(ast::ty_i64) } - else { Unsigned(ast::ty_u64) }; + tp = if signed { Signed(ast::TyI64) } + else { Unsigned(ast::TyU64) }; } if num_str.len() == 0u { fatal_span(rdr, start_bpos, rdr.last_pos.get(), @@ -566,13 +566,11 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { if c == '3' && n == '2' { bump(rdr); bump(rdr); - return token::LIT_FLOAT(str_to_ident(num_str), - ast::ty_f32); + return token::LIT_FLOAT(str_to_ident(num_str), ast::TyF32); } else if c == '6' && n == '4' { bump(rdr); bump(rdr); - return token::LIT_FLOAT(str_to_ident(num_str), - ast::ty_f64); + return token::LIT_FLOAT(str_to_ident(num_str), ast::TyF64); /* FIXME (#2252): if this is out of range for either a 32-bit or 64-bit float, it won't be noticed till the back-end. */ @@ -665,7 +663,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { if is_dec_digit(c) { return scan_number(c, rdr); } - fn binop(rdr: @StringReader, op: token::binop) -> token::Token { + fn binop(rdr: @StringReader, op: token::BinOp) -> token::Token { bump(rdr); if rdr.curr.get() == '=' { bump(rdr); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index b64f16aff59..ea069c2ffe3 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -15,8 +15,7 @@ use ast; use codemap::{Span, CodeMap, FileMap, FileSubstr}; use codemap; use diagnostic::{SpanHandler, mk_span_handler, mk_handler, Emitter}; -use parse::attr::parser_attr; -use parse::lexer::reader; +use parse::attr::ParserAttr; use parse::parser::Parser; use std::cell::RefCell; @@ -133,7 +132,7 @@ pub fn parse_item_from_source_str( cfg: ast::CrateConfig, attrs: ~[ast::Attribute], sess: @ParseSess -) -> Option<@ast::item> { +) -> Option<@ast::Item> { let mut p = new_parser_from_source_str(sess, cfg, name, source); maybe_aborted(p.parse_item(attrs),p) } @@ -169,7 +168,7 @@ pub fn parse_tts_from_source_str( source: @str, cfg: ast::CrateConfig, sess: @ParseSess -) -> ~[ast::token_tree] { +) -> ~[ast::TokenTree] { let mut p = new_parser_from_source_str( sess, cfg, @@ -255,7 +254,7 @@ pub fn filemap_to_parser(sess: @ParseSess, // compiler expands into it pub fn new_parser_from_tts(sess: @ParseSess, cfg: ast::CrateConfig, - tts: ~[ast::token_tree]) -> Parser { + tts: ~[ast::TokenTree]) -> Parser { tts_to_parser(sess,tts,cfg) } @@ -307,21 +306,21 @@ pub fn substring_to_filemap(sess: @ParseSess, source: @str, path: @str, // given a filemap, produce a sequence of token-trees pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap) - -> ~[ast::token_tree] { + -> ~[ast::TokenTree] { // it appears to me that the cfg doesn't matter here... indeed, // parsing tt's probably shouldn't require a parser at all. let cfg = ~[]; let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap); - let mut p1 = Parser(sess, cfg, srdr as @reader); + let mut p1 = Parser(sess, cfg, srdr as @lexer::Reader); p1.parse_all_token_trees() } // given tts and cfg, produce a parser pub fn tts_to_parser(sess: @ParseSess, - tts: ~[ast::token_tree], + tts: ~[ast::TokenTree], cfg: ast::CrateConfig) -> Parser { let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts); - Parser(sess, cfg, trdr as @reader) + Parser(sess, cfg, trdr as @lexer::Reader) } // abort if necessary @@ -415,26 +414,26 @@ mod test { #[test] fn string_to_tts_macro () { let tts = string_to_tts(@"macro_rules! zip (($a)=>($a))"); match tts { - [ast::tt_tok(_,_), - ast::tt_tok(_,token::NOT), - ast::tt_tok(_,_), - ast::tt_delim(delim_elts)] => + [ast::TTTok(_,_), + ast::TTTok(_,token::NOT), + ast::TTTok(_,_), + ast::TTDelim(delim_elts)] => match *delim_elts { - [ast::tt_tok(_,token::LPAREN), - ast::tt_delim(first_set), - ast::tt_tok(_,token::FAT_ARROW), - ast::tt_delim(second_set), - ast::tt_tok(_,token::RPAREN)] => + [ast::TTTok(_,token::LPAREN), + ast::TTDelim(first_set), + ast::TTTok(_,token::FAT_ARROW), + ast::TTDelim(second_set), + ast::TTTok(_,token::RPAREN)] => match *first_set { - [ast::tt_tok(_,token::LPAREN), - ast::tt_tok(_,token::DOLLAR), - ast::tt_tok(_,_), - ast::tt_tok(_,token::RPAREN)] => + [ast::TTTok(_,token::LPAREN), + ast::TTTok(_,token::DOLLAR), + ast::TTTok(_,_), + ast::TTTok(_,token::RPAREN)] => match *second_set { - [ast::tt_tok(_,token::LPAREN), - ast::tt_tok(_,token::DOLLAR), - ast::tt_tok(_,_), - ast::tt_tok(_,token::RPAREN)] => + [ast::TTTok(_,token::LPAREN), + ast::TTTok(_,token::DOLLAR), + ast::TTTok(_,_), + ast::TTTok(_,token::RPAREN)] => assert_eq!("correct","correct"), _ => assert_eq!("wrong 4","correct") }, @@ -461,7 +460,7 @@ mod test { assert_eq!(to_json_str(@tts), ~"[\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ {\ @@ -474,7 +473,7 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ {\ @@ -487,18 +486,18 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_delim\",\ + \"variant\":\"TTDelim\",\ \"fields\":[\ [\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"LPAREN\"\ ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ {\ @@ -511,14 +510,14 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"COLON\"\ ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ {\ @@ -531,7 +530,7 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"RPAREN\"\ @@ -541,18 +540,18 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_delim\",\ + \"variant\":\"TTDelim\",\ \"fields\":[\ [\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"LBRACE\"\ ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ {\ @@ -565,14 +564,14 @@ mod test { ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"SEMI\"\ ]\ },\ {\ - \"variant\":\"tt_tok\",\ + \"variant\":\"TTTok\",\ \"fields\":[\ null,\ \"RBRACE\"\ @@ -661,13 +660,13 @@ mod test { // this test depends on the intern order of "fn" and "int" assert_eq!(string_to_item(@"fn a (b : int) { b; }"), Some( - @ast::item{ident:str_to_ident("a"), + @ast::Item{ident:str_to_ident("a"), attrs:~[], id: ast::DUMMY_NODE_ID, - node: ast::item_fn(ast::P(ast::fn_decl{ - inputs: ~[ast::arg{ + node: ast::ItemFn(ast::P(ast::FnDecl { + inputs: ~[ast::Arg{ ty: ast::P(ast::Ty{id: ast::DUMMY_NODE_ID, - node: ast::ty_path(ast::Path{ + node: ast::TyPath(ast::Path{ span:sp(10,13), global:false, segments: ~[ @@ -704,12 +703,12 @@ mod test { id: ast::DUMMY_NODE_ID }], output: ast::P(ast::Ty{id: ast::DUMMY_NODE_ID, - node: ast::ty_nil, + node: ast::TyNil, span:sp(15,15)}), // not sure - cf: ast::return_val, + cf: ast::Return, variadic: false }), - ast::impure_fn, + ast::ImpureFn, abi::AbiSet::Rust(), ast::Generics{ // no idea on either of these: lifetimes: opt_vec::Empty, @@ -744,7 +743,7 @@ mod test { rules: ast::DefaultBlock, // no idea span: sp(15,21), })), - vis: ast::inherited, + vis: ast::Inherited, span: sp(0,21)})); } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 824420e9966..dba4f62aa9c 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -17,7 +17,7 @@ Obsolete syntax that becomes too hard to parse can be removed. */ -use ast::{Expr, ExprLit, lit_nil}; +use ast::{Expr, ExprLit, LitNil}; use codemap::{Span, respan}; use parse::parser::Parser; use parse::token; @@ -158,7 +158,7 @@ impl ParserObsoleteMethods for Parser { // a placeholder expression fn obsolete_expr(&mut self, sp: Span, kind: ObsoleteSyntax) -> @Expr { self.obsolete(sp, kind); - self.mk_expr(sp.lo, sp.hi, ExprLit(@respan(sp, lit_nil))) + self.mk_expr(sp.lo, sp.hi, ExprLit(@respan(sp, LitNil))) } fn report(&mut self, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 26653fe4a1e..149b7c1cf18 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -14,14 +14,14 @@ use abi; use abi::AbiSet; use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil}; use ast::{CallSugar, NoSugar, DoSugar}; -use ast::{TyBareFn, TyClosure}; +use ast::{BareFnTy, ClosureTy}; use ast::{RegionTyParamBound, TraitTyParamBound}; -use ast::{provided, public, purity}; -use ast::{_mod, BiAdd, arg, Arm, Attribute, BindByRef, BindByValue}; +use ast::{Provided, Public, Purity}; +use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, Block}; use ast::{BlockCheckMode, UnBox}; use ast::{Crate, CrateConfig, Decl, DeclItem}; -use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, enum_def, explicit_self}; +use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock}; use ast::{ExprBreak, ExprCall, ExprCast, ExprDoBody}; @@ -30,45 +30,45 @@ use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac}; use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc, ExprRepeat}; use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary}; use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox}; -use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl}; +use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl}; use ast::{ExprVstoreUniq, Onceness, Once, Many}; -use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod}; -use ast::{Ident, impure_fn, inherited, item, item_, item_static}; -use ast::{item_enum, item_fn, item_foreign_mod, item_impl}; -use ast::{item_mac, item_mod, item_struct, item_trait, item_ty, lit, lit_}; -use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int, lit_char}; -use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, Local}; -use ast::{MutImmutable, MutMutable, mac_, mac_invoc_tt, matcher, match_nonterminal}; -use ast::{match_seq, match_tok, method, mt, BiMul, Mutability}; -use ast::{named_field, UnNeg, noreturn, UnNot, P, Pat, PatBox, PatEnum}; +use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod}; +use ast::{Ident, ImpureFn, Inherited, Item, Item_, ItemStatic}; +use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl}; +use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_}; +use ast::{LitBool, LitFloat, LitFloatUnsuffixed, LitInt, LitChar}; +use ast::{LitIntUnsuffixed, LitNil, LitStr, LitUint, Local}; +use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal}; +use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability}; +use ast::{NamedField, UnNeg, NoReturn, UnNot, P, Pat, PatBox, PatEnum}; use ast::{PatIdent, PatLit, PatRange, PatRegion, PatStruct}; -use ast::{PatTup, PatUniq, PatWild, PatWildMulti, private}; -use ast::{BiRem, required}; -use ast::{ret_style, return_val, BiShl, BiShr, Stmt, StmtDecl}; -use ast::{StmtExpr, StmtSemi, StmtMac, struct_def, struct_field}; -use ast::{struct_variant_kind, BiSub}; +use ast::{PatTup, PatUniq, PatWild, PatWildMulti, Private}; +use ast::{BiRem, Required}; +use ast::{RetStyle, Return, BiShl, BiShr, Stmt, StmtDecl}; +use ast::{StmtExpr, StmtSemi, StmtMac, StructDef, StructField}; +use ast::{StructVariantKind, BiSub}; use ast::StrStyle; -use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value}; -use ast::{token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok}; -use ast::{tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box}; -use ast::{TypeField, ty_fixed_length_vec, ty_closure, ty_bare_fn, ty_typeof}; -use ast::{ty_infer, TypeMethod}; -use ast::{ty_nil, TyParam, TyParamBound, ty_path, ty_ptr, ty_rptr}; -use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, UnUniq}; -use ast::{unnamed_field, UnsafeBlock, unsafe_fn, view_item}; -use ast::{view_item_, view_item_extern_mod, view_item_use}; -use ast::{view_path, view_path_glob, view_path_list, view_path_simple}; -use ast::visibility; +use ast::{SelfBox, SelfRegion, SelfStatic, SelfUniq, SelfValue}; +use ast::{TokenTree, TraitMethod, TraitRef, TTDelim, TTSeq, TTTok}; +use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; +use ast::{TypeField, TyFixedLengthVec, TyClosure, TyBareFn, TyTypeof}; +use ast::{TyInfer, TypeMethod}; +use ast::{TyNil, TyParam, TyParamBound, TyPath, TyPtr, TyRptr}; +use ast::{TyTup, TyU32, TyUniq, TyVec, UnUniq}; +use ast::{UnnamedField, UnsafeBlock, UnsafeFn, ViewItem}; +use ast::{ViewItem_, ViewItemExternMod, ViewItemUse}; +use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; +use ast::Visibility; use ast; use ast_util::{as_prec, operator_prec}; use ast_util; use codemap::{Span, BytePos, Spanned, spanned, mk_sp}; use codemap; -use parse::attr::parser_attr; +use parse::attr::ParserAttr; use parse::classify; use parse::common::{SeqSep, seq_sep_none}; use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed}; -use parse::lexer::reader; +use parse::lexer::Reader; use parse::lexer::TokenAndSpan; use parse::obsolete::*; use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident}; @@ -85,6 +85,7 @@ use std::hashmap::HashSet; use std::util; use std::vec; +#[allow(non_camel_case_types)] #[deriving(Eq)] enum restriction { UNRESTRICTED, @@ -93,7 +94,7 @@ enum restriction { RESTRICT_NO_BAR_OR_DOUBLEBAR_OP, } -type item_info = (Ident, item_, Option<~[Attribute]>); +type ItemInfo = (Ident, Item_, Option<~[Attribute]>); /// How to parse a path. There are four different kinds of paths, all of which /// are parsed somewhat differently. @@ -126,13 +127,13 @@ struct PathAndBounds { bounds: Option<OptVec<TyParamBound>>, } -pub enum item_or_view_item { +enum ItemOrViewItem { // Indicates a failure to parse any kind of item. The attributes are // returned. - iovi_none(~[Attribute]), - iovi_item(@item), - iovi_foreign_item(@foreign_item), - iovi_view_item(view_item) + IoviNone(~[Attribute]), + IoviItem(@Item), + IoviForeignItem(@ForeignItem), + IoviViewItem(ViewItem) } /* The expr situation is not as complex as I thought it would be. @@ -144,14 +145,14 @@ macro_rules! maybe_whole_expr ( // This horrible convolution is brought to you by // @mut, have a terrible day let mut maybe_path = match ($p).token { - INTERPOLATED(token::nt_path(ref pt)) => Some((**pt).clone()), + INTERPOLATED(token::NtPath(ref pt)) => Some((**pt).clone()), _ => None, }; let ret = match ($p).token { - INTERPOLATED(token::nt_expr(e)) => { + INTERPOLATED(token::NtExpr(e)) => { Some(e) } - INTERPOLATED(token::nt_path(_)) => { + INTERPOLATED(token::NtPath(_)) => { let pt = maybe_path.take_unwrap(); Some($p.mk_expr(($p).span.lo, ($p).span.hi, ExprPath(pt))) } @@ -243,7 +244,7 @@ macro_rules! maybe_whole ( }; match __found__ { Some(INTERPOLATED(token::$constructor(x))) => { - return iovi_item(x.clone()) + return IoviItem(x.clone()) } _ => {} } @@ -279,14 +280,14 @@ fn maybe_append(lhs: ~[Attribute], rhs: Option<~[Attribute]>) struct ParsedItemsAndViewItems { attrs_remaining: ~[Attribute], - view_items: ~[view_item], - items: ~[@item], - foreign_items: ~[@foreign_item] + view_items: ~[ViewItem], + items: ~[@Item], + foreign_items: ~[@ForeignItem] } /* ident is handled by common.rs */ -pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: @reader) +pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: @Reader) -> Parser { let tok0 = rdr.next_token(); let interner = get_ident_interner(); @@ -340,8 +341,8 @@ pub struct Parser { tokens_consumed: uint, restriction: restriction, quote_depth: uint, // not (yet) related to the quasiquoter - reader: @reader, - interner: @token::ident_interner, + reader: @Reader, + interner: @token::IdentInterner, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice obsolete_set: HashSet<ObsoleteSyntax>, @@ -486,7 +487,7 @@ impl Parser { self.bump(); i } - token::INTERPOLATED(token::nt_ident(..)) => { + token::INTERPOLATED(token::NtIdent(..)) => { self.bug("ident interpolation not converted to real token"); } _ => { @@ -496,12 +497,12 @@ impl Parser { } } - pub fn parse_path_list_ident(&mut self) -> ast::path_list_ident { + pub fn parse_path_list_ident(&mut self) -> ast::PathListIdent { let lo = self.span.lo; let ident = self.parse_ident(); let hi = self.last_span.hi; - spanned(lo, hi, ast::path_list_ident_ { name: ident, - id: ast::DUMMY_NODE_ID }) + spanned(lo, hi, ast::PathListIdent_ { name: ident, + id: ast::DUMMY_NODE_ID }) } // consume token 'tok' if it exists. Returns true if the given @@ -850,8 +851,8 @@ impl Parser { } } - // parse a ty_bare_fun type: - pub fn parse_ty_bare_fn(&mut self) -> ty_ { + // parse a TyBareFn type: + pub fn parse_ty_bare_fn(&mut self) -> Ty_ { /* [extern "ABI"] [unsafe] fn <'lt> (S) -> T @@ -871,7 +872,7 @@ impl Parser { let purity = self.parse_unsafety(); self.expect_keyword(keywords::Fn); let (decl, lifetimes) = self.parse_ty_fn_decl(true); - return ty_bare_fn(@TyBareFn { + return TyBareFn(@BareFnTy { abis: abis, purity: purity, lifetimes: lifetimes, @@ -881,12 +882,12 @@ impl Parser { // Parses a procedure type (`proc`). The initial `proc` keyword must // already have been parsed. - pub fn parse_proc_type(&mut self) -> ty_ { + pub fn parse_proc_type(&mut self) -> Ty_ { let (decl, lifetimes) = self.parse_ty_fn_decl(false); - ty_closure(@TyClosure { + TyClosure(@ClosureTy { sigil: OwnedSigil, region: None, - purity: impure_fn, + purity: ImpureFn, onceness: Once, bounds: None, decl: decl, @@ -894,11 +895,11 @@ impl Parser { }) } - // parse a ty_closure type + // parse a TyClosure type pub fn parse_ty_closure(&mut self, opt_sigil: Option<ast::Sigil>, mut region: Option<ast::Lifetime>) - -> ty_ { + -> Ty_ { /* (&|~|@) ['r] [unsafe] [once] fn [:Bounds] <'lt> (S) -> T @@ -963,7 +964,7 @@ impl Parser { let bounds = self.parse_optional_ty_param_bounds(); let (return_style, output) = self.parse_ret_ty(); - let decl = P(ast::fn_decl { + let decl = P(FnDecl { inputs: inputs, output: output, cf: return_style, @@ -974,7 +975,7 @@ impl Parser { } }; - return ty_closure(@TyClosure { + return TyClosure(@ClosureTy { sigil: sigil, region: region, purity: purity, @@ -993,17 +994,17 @@ impl Parser { } } - pub fn parse_unsafety(&mut self) -> purity { + pub fn parse_unsafety(&mut self) -> Purity { if self.eat_keyword(keywords::Unsafe) { - return unsafe_fn; + return UnsafeFn; } else { - return impure_fn; + return ImpureFn; } } // parse a function type (following the 'fn') pub fn parse_ty_fn_decl(&mut self, allow_variadic: bool) - -> (P<fn_decl>, OptVec<ast::Lifetime>) { + -> (P<FnDecl>, OptVec<ast::Lifetime>) { /* (fn) <'lt> (S) -> T @@ -1024,7 +1025,7 @@ impl Parser { let (inputs, variadic) = self.parse_fn_args(false, allow_variadic); let (ret_style, ret_ty) = self.parse_ret_ty(); - let decl = P(ast::fn_decl { + let decl = P(FnDecl { inputs: inputs, output: ret_ty, cf: ret_style, @@ -1034,7 +1035,7 @@ impl Parser { } // parse the methods in a trait declaration - pub fn parse_trait_methods(&mut self) -> ~[trait_method] { + pub fn parse_trait_methods(&mut self) -> ~[TraitMethod] { self.parse_unspanned_seq( &token::LBRACE, &token::RBRACE, @@ -1065,10 +1066,10 @@ impl Parser { debug!("parse_trait_methods(): parsing required method"); // NB: at the moment, visibility annotations on required // methods are ignored; this could change. - if vis != ast::inherited { + if vis != ast::Inherited { p.obsolete(vis_span, ObsoleteTraitFuncVisibility); } - required(TypeMethod { + Required(TypeMethod { ident: ident, attrs: attrs, purity: pur, @@ -1084,7 +1085,7 @@ impl Parser { let (inner_attrs, body) = p.parse_inner_attrs_and_block(); let attrs = vec::append(attrs, inner_attrs); - provided(@ast::method { + Provided(@ast::Method { ident: ident, attrs: attrs, generics: generics, @@ -1109,10 +1110,10 @@ impl Parser { } // parse a possibly mutable type - pub fn parse_mt(&mut self) -> mt { + pub fn parse_mt(&mut self) -> MutTy { let mutbl = self.parse_mutability(); let t = self.parse_ty(false); - mt { ty: t, mutbl: mutbl } + MutTy { ty: t, mutbl: mutbl } } // parse [mut/const/imm] ID : TY @@ -1126,34 +1127,34 @@ impl Parser { let hi = ty.span.hi; ast::TypeField { ident: id, - mt: ast::mt { ty: ty, mutbl: mutbl }, + mt: MutTy { ty: ty, mutbl: mutbl }, span: mk_sp(lo, hi), } } // parse optional return type [ -> TY ] in function decl - pub fn parse_ret_ty(&mut self) -> (ret_style, P<Ty>) { + pub fn parse_ret_ty(&mut self) -> (RetStyle, P<Ty>) { return if self.eat(&token::RARROW) { let lo = self.span.lo; if self.eat(&token::NOT) { ( - noreturn, + NoReturn, P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_bot, + node: TyBot, span: mk_sp(lo, self.last_span.hi) }) ) } else { - (return_val, self.parse_ty(false)) + (Return, self.parse_ty(false)) } } else { let pos = self.span.lo; ( - return_val, + Return, P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_nil, + node: TyNil, span: mk_sp(pos, pos), }) ) @@ -1164,7 +1165,7 @@ impl Parser { // Useless second parameter for compatibility with quasiquote macros. // Bleh! pub fn parse_ty(&mut self, _: bool) -> P<Ty> { - maybe_whole!(no_clone self, nt_ty); + maybe_whole!(no_clone self, NtTy); let lo = self.span.lo; @@ -1172,7 +1173,7 @@ impl Parser { self.bump(); if self.token == token::RPAREN { self.bump(); - ty_nil + TyNil } else { // (t) is a parenthesized ty // (t,) is the type of a tuple with only one field, @@ -1194,7 +1195,7 @@ impl Parser { return ts[0] } - let t = ty_tup(ts); + let t = TyTup(ts); self.expect(&token::RPAREN); t } @@ -1209,7 +1210,7 @@ impl Parser { } else if self.token == token::BINOP(token::STAR) { // STAR POINTER (bare pointer?) self.bump(); - ty_ptr(self.parse_mt()) + TyPtr(self.parse_mt()) } else if self.token == token::LBRACKET { // VECTOR self.expect(&token::LBRACKET); @@ -1218,8 +1219,8 @@ impl Parser { // Parse the `, ..e` in `[ int, ..e ]` // where `e` is a const expression let t = match self.maybe_parse_fixed_vstore() { - None => ty_vec(t), - Some(suffix) => ty_fixed_length_vec(t, suffix) + None => TyVec(t), + Some(suffix) => TyFixedLengthVec(t, suffix) }; self.expect(&token::RBRACKET); t @@ -1251,7 +1252,7 @@ impl Parser { self.expect(&token::LPAREN); let e = self.parse_expr(); self.expect(&token::RPAREN); - ty_typeof(e) + TyTypeof(e) } else if self.eat_keyword(keywords::Proc) { self.parse_proc_type() } else if self.token == token::MOD_SEP @@ -1261,7 +1262,7 @@ impl Parser { path, bounds } = self.parse_path(LifetimeAndTypesAndBounds); - ty_path(path, bounds, ast::DUMMY_NODE_ID) + TyPath(path, bounds, ast::DUMMY_NODE_ID) } else { let msg = format!("expected type, found token {:?}", self.token); self.fatal(msg); @@ -1274,7 +1275,7 @@ impl Parser { // parse the type following a @ or a ~ pub fn parse_box_or_uniq_pointee(&mut self, sigil: ast::Sigil) - -> ty_ { + -> Ty_ { // ~'foo fn() or ~fn() are parsed directly as obsolete fn types: match self.token { token::LIFETIME(..) => { @@ -1297,13 +1298,13 @@ impl Parser { // rather than boxed ptrs. But the special casing of str/vec is not // reflected in the AST type. if sigil == OwnedSigil { - ty_uniq(self.parse_ty(false)) + TyUniq(self.parse_ty(false)) } else { - ty_box(self.parse_ty(false)) + TyBox(self.parse_ty(false)) } } - pub fn parse_borrowed_pointee(&mut self) -> ty_ { + pub fn parse_borrowed_pointee(&mut self) -> Ty_ { // look for `&'lt` or `&'foo ` and interpret `foo` as the region name: let opt_lifetime = self.parse_opt_lifetime(); @@ -1313,7 +1314,7 @@ impl Parser { } let mt = self.parse_mt(); - return ty_rptr(opt_lifetime, mt); + return TyRptr(opt_lifetime, mt); } pub fn is_named_argument(&mut self) -> bool { @@ -1337,7 +1338,7 @@ impl Parser { // This version of parse arg doesn't necessarily require // identifier names. - pub fn parse_arg_general(&mut self, require_name: bool) -> arg { + pub fn parse_arg_general(&mut self, require_name: bool) -> Arg { let pat = if require_name || self.is_named_argument() { debug!("parse_arg_general parse_pat (require_name:{:?})", require_name); @@ -1354,7 +1355,7 @@ impl Parser { let t = self.parse_ty(false); - ast::arg { + Arg { ty: t, pat: pat, id: ast::DUMMY_NODE_ID, @@ -1362,23 +1363,23 @@ impl Parser { } // parse a single function argument - pub fn parse_arg(&mut self) -> arg { + pub fn parse_arg(&mut self) -> Arg { self.parse_arg_general(true) } // parse an argument in a lambda header e.g. |arg, arg| - pub fn parse_fn_block_arg(&mut self) -> arg { + pub fn parse_fn_block_arg(&mut self) -> Arg { let pat = self.parse_pat(); let t = if self.eat(&token::COLON) { self.parse_ty(false) } else { P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_infer, + node: TyInfer, span: mk_sp(self.span.lo, self.span.hi), }) }; - ast::arg { + Arg { ty: t, pat: pat, id: ast::DUMMY_NODE_ID @@ -1397,29 +1398,29 @@ impl Parser { } // matches token_lit = LIT_INT | ... - pub fn lit_from_token(&mut self, tok: &token::Token) -> lit_ { + pub fn lit_from_token(&mut self, tok: &token::Token) -> Lit_ { match *tok { - token::LIT_CHAR(i) => lit_char(i), - token::LIT_INT(i, it) => lit_int(i, it), - token::LIT_UINT(u, ut) => lit_uint(u, ut), - token::LIT_INT_UNSUFFIXED(i) => lit_int_unsuffixed(i), - token::LIT_FLOAT(s, ft) => lit_float(self.id_to_str(s), ft), + token::LIT_CHAR(i) => LitChar(i), + token::LIT_INT(i, it) => LitInt(i, it), + token::LIT_UINT(u, ut) => LitUint(u, ut), + token::LIT_INT_UNSUFFIXED(i) => LitIntUnsuffixed(i), + token::LIT_FLOAT(s, ft) => LitFloat(self.id_to_str(s), ft), token::LIT_FLOAT_UNSUFFIXED(s) => - lit_float_unsuffixed(self.id_to_str(s)), - token::LIT_STR(s) => lit_str(self.id_to_str(s), ast::CookedStr), - token::LIT_STR_RAW(s, n) => lit_str(self.id_to_str(s), ast::RawStr(n)), - token::LPAREN => { self.expect(&token::RPAREN); lit_nil }, + LitFloatUnsuffixed(self.id_to_str(s)), + token::LIT_STR(s) => LitStr(self.id_to_str(s), ast::CookedStr), + token::LIT_STR_RAW(s, n) => LitStr(self.id_to_str(s), ast::RawStr(n)), + token::LPAREN => { self.expect(&token::RPAREN); LitNil }, _ => { self.unexpected_last(tok); } } } // matches lit = true | false | token_lit - pub fn parse_lit(&mut self) -> lit { + pub fn parse_lit(&mut self) -> Lit { let lo = self.span.lo; let lit = if self.eat_keyword(keywords::True) { - lit_bool(true) + LitBool(true) } else if self.eat_keyword(keywords::False) { - lit_bool(false) + LitBool(false) } else { let token = self.bump_and_get(); let lit = self.lit_from_token(&token); @@ -1454,11 +1455,11 @@ impl Parser { pub fn parse_path(&mut self, mode: PathParsingMode) -> PathAndBounds { // Check for a whole path... let found = match self.token { - INTERPOLATED(token::nt_path(_)) => Some(self.bump_and_get()), + INTERPOLATED(token::NtPath(_)) => Some(self.bump_and_get()), _ => None, }; match found { - Some(INTERPOLATED(token::nt_path(~path))) => { + Some(INTERPOLATED(token::NtPath(~path))) => { return PathAndBounds { path: path, bounds: None, @@ -1709,7 +1710,7 @@ impl Parser { ExprAssignOp(ast::DUMMY_NODE_ID, binop, lhs, rhs) } - pub fn mk_mac_expr(&mut self, lo: BytePos, hi: BytePos, m: mac_) -> @Expr { + pub fn mk_mac_expr(&mut self, lo: BytePos, hi: BytePos, m: Mac_) -> @Expr { @Expr { id: ast::DUMMY_NODE_ID, node: ExprMac(codemap::Spanned {node: m, span: mk_sp(lo, hi)}), @@ -1720,7 +1721,7 @@ impl Parser { pub fn mk_lit_u32(&mut self, i: u32) -> @Expr { let span = &self.span; let lv_lit = @codemap::Spanned { - node: lit_uint(i as u64, ty_u32), + node: LitUint(i as u64, TyU32), span: *span }; @@ -1750,7 +1751,7 @@ impl Parser { if self.token == token::RPAREN { hi = self.span.hi; self.bump(); - let lit = @spanned(lo, hi, lit_nil); + let lit = @spanned(lo, hi, LitNil); return self.mk_expr(lo, hi, ExprLit(lit)); } let mut es = ~[self.parse_expr()]; @@ -1914,7 +1915,7 @@ impl Parser { |p| p.parse_token_tree()); let hi = self.span.hi; - return self.mk_mac_expr(lo, hi, mac_invoc_tt(pth, tts, EMPTY_CTXT)); + return self.mk_mac_expr(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT)); } else if self.token == token::LBRACE { // This might be a struct literal. if self.looking_at_struct_literal() { @@ -2073,21 +2074,21 @@ impl Parser { } // parse a single token tree from the input. - pub fn parse_token_tree(&mut self) -> token_tree { + pub fn parse_token_tree(&mut self) -> TokenTree { // FIXME #6994: currently, this is too eager. It - // parses token trees but also identifies tt_seq's - // and tt_nonterminals; it's too early to know yet + // parses token trees but also identifies TTSeq's + // and TTNonterminal's; it's too early to know yet // whether something will be a nonterminal or a seq // yet. - maybe_whole!(deref self, nt_tt); + maybe_whole!(deref self, NtTT); // this is the fall-through for the 'match' below. // invariants: the current token is not a left-delimiter, // not an EOF, and not the desired right-delimiter (if // it were, parse_seq_to_before_end would have prevented // reaching this point. - fn parse_non_delim_tt_tok(p: &mut Parser) -> token_tree { - maybe_whole!(deref p, nt_tt); + fn parse_non_delim_tt_tok(p: &mut Parser) -> TokenTree { + maybe_whole!(deref p, NtTT); match p.token { token::RPAREN | token::RBRACE | token::RBRACKET => { // This is a conservative error: only report the last unclosed delimiter. The @@ -2117,14 +2118,9 @@ impl Parser { let seq = match seq { Spanned { node, .. } => node, }; - tt_seq( - mk_sp(sp.lo, p.span.hi), - @seq, - s, - z - ) + TTSeq(mk_sp(sp.lo, p.span.hi), @seq, s, z) } else { - tt_nonterminal(sp, p.parse_ident()) + TTNonterminal(sp, p.parse_ident()) } } _ => { @@ -2133,9 +2129,9 @@ impl Parser { } } - // turn the next token into a tt_tok: - fn parse_any_tt_tok(p: &mut Parser) -> token_tree{ - tt_tok(p.span, p.bump_and_get()) + // turn the next token into a TTTok: + fn parse_any_tt_tok(p: &mut Parser) -> TokenTree { + TTTok(p.span, p.bump_and_get()) } match self.token { @@ -2165,15 +2161,15 @@ impl Parser { result.push(parse_any_tt_tok(self)); self.open_braces.pop(); - tt_delim(@result) + TTDelim(@result) } _ => parse_non_delim_tt_tok(self) } } - // parse a stream of tokens into a list of token_trees, + // parse a stream of tokens into a list of TokenTree's, // up to EOF. - pub fn parse_all_token_trees(&mut self) -> ~[token_tree] { + pub fn parse_all_token_trees(&mut self) -> ~[TokenTree] { let mut tts = ~[]; while self.token != token::EOF { tts.push(self.parse_token_tree()); @@ -2181,10 +2177,10 @@ impl Parser { tts } - pub fn parse_matchers(&mut self) -> ~[matcher] { - // unification of matchers and token_trees would vastly improve - // the interpolation of matchers - maybe_whole!(self, nt_matchers); + pub fn parse_matchers(&mut self) -> ~[Matcher] { + // unification of Matcher's and TokenTree's would vastly improve + // the interpolation of Matcher's + maybe_whole!(self, NtMatchers); let name_idx = @Cell::new(0u); match self.token { token::LBRACE | token::LPAREN | token::LBRACKET => { @@ -2196,13 +2192,13 @@ impl Parser { } } - // This goofy function is necessary to correctly match parens in matchers. - // Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be + // This goofy function is necessary to correctly match parens in Matcher's. + // Otherwise, `$( ( )` would be a valid Matcher, and `$( () )` would be // invalid. It's similar to common::parse_seq. pub fn parse_matcher_subseq_upto(&mut self, name_idx: @Cell<uint>, ket: &token::Token) - -> ~[matcher] { + -> ~[Matcher] { let mut ret_val = ~[]; let mut lparens = 0u; @@ -2217,7 +2213,7 @@ impl Parser { return ret_val; } - pub fn parse_matcher(&mut self, name_idx: @Cell<uint>) -> matcher { + pub fn parse_matcher(&mut self, name_idx: @Cell<uint>) -> Matcher { let lo = self.span.lo; let m = if self.token == token::DOLLAR { @@ -2231,17 +2227,17 @@ impl Parser { self.fatal("repetition body must be nonempty"); } let (sep, zerok) = self.parse_sep_and_zerok(); - match_seq(ms, sep, zerok, name_idx_lo, name_idx.get()) + MatchSeq(ms, sep, zerok, name_idx_lo, name_idx.get()) } else { let bound_to = self.parse_ident(); self.expect(&token::COLON); let nt_name = self.parse_ident(); - let m = match_nonterminal(bound_to, nt_name, name_idx.get()); + let m = MatchNonterminal(bound_to, nt_name, name_idx.get()); name_idx.set(name_idx.get() + 1u); m } } else { - match_tok(self.bump_and_get()) + MatchTok(self.bump_and_get()) }; return spanned(lo, self.span.hi, m); @@ -2283,7 +2279,7 @@ impl Parser { // HACK: turn &[...] into a &-evec ex = match e.node { ExprVec(..) | ExprLit(@codemap::Spanned { - node: lit_str(..), span: _ + node: LitStr(..), span: _ }) if m == MutImmutable => { ExprVstore(e, ExprVstoreSlice) @@ -2304,7 +2300,7 @@ impl Parser { // HACK: turn @[...] into a @-evec ex = match e.node { ExprVec(..) | - ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) | + ExprLit(@codemap::Spanned { node: LitStr(..), span: _}) | ExprRepeat(..) => ExprVstore(e, ExprVstoreBox), _ => self.mk_unary(UnBox, e) }; @@ -2317,7 +2313,7 @@ impl Parser { // HACK: turn ~[...] into a ~-evec ex = match e.node { ExprVec(..) | - ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) | + ExprLit(@codemap::Spanned { node: LitStr(..), span: _}) | ExprRepeat(..) => ExprVstore(e, ExprVstoreUniq), _ => self.mk_unary(UnUniq, e) }; @@ -2331,7 +2327,7 @@ impl Parser { ex = match subexpression.node { ExprVec(..) | ExprLit(@codemap::Spanned { - node: lit_str(..), + node: LitStr(..), span: _ }) | ExprRepeat(..) => ExprVstore(subexpression, ExprVstoreUniq), @@ -2459,22 +2455,22 @@ impl Parser { self.parse_lambda_expr_( |p| { match p.token { - token::BINOP(token::OR) | token::OROR => { - p.parse_fn_block_decl() - } - _ => { - // No argument list - `do foo {` - P(ast::fn_decl { - inputs: ~[], - output: P(Ty { - id: ast::DUMMY_NODE_ID, - node: ty_infer, - span: p.span - }), - cf: return_val, - variadic: false - }) - } + token::BINOP(token::OR) | token::OROR => { + p.parse_fn_block_decl() + } + _ => { + // No argument list - `do foo {` + P(FnDecl { + inputs: ~[], + output: P(Ty { + id: ast::DUMMY_NODE_ID, + node: TyInfer, + span: p.span + }), + cf: Return, + variadic: false + }) + } } }, |p| { @@ -2493,7 +2489,7 @@ impl Parser { // this is used both in parsing a lambda expr // and in parsing a block expr as e.g. in for... pub fn parse_lambda_expr_(&mut self, - parse_decl: |&mut Parser| -> P<fn_decl>, + parse_decl: |&mut Parser| -> P<FnDecl>, parse_body: |&mut Parser| -> @Expr) -> @Expr { let lo = self.last_span.lo; @@ -2857,7 +2853,7 @@ impl Parser { // parse a pattern. pub fn parse_pat(&mut self) -> @Pat { - maybe_whole!(self, nt_pat); + maybe_whole!(self, NtPat); let lo = self.span.lo; let mut hi; @@ -2883,7 +2879,7 @@ impl Parser { pat = match sub.node { PatLit(e@@Expr { node: ExprLit(@codemap::Spanned { - node: lit_str(..), + node: LitStr(..), span: _}), .. }) => { let vst = @Expr { @@ -2911,7 +2907,7 @@ impl Parser { pat = match sub.node { PatLit(e@@Expr { node: ExprLit(@codemap::Spanned { - node: lit_str(..), + node: LitStr(..), span: _}), .. }) => { let vst = @Expr { @@ -2939,7 +2935,7 @@ impl Parser { // HACK: parse &"..." as a literal of a borrowed str pat = match sub.node { PatLit(e@@Expr { - node: ExprLit(@codemap::Spanned{ node: lit_str(..), .. }), + node: ExprLit(@codemap::Spanned{ node: LitStr(..), .. }), .. }) => { let vst = @Expr { @@ -2965,7 +2961,7 @@ impl Parser { hi = self.span.hi; self.bump(); let lit = @codemap::Spanned { - node: lit_nil, + node: LitNil, span: mk_sp(lo, hi)}; let expr = self.mk_expr(lo, hi, ExprLit(lit)); pat = PatLit(expr); @@ -3170,7 +3166,7 @@ impl Parser { let mut ty = P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_infer, + node: TyInfer, span: mk_sp(lo, lo), }); if self.eat(&token::COLON) { ty = self.parse_ty(false); } @@ -3196,9 +3192,8 @@ impl Parser { } // parse a structure field - fn parse_name_and_ty(&mut self, - pr: visibility, - attrs: ~[Attribute]) -> struct_field { + fn parse_name_and_ty(&mut self, pr: Visibility, + attrs: ~[Attribute]) -> StructField { let lo = self.span.lo; if !is_plain_ident(&self.token) { self.fatal("expected ident"); @@ -3206,8 +3201,8 @@ impl Parser { let name = self.parse_ident(); self.expect(&token::COLON); let ty = self.parse_ty(false); - spanned(lo, self.last_span.hi, ast::struct_field_ { - kind: named_field(name, pr), + spanned(lo, self.last_span.hi, ast::StructField_ { + kind: NamedField(name, pr), id: ast::DUMMY_NODE_ID, ty: ty, attrs: attrs, @@ -3217,7 +3212,7 @@ impl Parser { // parse a statement. may include decl. // precondition: any attributes are parsed already pub fn parse_stmt(&mut self, item_attrs: ~[Attribute]) -> @Stmt { - maybe_whole!(self, nt_stmt); + maybe_whole!(self, NtStmt); fn check_expected_item(p: &mut Parser, found_attrs: bool) { // If we have attributes then we should have an item @@ -3271,34 +3266,34 @@ impl Parser { if id == token::special_idents::invalid { return @spanned(lo, hi, StmtMac( - spanned(lo, hi, mac_invoc_tt(pth, tts, EMPTY_CTXT)), false)); + spanned(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT)), false)); } else { // if it has a special ident, it's definitely an item return @spanned(lo, hi, StmtDecl( @spanned(lo, hi, DeclItem( self.mk_item( lo, hi, id /*id is good here*/, - item_mac(spanned(lo, hi, mac_invoc_tt(pth, tts, EMPTY_CTXT))), - inherited, ~[/*no attrs*/]))), + ItemMac(spanned(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT))), + Inherited, ~[/*no attrs*/]))), ast::DUMMY_NODE_ID)); } } else { let found_attrs = !item_attrs.is_empty(); match self.parse_item_or_view_item(item_attrs, false) { - iovi_item(i) => { + IoviItem(i) => { let hi = i.span.hi; let decl = @spanned(lo, hi, DeclItem(i)); return @spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID)); } - iovi_view_item(vi) => { + IoviViewItem(vi) => { self.span_fatal(vi.span, "view items must be declared at the top of the block"); } - iovi_foreign_item(_) => { + IoviForeignItem(_) => { self.fatal("foreign items are not allowed here"); } - iovi_none(_) => { /* fallthrough */ } + IoviNone(_) => { /* fallthrough */ } } check_expected_item(self, found_attrs); @@ -3317,7 +3312,7 @@ impl Parser { // parse a block. No inner attrs are allowed. pub fn parse_block(&mut self) -> P<Block> { - maybe_whole!(no_clone self, nt_block); + maybe_whole!(no_clone self, NtBlock); let lo = self.span.lo; if self.eat_keyword(keywords::Unsafe) { @@ -3332,7 +3327,7 @@ impl Parser { fn parse_inner_attrs_and_block(&mut self) -> (~[Attribute], P<Block>) { - maybe_whole!(pair_empty self, nt_block); + maybe_whole!(pair_empty self, NtBlock); let lo = self.span.lo; if self.eat_keyword(keywords::Unsafe) { @@ -3548,9 +3543,9 @@ impl Parser { } fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool) - -> (~[arg], bool) { + -> (~[Arg], bool) { let sp = self.span; - let mut args: ~[Option<arg>] = + let mut args: ~[Option<Arg>] = self.parse_unspanned_seq( &token::LPAREN, &token::RPAREN, @@ -3595,12 +3590,12 @@ impl Parser { } // parse the argument list and result type of a function declaration - pub fn parse_fn_decl(&mut self, allow_variadic: bool) -> P<fn_decl> { + pub fn parse_fn_decl(&mut self, allow_variadic: bool) -> P<FnDecl> { let (args, variadic) = self.parse_fn_args(true, allow_variadic); let (ret_style, ret_ty) = self.parse_ret_ty(); - P(ast::fn_decl { + P(FnDecl { inputs: args, output: ret_ty, cf: ret_style, @@ -3625,12 +3620,12 @@ impl Parser { // parse the argument list and result type of a function // that may have a self type. - fn parse_fn_decl_with_self(&mut self, parse_arg_fn: |&mut Parser| -> arg) - -> (explicit_self, P<fn_decl>) { + fn parse_fn_decl_with_self(&mut self, parse_arg_fn: |&mut Parser| -> Arg) + -> (ExplicitSelf, P<FnDecl>) { fn maybe_parse_explicit_self(cnstr: |v: Mutability| -> - ast::explicit_self_, + ast::ExplicitSelf_, p: &mut Parser) - -> ast::explicit_self_ { + -> ast::ExplicitSelf_ { // We need to make sure it isn't a type if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) || ((p.look_ahead(1, |t| token::is_keyword(keywords::Const, t)) || @@ -3642,12 +3637,12 @@ impl Parser { p.expect_self_ident(); cnstr(mutability) } else { - sty_static + SelfStatic } } fn maybe_parse_borrowed_explicit_self(this: &mut Parser) - -> ast::explicit_self_ { + -> ast::ExplicitSelf_ { // The following things are possible to see here: // // fn(&mut self) @@ -3660,7 +3655,7 @@ impl Parser { if this.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { this.bump(); this.expect_self_ident(); - sty_region(None, MutImmutable) + SelfRegion(None, MutImmutable) } else if this.look_ahead(1, |t| Parser::token_is_mutability(t)) && this.look_ahead(2, |t| token::is_keyword(keywords::Self, @@ -3668,7 +3663,7 @@ impl Parser { this.bump(); let mutability = this.parse_mutability(); this.expect_self_ident(); - sty_region(None, mutability) + SelfRegion(None, mutability) } else if this.look_ahead(1, |t| Parser::token_is_lifetime(t)) && this.look_ahead(2, |t| token::is_keyword(keywords::Self, @@ -3676,7 +3671,7 @@ impl Parser { this.bump(); let lifetime = this.parse_lifetime(); this.expect_self_ident(); - sty_region(Some(lifetime), MutImmutable) + SelfRegion(Some(lifetime), MutImmutable) } else if this.look_ahead(1, |t| Parser::token_is_lifetime(t)) && this.look_ahead(2, |t| { Parser::token_is_mutability(t) @@ -3687,9 +3682,9 @@ impl Parser { let lifetime = this.parse_lifetime(); let mutability = this.parse_mutability(); this.expect_self_ident(); - sty_region(Some(lifetime), mutability) + SelfRegion(Some(lifetime), mutability) } else { - sty_static + SelfStatic } } @@ -3703,7 +3698,7 @@ impl Parser { maybe_parse_borrowed_explicit_self(self) } token::AT => { - maybe_parse_explicit_self(sty_box, self) + maybe_parse_explicit_self(SelfBox, self) } token::TILDE => { maybe_parse_explicit_self(|mutability| { @@ -3711,12 +3706,12 @@ impl Parser { self.span_err(self.last_span, "mutability declaration not allowed here"); } - sty_uniq(MutImmutable) + SelfUniq(MutImmutable) }, self) } token::IDENT(..) if self.is_self_ident() => { self.bump(); - sty_value(MutImmutable) + SelfValue(MutImmutable) } token::BINOP(token::STAR) => { // Possibly "*self" or "*mut self" -- not supported. Try to avoid @@ -3729,13 +3724,13 @@ impl Parser { self.span_err(self.span, "cannot pass self by unsafe pointer"); self.bump(); } - sty_value(mutability) + SelfValue(mutability) } _ if Parser::token_is_mutability(&self.token) && self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => { let mutability = self.parse_mutability(); self.expect_self_ident(); - sty_value(mutability) + SelfValue(mutability) } _ if Parser::token_is_mutability(&self.token) && self.look_ahead(1, |t| *t == token::TILDE) && @@ -3743,16 +3738,16 @@ impl Parser { let mutability = self.parse_mutability(); self.bump(); self.expect_self_ident(); - sty_uniq(mutability) + SelfUniq(mutability) } _ => { - sty_static + SelfStatic } }; // If we parsed a self type, expect a comma before the argument list. let fn_inputs; - if explicit_self != sty_static { + if explicit_self != SelfStatic { match self.token { token::COMMA => { self.bump(); @@ -3785,7 +3780,7 @@ impl Parser { let (ret_style, ret_ty) = self.parse_ret_ty(); - let fn_decl = P(ast::fn_decl { + let fn_decl = P(FnDecl { inputs: fn_inputs, output: ret_ty, cf: ret_style, @@ -3796,7 +3791,7 @@ impl Parser { } // parse the |arg, arg| header on a lambda - fn parse_fn_block_decl(&mut self) -> P<fn_decl> { + fn parse_fn_block_decl(&mut self) -> P<FnDecl> { let inputs_captures = { if self.eat(&token::OROR) { ~[] @@ -3814,21 +3809,21 @@ impl Parser { } else { P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_infer, + node: TyInfer, span: self.span, }) }; - P(ast::fn_decl { + P(FnDecl { inputs: inputs_captures, output: output, - cf: return_val, + cf: Return, variadic: false }) } // Parses the `(arg, arg) -> return_type` header on a procedure. - fn parse_proc_decl(&mut self) -> P<fn_decl> { + fn parse_proc_decl(&mut self) -> P<FnDecl> { let inputs = self.parse_unspanned_seq(&token::LPAREN, &token::RPAREN, @@ -3840,15 +3835,15 @@ impl Parser { } else { P(Ty { id: ast::DUMMY_NODE_ID, - node: ty_infer, + node: TyInfer, span: self.span, }) }; - P(ast::fn_decl { + P(FnDecl { inputs: inputs, output: output, - cf: return_val, + cf: Return, variadic: false }) } @@ -3861,28 +3856,28 @@ impl Parser { } fn mk_item(&mut self, lo: BytePos, hi: BytePos, ident: Ident, - node: item_, vis: visibility, - attrs: ~[Attribute]) -> @item { - @ast::item { ident: ident, - attrs: attrs, - id: ast::DUMMY_NODE_ID, - node: node, - vis: vis, - span: mk_sp(lo, hi) } + node: Item_, vis: Visibility, + attrs: ~[Attribute]) -> @Item { + @Item { + ident: ident, + attrs: attrs, + id: ast::DUMMY_NODE_ID, + node: node, + vis: vis, + span: mk_sp(lo, hi) + } } // parse an item-position function declaration. - fn parse_item_fn(&mut self, purity: purity, abis: AbiSet) -> item_info { + fn parse_item_fn(&mut self, purity: Purity, abis: AbiSet) -> ItemInfo { let (ident, generics) = self.parse_fn_header(); let decl = self.parse_fn_decl(false); let (inner_attrs, body) = self.parse_inner_attrs_and_block(); - (ident, - item_fn(decl, purity, abis, generics, body), - Some(inner_attrs)) + (ident, ItemFn(decl, purity, abis, generics, body), Some(inner_attrs)) } // parse a method in a trait impl, starting with `attrs` attributes. - fn parse_method(&mut self, already_parsed_attrs: Option<~[Attribute]>) -> @method { + fn parse_method(&mut self, already_parsed_attrs: Option<~[Attribute]>) -> @Method { let next_attrs = self.parse_outer_attributes(); let attrs = match already_parsed_attrs { Some(mut a) => { a.push_all_move(next_attrs); a } @@ -3902,7 +3897,7 @@ impl Parser { let (inner_attrs, body) = self.parse_inner_attrs_and_block(); let hi = body.span.hi; let attrs = vec::append(attrs, inner_attrs); - @ast::method { + @ast::Method { ident: ident, attrs: attrs, generics: generics, @@ -3918,7 +3913,7 @@ impl Parser { } // parse trait Foo { ... } - fn parse_item_trait(&mut self) -> item_info { + fn parse_item_trait(&mut self) -> ItemInfo { let ident = self.parse_ident(); let tps = self.parse_generics(); @@ -3932,13 +3927,13 @@ impl Parser { } let meths = self.parse_trait_methods(); - (ident, item_trait(tps, traits, meths), None) + (ident, ItemTrait(tps, traits, meths), None) } // Parses two variants (with the region/type params always optional): // impl<T> Foo { ... } // impl<T> ToStr for ~[T] { ... } - fn parse_item_impl(&mut self) -> item_info { + fn parse_item_impl(&mut self) -> ItemInfo { // First, parse type parameters if necessary. let generics = self.parse_generics(); @@ -3957,13 +3952,13 @@ impl Parser { let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) { // New-style trait. Reinterpret the type as a trait. let opt_trait_ref = match ty.node { - ty_path(ref path, None, node_id) => { - Some(trait_ref { + TyPath(ref path, None, node_id) => { + Some(TraitRef { path: /* bad */ (*path).clone(), ref_id: node_id }) } - ty_path(..) => { + TyPath(..) => { self.span_err(ty.span, "bounded traits are only valid in type position"); None @@ -3995,19 +3990,19 @@ impl Parser { Some(inner_attrs) }; - (ident, item_impl(generics, opt_trait, ty, meths), inner_attrs) + (ident, ItemImpl(generics, opt_trait, ty, meths), inner_attrs) } // parse a::B<~str,int> - fn parse_trait_ref(&mut self) -> trait_ref { - ast::trait_ref { + fn parse_trait_ref(&mut self) -> TraitRef { + ast::TraitRef { path: self.parse_path(LifetimeAndTypesWithoutColons).path, ref_id: ast::DUMMY_NODE_ID, } } // parse B + C<~str,int> + D - fn parse_trait_ref_list(&mut self, ket: &token::Token) -> ~[trait_ref] { + fn parse_trait_ref_list(&mut self, ket: &token::Token) -> ~[TraitRef] { self.parse_seq_to_before_end( ket, seq_sep_trailing_disallowed(token::BINOP(token::PLUS)), @@ -4016,11 +4011,11 @@ impl Parser { } // parse struct Foo { ... } - fn parse_item_struct(&mut self) -> item_info { + fn parse_item_struct(&mut self) -> ItemInfo { let class_name = self.parse_ident(); let generics = self.parse_generics(); - let mut fields: ~[struct_field]; + let mut fields: ~[StructField]; let is_tuple_like; if self.eat(&token::LBRACE) { @@ -4045,8 +4040,8 @@ impl Parser { |p| { let attrs = p.parse_outer_attributes(); let lo = p.span.lo; - let struct_field_ = ast::struct_field_ { - kind: unnamed_field, + let struct_field_ = ast::StructField_ { + kind: UnnamedField, id: ast::DUMMY_NODE_ID, ty: p.parse_ty(false), attrs: attrs, @@ -4068,7 +4063,7 @@ impl Parser { let _ = ast::DUMMY_NODE_ID; // XXX: Workaround for crazy bug. let new_id = ast::DUMMY_NODE_ID; (class_name, - item_struct(@ast::struct_def { + ItemStruct(@ast::StructDef { fields: fields, ctor_id: if is_tuple_like { Some(new_id) } else { None } }, generics), @@ -4077,9 +4072,9 @@ impl Parser { // parse a structure field declaration pub fn parse_single_struct_field(&mut self, - vis: visibility, + vis: Visibility, attrs: ~[Attribute]) - -> struct_field { + -> StructField { let a_var = self.parse_name_and_ty(vis, attrs); match self.token { token::COMMA => { @@ -4097,26 +4092,26 @@ impl Parser { } // parse an element of a struct definition - fn parse_struct_decl_field(&mut self) -> struct_field { + fn parse_struct_decl_field(&mut self) -> StructField { let attrs = self.parse_outer_attributes(); if self.eat_keyword(keywords::Priv) { - return self.parse_single_struct_field(private, attrs); + return self.parse_single_struct_field(Private, attrs); } if self.eat_keyword(keywords::Pub) { - return self.parse_single_struct_field(public, attrs); + return self.parse_single_struct_field(Public, attrs); } - return self.parse_single_struct_field(inherited, attrs); + return self.parse_single_struct_field(Inherited, attrs); } // parse visiility: PUB, PRIV, or nothing - fn parse_visibility(&mut self) -> visibility { - if self.eat_keyword(keywords::Pub) { public } - else if self.eat_keyword(keywords::Priv) { private } - else { inherited } + fn parse_visibility(&mut self) -> Visibility { + if self.eat_keyword(keywords::Pub) { Public } + else if self.eat_keyword(keywords::Priv) { Private } + else { Inherited } } // given a termination token and a vector of already-parsed @@ -4124,7 +4119,7 @@ impl Parser { fn parse_mod_items(&mut self, term: token::Token, first_item_attrs: ~[Attribute]) - -> _mod { + -> Mod { // parse all of the items up to closing or an attribute. // view items are legal here. let ParsedItemsAndViewItems { @@ -4133,7 +4128,7 @@ impl Parser { items: starting_items, .. } = self.parse_items_and_view_items(first_item_attrs, true, true); - let mut items: ~[@item] = starting_items; + let mut items: ~[@Item] = starting_items; let attrs_remaining_len = attrs_remaining.len(); // don't think this other loop is even necessary.... @@ -4149,8 +4144,8 @@ impl Parser { attrs); match self.parse_item_or_view_item(attrs, true /* macros allowed */) { - iovi_item(item) => items.push(item), - iovi_view_item(view_item) => { + IoviItem(item) => items.push(item), + IoviViewItem(view_item) => { self.span_fatal(view_item.span, "view items must be declared at the top of \ the module"); @@ -4168,10 +4163,10 @@ impl Parser { self.span_err(self.last_span, "expected item after attributes"); } - ast::_mod { view_items: view_items, items: items } + ast::Mod { view_items: view_items, items: items } } - fn parse_item_const(&mut self) -> item_info { + fn parse_item_const(&mut self) -> ItemInfo { let m = if self.eat_keyword(keywords::Mut) {MutMutable} else {MutImmutable}; let id = self.parse_ident(); self.expect(&token::COLON); @@ -4179,11 +4174,11 @@ impl Parser { self.expect(&token::EQ); let e = self.parse_expr(); self.commit_expr_expecting(e, token::SEMI); - (id, item_static(ty, m, e), None) + (id, ItemStatic(ty, m, e), None) } // parse a `mod <foo> { ... }` or `mod <foo>;` item - fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> item_info { + fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> ItemInfo { let id_span = self.span; let id = self.parse_ident(); if self.token == token::SEMI { @@ -4198,7 +4193,7 @@ impl Parser { let m = self.parse_mod_items(token::RBRACE, next); self.expect(&token::RBRACE); self.pop_mod_path(); - (id, item_mod(m), Some(inner)) + (id, ItemMod(m), Some(inner)) } } @@ -4221,7 +4216,7 @@ impl Parser { id: ast::Ident, outer_attrs: &[ast::Attribute], id_sp: Span) - -> (ast::item_, ~[ast::Attribute]) { + -> (ast::Item_, ~[ast::Attribute]) { let mut prefix = Path::new(self.sess.cm.span_to_filename(self.span)); prefix.pop(); let mod_path = Path::new(".").join_many(self.mod_path_stack); @@ -4260,7 +4255,7 @@ impl Parser { fn eval_src_mod_from_path(&mut self, path: Path, outer_attrs: ~[ast::Attribute], - id_sp: Span) -> (ast::item_, ~[ast::Attribute]) { + id_sp: Span) -> (ast::Item_, ~[ast::Attribute]) { { let mut included_mod_stack = self.sess .included_mod_stack @@ -4299,17 +4294,17 @@ impl Parser { .borrow_mut(); included_mod_stack.get().pop(); } - return (ast::item_mod(m0), mod_attrs); + return (ast::ItemMod(m0), mod_attrs); } // parse a function declaration from a foreign module - fn parse_item_foreign_fn(&mut self, vis: ast::visibility, - attrs: ~[Attribute]) -> @foreign_item { + fn parse_item_foreign_fn(&mut self, vis: ast::Visibility, + attrs: ~[Attribute]) -> @ForeignItem { let lo = self.span.lo; // Parse obsolete purity. let purity = self.parse_fn_purity(); - if purity != impure_fn { + if purity != ImpureFn { self.obsolete(self.last_span, ObsoleteUnsafeExternFn); } @@ -4317,17 +4312,17 @@ impl Parser { let decl = self.parse_fn_decl(true); let hi = self.span.hi; self.expect(&token::SEMI); - @ast::foreign_item { ident: ident, - attrs: attrs, - node: foreign_item_fn(decl, generics), - id: ast::DUMMY_NODE_ID, - span: mk_sp(lo, hi), - vis: vis } + @ast::ForeignItem { ident: ident, + attrs: attrs, + node: ForeignItemFn(decl, generics), + id: ast::DUMMY_NODE_ID, + span: mk_sp(lo, hi), + vis: vis } } // parse a static item from a foreign module - fn parse_item_foreign_static(&mut self, vis: ast::visibility, - attrs: ~[Attribute]) -> @foreign_item { + fn parse_item_foreign_static(&mut self, vis: ast::Visibility, + attrs: ~[Attribute]) -> @ForeignItem { let lo = self.span.lo; self.expect_keyword(keywords::Static); @@ -4338,20 +4333,20 @@ impl Parser { let ty = self.parse_ty(false); let hi = self.span.hi; self.expect(&token::SEMI); - @ast::foreign_item { ident: ident, - attrs: attrs, - node: foreign_item_static(ty, mutbl), - id: ast::DUMMY_NODE_ID, - span: mk_sp(lo, hi), - vis: vis } + @ast::ForeignItem { ident: ident, + attrs: attrs, + node: ForeignItemStatic(ty, mutbl), + id: ast::DUMMY_NODE_ID, + span: mk_sp(lo, hi), + vis: vis } } // parse safe/unsafe and fn - fn parse_fn_purity(&mut self) -> purity { - if self.eat_keyword(keywords::Fn) { impure_fn } + fn parse_fn_purity(&mut self) -> Purity { + if self.eat_keyword(keywords::Fn) { ImpureFn } else if self.eat_keyword(keywords::Unsafe) { self.expect_keyword(keywords::Fn); - unsafe_fn + UnsafeFn } else { self.unexpected(); } } @@ -4362,7 +4357,7 @@ impl Parser { fn parse_foreign_mod_items(&mut self, abis: AbiSet, first_item_attrs: ~[Attribute]) - -> foreign_mod { + -> ForeignMod { let ParsedItemsAndViewItems { attrs_remaining: attrs_remaining, view_items: view_items, @@ -4374,7 +4369,7 @@ impl Parser { "expected item after attributes"); } assert!(self.token == token::RBRACE); - ast::foreign_mod { + ast::ForeignMod { abis: abis, view_items: view_items, items: foreign_items @@ -4385,10 +4380,10 @@ impl Parser { fn parse_item_foreign_mod(&mut self, lo: BytePos, opt_abis: Option<AbiSet>, - visibility: visibility, + visibility: Visibility, attrs: ~[Attribute], items_allowed: bool) - -> item_or_view_item { + -> ItemOrViewItem { let mut must_be_named_mod = false; if self.is_keyword(keywords::Mod) { must_be_named_mod = true; @@ -4440,10 +4435,10 @@ impl Parser { let item = self.mk_item(lo, self.last_span.hi, ident, - item_foreign_mod(m), + ItemForeignMod(m), visibility, maybe_append(attrs, Some(inner))); - return iovi_item(item); + return IoviItem(item); } if opt_abis.is_some() { @@ -4460,8 +4455,8 @@ impl Parser { } // extern mod foo; self.expect(&token::SEMI); - iovi_view_item(ast::view_item { - node: view_item_extern_mod(ident, maybe_path, ast::DUMMY_NODE_ID), + IoviViewItem(ast::ViewItem { + node: ViewItemExternMod(ident, maybe_path, ast::DUMMY_NODE_ID), attrs: attrs, vis: visibility, span: mk_sp(lo, self.last_span.hi) @@ -4469,32 +4464,32 @@ impl Parser { } // parse type Foo = Bar; - fn parse_item_type(&mut self) -> item_info { + fn parse_item_type(&mut self) -> ItemInfo { let ident = self.parse_ident(); let tps = self.parse_generics(); self.expect(&token::EQ); let ty = self.parse_ty(false); self.expect(&token::SEMI); - (ident, item_ty(ty, tps), None) + (ident, ItemTy(ty, tps), None) } // parse a structure-like enum variant definition // this should probably be renamed or refactored... - fn parse_struct_def(&mut self) -> @struct_def { - let mut fields: ~[struct_field] = ~[]; + fn parse_struct_def(&mut self) -> @StructDef { + let mut fields: ~[StructField] = ~[]; while self.token != token::RBRACE { fields.push(self.parse_struct_decl_field()); } self.bump(); - return @ast::struct_def { + return @ast::StructDef { fields: fields, ctor_id: None }; } // parse the part of an "enum" decl following the '{' - fn parse_enum_def(&mut self, _generics: &ast::Generics) -> enum_def { + fn parse_enum_def(&mut self, _generics: &ast::Generics) -> EnumDef { let mut variants = ~[]; let mut all_nullary = true; let mut have_disr = false; @@ -4512,7 +4507,7 @@ impl Parser { if self.eat(&token::LBRACE) { // Parse a struct variant. all_nullary = false; - kind = struct_variant_kind(self.parse_struct_def()); + kind = StructVariantKind(self.parse_struct_def()); } else if self.token == token::LPAREN { all_nullary = false; let arg_tys = self.parse_unspanned_seq( @@ -4522,21 +4517,21 @@ impl Parser { |p| p.parse_ty(false) ); for ty in arg_tys.move_iter() { - args.push(ast::variant_arg { + args.push(ast::VariantArg { ty: ty, id: ast::DUMMY_NODE_ID, }); } - kind = tuple_variant_kind(args); + kind = TupleVariantKind(args); } else if self.eat(&token::EQ) { have_disr = true; disr_expr = Some(self.parse_expr()); - kind = tuple_variant_kind(args); + kind = TupleVariantKind(args); } else { - kind = tuple_variant_kind(~[]); + kind = TupleVariantKind(~[]); } - let vr = ast::variant_ { + let vr = ast::Variant_ { name: ident, attrs: variant_attrs, kind: kind, @@ -4554,17 +4549,17 @@ impl Parser { enum"); } - ast::enum_def { variants: variants } + ast::EnumDef { variants: variants } } // parse an "enum" declaration - fn parse_item_enum(&mut self) -> item_info { + fn parse_item_enum(&mut self) -> ItemInfo { let id = self.parse_ident(); let generics = self.parse_generics(); self.expect(&token::LBRACE); let enum_definition = self.parse_enum_def(&generics); - (id, item_enum(enum_definition, generics), None) + (id, ItemEnum(enum_definition, generics), None) } fn fn_expr_lookahead(tok: &token::Token) -> bool { @@ -4621,20 +4616,21 @@ impl Parser { } // parse one of the items or view items allowed by the - // flags; on failure, return iovi_none. + // flags; on failure, return IoviNone. // NB: this function no longer parses the items inside an // extern mod. fn parse_item_or_view_item(&mut self, attrs: ~[Attribute], macros_allowed: bool) - -> item_or_view_item { + -> ItemOrViewItem { match self.token { - INTERPOLATED(token::nt_item(item)) => { + INTERPOLATED(token::NtItem(item)) => { self.bump(); let new_attrs = vec::append(attrs, item.attrs); - return iovi_item(@ast::item { - attrs: new_attrs, - ..(*item).clone()}); + return IoviItem(@Item { + attrs: new_attrs, + ..(*item).clone() + }); } _ => {} } @@ -4645,10 +4641,10 @@ impl Parser { // must be a view item: if self.eat_keyword(keywords::Use) { - // USE ITEM (iovi_view_item) + // USE ITEM (IoviViewItem) let view_item = self.parse_use(); self.expect(&token::SEMI); - return iovi_view_item(ast::view_item { + return IoviViewItem(ast::ViewItem { node: view_item, attrs: attrs, vis: visibility, @@ -4663,16 +4659,16 @@ impl Parser { // EXTERN FUNCTION ITEM let abis = opt_abis.unwrap_or(AbiSet::C()); let (ident, item_, extra_attrs) = - self.parse_item_fn(extern_fn, abis); + self.parse_item_fn(ExternFn, abis); let item = self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } else { - // EXTERN MODULE ITEM (iovi_view_item) + // EXTERN MODULE ITEM (IoviViewItem) return self.parse_item_foreign_mod(lo, opt_abis, visibility, attrs, true); } @@ -4688,21 +4684,21 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.is_keyword(keywords::Fn) && self.look_ahead(1, |f| !Parser::fn_expr_lookahead(f)) { // FUNCTION ITEM self.bump(); let (ident, item_, extra_attrs) = - self.parse_item_fn(impure_fn, AbiSet::Rust()); + self.parse_item_fn(ImpureFn, AbiSet::Rust()); let item = self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.is_keyword(keywords::Unsafe) && self.look_ahead(1u, |t| *t != token::LBRACE) { @@ -4710,14 +4706,14 @@ impl Parser { self.bump(); self.expect_keyword(keywords::Fn); let (ident, item_, extra_attrs) = - self.parse_item_fn(unsafe_fn, AbiSet::Rust()); + self.parse_item_fn(UnsafeFn, AbiSet::Rust()); let item = self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Mod) { // MODULE ITEM @@ -4728,7 +4724,7 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Type) { // TYPE ITEM @@ -4739,7 +4735,7 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Enum) { // ENUM ITEM @@ -4750,7 +4746,7 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Trait) { // TRAIT ITEM @@ -4761,7 +4757,7 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Impl) { // IMPL ITEM @@ -4772,7 +4768,7 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } if self.eat_keyword(keywords::Struct) { // STRUCT ITEM @@ -4783,17 +4779,17 @@ impl Parser { item_, visibility, maybe_append(attrs, extra_attrs)); - return iovi_item(item); + return IoviItem(item); } self.parse_macro_use_or_failure(attrs,macros_allowed,lo,visibility) } - // parse a foreign item; on failure, return iovi_none. + // parse a foreign item; on failure, return IoviNone. fn parse_foreign_item(&mut self, attrs: ~[Attribute], macros_allowed: bool) - -> item_or_view_item { - maybe_whole!(iovi self, nt_item); + -> ItemOrViewItem { + maybe_whole!(iovi self, NtItem); let lo = self.span.lo; let visibility = self.parse_visibility(); @@ -4801,12 +4797,12 @@ impl Parser { if self.is_keyword(keywords::Static) { // FOREIGN STATIC ITEM let item = self.parse_item_foreign_static(visibility, attrs); - return iovi_foreign_item(item); + return IoviForeignItem(item); } if self.is_keyword(keywords::Fn) || self.is_keyword(keywords::Unsafe) { // FOREIGN FUNCTION ITEM let item = self.parse_item_foreign_fn(visibility, attrs); - return iovi_foreign_item(item); + return IoviForeignItem(item); } self.parse_macro_use_or_failure(attrs,macros_allowed,lo,visibility) } @@ -4816,9 +4812,9 @@ impl Parser { &mut self, attrs: ~[Attribute], macros_allowed: bool, - lo : BytePos, - visibility : visibility - ) -> item_or_view_item { + lo: BytePos, + visibility: Visibility + ) -> ItemOrViewItem { if macros_allowed && !token::is_any_keyword(&self.token) && self.look_ahead(1, |t| *t == token::NOT) && (self.look_ahead(2, |t| is_plain_ident(t)) @@ -4850,24 +4846,24 @@ impl Parser { _ => self.fatal("expected open delimiter") }; // single-variant-enum... : - let m = ast::mac_invoc_tt(pth, tts, EMPTY_CTXT); - let m: ast::mac = codemap::Spanned { node: m, + let m = ast::MacInvocTT(pth, tts, EMPTY_CTXT); + let m: ast::Mac = codemap::Spanned { node: m, span: mk_sp(self.span.lo, self.span.hi) }; - let item_ = item_mac(m); + let item_ = ItemMac(m); let item = self.mk_item(lo, self.last_span.hi, id, item_, visibility, attrs); - return iovi_item(item); + return IoviItem(item); } // FAILURE TO PARSE ITEM - if visibility != inherited { + if visibility != Inherited { let mut s = ~"unmatched visibility `"; - if visibility == public { + if visibility == Public { s.push_str("pub") } else { s.push_str("priv") @@ -4875,23 +4871,23 @@ impl Parser { s.push_char('`'); self.span_fatal(self.last_span, s); } - return iovi_none(attrs); + return IoviNone(attrs); } - pub fn parse_item(&mut self, attrs: ~[Attribute]) -> Option<@ast::item> { + pub fn parse_item(&mut self, attrs: ~[Attribute]) -> Option<@Item> { match self.parse_item_or_view_item(attrs, true) { - iovi_none(_) => None, - iovi_view_item(_) => + IoviNone(_) => None, + IoviViewItem(_) => self.fatal("view items are not allowed here"), - iovi_foreign_item(_) => + IoviForeignItem(_) => self.fatal("foreign items are not allowed here"), - iovi_item(item) => Some(item) + IoviItem(item) => Some(item) } } // parse, e.g., "use a::b::{z,y}" - fn parse_use(&mut self) -> view_item_ { - return view_item_use(self.parse_view_paths()); + fn parse_use(&mut self) -> ViewItem_ { + return ViewItemUse(self.parse_view_paths()); } @@ -4900,7 +4896,7 @@ impl Parser { // | MOD? non_global_path MOD_SEP LBRACE ident_seq RBRACE // | MOD? non_global_path MOD_SEP STAR // | MOD? non_global_path - fn parse_view_path(&mut self) -> @view_path { + fn parse_view_path(&mut self) -> @ViewPath { let lo = self.span.lo; if self.token == token::LBRACE { @@ -4915,12 +4911,12 @@ impl Parser { segments: ~[] }; return @spanned(lo, self.span.hi, - view_path_list(path, idents, ast::DUMMY_NODE_ID)); + ViewPathList(path, idents, ast::DUMMY_NODE_ID)); } let first_ident = self.parse_ident(); let mut path = ~[first_ident]; - debug!("parsed view_path: {}", self.id_to_str(first_ident)); + debug!("parsed view path: {}", self.id_to_str(first_ident)); match self.token { token::EQ => { // x = foo::bar @@ -4944,9 +4940,8 @@ impl Parser { }).collect() }; return @spanned(lo, self.span.hi, - view_path_simple(first_ident, - path, - ast::DUMMY_NODE_ID)); + ViewPathSimple(first_ident, path, + ast::DUMMY_NODE_ID)); } token::MOD_SEP => { @@ -4980,7 +4975,7 @@ impl Parser { }).collect() }; return @spanned(lo, self.span.hi, - view_path_list(path, idents, ast::DUMMY_NODE_ID)); + ViewPathList(path, idents, ast::DUMMY_NODE_ID)); } // foo::bar::* @@ -4998,7 +4993,7 @@ impl Parser { }).collect() }; return @spanned(lo, self.span.hi, - view_path_glob(path, ast::DUMMY_NODE_ID)); + ViewPathGlob(path, ast::DUMMY_NODE_ID)); } _ => break @@ -5021,11 +5016,11 @@ impl Parser { }; return @spanned(lo, self.last_span.hi, - view_path_simple(last, path, ast::DUMMY_NODE_ID)); + ViewPathSimple(last, path, ast::DUMMY_NODE_ID)); } // matches view_paths = view_path | view_path , view_paths - fn parse_view_paths(&mut self) -> ~[@view_path] { + fn parse_view_paths(&mut self) -> ~[@ViewPath] { let mut vp = ~[self.parse_view_path()]; while self.token == token::COMMA { self.bump(); @@ -5047,7 +5042,7 @@ impl Parser { let mut attrs = vec::append(first_item_attrs, self.parse_outer_attributes()); // First, parse view items. - let mut view_items : ~[ast::view_item] = ~[]; + let mut view_items : ~[ast::ViewItem] = ~[]; let mut items = ~[]; // I think this code would probably read better as a single @@ -5056,7 +5051,7 @@ impl Parser { // of macros, I'd like to delay that entire check until later. loop { match self.parse_item_or_view_item(attrs, macros_allowed) { - iovi_none(attrs) => { + IoviNone(attrs) => { return ParsedItemsAndViewItems { attrs_remaining: attrs, view_items: view_items, @@ -5064,27 +5059,26 @@ impl Parser { foreign_items: ~[] } } - iovi_view_item(view_item) => { + IoviViewItem(view_item) => { match view_item.node { - view_item_use(..) => { + ViewItemUse(..) => { // `extern mod` must precede `use`. extern_mod_allowed = false; } - view_item_extern_mod(..) - if !extern_mod_allowed => { + ViewItemExternMod(..) if !extern_mod_allowed => { self.span_err(view_item.span, "\"extern mod\" declarations are not allowed here"); } - view_item_extern_mod(..) => {} + ViewItemExternMod(..) => {} } view_items.push(view_item); } - iovi_item(item) => { + IoviItem(item) => { items.push(item); attrs = self.parse_outer_attributes(); break; } - iovi_foreign_item(_) => { + IoviForeignItem(_) => { fail!(); } } @@ -5094,20 +5088,20 @@ impl Parser { // Next, parse items. loop { match self.parse_item_or_view_item(attrs, macros_allowed) { - iovi_none(returned_attrs) => { + IoviNone(returned_attrs) => { attrs = returned_attrs; break } - iovi_view_item(view_item) => { + IoviViewItem(view_item) => { attrs = self.parse_outer_attributes(); self.span_err(view_item.span, "`use` and `extern mod` declarations must precede items"); } - iovi_item(item) => { + IoviItem(item) => { attrs = self.parse_outer_attributes(); items.push(item) } - iovi_foreign_item(_) => { + IoviForeignItem(_) => { fail!(); } } @@ -5131,23 +5125,23 @@ impl Parser { let mut foreign_items = ~[]; loop { match self.parse_foreign_item(attrs, macros_allowed) { - iovi_none(returned_attrs) => { + IoviNone(returned_attrs) => { if self.token == token::RBRACE { attrs = returned_attrs; break } self.unexpected(); }, - iovi_view_item(view_item) => { + IoviViewItem(view_item) => { // I think this can't occur: self.span_err(view_item.span, "`use` and `extern mod` declarations must precede items"); } - iovi_item(item) => { + IoviItem(item) => { // FIXME #5668: this will occur for a macro invocation: self.span_fatal(item.span, "macros cannot expand to foreign items"); } - iovi_foreign_item(foreign_item) => { + IoviForeignItem(foreign_item) => { foreign_items.push(foreign_item); } } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 9e1eec19b2c..42313e64283 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -19,8 +19,9 @@ use std::cast; use std::char; use std::local_data; +#[allow(non_camel_case_types)] #[deriving(Clone, Encodable, Decodable, Eq, IterBytes)] -pub enum binop { +pub enum BinOp { PLUS, MINUS, STAR, @@ -33,6 +34,7 @@ pub enum binop { SHR, } +#[allow(non_camel_case_types)] #[deriving(Clone, Encodable, Decodable, Eq, IterBytes)] pub enum Token { /* Expression-operator symbols. */ @@ -47,8 +49,8 @@ pub enum Token { OROR, NOT, TILDE, - BINOP(binop), - BINOPEQ(binop), + BINOP(BinOp), + BINOPEQ(BinOp), /* Structural symbols */ AT, @@ -74,10 +76,10 @@ pub enum Token { /* Literals */ LIT_CHAR(u32), - LIT_INT(i64, ast::int_ty), - LIT_UINT(u64, ast::uint_ty), + LIT_INT(i64, ast::IntTy), + LIT_UINT(u64, ast::UintTy), LIT_INT_UNSUFFIXED(i64), - LIT_FLOAT(ast::Ident, ast::float_ty), + LIT_FLOAT(ast::Ident, ast::FloatTy), LIT_FLOAT_UNSUFFIXED(ast::Ident), LIT_STR(ast::Ident), LIT_STR_RAW(ast::Ident, uint), /* raw str delimited by n hash symbols */ @@ -91,7 +93,7 @@ pub enum Token { LIFETIME(ast::Ident), /* For interpolation */ - INTERPOLATED(nonterminal), + INTERPOLATED(Nonterminal), DOC_COMMENT(ast::Ident), EOF, @@ -99,21 +101,21 @@ pub enum Token { #[deriving(Clone, Encodable, Decodable, Eq, IterBytes)] /// For interpolation during macro expansion. -pub enum nonterminal { - nt_item(@ast::item), - nt_block(P<ast::Block>), - nt_stmt(@ast::Stmt), - nt_pat( @ast::Pat), - nt_expr(@ast::Expr), - nt_ty( P<ast::Ty>), - nt_ident(~ast::Ident, bool), - nt_attr(@ast::Attribute), // #[foo] - nt_path(~ast::Path), - nt_tt( @ast::token_tree), //needs @ed to break a circularity - nt_matchers(~[ast::matcher]) -} - -pub fn binop_to_str(o: binop) -> ~str { +pub enum Nonterminal { + NtItem(@ast::Item), + NtBlock(P<ast::Block>), + NtStmt(@ast::Stmt), + NtPat( @ast::Pat), + NtExpr(@ast::Expr), + NtTy( P<ast::Ty>), + NtIdent(~ast::Ident, bool), + NtAttr(@ast::Attribute), // #[foo] + NtPath(~ast::Path), + NtTT( @ast::TokenTree), // needs @ed to break a circularity + NtMatchers(~[ast::Matcher]) +} + +pub fn binop_to_str(o: BinOp) -> ~str { match o { PLUS => ~"+", MINUS => ~"-", @@ -128,7 +130,7 @@ pub fn binop_to_str(o: binop) -> ~str { } } -pub fn to_str(input: @ident_interner, t: &Token) -> ~str { +pub fn to_str(input: @IdentInterner, t: &Token) -> ~str { match *t { EQ => ~"=", LT => ~"<", @@ -212,22 +214,22 @@ pub fn to_str(input: @ident_interner, t: &Token) -> ~str { EOF => ~"<eof>", INTERPOLATED(ref nt) => { match nt { - &nt_expr(e) => ::print::pprust::expr_to_str(e, input), - &nt_attr(e) => ::print::pprust::attribute_to_str(e, input), + &NtExpr(e) => ::print::pprust::expr_to_str(e, input), + &NtAttr(e) => ::print::pprust::attribute_to_str(e, input), _ => { ~"an interpolated " + match (*nt) { - nt_item(..) => ~"item", - nt_block(..) => ~"block", - nt_stmt(..) => ~"statement", - nt_pat(..) => ~"pattern", - nt_attr(..) => fail!("should have been handled"), - nt_expr(..) => fail!("should have been handled above"), - nt_ty(..) => ~"type", - nt_ident(..) => ~"identifier", - nt_path(..) => ~"path", - nt_tt(..) => ~"tt", - nt_matchers(..) => ~"matcher sequence" + NtItem(..) => ~"item", + NtBlock(..) => ~"block", + NtStmt(..) => ~"statement", + NtPat(..) => ~"pattern", + NtAttr(..) => fail!("should have been handled"), + NtExpr(..) => fail!("should have been handled above"), + NtTy(..) => ~"type", + NtIdent(..) => ~"identifier", + NtPath(..) => ~"path", + NtTT(..) => ~"tt", + NtMatchers(..) => ~"matcher sequence" } } } @@ -260,10 +262,10 @@ pub fn can_begin_expr(t: &Token) -> bool { BINOP(OR) => true, // in lambda syntax OROR => true, // in lambda syntax MOD_SEP => true, - INTERPOLATED(nt_expr(..)) - | INTERPOLATED(nt_ident(..)) - | INTERPOLATED(nt_block(..)) - | INTERPOLATED(nt_path(..)) => true, + INTERPOLATED(NtExpr(..)) + | INTERPOLATED(NtIdent(..)) + | INTERPOLATED(NtBlock(..)) + | INTERPOLATED(NtPath(..)) => true, _ => false } } @@ -303,7 +305,7 @@ pub fn is_ident(t: &Token) -> bool { pub fn is_ident_or_path(t: &Token) -> bool { match *t { - IDENT(_, _) | INTERPOLATED(nt_path(..)) => true, + IDENT(_, _) | INTERPOLATED(NtPath(..)) => true, _ => false } } @@ -381,7 +383,7 @@ macro_rules! declare_special_idents_and_keywords {( } } - fn mk_fresh_ident_interner() -> @ident_interner { + fn mk_fresh_ident_interner() -> @IdentInterner { // The indices here must correspond to the numbers in // special_idents, in Keyword to_ident(), and in static // constants below. @@ -508,12 +510,12 @@ pub fn token_to_binop(tok: &Token) -> Option<ast::BinOp> { } // looks like we can get rid of this completely... -pub type ident_interner = StrInterner; +pub type IdentInterner = StrInterner; // if an interner exists in TLS, return it. Otherwise, prepare a // fresh one. -pub fn get_ident_interner() -> @ident_interner { - local_data_key!(key: @@::parse::token::ident_interner) +pub fn get_ident_interner() -> @IdentInterner { + local_data_key!(key: @@::parse::token::IdentInterner) match local_data::get(key, |k| k.map(|k| *k)) { Some(interner) => *interner, None => { @@ -526,7 +528,7 @@ pub fn get_ident_interner() -> @ident_interner { /* for when we don't care about the contents; doesn't interact with TLD or serialization */ -pub fn mk_fake_ident_interner() -> @ident_interner { +pub fn mk_fake_ident_interner() -> @IdentInterner { @interner::StrInterner::new() } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index a6239ab3806..c421c2f4d7a 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -41,12 +41,12 @@ * the Mesa implementation (somewhat randomly) stores the offset on the print * stack in terms of margin-col rather than col itself. I store col. * - * I also implemented a small change in the STRING token, in that I store an + * I also implemented a small change in the String token, in that I store an * explicit length for the string. For most tokens this is just the length of * the accompanying string. But it's necessary to permit it to differ, for * encoding things that are supposed to "go on their own line" -- certain * classes of comment and blank-line -- where relying on adjacent - * hardbreak-like BREAK tokens with long blankness indication doesn't actually + * hardbreak-like Break tokens with long blankness indication doesn't actually * work. To see why, consider when there is a "thing that should be on its own * line" between two long blocks, say functions. If you put a hardbreak after * each function (or before each) and the breaking algorithm decides to break @@ -65,43 +65,43 @@ use std::io; use std::vec; #[deriving(Clone, Eq)] -pub enum breaks { - consistent, - inconsistent, +pub enum Breaks { + Consistent, + Inconsistent, } #[deriving(Clone)] -pub struct break_t { +pub struct BreakToken { offset: int, blank_space: int } #[deriving(Clone)] -pub struct begin_t { +pub struct BeginToken { offset: int, - breaks: breaks + breaks: Breaks } #[deriving(Clone)] -pub enum token { - STRING(@str, int), - BREAK(break_t), - BEGIN(begin_t), - END, - EOF, +pub enum Token { + String(@str, int), + Break(BreakToken), + Begin(BeginToken), + End, + Eof, } -impl token { +impl Token { pub fn is_eof(&self) -> bool { - match *self { EOF => true, _ => false } + match *self { Eof => true, _ => false } } pub fn is_hardbreak_tok(&self) -> bool { match *self { - BREAK(break_t { + Break(BreakToken { offset: 0, blank_space: bs - }) if bs == size_infinity => + }) if bs == SIZE_INFINITY => true, _ => false @@ -109,17 +109,17 @@ impl token { } } -pub fn tok_str(t: token) -> ~str { +pub fn tok_str(t: Token) -> ~str { match t { - STRING(s, len) => return format!("STR({},{})", s, len), - BREAK(_) => return ~"BREAK", - BEGIN(_) => return ~"BEGIN", - END => return ~"END", - EOF => return ~"EOF" + String(s, len) => return format!("STR({},{})", s, len), + Break(_) => return ~"BREAK", + Begin(_) => return ~"BEGIN", + End => return ~"END", + Eof => return ~"EOF" } } -pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint, +pub fn buf_str(toks: ~[Token], szs: ~[int], left: uint, right: uint, lim: uint) -> ~str { let n = toks.len(); assert_eq!(n, szs.len()); @@ -139,21 +139,24 @@ pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint, return s; } -pub enum print_stack_break { fits, broken(breaks), } +enum PrintStackBreak { + Fits, + Broken(Breaks), +} -pub struct print_stack_elt { +struct PrintStackElem { offset: int, - pbreak: print_stack_break + pbreak: PrintStackBreak } -pub static size_infinity: int = 0xffff; +static SIZE_INFINITY: int = 0xffff; pub fn mk_printer(out: ~io::Writer, linewidth: uint) -> Printer { // Yes 3, it makes the ring buffers big enough to never // fall behind. let n: uint = 3 * linewidth; debug!("mk_printer {}", linewidth); - let token: ~[token] = vec::from_elem(n, EOF); + let token: ~[Token] = vec::from_elem(n, Eof); let size: ~[int] = vec::from_elem(n, 0); let scan_stack: ~[uint] = vec::from_elem(n, 0u); Printer { @@ -187,9 +190,9 @@ pub fn mk_printer(out: ~io::Writer, linewidth: uint) -> Printer { * Yes, linewidth is chars and tokens are multi-char, but in the worst * case every token worth buffering is 1 char long, so it's ok. * - * Tokens are STRING, BREAK, and BEGIN/END to delimit blocks. + * Tokens are String, Break, and Begin/End to delimit blocks. * - * BEGIN tokens can carry an offset, saying "how far to indent when you break + * Begin tokens can carry an offset, saying "how far to indent when you break * inside here", as well as a flag indicating "consistent" or "inconsistent" * breaking. Consistent breaking means that after the first break, no attempt * will be made to flow subsequent breaks together onto lines. Inconsistent @@ -223,10 +226,10 @@ pub fn mk_printer(out: ~io::Writer, linewidth: uint) -> Printer { * and point-in-infinite-stream senses freely. * * There is a parallel ring buffer, 'size', that holds the calculated size of - * each token. Why calculated? Because for BEGIN/END pairs, the "size" - * includes everything betwen the pair. That is, the "size" of BEGIN is - * actually the sum of the sizes of everything between BEGIN and the paired - * END that follows. Since that is arbitrarily far in the future, 'size' is + * each token. Why calculated? Because for Begin/End pairs, the "size" + * includes everything betwen the pair. That is, the "size" of Begin is + * actually the sum of the sizes of everything between Begin and the paired + * End that follows. Since that is arbitrarily far in the future, 'size' is * being rewritten regularly while the printer runs; in fact most of the * machinery is here to work out 'size' entries on the fly (and give up when * they're so obviously over-long that "infinity" is a good enough @@ -261,14 +264,14 @@ pub struct Printer { space: int, // number of spaces left on line left: uint, // index of left side of input stream right: uint, // index of right side of input stream - token: ~[token], // ring-buffr stream goes through + token: ~[Token], // ring-buffr stream goes through size: ~[int], // ring-buffer of calculated sizes left_total: int, // running size of stream "...left" right_total: int, // running size of stream "...right" // pseudo-stack, really a ring too. Holds the - // primary-ring-buffers index of the BEGIN that started the - // current block, possibly with the most recent BREAK after that - // BEGIN (if there is any) on top of it. Stuff is flushed off the + // primary-ring-buffers index of the Begin that started the + // current block, possibly with the most recent Break after that + // Begin (if there is any) on top of it. Stuff is flushed off the // bottom as it becomes irrelevant due to the primary ring-buffer // advancing. scan_stack: ~[uint], @@ -276,21 +279,21 @@ pub struct Printer { top: uint, // index of top of scan_stack bottom: uint, // index of bottom of scan_stack // stack of blocks-in-progress being flushed by print - print_stack: ~[print_stack_elt], + print_stack: ~[PrintStackElem], // buffered indentation to avoid writing trailing whitespace pending_indentation: int, } impl Printer { - pub fn last_token(&mut self) -> token { self.token[self.right] } + pub fn last_token(&mut self) -> Token { self.token[self.right] } // be very careful with this! - pub fn replace_last_token(&mut self, t: token) { + pub fn replace_last_token(&mut self, t: Token) { self.token[self.right] = t; } - pub fn pretty_print(&mut self, t: token) { + pub fn pretty_print(&mut self, t: Token) { debug!("pp ~[{},{}]", self.left, self.right); match t { - EOF => { + Eof => { if !self.scan_stack_empty { self.check_stack(0); self.advance_left(self.token[self.left], @@ -298,39 +301,39 @@ impl Printer { } self.indent(0); } - BEGIN(b) => { + Begin(b) => { if self.scan_stack_empty { self.left_total = 1; self.right_total = 1; self.left = 0u; self.right = 0u; } else { self.advance_right(); } - debug!("pp BEGIN({})/buffer ~[{},{}]", + debug!("pp Begin({})/buffer ~[{},{}]", b.offset, self.left, self.right); self.token[self.right] = t; self.size[self.right] = -self.right_total; self.scan_push(self.right); } - END => { + End => { if self.scan_stack_empty { - debug!("pp END/print ~[{},{}]", self.left, self.right); + debug!("pp End/print ~[{},{}]", self.left, self.right); self.print(t, 0); } else { - debug!("pp END/buffer ~[{},{}]", self.left, self.right); + debug!("pp End/buffer ~[{},{}]", self.left, self.right); self.advance_right(); self.token[self.right] = t; self.size[self.right] = -1; self.scan_push(self.right); } } - BREAK(b) => { + Break(b) => { if self.scan_stack_empty { self.left_total = 1; self.right_total = 1; self.left = 0u; self.right = 0u; } else { self.advance_right(); } - debug!("pp BREAK({})/buffer ~[{},{}]", + debug!("pp Break({})/buffer ~[{},{}]", b.offset, self.left, self.right); self.check_stack(0); self.scan_push(self.right); @@ -338,13 +341,13 @@ impl Printer { self.size[self.right] = -self.right_total; self.right_total += b.blank_space; } - STRING(s, len) => { + String(s, len) => { if self.scan_stack_empty { - debug!("pp STRING('{}')/print ~[{},{}]", + debug!("pp String('{}')/print ~[{},{}]", s, self.left, self.right); self.print(t, len); } else { - debug!("pp STRING('{}')/buffer ~[{},{}]", + debug!("pp String('{}')/buffer ~[{},{}]", s, self.left, self.right); self.advance_right(); self.token[self.right] = t; @@ -364,7 +367,7 @@ impl Printer { if !self.scan_stack_empty { if self.left == self.scan_stack[self.bottom] { debug!("setting {} to infinity and popping", self.left); - self.size[self.scan_pop_bottom()] = size_infinity; + self.size[self.scan_pop_bottom()] = SIZE_INFINITY; } } self.advance_left(self.token[self.left], self.size[self.left]); @@ -407,14 +410,14 @@ impl Printer { self.right %= self.buf_len; assert!((self.right != self.left)); } - pub fn advance_left(&mut self, x: token, L: int) { + pub fn advance_left(&mut self, x: Token, L: int) { debug!("advnce_left ~[{},{}], sizeof({})={}", self.left, self.right, self.left, L); if L >= 0 { self.print(x, L); match x { - BREAK(b) => self.left_total += b.blank_space, - STRING(_, len) => { + Break(b) => self.left_total += b.blank_space, + String(_, len) => { assert_eq!(len, L); self.left_total += len; } _ => () @@ -431,14 +434,14 @@ impl Printer { if !self.scan_stack_empty { let x = self.scan_top(); match self.token[x] { - BEGIN(_) => { + Begin(_) => { if k > 0 { self.size[self.scan_pop()] = self.size[x] + self.right_total; self.check_stack(k - 1); } } - END => { + End => { // paper says + not =, but that makes no sense. self.size[self.scan_pop()] = 1; self.check_stack(k + 1); @@ -460,15 +463,15 @@ impl Printer { debug!("INDENT {}", amount); self.pending_indentation += amount; } - pub fn get_top(&mut self) -> print_stack_elt { + pub fn get_top(&mut self) -> PrintStackElem { let print_stack = &mut self.print_stack; let n = print_stack.len(); if n != 0u { print_stack[n - 1u] } else { - print_stack_elt { + PrintStackElem { offset: 0, - pbreak: broken(inconsistent) + pbreak: Broken(Inconsistent) } } } @@ -479,7 +482,7 @@ impl Printer { } write!(self.out, "{}", s); } - pub fn print(&mut self, x: token, L: int) { + pub fn print(&mut self, x: Token, L: int) { debug!("print {} {} (remaining line space={})", tok_str(x), L, self.space); debug!("{}", buf_str(self.token.clone(), @@ -488,50 +491,50 @@ impl Printer { self.right, 6)); match x { - BEGIN(b) => { + Begin(b) => { if L > self.space { let col = self.margin - self.space + b.offset; - debug!("print BEGIN -> push broken block at col {}", col); - self.print_stack.push(print_stack_elt { + debug!("print Begin -> push broken block at col {}", col); + self.print_stack.push(PrintStackElem { offset: col, - pbreak: broken(b.breaks) + pbreak: Broken(b.breaks) }); } else { - debug!("print BEGIN -> push fitting block"); - self.print_stack.push(print_stack_elt { + debug!("print Begin -> push fitting block"); + self.print_stack.push(PrintStackElem { offset: 0, - pbreak: fits + pbreak: Fits }); } } - END => { - debug!("print END -> pop END"); + End => { + debug!("print End -> pop End"); let print_stack = &mut self.print_stack; assert!((print_stack.len() != 0u)); print_stack.pop(); } - BREAK(b) => { + Break(b) => { let top = self.get_top(); match top.pbreak { - fits => { - debug!("print BREAK({}) in fitting block", b.blank_space); + Fits => { + debug!("print Break({}) in fitting block", b.blank_space); self.space -= b.blank_space; self.indent(b.blank_space); } - broken(consistent) => { - debug!("print BREAK({}+{}) in consistent block", + Broken(Consistent) => { + debug!("print Break({}+{}) in consistent block", top.offset, b.offset); self.print_newline(top.offset + b.offset); self.space = self.margin - (top.offset + b.offset); } - broken(inconsistent) => { + Broken(Inconsistent) => { if L > self.space { - debug!("print BREAK({}+{}) w/ newline in inconsistent", + debug!("print Break({}+{}) w/ newline in inconsistent", top.offset, b.offset); self.print_newline(top.offset + b.offset); self.space = self.margin - (top.offset + b.offset); } else { - debug!("print BREAK({}) w/o newline in inconsistent", + debug!("print Break({}) w/o newline in inconsistent", b.blank_space); self.indent(b.blank_space); self.space -= b.blank_space; @@ -539,15 +542,15 @@ impl Printer { } } } - STRING(s, len) => { - debug!("print STRING({})", s); + String(s, len) => { + debug!("print String({})", s); assert_eq!(L, len); // assert!(L <= space); self.space -= len; self.print_str(s); } - EOF => { - // EOF should never get here. + Eof => { + // Eof should never get here. fail!(); } } @@ -557,38 +560,38 @@ impl Printer { // Convenience functions to talk to the printer. // // "raw box" -pub fn rbox(p: &mut Printer, indent: uint, b: breaks) { - p.pretty_print(BEGIN(begin_t { +pub fn rbox(p: &mut Printer, indent: uint, b: Breaks) { + p.pretty_print(Begin(BeginToken { offset: indent as int, breaks: b })); } -pub fn ibox(p: &mut Printer, indent: uint) { rbox(p, indent, inconsistent); } +pub fn ibox(p: &mut Printer, indent: uint) { rbox(p, indent, Inconsistent); } -pub fn cbox(p: &mut Printer, indent: uint) { rbox(p, indent, consistent); } +pub fn cbox(p: &mut Printer, indent: uint) { rbox(p, indent, Consistent); } pub fn break_offset(p: &mut Printer, n: uint, off: int) { - p.pretty_print(BREAK(break_t { + p.pretty_print(Break(BreakToken { offset: off, blank_space: n as int })); } -pub fn end(p: &mut Printer) { p.pretty_print(END); } +pub fn end(p: &mut Printer) { p.pretty_print(End); } -pub fn eof(p: &mut Printer) { p.pretty_print(EOF); } +pub fn eof(p: &mut Printer) { p.pretty_print(Eof); } pub fn word(p: &mut Printer, wrd: &str) { - p.pretty_print(STRING(/* bad */ wrd.to_managed(), wrd.len() as int)); + p.pretty_print(String(/* bad */ wrd.to_managed(), wrd.len() as int)); } pub fn huge_word(p: &mut Printer, wrd: &str) { - p.pretty_print(STRING(/* bad */ wrd.to_managed(), size_infinity)); + p.pretty_print(String(/* bad */ wrd.to_managed(), SIZE_INFINITY)); } pub fn zero_word(p: &mut Printer, wrd: &str) { - p.pretty_print(STRING(/* bad */ wrd.to_managed(), 0)); + p.pretty_print(String(/* bad */ wrd.to_managed(), 0)); } pub fn spaces(p: &mut Printer, n: uint) { break_offset(p, n, 0); } @@ -597,10 +600,10 @@ pub fn zerobreak(p: &mut Printer) { spaces(p, 0u); } pub fn space(p: &mut Printer) { spaces(p, 1u); } -pub fn hardbreak(p: &mut Printer) { spaces(p, size_infinity as uint); } +pub fn hardbreak(p: &mut Printer) { spaces(p, SIZE_INFINITY as uint); } -pub fn hardbreak_tok_offset(off: int) -> token { - BREAK(break_t {offset: off, blank_space: size_infinity}) +pub fn hardbreak_tok_offset(off: int) -> Token { + Break(BreakToken {offset: off, blank_space: SIZE_INFINITY}) } -pub fn hardbreak_tok() -> token { return hardbreak_tok_offset(0); } +pub fn hardbreak_tok() -> Token { return hardbreak_tok_offset(0); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 82a7d550f64..1e2e5dbc010 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -9,7 +9,7 @@ // except according to those terms. use abi::AbiSet; -use ast::{P, RegionTyParamBound, TraitTyParamBound, required, provided}; +use ast::{P, RegionTyParamBound, TraitTyParamBound, Required, Provided}; use ast; use ast_util; use opt_vec::OptVec; @@ -19,11 +19,11 @@ use codemap::{CodeMap, BytePos}; use codemap; use diagnostic; use parse::classify::expr_is_simple_block; -use parse::token::{ident_interner, ident_to_str, interner_get}; +use parse::token::{IdentInterner, ident_to_str, interner_get}; use parse::{comments, token}; use parse; use print::pp::{break_offset, word, space, zerobreak, hardbreak}; -use print::pp::{breaks, consistent, inconsistent, eof}; +use print::pp::{Breaks, Consistent, Inconsistent, eof}; use print::pp; use print::pprust; @@ -34,58 +34,48 @@ use std::str; use std::io; use std::io::mem::MemWriter; -// The &mut ps is stored here to prevent recursive type. -pub enum ann_node<'a,'b> { - node_block(&'b mut ps, &'a ast::Block), - node_item(&'b mut ps, &'a ast::item), - node_expr(&'b mut ps, &'a ast::Expr), - node_pat(&'b mut ps, &'a ast::Pat), +// The &mut State is stored here to prevent recursive type. +pub enum AnnNode<'a,'b> { + NodeBlock(&'b mut State, &'a ast::Block), + NodeItem(&'b mut State, &'a ast::Item), + NodeExpr(&'b mut State, &'a ast::Expr), + NodePat(&'b mut State, &'a ast::Pat), } -pub trait pp_ann { - fn pre(&self, _node: ann_node) {} - fn post(&self, _node: ann_node) {} +pub trait PpAnn { + fn pre(&self, _node: AnnNode) {} + fn post(&self, _node: AnnNode) {} } -pub struct no_ann { - contents: (), -} - -impl no_ann { - pub fn new() -> no_ann { - no_ann { - contents: (), - } - } -} +pub struct NoAnn; -impl pp_ann for no_ann {} +impl PpAnn for NoAnn {} pub struct CurrentCommentAndLiteral { cur_cmnt: uint, cur_lit: uint, } -pub struct ps { +pub struct State { s: pp::Printer, cm: Option<@CodeMap>, - intr: @token::ident_interner, - comments: Option<~[comments::cmnt]>, - literals: Option<~[comments::lit]>, + intr: @token::IdentInterner, + comments: Option<~[comments::Comment]>, + literals: Option<~[comments::Literal]>, cur_cmnt_and_lit: CurrentCommentAndLiteral, - boxes: RefCell<~[pp::breaks]>, - ann: @pp_ann + boxes: RefCell<~[pp::Breaks]>, + ann: @PpAnn } -pub fn ibox(s: &mut ps, u: uint) { +pub fn ibox(s: &mut State, u: uint) { { let mut boxes = s.boxes.borrow_mut(); - boxes.get().push(pp::inconsistent); + boxes.get().push(pp::Inconsistent); } pp::ibox(&mut s.s, u); } -pub fn end(s: &mut ps) { +pub fn end(s: &mut State) { { let mut boxes = s.boxes.borrow_mut(); boxes.get().pop(); @@ -93,20 +83,20 @@ pub fn end(s: &mut ps) { pp::end(&mut s.s); } -pub fn rust_printer(writer: ~io::Writer, intr: @ident_interner) -> ps { - return rust_printer_annotated(writer, intr, @no_ann::new() as @pp_ann); +pub fn rust_printer(writer: ~io::Writer, intr: @IdentInterner) -> State { + return rust_printer_annotated(writer, intr, @NoAnn as @PpAnn); } pub fn rust_printer_annotated(writer: ~io::Writer, - intr: @ident_interner, - ann: @pp_ann) - -> ps { - return ps { + intr: @IdentInterner, + ann: @PpAnn) + -> State { + return State { s: pp::mk_printer(writer, default_columns), - cm: None::<@CodeMap>, + cm: None, intr: intr, - comments: None::<~[comments::cmnt]>, - literals: None::<~[comments::lit]>, + comments: None, + literals: None, cur_cmnt_and_lit: CurrentCommentAndLiteral { cur_cmnt: 0, cur_lit: 0 @@ -124,20 +114,20 @@ pub static default_columns: uint = 78u; // it can scan the input text for comments and literals to // copy forward. pub fn print_crate(cm: @CodeMap, - intr: @ident_interner, + intr: @IdentInterner, span_diagnostic: @diagnostic::SpanHandler, crate: &ast::Crate, filename: @str, input: &mut io::Reader, out: ~io::Writer, - ann: @pp_ann, + ann: @PpAnn, is_expanded: bool) { let (cmnts, lits) = comments::gather_comments_and_literals( span_diagnostic, filename, input ); - let mut s = ps { + let mut s = State { s: pp::mk_printer(out, default_columns), cm: Some(cm), intr: intr, @@ -160,60 +150,60 @@ pub fn print_crate(cm: @CodeMap, print_crate_(&mut s, crate); } -pub fn print_crate_(s: &mut ps, crate: &ast::Crate) { +pub fn print_crate_(s: &mut State, crate: &ast::Crate) { print_mod(s, &crate.module, crate.attrs); print_remaining_comments(s); eof(&mut s.s); } -pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str { +pub fn ty_to_str(ty: &ast::Ty, intr: @IdentInterner) -> ~str { to_str(ty, print_type, intr) } -pub fn pat_to_str(pat: &ast::Pat, intr: @ident_interner) -> ~str { +pub fn pat_to_str(pat: &ast::Pat, intr: @IdentInterner) -> ~str { to_str(pat, print_pat, intr) } -pub fn expr_to_str(e: &ast::Expr, intr: @ident_interner) -> ~str { +pub fn expr_to_str(e: &ast::Expr, intr: @IdentInterner) -> ~str { to_str(e, print_expr, intr) } -pub fn lifetime_to_str(e: &ast::Lifetime, intr: @ident_interner) -> ~str { +pub fn lifetime_to_str(e: &ast::Lifetime, intr: @IdentInterner) -> ~str { to_str(e, print_lifetime, intr) } -pub fn tt_to_str(tt: &ast::token_tree, intr: @ident_interner) -> ~str { +pub fn tt_to_str(tt: &ast::TokenTree, intr: @IdentInterner) -> ~str { to_str(tt, print_tt, intr) } -pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str { +pub fn tts_to_str(tts: &[ast::TokenTree], intr: @IdentInterner) -> ~str { to_str(&tts, print_tts, intr) } -pub fn stmt_to_str(s: &ast::Stmt, intr: @ident_interner) -> ~str { +pub fn stmt_to_str(s: &ast::Stmt, intr: @IdentInterner) -> ~str { to_str(s, print_stmt, intr) } -pub fn item_to_str(i: &ast::item, intr: @ident_interner) -> ~str { +pub fn item_to_str(i: &ast::Item, intr: @IdentInterner) -> ~str { to_str(i, print_item, intr) } pub fn generics_to_str(generics: &ast::Generics, - intr: @ident_interner) -> ~str { + intr: @IdentInterner) -> ~str { to_str(generics, print_generics, intr) } -pub fn path_to_str(p: &ast::Path, intr: @ident_interner) -> ~str { +pub fn path_to_str(p: &ast::Path, intr: @IdentInterner) -> ~str { to_str(p, |a,b| print_path(a, b, false), intr) } -pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident, - opt_explicit_self: Option<ast::explicit_self_>, - generics: &ast::Generics, intr: @ident_interner) -> ~str { +pub fn fun_to_str(decl: &ast::FnDecl, purity: ast::Purity, name: ast::Ident, + opt_explicit_self: Option<ast::ExplicitSelf_>, + generics: &ast::Generics, intr: @IdentInterner) -> ~str { let wr = ~MemWriter::new(); let mut s = rust_printer(wr as ~io::Writer, intr); print_fn(&mut s, decl, Some(purity), AbiSet::Rust(), - name, generics, opt_explicit_self, ast::inherited); + name, generics, opt_explicit_self, ast::Inherited); end(&mut s); // Close the head box end(&mut s); // Close the outer box eof(&mut s.s); @@ -222,7 +212,7 @@ pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident, } } -pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { +pub fn block_to_str(blk: &ast::Block, intr: @IdentInterner) -> ~str { let wr = ~MemWriter::new(); let mut s = rust_printer(wr as ~io::Writer, intr); // containing cbox, will be closed by print-block at } @@ -236,28 +226,28 @@ pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { } } -pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @ident_interner) -> ~str { +pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @IdentInterner) -> ~str { to_str(mi, print_meta_item, intr) } -pub fn attribute_to_str(attr: &ast::Attribute, intr: @ident_interner) -> ~str { +pub fn attribute_to_str(attr: &ast::Attribute, intr: @IdentInterner) -> ~str { to_str(attr, print_attribute, intr) } -pub fn variant_to_str(var: &ast::variant, intr: @ident_interner) -> ~str { +pub fn variant_to_str(var: &ast::Variant, intr: @IdentInterner) -> ~str { to_str(var, print_variant, intr) } -pub fn cbox(s: &mut ps, u: uint) { +pub fn cbox(s: &mut State, u: uint) { { let mut boxes = s.boxes.borrow_mut(); - boxes.get().push(pp::consistent); + boxes.get().push(pp::Consistent); } pp::cbox(&mut s.s, u); } // "raw box" -pub fn rbox(s: &mut ps, u: uint, b: pp::breaks) { +pub fn rbox(s: &mut State, u: uint, b: pp::Breaks) { { let mut boxes = s.boxes.borrow_mut(); boxes.get().push(b); @@ -265,17 +255,17 @@ pub fn rbox(s: &mut ps, u: uint, b: pp::breaks) { pp::rbox(&mut s.s, u, b); } -pub fn nbsp(s: &mut ps) { word(&mut s.s, " "); } +pub fn nbsp(s: &mut State) { word(&mut s.s, " "); } -pub fn word_nbsp(s: &mut ps, w: &str) { word(&mut s.s, w); nbsp(s); } +pub fn word_nbsp(s: &mut State, w: &str) { word(&mut s.s, w); nbsp(s); } -pub fn word_space(s: &mut ps, w: &str) { word(&mut s.s, w); space(&mut s.s); } +pub fn word_space(s: &mut State, w: &str) { word(&mut s.s, w); space(&mut s.s); } -pub fn popen(s: &mut ps) { word(&mut s.s, "("); } +pub fn popen(s: &mut State) { word(&mut s.s, "("); } -pub fn pclose(s: &mut ps) { word(&mut s.s, ")"); } +pub fn pclose(s: &mut State) { word(&mut s.s, ")"); } -pub fn head(s: &mut ps, w: &str) { +pub fn head(s: &mut State, w: &str) { // outer-box is consistent cbox(s, indent_unit); // head-box is inconsistent @@ -286,16 +276,16 @@ pub fn head(s: &mut ps, w: &str) { } } -pub fn bopen(s: &mut ps) { +pub fn bopen(s: &mut State) { word(&mut s.s, "{"); end(s); // close the head-box } -pub fn bclose_(s: &mut ps, span: codemap::Span, indented: uint) { +pub fn bclose_(s: &mut State, span: codemap::Span, indented: uint) { bclose_maybe_open(s, span, indented, true); } -pub fn bclose_maybe_open (s: &mut ps, span: codemap::Span, indented: uint, - close_box: bool) { +pub fn bclose_maybe_open (s: &mut State, span: codemap::Span, + indented: uint, close_box: bool) { maybe_print_comment(s, span.hi); break_offset_if_not_bol(s, 1u, -(indented as int)); word(&mut s.s, "}"); @@ -303,34 +293,36 @@ pub fn bclose_maybe_open (s: &mut ps, span: codemap::Span, indented: uint, end(s); // close the outer-box } } -pub fn bclose(s: &mut ps, span: codemap::Span) { bclose_(s, span, indent_unit); } +pub fn bclose(s: &mut State, span: codemap::Span) { + bclose_(s, span, indent_unit); +} -pub fn is_begin(s: &mut ps) -> bool { - match s.s.last_token() { pp::BEGIN(_) => true, _ => false } +pub fn is_begin(s: &mut State) -> bool { + match s.s.last_token() { pp::Begin(_) => true, _ => false } } -pub fn is_end(s: &mut ps) -> bool { - match s.s.last_token() { pp::END => true, _ => false } +pub fn is_end(s: &mut State) -> bool { + match s.s.last_token() { pp::End => true, _ => false } } -pub fn is_bol(s: &mut ps) -> bool { +pub fn is_bol(s: &mut State) -> bool { return s.s.last_token().is_eof() || s.s.last_token().is_hardbreak_tok(); } -pub fn in_cbox(s: &mut ps) -> bool { +pub fn in_cbox(s: &mut State) -> bool { let boxes = s.boxes.borrow(); let len = boxes.get().len(); if len == 0u { return false; } - return boxes.get()[len - 1u] == pp::consistent; + return boxes.get()[len - 1u] == pp::Consistent; } -pub fn hardbreak_if_not_bol(s: &mut ps) { +pub fn hardbreak_if_not_bol(s: &mut State) { if !is_bol(s) { hardbreak(&mut s.s) } } -pub fn space_if_not_bol(s: &mut ps) { if !is_bol(s) { space(&mut s.s); } } -pub fn break_offset_if_not_bol(s: &mut ps, n: uint, off: int) { +pub fn space_if_not_bol(s: &mut State) { if !is_bol(s) { space(&mut s.s); } } +pub fn break_offset_if_not_bol(s: &mut State, n: uint, off: int) { if !is_bol(s) { break_offset(&mut s.s, n, off); } else { @@ -345,7 +337,7 @@ pub fn break_offset_if_not_bol(s: &mut ps, n: uint, off: int) { // Synthesizes a comment that was not textually present in the original source // file. -pub fn synth_comment(s: &mut ps, text: ~str) { +pub fn synth_comment(s: &mut State, text: ~str) { word(&mut s.s, "/*"); space(&mut s.s); word(&mut s.s, text); @@ -353,7 +345,7 @@ pub fn synth_comment(s: &mut ps, text: ~str) { word(&mut s.s, "*/"); } -pub fn commasep<T>(s: &mut ps, b: breaks, elts: &[T], op: |&mut ps, &T|) { +pub fn commasep<T>(s: &mut State, b: Breaks, elts: &[T], op: |&mut State, &T|) { rbox(s, 0u, b); let mut first = true; for elt in elts.iter() { @@ -365,10 +357,10 @@ pub fn commasep<T>(s: &mut ps, b: breaks, elts: &[T], op: |&mut ps, &T|) { pub fn commasep_cmnt<T>( - s: &mut ps, - b: breaks, + s: &mut State, + b: Breaks, elts: &[T], - op: |&mut ps, &T|, + op: |&mut State, &T|, get_span: |&T| -> codemap::Span) { rbox(s, 0u, b); let len = elts.len(); @@ -387,11 +379,11 @@ pub fn commasep_cmnt<T>( end(s); } -pub fn commasep_exprs(s: &mut ps, b: breaks, exprs: &[@ast::Expr]) { +pub fn commasep_exprs(s: &mut State, b: Breaks, exprs: &[@ast::Expr]) { commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span); } -pub fn print_mod(s: &mut ps, _mod: &ast::_mod, attrs: &[ast::Attribute]) { +pub fn print_mod(s: &mut State, _mod: &ast::Mod, attrs: &[ast::Attribute]) { print_inner_attributes(s, attrs); for vitem in _mod.view_items.iter() { print_view_item(s, vitem); @@ -399,7 +391,7 @@ pub fn print_mod(s: &mut ps, _mod: &ast::_mod, attrs: &[ast::Attribute]) { for item in _mod.items.iter() { print_item(s, *item); } } -pub fn print_foreign_mod(s: &mut ps, nmod: &ast::foreign_mod, +pub fn print_foreign_mod(s: &mut State, nmod: &ast::ForeignMod, attrs: &[ast::Attribute]) { print_inner_attributes(s, attrs); for vitem in nmod.view_items.iter() { @@ -408,96 +400,95 @@ pub fn print_foreign_mod(s: &mut ps, nmod: &ast::foreign_mod, for item in nmod.items.iter() { print_foreign_item(s, *item); } } -pub fn print_opt_lifetime(s: &mut ps, lifetime: &Option<ast::Lifetime>) { +pub fn print_opt_lifetime(s: &mut State, lifetime: &Option<ast::Lifetime>) { for l in lifetime.iter() { print_lifetime(s, l); nbsp(s); } } -pub fn print_type(s: &mut ps, ty: &ast::Ty) { +pub fn print_type(s: &mut State, ty: &ast::Ty) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); match ty.node { - ast::ty_nil => word(&mut s.s, "()"), - ast::ty_bot => word(&mut s.s, "!"), - ast::ty_box(ty) => { word(&mut s.s, "@"); print_type(s, ty); } - ast::ty_uniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); } - ast::ty_vec(ty) => { - word(&mut s.s, "["); - print_type(s, ty); - word(&mut s.s, "]"); - } - ast::ty_ptr(ref mt) => { word(&mut s.s, "*"); print_mt(s, mt); } - ast::ty_rptr(ref lifetime, ref mt) => { - word(&mut s.s, "&"); - print_opt_lifetime(s, lifetime); - print_mt(s, mt); - } - ast::ty_tup(ref elts) => { - popen(s); - commasep(s, inconsistent, *elts, print_type_ref); - if elts.len() == 1 { - word(&mut s.s, ","); + ast::TyNil => word(&mut s.s, "()"), + ast::TyBot => word(&mut s.s, "!"), + ast::TyBox(ty) => { word(&mut s.s, "@"); print_type(s, ty); } + ast::TyUniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); } + ast::TyVec(ty) => { + word(&mut s.s, "["); + print_type(s, ty); + word(&mut s.s, "]"); + } + ast::TyPtr(ref mt) => { word(&mut s.s, "*"); print_mt(s, mt); } + ast::TyRptr(ref lifetime, ref mt) => { + word(&mut s.s, "&"); + print_opt_lifetime(s, lifetime); + print_mt(s, mt); + } + ast::TyTup(ref elts) => { + popen(s); + commasep(s, Inconsistent, *elts, print_type_ref); + if elts.len() == 1 { + word(&mut s.s, ","); + } + pclose(s); + } + ast::TyBareFn(f) => { + let generics = ast::Generics { + lifetimes: f.lifetimes.clone(), + ty_params: opt_vec::Empty + }; + print_ty_fn(s, Some(f.abis), None, &None, + f.purity, ast::Many, f.decl, None, &None, + Some(&generics), None); + } + ast::TyClosure(f) => { + let generics = ast::Generics { + lifetimes: f.lifetimes.clone(), + ty_params: opt_vec::Empty + }; + print_ty_fn(s, None, Some(f.sigil), &f.region, + f.purity, f.onceness, f.decl, None, &f.bounds, + Some(&generics), None); + } + ast::TyPath(ref path, ref bounds, _) => print_bounded_path(s, path, bounds), + ast::TyFixedLengthVec(ty, v) => { + word(&mut s.s, "["); + print_type(s, ty); + word(&mut s.s, ", .."); + print_expr(s, v); + word(&mut s.s, "]"); + } + ast::TyTypeof(e) => { + word(&mut s.s, "typeof("); + print_expr(s, e); + word(&mut s.s, ")"); + } + ast::TyInfer => { + fail!("print_type shouldn't see a ty_infer"); } - pclose(s); - } - ast::ty_bare_fn(f) => { - let generics = ast::Generics { - lifetimes: f.lifetimes.clone(), - ty_params: opt_vec::Empty - }; - print_ty_fn(s, Some(f.abis), None, &None, - f.purity, ast::Many, f.decl, None, &None, - Some(&generics), None); - } - ast::ty_closure(f) => { - let generics = ast::Generics { - lifetimes: f.lifetimes.clone(), - ty_params: opt_vec::Empty - }; - print_ty_fn(s, None, Some(f.sigil), &f.region, - f.purity, f.onceness, f.decl, None, &f.bounds, - Some(&generics), None); - } - ast::ty_path(ref path, ref bounds, _) => print_bounded_path(s, path, bounds), - ast::ty_fixed_length_vec(ty, v) => { - word(&mut s.s, "["); - print_type(s, ty); - word(&mut s.s, ", .."); - print_expr(s, v); - word(&mut s.s, "]"); - } - ast::ty_typeof(e) => { - word(&mut s.s, "typeof("); - print_expr(s, e); - word(&mut s.s, ")"); - } - ast::ty_infer => { - fail!("print_type shouldn't see a ty_infer"); - } - } end(s); } -pub fn print_type_ref(s: &mut ps, ty: &P<ast::Ty>) { +pub fn print_type_ref(s: &mut State, ty: &P<ast::Ty>) { print_type(s, *ty); } -pub fn print_foreign_item(s: &mut ps, item: &ast::foreign_item) { +pub fn print_foreign_item(s: &mut State, item: &ast::ForeignItem) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); match item.node { - ast::foreign_item_fn(decl, ref generics) => { + ast::ForeignItemFn(decl, ref generics) => { print_fn(s, decl, None, AbiSet::Rust(), item.ident, generics, None, item.vis); end(s); // end head-ibox word(&mut s.s, ";"); end(s); // end the outer fn box } - ast::foreign_item_static(t, m) => { + ast::ForeignItemStatic(t, m) => { head(s, visibility_qualified(item.vis, "static")); if m { word_space(s, "mut"); @@ -512,16 +503,16 @@ pub fn print_foreign_item(s: &mut ps, item: &ast::foreign_item) { } } -pub fn print_item(s: &mut ps, item: &ast::item) { +pub fn print_item(s: &mut State, item: &ast::Item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); { - let ann_node = node_item(s, item); + let ann_node = NodeItem(s, item); s.ann.pre(ann_node); } match item.node { - ast::item_static(ty, m, expr) => { + ast::ItemStatic(ty, m, expr) => { head(s, visibility_qualified(item.vis, "static")); if m == ast::MutMutable { word_space(s, "mut"); @@ -538,7 +529,7 @@ pub fn print_item(s: &mut ps, item: &ast::item) { end(s); // end the outer cbox } - ast::item_fn(decl, purity, abi, ref typarams, body) => { + ast::ItemFn(decl, purity, abi, ref typarams, body) => { print_fn( s, decl, @@ -552,7 +543,7 @@ pub fn print_item(s: &mut ps, item: &ast::item) { word(&mut s.s, " "); print_block_with_attrs(s, body, item.attrs); } - ast::item_mod(ref _mod) => { + ast::ItemMod(ref _mod) => { head(s, visibility_qualified(item.vis, "mod")); print_ident(s, item.ident); nbsp(s); @@ -560,14 +551,14 @@ pub fn print_item(s: &mut ps, item: &ast::item) { print_mod(s, _mod, item.attrs); bclose(s, item.span); } - ast::item_foreign_mod(ref nmod) => { + ast::ItemForeignMod(ref nmod) => { head(s, "extern"); word_nbsp(s, nmod.abis.to_str()); bopen(s); print_foreign_mod(s, nmod, item.attrs); bclose(s, item.span); } - ast::item_ty(ty, ref params) => { + ast::ItemTy(ty, ref params) => { ibox(s, indent_unit); ibox(s, 0u); word_nbsp(s, visibility_qualified(item.vis, "type")); @@ -581,7 +572,7 @@ pub fn print_item(s: &mut ps, item: &ast::item) { word(&mut s.s, ";"); end(s); // end the outer ibox } - ast::item_enum(ref enum_definition, ref params) => { + ast::ItemEnum(ref enum_definition, ref params) => { print_enum_def( s, enum_definition, @@ -591,12 +582,12 @@ pub fn print_item(s: &mut ps, item: &ast::item) { item.vis ); } - ast::item_struct(struct_def, ref generics) => { + ast::ItemStruct(struct_def, ref generics) => { head(s, visibility_qualified(item.vis, "struct")); print_struct(s, struct_def, generics, item.ident, item.span); } - ast::item_impl(ref generics, ref opt_trait, ty, ref methods) => { + ast::ItemImpl(ref generics, ref opt_trait, ty, ref methods) => { head(s, visibility_qualified(item.vis, "impl")); if generics.is_parameterized() { print_generics(s, generics); @@ -622,7 +613,7 @@ pub fn print_item(s: &mut ps, item: &ast::item) { } bclose(s, item.span); } - ast::item_trait(ref generics, ref traits, ref methods) => { + ast::ItemTrait(ref generics, ref traits, ref methods) => { head(s, visibility_qualified(item.vis, "trait")); print_ident(s, item.ident); print_generics(s, generics); @@ -644,7 +635,7 @@ pub fn print_item(s: &mut ps, item: &ast::item) { bclose(s, item.span); } // I think it's reasonable to hide the context here: - ast::item_mac(codemap::Spanned { node: ast::mac_invoc_tt(ref pth, ref tts, _), + ast::ItemMac(codemap::Spanned { node: ast::MacInvocTT(ref pth, ref tts, _), ..}) => { print_visibility(s, item.vis); print_path(s, pth, false); @@ -658,18 +649,18 @@ pub fn print_item(s: &mut ps, item: &ast::item) { } } { - let ann_node = node_item(s, item); + let ann_node = NodeItem(s, item); s.ann.post(ann_node); } } -fn print_trait_ref(s: &mut ps, t: &ast::trait_ref) { +fn print_trait_ref(s: &mut State, t: &ast::TraitRef) { print_path(s, &t.path, false); } -pub fn print_enum_def(s: &mut ps, enum_definition: &ast::enum_def, +pub fn print_enum_def(s: &mut State, enum_definition: &ast::EnumDef, generics: &ast::Generics, ident: ast::Ident, - span: codemap::Span, visibility: ast::visibility) { + span: codemap::Span, visibility: ast::Visibility) { head(s, visibility_qualified(visibility, "enum")); print_ident(s, ident); print_generics(s, generics); @@ -677,8 +668,8 @@ pub fn print_enum_def(s: &mut ps, enum_definition: &ast::enum_def, print_variants(s, enum_definition.variants, span); } -pub fn print_variants(s: &mut ps, - variants: &[P<ast::variant>], +pub fn print_variants(s: &mut State, + variants: &[P<ast::Variant>], span: codemap::Span) { bopen(s); for &v in variants.iter() { @@ -694,31 +685,31 @@ pub fn print_variants(s: &mut ps, bclose(s, span); } -pub fn visibility_to_str(vis: ast::visibility) -> ~str { +pub fn visibility_to_str(vis: ast::Visibility) -> ~str { match vis { - ast::private => ~"priv", - ast::public => ~"pub", - ast::inherited => ~"" + ast::Private => ~"priv", + ast::Public => ~"pub", + ast::Inherited => ~"" } } -pub fn visibility_qualified(vis: ast::visibility, s: &str) -> ~str { +pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> ~str { match vis { - ast::private | ast::public => visibility_to_str(vis) + " " + s, - ast::inherited => s.to_owned() + ast::Private | ast::Public => visibility_to_str(vis) + " " + s, + ast::Inherited => s.to_owned() } } -pub fn print_visibility(s: &mut ps, vis: ast::visibility) { +pub fn print_visibility(s: &mut State, vis: ast::Visibility) { match vis { - ast::private | ast::public => + ast::Private | ast::Public => word_nbsp(s, visibility_to_str(vis)), - ast::inherited => () + ast::Inherited => () } } -pub fn print_struct(s: &mut ps, - struct_def: &ast::struct_def, +pub fn print_struct(s: &mut State, + struct_def: &ast::StructDef, generics: &ast::Generics, ident: ast::Ident, span: codemap::Span) { @@ -727,10 +718,10 @@ pub fn print_struct(s: &mut ps, if ast_util::struct_def_is_tuple_like(struct_def) { if !struct_def.fields.is_empty() { popen(s); - commasep(s, inconsistent, struct_def.fields, |s, field| { + commasep(s, Inconsistent, struct_def.fields, |s, field| { match field.node.kind { - ast::named_field(..) => fail!("unexpected named field"), - ast::unnamed_field => { + ast::NamedField(..) => fail!("unexpected named field"), + ast::UnnamedField => { maybe_print_comment(s, field.span.lo); print_type(s, field.node.ty); } @@ -748,8 +739,8 @@ pub fn print_struct(s: &mut ps, for field in struct_def.fields.iter() { match field.node.kind { - ast::unnamed_field => fail!("unexpected unnamed field"), - ast::named_field(ident, visibility) => { + ast::UnnamedField => fail!("unexpected unnamed field"), + ast::NamedField(ident, visibility) => { hardbreak_if_not_bol(s); maybe_print_comment(s, field.span.lo); print_outer_attributes(s, field.node.attrs); @@ -773,13 +764,13 @@ pub fn print_struct(s: &mut ps, /// appropriate macro, transcribe back into the grammar we just parsed from, /// and then pretty-print the resulting AST nodes (so, e.g., we print /// expression arguments as expressions). It can be done! I think. -pub fn print_tt(s: &mut ps, tt: &ast::token_tree) { +pub fn print_tt(s: &mut State, tt: &ast::TokenTree) { match *tt { - ast::tt_delim(ref tts) => print_tts(s, &(tts.as_slice())), - ast::tt_tok(_, ref tk) => { + ast::TTDelim(ref tts) => print_tts(s, &(tts.as_slice())), + ast::TTTok(_, ref tk) => { word(&mut s.s, parse::token::to_str(s.intr, tk)); } - ast::tt_seq(_, ref tts, ref sep, zerok) => { + ast::TTSeq(_, ref tts, ref sep, zerok) => { word(&mut s.s, "$("); for tt_elt in (*tts).iter() { print_tt(s, tt_elt); } word(&mut s.s, ")"); @@ -789,14 +780,14 @@ pub fn print_tt(s: &mut ps, tt: &ast::token_tree) { } word(&mut s.s, if zerok { "*" } else { "+" }); } - ast::tt_nonterminal(_, name) => { + ast::TTNonterminal(_, name) => { word(&mut s.s, "$"); print_ident(s, name); } } } -pub fn print_tts(s: &mut ps, tts: & &[ast::token_tree]) { +pub fn print_tts(s: &mut State, tts: & &[ast::TokenTree]) { ibox(s, 0); for (i, tt) in tts.iter().enumerate() { if i != 0 { @@ -807,21 +798,21 @@ pub fn print_tts(s: &mut ps, tts: & &[ast::token_tree]) { end(s); } -pub fn print_variant(s: &mut ps, v: &ast::variant) { +pub fn print_variant(s: &mut State, v: &ast::Variant) { print_visibility(s, v.node.vis); match v.node.kind { - ast::tuple_variant_kind(ref args) => { + ast::TupleVariantKind(ref args) => { print_ident(s, v.node.name); if !args.is_empty() { popen(s); - fn print_variant_arg(s: &mut ps, arg: &ast::variant_arg) { + fn print_variant_arg(s: &mut State, arg: &ast::VariantArg) { print_type(s, arg.ty); } - commasep(s, consistent, *args, print_variant_arg); + commasep(s, Consistent, *args, print_variant_arg); pclose(s); } } - ast::struct_variant_kind(struct_def) => { + ast::StructVariantKind(struct_def) => { head(s, ""); let generics = ast_util::empty_generics(); print_struct(s, struct_def, &generics, v.node.name, v.span); @@ -837,7 +828,7 @@ pub fn print_variant(s: &mut ps, v: &ast::variant) { } } -pub fn print_ty_method(s: &mut ps, m: &ast::TypeMethod) { +pub fn print_ty_method(s: &mut State, m: &ast::TypeMethod) { hardbreak_if_not_bol(s); maybe_print_comment(s, m.span.lo); print_outer_attributes(s, m.attrs); @@ -855,14 +846,14 @@ pub fn print_ty_method(s: &mut ps, m: &ast::TypeMethod) { word(&mut s.s, ";"); } -pub fn print_trait_method(s: &mut ps, m: &ast::trait_method) { +pub fn print_trait_method(s: &mut State, m: &ast::TraitMethod) { match *m { - required(ref ty_m) => print_ty_method(s, ty_m), - provided(m) => print_method(s, m) + Required(ref ty_m) => print_ty_method(s, ty_m), + Provided(m) => print_method(s, m) } } -pub fn print_method(s: &mut ps, meth: &ast::method) { +pub fn print_method(s: &mut State, meth: &ast::Method) { hardbreak_if_not_bol(s); maybe_print_comment(s, meth.span.lo); print_outer_attributes(s, meth.attrs); @@ -873,7 +864,7 @@ pub fn print_method(s: &mut ps, meth: &ast::method) { print_block_with_attrs(s, meth.body, meth.attrs); } -pub fn print_outer_attributes(s: &mut ps, attrs: &[ast::Attribute]) { +pub fn print_outer_attributes(s: &mut State, attrs: &[ast::Attribute]) { let mut count = 0; for attr in attrs.iter() { match attr.node.style { @@ -884,7 +875,7 @@ pub fn print_outer_attributes(s: &mut ps, attrs: &[ast::Attribute]) { if count > 0 { hardbreak_if_not_bol(s); } } -pub fn print_inner_attributes(s: &mut ps, attrs: &[ast::Attribute]) { +pub fn print_inner_attributes(s: &mut State, attrs: &[ast::Attribute]) { let mut count = 0; for attr in attrs.iter() { match attr.node.style { @@ -901,7 +892,7 @@ pub fn print_inner_attributes(s: &mut ps, attrs: &[ast::Attribute]) { if count > 0 { hardbreak_if_not_bol(s); } } -pub fn print_attribute(s: &mut ps, attr: &ast::Attribute) { +pub fn print_attribute(s: &mut State, attr: &ast::Attribute) { hardbreak_if_not_bol(s); maybe_print_comment(s, attr.span.lo); if attr.node.is_sugared_doc { @@ -915,7 +906,7 @@ pub fn print_attribute(s: &mut ps, attr: &ast::Attribute) { } -pub fn print_stmt(s: &mut ps, st: &ast::Stmt) { +pub fn print_stmt(s: &mut State, st: &ast::Stmt) { maybe_print_comment(s, st.span.lo); match st.node { ast::StmtDecl(decl, _) => { @@ -940,40 +931,42 @@ pub fn print_stmt(s: &mut ps, st: &ast::Stmt) { maybe_print_trailing_comment(s, st.span, None); } -pub fn print_block(s: &mut ps, blk: &ast::Block) { - print_possibly_embedded_block(s, blk, block_normal, indent_unit); +pub fn print_block(s: &mut State, blk: &ast::Block) { + print_possibly_embedded_block(s, blk, BlockNormal, indent_unit); } -pub fn print_block_unclosed(s: &mut ps, blk: &ast::Block) { - print_possibly_embedded_block_(s, blk, block_normal, indent_unit, &[], +pub fn print_block_unclosed(s: &mut State, blk: &ast::Block) { + print_possibly_embedded_block_(s, blk, BlockNormal, indent_unit, &[], false); } -pub fn print_block_unclosed_indent(s: &mut ps, blk: &ast::Block, indented: uint) { - print_possibly_embedded_block_(s, blk, block_normal, indented, &[], - false); +pub fn print_block_unclosed_indent(s: &mut State, blk: &ast::Block, indented: uint) { + print_possibly_embedded_block_(s, blk, BlockNormal, indented, &[], false); } -pub fn print_block_with_attrs(s: &mut ps, +pub fn print_block_with_attrs(s: &mut State, blk: &ast::Block, attrs: &[ast::Attribute]) { - print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs, + print_possibly_embedded_block_(s, blk, BlockNormal, indent_unit, attrs, true); } -pub enum embed_type { block_block_fn, block_normal, } +enum EmbedType { + BlockBlockFn, + BlockNormal, +} -pub fn print_possibly_embedded_block(s: &mut ps, +pub fn print_possibly_embedded_block(s: &mut State, blk: &ast::Block, - embedded: embed_type, + embedded: EmbedType, indented: uint) { print_possibly_embedded_block_( s, blk, embedded, indented, &[], true); } -pub fn print_possibly_embedded_block_(s: &mut ps, +pub fn print_possibly_embedded_block_(s: &mut State, blk: &ast::Block, - embedded: embed_type, + embedded: EmbedType, indented: uint, attrs: &[ast::Attribute], close_box: bool) { @@ -983,12 +976,12 @@ pub fn print_possibly_embedded_block_(s: &mut ps, } maybe_print_comment(s, blk.span.lo); { - let ann_node = node_block(s, blk); + let ann_node = NodeBlock(s, blk); s.ann.pre(ann_node); } match embedded { - block_block_fn => end(s), - block_normal => bopen(s) + BlockBlockFn => end(s), + BlockNormal => bopen(s) } print_inner_attributes(s, attrs); @@ -1007,19 +1000,19 @@ pub fn print_possibly_embedded_block_(s: &mut ps, } bclose_maybe_open(s, blk.span, indented, close_box); { - let ann_node = node_block(s, blk); + let ann_node = NodeBlock(s, blk); s.ann.post(ann_node); } } -pub fn print_if(s: &mut ps, test: &ast::Expr, blk: &ast::Block, +pub fn print_if(s: &mut State, test: &ast::Expr, blk: &ast::Block, elseopt: Option<@ast::Expr>, chk: bool) { head(s, "if"); if chk { word_nbsp(s, "check"); } print_expr(s, test); space(&mut s.s); print_block(s, blk); - fn do_else(s: &mut ps, els: Option<@ast::Expr>) { + fn do_else(s: &mut State, els: Option<@ast::Expr>) { match els { Some(_else) => { match _else.node { @@ -1052,10 +1045,10 @@ pub fn print_if(s: &mut ps, test: &ast::Expr, blk: &ast::Block, do_else(s, elseopt); } -pub fn print_mac(s: &mut ps, m: &ast::mac) { +pub fn print_mac(s: &mut State, m: &ast::Mac) { match m.node { // I think it's reasonable to hide the ctxt here: - ast::mac_invoc_tt(ref pth, ref tts, _) => { + ast::MacInvocTT(ref pth, ref tts, _) => { print_path(s, pth, false); word(&mut s.s, "!"); popen(s); @@ -1065,7 +1058,7 @@ pub fn print_mac(s: &mut ps, m: &ast::mac) { } } -pub fn print_vstore(s: &mut ps, t: ast::Vstore) { +pub fn print_vstore(s: &mut State, t: ast::Vstore) { match t { ast::VstoreFixed(Some(i)) => word(&mut s.s, format!("{}", i)), ast::VstoreFixed(None) => word(&mut s.s, "_"), @@ -1078,7 +1071,7 @@ pub fn print_vstore(s: &mut ps, t: ast::Vstore) { } } -pub fn print_expr_vstore(s: &mut ps, t: ast::ExprVstore) { +pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) { match t { ast::ExprVstoreUniq => word(&mut s.s, "~"), ast::ExprVstoreBox => word(&mut s.s, "@"), @@ -1090,7 +1083,7 @@ pub fn print_expr_vstore(s: &mut ps, t: ast::ExprVstore) { } } -pub fn print_call_pre(s: &mut ps, +pub fn print_call_pre(s: &mut State, sugar: ast::CallSugar, base_args: &mut ~[@ast::Expr]) -> Option<@ast::Expr> { @@ -1107,13 +1100,13 @@ pub fn print_call_pre(s: &mut ps, } } -pub fn print_call_post(s: &mut ps, +pub fn print_call_post(s: &mut State, sugar: ast::CallSugar, blk: &Option<@ast::Expr>, base_args: &mut ~[@ast::Expr]) { if sugar == ast::NoSugar || !base_args.is_empty() { popen(s); - commasep_exprs(s, inconsistent, *base_args); + commasep_exprs(s, Inconsistent, *base_args); pclose(s); } if sugar != ast::NoSugar { @@ -1134,8 +1127,8 @@ pub fn print_call_post(s: &mut ps, } } -pub fn print_expr(s: &mut ps, expr: &ast::Expr) { - fn print_field(s: &mut ps, field: &ast::Field) { +pub fn print_expr(s: &mut State, expr: &ast::Expr) { + fn print_field(s: &mut State, field: &ast::Field) { ibox(s, indent_unit); print_ident(s, field.ident.node); word_space(s, ":"); @@ -1147,7 +1140,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { maybe_print_comment(s, expr.span.lo); ibox(s, indent_unit); { - let ann_node = node_expr(s, expr); + let ann_node = NodeExpr(s, expr); s.ann.pre(ann_node); } match expr.node { @@ -1162,7 +1155,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { word(&mut s.s, "mut"); if exprs.len() > 0u { nbsp(s); } } - commasep_exprs(s, inconsistent, *exprs); + commasep_exprs(s, Inconsistent, *exprs); word(&mut s.s, "]"); end(s); } @@ -1185,7 +1178,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { ast::ExprStruct(ref path, ref fields, wth) => { print_path(s, path, true); word(&mut s.s, "{"); - commasep_cmnt(s, consistent, (*fields), print_field, get_span); + commasep_cmnt(s, Consistent, (*fields), print_field, get_span); match wth { Some(expr) => { ibox(s, indent_unit); @@ -1201,7 +1194,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { } ast::ExprTup(ref exprs) => { popen(s); - commasep_exprs(s, inconsistent, *exprs); + commasep_exprs(s, Inconsistent, *exprs); if exprs.len() == 1 { word(&mut s.s, ","); } @@ -1221,7 +1214,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { print_ident(s, ident); if tys.len() > 0u { word(&mut s.s, "::<"); - commasep(s, inconsistent, *tys, print_type_ref); + commasep(s, Inconsistent, *tys, print_type_ref); word(&mut s.s, ">"); } print_call_post(s, sugar, &blk, &mut base_args); @@ -1434,7 +1427,7 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { print_ident(s, id); if tys.len() > 0u { word(&mut s.s, "::<"); - commasep(s, inconsistent, *tys, print_type_ref); + commasep(s, Inconsistent, *tys, print_type_ref); word(&mut s.s, ">"); } } @@ -1512,21 +1505,21 @@ pub fn print_expr(s: &mut ps, expr: &ast::Expr) { } } { - let ann_node = node_expr(s, expr); + let ann_node = NodeExpr(s, expr); s.ann.post(ann_node); } end(s); } -pub fn print_local_decl(s: &mut ps, loc: &ast::Local) { +pub fn print_local_decl(s: &mut State, loc: &ast::Local) { print_pat(s, loc.pat); match loc.ty.node { - ast::ty_infer => (), - _ => { word_space(s, ":"); print_type(s, loc.ty); } + ast::TyInfer => {} + _ => { word_space(s, ":"); print_type(s, loc.ty); } } } -pub fn print_decl(s: &mut ps, decl: &ast::Decl) { +pub fn print_decl(s: &mut State, decl: &ast::Decl) { maybe_print_comment(s, decl.span.lo); match decl.node { ast::DeclLocal(ref loc) => { @@ -1534,7 +1527,7 @@ pub fn print_decl(s: &mut ps, decl: &ast::Decl) { ibox(s, indent_unit); word_nbsp(s, "let"); - fn print_local(s: &mut ps, loc: &ast::Local) { + fn print_local(s: &mut State, loc: &ast::Local) { ibox(s, indent_unit); print_local_decl(s, loc); end(s); @@ -1555,22 +1548,22 @@ pub fn print_decl(s: &mut ps, decl: &ast::Decl) { } } -pub fn print_ident(s: &mut ps, ident: ast::Ident) { +pub fn print_ident(s: &mut State, ident: ast::Ident) { word(&mut s.s, ident_to_str(&ident)); } -pub fn print_name(s: &mut ps, name: ast::Name) { +pub fn print_name(s: &mut State, name: ast::Name) { word(&mut s.s, interner_get(name)); } -pub fn print_for_decl(s: &mut ps, loc: &ast::Local, coll: &ast::Expr) { +pub fn print_for_decl(s: &mut State, loc: &ast::Local, coll: &ast::Expr) { print_local_decl(s, loc); space(&mut s.s); word_space(s, "in"); print_expr(s, coll); } -fn print_path_(s: &mut ps, +fn print_path_(s: &mut State, path: &ast::Path, colons_before_params: bool, opt_bounds: &Option<OptVec<ast::TyParamBound>>) { @@ -1617,7 +1610,7 @@ fn print_path_(s: &mut ps, word_space(s, ",") } commasep(s, - inconsistent, + Inconsistent, segment.types.map_to_vec(|&t| t), print_type_ref); } @@ -1627,19 +1620,19 @@ fn print_path_(s: &mut ps, } } -pub fn print_path(s: &mut ps, path: &ast::Path, colons_before_params: bool) { +pub fn print_path(s: &mut State, path: &ast::Path, colons_before_params: bool) { print_path_(s, path, colons_before_params, &None) } -pub fn print_bounded_path(s: &mut ps, path: &ast::Path, +pub fn print_bounded_path(s: &mut State, path: &ast::Path, bounds: &Option<OptVec<ast::TyParamBound>>) { print_path_(s, path, false, bounds) } -pub fn print_pat(s: &mut ps, pat: &ast::Pat) { +pub fn print_pat(s: &mut State, pat: &ast::Pat) { maybe_print_comment(s, pat.span.lo); { - let ann_node = node_pat(s, pat); + let ann_node = NodePat(s, pat); s.ann.pre(ann_node); } /* Pat isn't normalized, but the beauty of it @@ -1674,7 +1667,7 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { Some(ref args) => { if !args.is_empty() { popen(s); - commasep(s, inconsistent, *args, + commasep(s, Inconsistent, *args, |s, &p| print_pat(s, p)); pclose(s); } else { } @@ -1684,7 +1677,7 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { ast::PatStruct(ref path, ref fields, etc) => { print_path(s, path, true); word(&mut s.s, "{"); - fn print_field(s: &mut ps, f: &ast::FieldPat) { + fn print_field(s: &mut State, f: &ast::FieldPat) { cbox(s, indent_unit); print_ident(s, f.ident); word_space(s, ":"); @@ -1692,7 +1685,7 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { end(s); } fn get_span(f: &ast::FieldPat) -> codemap::Span { return f.pat.span; } - commasep_cmnt(s, consistent, *fields, + commasep_cmnt(s, Consistent, *fields, |s, f| print_field(s,f), get_span); if etc { @@ -1703,7 +1696,7 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { } ast::PatTup(ref elts) => { popen(s); - commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p)); + commasep(s, Inconsistent, *elts, |s, &p| print_pat(s, p)); if elts.len() == 1 { word(&mut s.s, ","); } @@ -1730,7 +1723,7 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { } ast::PatVec(ref before, slice, ref after) => { word(&mut s.s, "["); - commasep(s, inconsistent, *before, |s, &p| print_pat(s, p)); + commasep(s, Inconsistent, *before, |s, &p| print_pat(s, p)); for &p in slice.iter() { if !before.is_empty() { word_space(s, ","); } match p { @@ -1742,53 +1735,53 @@ pub fn print_pat(s: &mut ps, pat: &ast::Pat) { print_pat(s, p); if !after.is_empty() { word_space(s, ","); } } - commasep(s, inconsistent, *after, |s, &p| print_pat(s, p)); + commasep(s, Inconsistent, *after, |s, &p| print_pat(s, p)); word(&mut s.s, "]"); } } { - let ann_node = node_pat(s, pat); + let ann_node = NodePat(s, pat); s.ann.post(ann_node); } } -pub fn explicit_self_to_str(explicit_self: &ast::explicit_self_, intr: @ident_interner) -> ~str { +pub fn explicit_self_to_str(explicit_self: &ast::ExplicitSelf_, intr: @IdentInterner) -> ~str { to_str(explicit_self, |a, &b| { print_explicit_self(a, b); () }, intr) } // Returns whether it printed anything -pub fn print_explicit_self(s: &mut ps, explicit_self: ast::explicit_self_) -> bool { +pub fn print_explicit_self(s: &mut State, explicit_self: ast::ExplicitSelf_) -> bool { match explicit_self { - ast::sty_static => { return false; } - ast::sty_value(m) => { + ast::SelfStatic => { return false; } + ast::SelfValue(m) => { print_mutability(s, m); word(&mut s.s, "self"); } - ast::sty_uniq(m) => { + ast::SelfUniq(m) => { print_mutability(s, m); word(&mut s.s, "~self"); } - ast::sty_region(ref lt, m) => { + ast::SelfRegion(ref lt, m) => { word(&mut s.s, "&"); print_opt_lifetime(s, lt); print_mutability(s, m); word(&mut s.s, "self"); } - ast::sty_box(m) => { + ast::SelfBox(m) => { word(&mut s.s, "@"); print_mutability(s, m); word(&mut s.s, "self"); } } return true; } -pub fn print_fn(s: &mut ps, - decl: &ast::fn_decl, - purity: Option<ast::purity>, +pub fn print_fn(s: &mut State, + decl: &ast::FnDecl, + purity: Option<ast::Purity>, abis: AbiSet, name: ast::Ident, generics: &ast::Generics, - opt_explicit_self: Option<ast::explicit_self_>, - vis: ast::visibility) { + opt_explicit_self: Option<ast::ExplicitSelf_>, + vis: ast::Visibility) { head(s, ""); print_fn_header_info(s, opt_explicit_self, purity, abis, ast::Many, None, vis); nbsp(s); @@ -1797,11 +1790,11 @@ pub fn print_fn(s: &mut ps, print_fn_args_and_ret(s, decl, opt_explicit_self); } -pub fn print_fn_args(s: &mut ps, decl: &ast::fn_decl, - opt_explicit_self: Option<ast::explicit_self_>) { +pub fn print_fn_args(s: &mut State, decl: &ast::FnDecl, + opt_explicit_self: Option<ast::ExplicitSelf_>) { // It is unfortunate to duplicate the commasep logic, but we want the // self type and the args all in the same box. - rbox(s, 0u, inconsistent); + rbox(s, 0u, Inconsistent); let mut first = true; for explicit_self in opt_explicit_self.iter() { first = !print_explicit_self(s, *explicit_self); @@ -1815,8 +1808,8 @@ pub fn print_fn_args(s: &mut ps, decl: &ast::fn_decl, end(s); } -pub fn print_fn_args_and_ret(s: &mut ps, decl: &ast::fn_decl, - opt_explicit_self: Option<ast::explicit_self_>) { +pub fn print_fn_args_and_ret(s: &mut State, decl: &ast::FnDecl, + opt_explicit_self: Option<ast::ExplicitSelf_>) { popen(s); print_fn_args(s, decl, opt_explicit_self); if decl.variadic { @@ -1826,7 +1819,7 @@ pub fn print_fn_args_and_ret(s: &mut ps, decl: &ast::fn_decl, maybe_print_comment(s, decl.output.span.lo); match decl.output.node { - ast::ty_nil => {} + ast::TyNil => {} _ => { space_if_not_bol(s); word_space(s, "->"); @@ -1835,13 +1828,13 @@ pub fn print_fn_args_and_ret(s: &mut ps, decl: &ast::fn_decl, } } -pub fn print_fn_block_args(s: &mut ps, decl: &ast::fn_decl) { +pub fn print_fn_block_args(s: &mut State, decl: &ast::FnDecl) { word(&mut s.s, "|"); print_fn_args(s, decl, None); word(&mut s.s, "|"); match decl.output.node { - ast::ty_infer => {} + ast::TyInfer => {} _ => { space_if_not_bol(s); word_space(s, "->"); @@ -1852,14 +1845,14 @@ pub fn print_fn_block_args(s: &mut ps, decl: &ast::fn_decl) { maybe_print_comment(s, decl.output.span.lo); } -pub fn print_proc_args(s: &mut ps, decl: &ast::fn_decl) { +pub fn print_proc_args(s: &mut State, decl: &ast::FnDecl) { word(&mut s.s, "proc"); word(&mut s.s, "("); print_fn_args(s, decl, None); word(&mut s.s, ")"); match decl.output.node { - ast::ty_infer => {} + ast::TyInfer => {} _ => { space_if_not_bol(s); word_space(s, "->"); @@ -1870,7 +1863,7 @@ pub fn print_proc_args(s: &mut ps, decl: &ast::fn_decl) { maybe_print_comment(s, decl.output.span.lo); } -pub fn print_bounds(s: &mut ps, bounds: &OptVec<ast::TyParamBound>, +pub fn print_bounds(s: &mut State, bounds: &OptVec<ast::TyParamBound>, print_colon_anyway: bool) { if !bounds.is_empty() { word(&mut s.s, ":"); @@ -1893,16 +1886,16 @@ pub fn print_bounds(s: &mut ps, bounds: &OptVec<ast::TyParamBound>, } } -pub fn print_lifetime(s: &mut ps, lifetime: &ast::Lifetime) { +pub fn print_lifetime(s: &mut State, lifetime: &ast::Lifetime) { word(&mut s.s, "'"); print_ident(s, lifetime.ident); } -pub fn print_generics(s: &mut ps, generics: &ast::Generics) { +pub fn print_generics(s: &mut State, generics: &ast::Generics) { let total = generics.lifetimes.len() + generics.ty_params.len(); if total > 0 { word(&mut s.s, "<"); - fn print_item(s: &mut ps, generics: &ast::Generics, idx: uint) { + fn print_item(s: &mut State, generics: &ast::Generics, idx: uint) { if idx < generics.lifetimes.len() { let lifetime = generics.lifetimes.get(idx); print_lifetime(s, lifetime); @@ -1919,13 +1912,13 @@ pub fn print_generics(s: &mut ps, generics: &ast::Generics) { ints.push(i); } - commasep(s, inconsistent, ints, + commasep(s, Inconsistent, ints, |s, &i| print_item(s, generics, i)); word(&mut s.s, ">"); } } -pub fn print_meta_item(s: &mut ps, item: &ast::MetaItem) { +pub fn print_meta_item(s: &mut State, item: &ast::MetaItem) { ibox(s, indent_unit); match item.node { ast::MetaWord(name) => word(&mut s.s, name), @@ -1938,7 +1931,7 @@ pub fn print_meta_item(s: &mut ps, item: &ast::MetaItem) { word(&mut s.s, name); popen(s); commasep(s, - consistent, + Consistent, items.as_slice(), |p, &i| print_meta_item(p, i)); pclose(s); @@ -1947,9 +1940,9 @@ pub fn print_meta_item(s: &mut ps, item: &ast::MetaItem) { end(s); } -pub fn print_view_path(s: &mut ps, vp: &ast::view_path) { +pub fn print_view_path(s: &mut State, vp: &ast::ViewPath) { match vp.node { - ast::view_path_simple(ident, ref path, _) => { + ast::ViewPathSimple(ident, ref path, _) => { // FIXME(#6993) can't compare identifiers directly here if path.segments.last().identifier.name != ident.name { print_ident(s, ident); @@ -1959,19 +1952,19 @@ pub fn print_view_path(s: &mut ps, vp: &ast::view_path) { print_path(s, path, false); } - ast::view_path_glob(ref path, _) => { + ast::ViewPathGlob(ref path, _) => { print_path(s, path, false); word(&mut s.s, "::*"); } - ast::view_path_list(ref path, ref idents, _) => { + ast::ViewPathList(ref path, ref idents, _) => { if path.segments.is_empty() { word(&mut s.s, "{"); } else { print_path(s, path, false); word(&mut s.s, "::{"); } - commasep(s, inconsistent, (*idents), |s, w| { + commasep(s, Inconsistent, (*idents), |s, w| { print_ident(s, w.node.name); }); word(&mut s.s, "}"); @@ -1979,17 +1972,17 @@ pub fn print_view_path(s: &mut ps, vp: &ast::view_path) { } } -pub fn print_view_paths(s: &mut ps, vps: &[@ast::view_path]) { - commasep(s, inconsistent, vps, |p, &vp| print_view_path(p, vp)); +pub fn print_view_paths(s: &mut State, vps: &[@ast::ViewPath]) { + commasep(s, Inconsistent, vps, |p, &vp| print_view_path(p, vp)); } -pub fn print_view_item(s: &mut ps, item: &ast::view_item) { +pub fn print_view_item(s: &mut State, item: &ast::ViewItem) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); print_visibility(s, item.vis); match item.node { - ast::view_item_extern_mod(id, ref optional_path, _) => { + ast::ViewItemExternMod(id, ref optional_path, _) => { head(s, "extern mod"); print_ident(s, id); for &(ref p, style) in optional_path.iter() { @@ -2000,7 +1993,7 @@ pub fn print_view_item(s: &mut ps, item: &ast::view_item) { } } - ast::view_item_use(ref vps) => { + ast::ViewItemUse(ref vps) => { head(s, "use"); print_view_paths(s, *vps); } @@ -2010,53 +2003,53 @@ pub fn print_view_item(s: &mut ps, item: &ast::view_item) { end(s); // end outer head-block } -pub fn print_mutability(s: &mut ps, mutbl: ast::Mutability) { +pub fn print_mutability(s: &mut State, mutbl: ast::Mutability) { match mutbl { ast::MutMutable => word_nbsp(s, "mut"), ast::MutImmutable => {/* nothing */ } } } -pub fn print_mt(s: &mut ps, mt: &ast::mt) { +pub fn print_mt(s: &mut State, mt: &ast::MutTy) { print_mutability(s, mt.mutbl); print_type(s, mt.ty); } -pub fn print_arg(s: &mut ps, input: &ast::arg) { +pub fn print_arg(s: &mut State, input: &ast::Arg) { ibox(s, indent_unit); match input.ty.node { - ast::ty_infer => print_pat(s, input.pat), - _ => { - match input.pat.node { - ast::PatIdent(_, ref path, _) if - path.segments.len() == 1 && - path.segments[0].identifier.name == - parse::token::special_idents::invalid.name => { - // Do nothing. - } - _ => { - print_pat(s, input.pat); - word(&mut s.s, ":"); - space(&mut s.s); + ast::TyInfer => print_pat(s, input.pat), + _ => { + match input.pat.node { + ast::PatIdent(_, ref path, _) if + path.segments.len() == 1 && + path.segments[0].identifier.name == + parse::token::special_idents::invalid.name => { + // Do nothing. + } + _ => { + print_pat(s, input.pat); + word(&mut s.s, ":"); + space(&mut s.s); + } } + print_type(s, input.ty); } - print_type(s, input.ty); - } } end(s); } -pub fn print_ty_fn(s: &mut ps, +pub fn print_ty_fn(s: &mut State, opt_abis: Option<AbiSet>, opt_sigil: Option<ast::Sigil>, opt_region: &Option<ast::Lifetime>, - purity: ast::purity, + purity: ast::Purity, onceness: ast::Onceness, - decl: &ast::fn_decl, + decl: &ast::FnDecl, id: Option<ast::Ident>, opt_bounds: &Option<OptVec<ast::TyParamBound>>, generics: Option<&ast::Generics>, - opt_explicit_self: Option<ast::explicit_self_>) { + opt_explicit_self: Option<ast::ExplicitSelf_>) { ibox(s, indent_unit); // Duplicates the logic in `print_fn_header_info()`. This is because that @@ -2096,7 +2089,7 @@ pub fn print_ty_fn(s: &mut ps, // It is unfortunate to duplicate the commasep logic, but we want the // self type and the args all in the same box. - rbox(s, 0u, inconsistent); + rbox(s, 0u, Inconsistent); let mut first = true; for explicit_self in opt_explicit_self.iter() { first = !print_explicit_self(s, *explicit_self); @@ -2121,12 +2114,12 @@ pub fn print_ty_fn(s: &mut ps, maybe_print_comment(s, decl.output.span.lo); match decl.output.node { - ast::ty_nil => {} + ast::TyNil => {} _ => { space_if_not_bol(s); ibox(s, indent_unit); word_space(s, "->"); - if decl.cf == ast::noreturn { word_nbsp(s, "!"); } + if decl.cf == ast::NoReturn { word_nbsp(s, "!"); } else { print_type(s, decl.output); } end(s); } @@ -2135,13 +2128,13 @@ pub fn print_ty_fn(s: &mut ps, end(s); } -pub fn maybe_print_trailing_comment(s: &mut ps, span: codemap::Span, +pub fn maybe_print_trailing_comment(s: &mut State, span: codemap::Span, next_pos: Option<BytePos>) { let cm; match s.cm { Some(ccm) => cm = ccm, _ => return } match next_comment(s) { Some(ref cmnt) => { - if (*cmnt).style != comments::trailing { return; } + if (*cmnt).style != comments::Trailing { return; } let span_line = cm.lookup_char_pos(span.hi); let comment_line = cm.lookup_char_pos((*cmnt).pos); let mut next = (*cmnt).pos + BytePos(1); @@ -2156,7 +2149,7 @@ pub fn maybe_print_trailing_comment(s: &mut ps, span: codemap::Span, } } -pub fn print_remaining_comments(s: &mut ps) { +pub fn print_remaining_comments(s: &mut State) { // If there aren't any remaining comments, then we need to manually // make sure there is a line break at the end. if next_comment(s).is_none() { hardbreak(&mut s.s); } @@ -2171,7 +2164,7 @@ pub fn print_remaining_comments(s: &mut ps) { } } -pub fn print_literal(s: &mut ps, lit: &ast::lit) { +pub fn print_literal(s: &mut State, lit: &ast::Lit) { maybe_print_comment(s, lit.span.lo); match next_lit(s, lit.span.lo) { Some(ref ltrl) => { @@ -2181,14 +2174,14 @@ pub fn print_literal(s: &mut ps, lit: &ast::lit) { _ => () } match lit.node { - ast::lit_str(st, style) => print_string(s, st, style), - ast::lit_char(ch) => { + ast::LitStr(st, style) => print_string(s, st, style), + ast::LitChar(ch) => { let mut res = ~"'"; char::from_u32(ch).unwrap().escape_default(|c| res.push_char(c)); res.push_char('\''); word(&mut s.s, res); } - ast::lit_int(i, t) => { + ast::LitInt(i, t) => { if i < 0_i64 { word(&mut s.s, ~"-" + (-i as u64).to_str_radix(10u) @@ -2199,30 +2192,30 @@ pub fn print_literal(s: &mut ps, lit: &ast::lit) { + ast_util::int_ty_to_str(t)); } } - ast::lit_uint(u, t) => { + ast::LitUint(u, t) => { word(&mut s.s, u.to_str_radix(10u) + ast_util::uint_ty_to_str(t)); } - ast::lit_int_unsuffixed(i) => { + ast::LitIntUnsuffixed(i) => { if i < 0_i64 { word(&mut s.s, ~"-" + (-i as u64).to_str_radix(10u)); } else { word(&mut s.s, (i as u64).to_str_radix(10u)); } } - ast::lit_float(f, t) => { + ast::LitFloat(f, t) => { word(&mut s.s, f.to_owned() + ast_util::float_ty_to_str(t)); } - ast::lit_float_unsuffixed(f) => word(&mut s.s, f), - ast::lit_nil => word(&mut s.s, "()"), - ast::lit_bool(val) => { + ast::LitFloatUnsuffixed(f) => word(&mut s.s, f), + ast::LitNil => word(&mut s.s, "()"), + ast::LitBool(val) => { if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); } } - ast::lit_binary(arr) => { + ast::LitBinary(arr) => { ibox(s, indent_unit); word(&mut s.s, "["); - commasep_cmnt(s, inconsistent, arr, |s, u| word(&mut s.s, format!("{}", *u)), + commasep_cmnt(s, Inconsistent, arr, |s, u| word(&mut s.s, format!("{}", *u)), |_| lit.span); word(&mut s.s, "]"); end(s); @@ -2230,11 +2223,11 @@ pub fn print_literal(s: &mut ps, lit: &ast::lit) { } } -pub fn lit_to_str(l: &ast::lit) -> ~str { +pub fn lit_to_str(l: &ast::Lit) -> ~str { return to_str(l, print_literal, parse::token::mk_fake_ident_interner()); } -pub fn next_lit(s: &mut ps, pos: BytePos) -> Option<comments::lit> { +pub fn next_lit(s: &mut State, pos: BytePos) -> Option<comments::Literal> { match s.literals { Some(ref lits) => { while s.cur_cmnt_and_lit.cur_lit < lits.len() { @@ -2249,7 +2242,7 @@ pub fn next_lit(s: &mut ps, pos: BytePos) -> Option<comments::lit> { } } -pub fn maybe_print_comment(s: &mut ps, pos: BytePos) { +pub fn maybe_print_comment(s: &mut State, pos: BytePos) { loop { match next_comment(s) { Some(ref cmnt) => { @@ -2263,51 +2256,50 @@ pub fn maybe_print_comment(s: &mut ps, pos: BytePos) { } } -pub fn print_comment(s: &mut ps, cmnt: &comments::cmnt) { +pub fn print_comment(s: &mut State, cmnt: &comments::Comment) { match cmnt.style { - comments::mixed => { - assert_eq!(cmnt.lines.len(), 1u); - zerobreak(&mut s.s); - word(&mut s.s, cmnt.lines[0]); - zerobreak(&mut s.s); - } - comments::isolated => { - pprust::hardbreak_if_not_bol(s); - for line in cmnt.lines.iter() { - // Don't print empty lines because they will end up as trailing - // whitespace - if !line.is_empty() { word(&mut s.s, *line); } - hardbreak(&mut s.s); - } - } - comments::trailing => { - word(&mut s.s, " "); - if cmnt.lines.len() == 1u { + comments::Mixed => { + assert_eq!(cmnt.lines.len(), 1u); + zerobreak(&mut s.s); word(&mut s.s, cmnt.lines[0]); - hardbreak(&mut s.s); - } else { - ibox(s, 0u); + zerobreak(&mut s.s); + } + comments::Isolated => { + pprust::hardbreak_if_not_bol(s); for line in cmnt.lines.iter() { + // Don't print empty lines because they will end up as trailing + // whitespace if !line.is_empty() { word(&mut s.s, *line); } hardbreak(&mut s.s); } - end(s); } - } - comments::blank_line => { - // We need to do at least one, possibly two hardbreaks. - let is_semi = - match s.s.last_token() { - pp::STRING(s, _) => ";" == s, - _ => false + comments::Trailing => { + word(&mut s.s, " "); + if cmnt.lines.len() == 1u { + word(&mut s.s, cmnt.lines[0]); + hardbreak(&mut s.s); + } else { + ibox(s, 0u); + for line in cmnt.lines.iter() { + if !line.is_empty() { word(&mut s.s, *line); } + hardbreak(&mut s.s); + } + end(s); + } + } + comments::BlankLine => { + // We need to do at least one, possibly two hardbreaks. + let is_semi = match s.s.last_token() { + pp::String(s, _) => ";" == s, + _ => false }; - if is_semi || is_begin(s) || is_end(s) { hardbreak(&mut s.s); } - hardbreak(&mut s.s); - } + if is_semi || is_begin(s) || is_end(s) { hardbreak(&mut s.s); } + hardbreak(&mut s.s); + } } } -pub fn print_string(s: &mut ps, st: &str, style: ast::StrStyle) { +pub fn print_string(s: &mut State, st: &str, style: ast::StrStyle) { let st = match style { ast::CookedStr => format!("\"{}\"", st.escape_default()), ast::RawStr(n) => format!("r{delim}\"{string}\"{delim}", @@ -2326,7 +2318,7 @@ unsafe fn get_mem_writer(writer: &mut ~io::Writer) -> ~str { result } -pub fn to_str<T>(t: &T, f: |&mut ps, &T|, intr: @ident_interner) -> ~str { +pub fn to_str<T>(t: &T, f: |&mut State, &T|, intr: @IdentInterner) -> ~str { let wr = ~MemWriter::new(); let mut s = rust_printer(wr as ~io::Writer, intr); f(&mut s, t); @@ -2336,22 +2328,22 @@ pub fn to_str<T>(t: &T, f: |&mut ps, &T|, intr: @ident_interner) -> ~str { } } -pub fn next_comment(s: &mut ps) -> Option<comments::cmnt> { +pub fn next_comment(s: &mut State) -> Option<comments::Comment> { match s.comments { - Some(ref cmnts) => { - if s.cur_cmnt_and_lit.cur_cmnt < cmnts.len() { - return Some(cmnts[s.cur_cmnt_and_lit.cur_cmnt].clone()); - } else { - return None::<comments::cmnt>; + Some(ref cmnts) => { + if s.cur_cmnt_and_lit.cur_cmnt < cmnts.len() { + Some(cmnts[s.cur_cmnt_and_lit.cur_cmnt].clone()) + } else { + None + } } - } - _ => return None::<comments::cmnt> + _ => None } } -pub fn print_opt_purity(s: &mut ps, opt_purity: Option<ast::purity>) { +pub fn print_opt_purity(s: &mut State, opt_purity: Option<ast::Purity>) { match opt_purity { - Some(ast::impure_fn) => { } + Some(ast::ImpureFn) => { } Some(purity) => { word_nbsp(s, purity_to_str(purity)); } @@ -2359,7 +2351,7 @@ pub fn print_opt_purity(s: &mut ps, opt_purity: Option<ast::purity>) { } } -pub fn print_opt_abis_and_extern_if_nondefault(s: &mut ps, +pub fn print_opt_abis_and_extern_if_nondefault(s: &mut State, opt_abis: Option<AbiSet>) { match opt_abis { Some(abis) if !abis.is_rust() => { @@ -2370,7 +2362,7 @@ pub fn print_opt_abis_and_extern_if_nondefault(s: &mut ps, }; } -pub fn print_extern_opt_abis(s: &mut ps, opt_abis: Option<AbiSet>) { +pub fn print_extern_opt_abis(s: &mut State, opt_abis: Option<AbiSet>) { match opt_abis { Some(abis) => { word_nbsp(s, "extern"); @@ -2380,7 +2372,7 @@ pub fn print_extern_opt_abis(s: &mut ps, opt_abis: Option<AbiSet>) { }; } -pub fn print_opt_sigil(s: &mut ps, opt_sigil: Option<ast::Sigil>) { +pub fn print_opt_sigil(s: &mut State, opt_sigil: Option<ast::Sigil>) { match opt_sigil { Some(ast::BorrowedSigil) => { word(&mut s.s, "&"); } Some(ast::OwnedSigil) => { word(&mut s.s, "~"); } @@ -2389,20 +2381,20 @@ pub fn print_opt_sigil(s: &mut ps, opt_sigil: Option<ast::Sigil>) { }; } -pub fn print_fn_header_info(s: &mut ps, - _opt_explicit_self: Option<ast::explicit_self_>, - opt_purity: Option<ast::purity>, +pub fn print_fn_header_info(s: &mut State, + _opt_explicit_self: Option<ast::ExplicitSelf_>, + opt_purity: Option<ast::Purity>, abis: AbiSet, onceness: ast::Onceness, opt_sigil: Option<ast::Sigil>, - vis: ast::visibility) { + vis: ast::Visibility) { word(&mut s.s, visibility_qualified(vis, "")); if abis != AbiSet::Rust() { word_nbsp(s, "extern"); word_nbsp(s, abis.to_str()); - if opt_purity != Some(ast::extern_fn) { + if opt_purity != Some(ast::ExternFn) { print_opt_purity(s, opt_purity); } } else { @@ -2414,11 +2406,11 @@ pub fn print_fn_header_info(s: &mut ps, print_opt_sigil(s, opt_sigil); } -pub fn purity_to_str(p: ast::purity) -> &'static str { +pub fn purity_to_str(p: ast::Purity) -> &'static str { match p { - ast::impure_fn => "impure", - ast::unsafe_fn => "unsafe", - ast::extern_fn => "extern" + ast::ImpureFn => "impure", + ast::UnsafeFn => "unsafe", + ast::ExternFn => "extern" } } @@ -2429,14 +2421,14 @@ pub fn onceness_to_str(o: ast::Onceness) -> &'static str { } } -pub fn print_purity(s: &mut ps, p: ast::purity) { +pub fn print_purity(s: &mut State, p: ast::Purity) { match p { - ast::impure_fn => (), + ast::ImpureFn => (), _ => word_nbsp(s, purity_to_str(p)) } } -pub fn print_onceness(s: &mut ps, o: ast::Onceness) { +pub fn print_onceness(s: &mut State, o: ast::Onceness) { match o { ast::Once => { word_nbsp(s, "once"); } ast::Many => {} @@ -2456,16 +2448,16 @@ mod test { fn test_fun_to_str() { let abba_ident = token::str_to_ident("abba"); - let decl = ast::fn_decl { + let decl = ast::FnDecl { inputs: ~[], output: ast::P(ast::Ty {id: 0, - node: ast::ty_nil, + node: ast::TyNil, span: codemap::DUMMY_SP}), - cf: ast::return_val, + cf: ast::Return, variadic: false }; let generics = ast_util::empty_generics(); - assert_eq!(&fun_to_str(&decl, ast::impure_fn, abba_ident, + assert_eq!(&fun_to_str(&decl, ast::ImpureFn, abba_ident, None, &generics, token::get_ident_interner()), &~"fn abba()"); } @@ -2474,14 +2466,14 @@ mod test { fn test_variant_to_str() { let ident = token::str_to_ident("principal_skinner"); - let var = codemap::respan(codemap::DUMMY_SP, ast::variant_ { + let var = codemap::respan(codemap::DUMMY_SP, ast::Variant_ { name: ident, attrs: ~[], // making this up as I go.... ? - kind: ast::tuple_variant_kind(~[]), + kind: ast::TupleVariantKind(~[]), id: 0, disr_expr: None, - vis: ast::public, + vis: ast::Public, }); let varstr = variant_to_str(&var,token::get_ident_interner()); diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index dc546c7610f..5153ddf1c7d 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -15,15 +15,15 @@ use parse::{new_parser_from_source_str}; use parse::parser::Parser; use parse::token; -// map a string to tts, using a made-up filename: return both the token_trees +// map a string to tts, using a made-up filename: return both the TokenTree's // and the ParseSess -pub fn string_to_tts_and_sess (source_str : @str) -> (~[ast::token_tree],@ParseSess) { +pub fn string_to_tts_and_sess (source_str : @str) -> (~[ast::TokenTree], @ParseSess) { let ps = new_parse_sess(None); (filemap_to_tts(ps,string_to_filemap(ps,source_str,@"bogofile")),ps) } // map a string to tts, using a made-up filename: -pub fn string_to_tts(source_str : @str) -> ~[ast::token_tree] { +pub fn string_to_tts(source_str : @str) -> ~[ast::TokenTree] { let (tts,_) = string_to_tts_and_sess(source_str); tts } @@ -67,7 +67,7 @@ pub fn string_to_expr (source_str : @str) -> @ast::Expr { } // parse a string, return an item -pub fn string_to_item (source_str : @str) -> Option<@ast::item> { +pub fn string_to_item (source_str : @str) -> Option<@ast::Item> { with_error_checking_parse(source_str, |p| { p.parse_item(~[]) }) @@ -86,7 +86,7 @@ pub fn string_to_pat(source_str : @str) -> @ast::Pat { string_to_parser(source_str).parse_pat() } -// convert a vector of strings to a vector of ast::idents +// convert a vector of strings to a vector of ast::Ident's pub fn strs_to_idents(ids: ~[&str]) -> ~[ast::Ident] { ids.map(|u| token::str_to_ident(*u)) } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6484855d9d9..8e678a9bb73 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -28,34 +28,32 @@ use opt_vec::OptVec; // execute before AST node B, then A is visited first. The borrow checker in // particular relies on this property. -pub enum fn_kind<'a> { +pub enum FnKind<'a> { // fn foo() or extern "Abi" fn foo() - fk_item_fn(Ident, &'a Generics, purity, AbiSet), + FkItemFn(Ident, &'a Generics, Purity, AbiSet), // fn foo(&self) - fk_method(Ident, &'a Generics, &'a method), + FkMethod(Ident, &'a Generics, &'a Method), // |x, y| ... // proc(x, y) ... - fk_fn_block, + FkFnBlock, } -pub fn name_of_fn(fk: &fn_kind) -> Ident { +pub fn name_of_fn(fk: &FnKind) -> Ident { match *fk { - fk_item_fn(name, _, _, _) | fk_method(name, _, _) => { - name - } - fk_fn_block(..) => parse::token::special_idents::anon, + FkItemFn(name, _, _, _) | FkMethod(name, _, _) => name, + FkFnBlock(..) => parse::token::special_idents::anon } } -pub fn generics_of_fn(fk: &fn_kind) -> Generics { +pub fn generics_of_fn(fk: &FnKind) -> Generics { match *fk { - fk_item_fn(_, generics, _, _) | - fk_method(_, generics, _) => { + FkItemFn(_, generics, _, _) | + FkMethod(_, generics, _) => { (*generics).clone() } - fk_fn_block(..) => { + FkFnBlock(..) => { Generics { lifetimes: opt_vec::Empty, ty_params: opt_vec::Empty, @@ -68,10 +66,10 @@ pub trait Visitor<E: Clone> { fn visit_ident(&mut self, _sp: Span, _ident: Ident, _e: E) { /*! Visit the idents */ } - fn visit_mod(&mut self, m: &_mod, _s: Span, _n: NodeId, e: E) { walk_mod(self, m, e) } - fn visit_view_item(&mut self, i: &view_item, e: E) { walk_view_item(self, i, e) } - fn visit_foreign_item(&mut self, i: &foreign_item, e: E) { walk_foreign_item(self, i, e) } - fn visit_item(&mut self, i: &item, e: E) { walk_item(self, i, e) } + fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId, e: E) { walk_mod(self, m, e) } + fn visit_view_item(&mut self, i: &ViewItem, e: E) { walk_view_item(self, i, e) } + fn visit_foreign_item(&mut self, i: &ForeignItem, e: E) { walk_foreign_item(self, i, e) } + fn visit_item(&mut self, i: &Item, e: E) { walk_item(self, i, e) } fn visit_local(&mut self, l: &Local, e: E) { walk_local(self, l, e) } fn visit_block(&mut self, b: &Block, e: E) { walk_block(self, b, e) } fn visit_stmt(&mut self, s: &Stmt, e: E) { walk_stmt(self, s, e) } @@ -82,16 +80,16 @@ pub trait Visitor<E: Clone> { fn visit_expr_post(&mut self, _ex: &Expr, _e: E) { } fn visit_ty(&mut self, t: &Ty, e: E) { walk_ty(self, t, e) } fn visit_generics(&mut self, g: &Generics, e: E) { walk_generics(self, g, e) } - fn visit_fn(&mut self, fk: &fn_kind, fd: &fn_decl, b: &Block, s: Span, n: NodeId, e: E) { + fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, e: E) { walk_fn(self, fk, fd, b, s, n , e) } fn visit_ty_method(&mut self, t: &TypeMethod, e: E) { walk_ty_method(self, t, e) } - fn visit_trait_method(&mut self, t: &trait_method, e: E) { walk_trait_method(self, t, e) } - fn visit_struct_def(&mut self, s: &struct_def, i: Ident, g: &Generics, n: NodeId, e: E) { + fn visit_trait_method(&mut self, t: &TraitMethod, e: E) { walk_trait_method(self, t, e) } + fn visit_struct_def(&mut self, s: &StructDef, i: Ident, g: &Generics, n: NodeId, e: E) { walk_struct_def(self, s, i, g, n, e) } - fn visit_struct_field(&mut self, s: &struct_field, e: E) { walk_struct_field(self, s, e) } - fn visit_variant(&mut self, v: &variant, g: &Generics, e: E) { walk_variant(self, v, g, e) } + fn visit_struct_field(&mut self, s: &StructField, e: E) { walk_struct_field(self, s, e) } + fn visit_variant(&mut self, v: &Variant, g: &Generics, e: E) { walk_variant(self, v, g, e) } fn visit_opt_lifetime_ref(&mut self, _span: Span, opt_lifetime: &Option<Lifetime>, @@ -112,10 +110,10 @@ pub trait Visitor<E: Clone> { fn visit_lifetime_decl(&mut self, _lifetime: &Lifetime, _e: E) { /*! Visits a declaration of a lifetime */ } - fn visit_explicit_self(&mut self, es: &explicit_self, e: E) { + fn visit_explicit_self(&mut self, es: &ExplicitSelf, e: E) { walk_explicit_self(self, es, e) } - fn visit_mac(&mut self, macro: &mac, e: E) { + fn visit_mac(&mut self, macro: &Mac, e: E) { walk_mac(self, macro, e) } fn visit_path(&mut self, path: &Path, _id: ast::NodeId, e: E) { @@ -127,7 +125,7 @@ pub fn walk_crate<E: Clone, V: Visitor<E>>(visitor: &mut V, crate: &Crate, env: visitor.visit_mod(&crate.module, crate.span, CRATE_NODE_ID, env) } -pub fn walk_mod<E: Clone, V: Visitor<E>>(visitor: &mut V, module: &_mod, env: E) { +pub fn walk_mod<E: Clone, V: Visitor<E>>(visitor: &mut V, module: &Mod, env: E) { for view_item in module.view_items.iter() { visitor.visit_view_item(view_item, env.clone()) } @@ -137,22 +135,22 @@ pub fn walk_mod<E: Clone, V: Visitor<E>>(visitor: &mut V, module: &_mod, env: E) } } -pub fn walk_view_item<E: Clone, V: Visitor<E>>(visitor: &mut V, vi: &view_item, env: E) { +pub fn walk_view_item<E: Clone, V: Visitor<E>>(visitor: &mut V, vi: &ViewItem, env: E) { match vi.node { - view_item_extern_mod(name, _, _) => { + ViewItemExternMod(name, _, _) => { visitor.visit_ident(vi.span, name, env) } - view_item_use(ref paths) => { + ViewItemUse(ref paths) => { for vp in paths.iter() { match vp.node { - view_path_simple(ident, ref path, id) => { + ViewPathSimple(ident, ref path, id) => { visitor.visit_ident(vp.span, ident, env.clone()); visitor.visit_path(path, id, env.clone()); } - view_path_glob(ref path, id) => { + ViewPathGlob(ref path, id) => { visitor.visit_path(path, id, env.clone()); } - view_path_list(ref path, ref list, _) => { + ViewPathList(ref path, ref list, _) => { for id in list.iter() { visitor.visit_ident(id.span, id.node.name, env.clone()) } @@ -174,42 +172,41 @@ pub fn walk_local<E: Clone, V: Visitor<E>>(visitor: &mut V, local: &Local, env: } fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V, - explicit_self: &explicit_self, + explicit_self: &ExplicitSelf, env: E) { match explicit_self.node { - sty_static | sty_value(_) | sty_box(_) | sty_uniq(_) => { - } - sty_region(ref lifetime, _) => { + SelfStatic | SelfValue(_) | SelfBox(_) | SelfUniq(_) => {} + SelfRegion(ref lifetime, _) => { visitor.visit_opt_lifetime_ref(explicit_self.span, lifetime, env) } } } fn walk_trait_ref<E: Clone, V: Visitor<E>>(visitor: &mut V, - trait_ref: &trait_ref, + trait_ref: &TraitRef, env: E) { visitor.visit_path(&trait_ref.path, trait_ref.ref_id, env) } -pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &item, env: E) { +pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E) { visitor.visit_ident(item.span, item.ident, env.clone()); match item.node { - item_static(typ, _, expr) => { + ItemStatic(typ, _, expr) => { visitor.visit_ty(typ, env.clone()); visitor.visit_expr(expr, env); } - item_fn(declaration, purity, abi, ref generics, body) => { - visitor.visit_fn(&fk_item_fn(item.ident, generics, purity, abi), + ItemFn(declaration, purity, abi, ref generics, body) => { + visitor.visit_fn(&FkItemFn(item.ident, generics, purity, abi), declaration, body, item.span, item.id, env) } - item_mod(ref module) => { + ItemMod(ref module) => { visitor.visit_mod(module, item.span, item.id, env) } - item_foreign_mod(ref foreign_module) => { + ItemForeignMod(ref foreign_module) => { for view_item in foreign_module.view_items.iter() { visitor.visit_view_item(view_item, env.clone()) } @@ -217,15 +214,15 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &item, env: E) visitor.visit_foreign_item(*foreign_item, env.clone()) } } - item_ty(typ, ref type_parameters) => { + ItemTy(typ, ref type_parameters) => { visitor.visit_ty(typ, env.clone()); visitor.visit_generics(type_parameters, env) } - item_enum(ref enum_definition, ref type_parameters) => { + ItemEnum(ref enum_definition, ref type_parameters) => { visitor.visit_generics(type_parameters, env.clone()); walk_enum_def(visitor, enum_definition, type_parameters, env) } - item_impl(ref type_parameters, + ItemImpl(ref type_parameters, ref trait_references, typ, ref methods) => { @@ -238,7 +235,7 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &item, env: E) walk_method_helper(visitor, *method, env.clone()) } } - item_struct(struct_definition, ref generics) => { + ItemStruct(struct_definition, ref generics) => { visitor.visit_generics(generics, env.clone()); visitor.visit_struct_def(struct_definition, item.ident, @@ -246,7 +243,7 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &item, env: E) item.id, env) } - item_trait(ref generics, ref trait_paths, ref methods) => { + ItemTrait(ref generics, ref trait_paths, ref methods) => { visitor.visit_generics(generics, env.clone()); for trait_path in trait_paths.iter() { visitor.visit_path(&trait_path.path, @@ -257,12 +254,12 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &item, env: E) visitor.visit_trait_method(method, env.clone()) } } - item_mac(ref macro) => visitor.visit_mac(macro, env), + ItemMac(ref macro) => visitor.visit_mac(macro, env), } } pub fn walk_enum_def<E: Clone, V:Visitor<E>>(visitor: &mut V, - enum_definition: &enum_def, + enum_definition: &EnumDef, generics: &Generics, env: E) { for &variant in enum_definition.variants.iter() { @@ -271,18 +268,18 @@ pub fn walk_enum_def<E: Clone, V:Visitor<E>>(visitor: &mut V, } pub fn walk_variant<E: Clone, V: Visitor<E>>(visitor: &mut V, - variant: &variant, + variant: &Variant, generics: &Generics, env: E) { visitor.visit_ident(variant.span, variant.node.name, env.clone()); match variant.node.kind { - tuple_variant_kind(ref variant_arguments) => { + TupleVariantKind(ref variant_arguments) => { for variant_argument in variant_arguments.iter() { visitor.visit_ty(variant_argument.ty, env.clone()) } } - struct_variant_kind(struct_definition) => { + StructVariantKind(struct_definition) => { visitor.visit_struct_def(struct_definition, variant.node.name, generics, @@ -302,22 +299,22 @@ pub fn skip_ty<E, V: Visitor<E>>(_: &mut V, _: &Ty, _: E) { pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) { match typ.node { - ty_uniq(ty) | ty_vec(ty) | ty_box(ty) => { + TyUniq(ty) | TyVec(ty) | TyBox(ty) => { visitor.visit_ty(ty, env) } - ty_ptr(ref mutable_type) => { + TyPtr(ref mutable_type) => { visitor.visit_ty(mutable_type.ty, env) } - ty_rptr(ref lifetime, ref mutable_type) => { + TyRptr(ref lifetime, ref mutable_type) => { visitor.visit_opt_lifetime_ref(typ.span, lifetime, env.clone()); visitor.visit_ty(mutable_type.ty, env) } - ty_tup(ref tuple_element_types) => { + TyTup(ref tuple_element_types) => { for &tuple_element_type in tuple_element_types.iter() { visitor.visit_ty(tuple_element_type, env.clone()) } } - ty_closure(ref function_declaration) => { + TyClosure(ref function_declaration) => { for argument in function_declaration.decl.inputs.iter() { visitor.visit_ty(argument.ty, env.clone()) } @@ -332,7 +329,7 @@ pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) { walk_lifetime_decls(visitor, &function_declaration.lifetimes, env.clone()); } - ty_bare_fn(ref function_declaration) => { + TyBareFn(ref function_declaration) => { for argument in function_declaration.decl.inputs.iter() { visitor.visit_ty(argument.ty, env.clone()) } @@ -340,20 +337,20 @@ pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) { walk_lifetime_decls(visitor, &function_declaration.lifetimes, env.clone()); } - ty_path(ref path, ref bounds, id) => { + TyPath(ref path, ref bounds, id) => { visitor.visit_path(path, id, env.clone()); for bounds in bounds.iter() { walk_ty_param_bounds(visitor, bounds, env.clone()) } } - ty_fixed_length_vec(ty, expression) => { + TyFixedLengthVec(ty, expression) => { visitor.visit_ty(ty, env.clone()); visitor.visit_expr(expression, env) } - ty_typeof(expression) => { + TyTypeof(expression) => { visitor.visit_expr(expression, env) } - ty_nil | ty_bot | ty_infer => () + TyNil | TyBot | TyInfer => {} } } @@ -432,16 +429,16 @@ pub fn walk_pat<E: Clone, V: Visitor<E>>(visitor: &mut V, pattern: &Pat, env: E) } pub fn walk_foreign_item<E: Clone, V: Visitor<E>>(visitor: &mut V, - foreign_item: &foreign_item, + foreign_item: &ForeignItem, env: E) { visitor.visit_ident(foreign_item.span, foreign_item.ident, env.clone()); match foreign_item.node { - foreign_item_fn(function_declaration, ref generics) => { + ForeignItemFn(function_declaration, ref generics) => { walk_fn_decl(visitor, function_declaration, env.clone()); visitor.visit_generics(generics, env) } - foreign_item_static(typ, _) => visitor.visit_ty(typ, env), + ForeignItemStatic(typ, _) => visitor.visit_ty(typ, env), } } @@ -468,7 +465,7 @@ pub fn walk_generics<E: Clone, V: Visitor<E>>(visitor: &mut V, } pub fn walk_fn_decl<E: Clone, V: Visitor<E>>(visitor: &mut V, - function_declaration: &fn_decl, + function_declaration: &FnDecl, env: E) { for argument in function_declaration.inputs.iter() { visitor.visit_pat(argument.pat, env.clone()); @@ -478,14 +475,14 @@ pub fn walk_fn_decl<E: Clone, V: Visitor<E>>(visitor: &mut V, } // Note: there is no visit_method() method in the visitor, instead override -// visit_fn() and check for fk_method(). I named this visit_method_helper() +// visit_fn() and check for FkMethod(). I named this visit_method_helper() // because it is not a default impl of any method, though I doubt that really // clarifies anything. - Niko pub fn walk_method_helper<E: Clone, V: Visitor<E>>(visitor: &mut V, - method: &method, + method: &Method, env: E) { visitor.visit_ident(method.span, method.ident, env.clone()); - visitor.visit_fn(&fk_method(method.ident, &method.generics, method), + visitor.visit_fn(&FkMethod(method.ident, &method.generics, method), method.decl, method.body, method.span, @@ -494,8 +491,8 @@ pub fn walk_method_helper<E: Clone, V: Visitor<E>>(visitor: &mut V, } pub fn walk_fn<E: Clone, V: Visitor<E>>(visitor: &mut V, - function_kind: &fn_kind, - function_declaration: &fn_decl, + function_kind: &FnKind, + function_declaration: &FnDecl, function_body: &Block, _span: Span, _: NodeId, @@ -503,16 +500,15 @@ pub fn walk_fn<E: Clone, V: Visitor<E>>(visitor: &mut V, walk_fn_decl(visitor, function_declaration, env.clone()); match *function_kind { - fk_item_fn(_, generics, _, _) => { + FkItemFn(_, generics, _, _) => { visitor.visit_generics(generics, env.clone()); } - fk_method(_, generics, method) => { + FkMethod(_, generics, method) => { visitor.visit_generics(generics, env.clone()); visitor.visit_explicit_self(&method.explicit_self, env.clone()); } - fk_fn_block(..) => { - } + FkFnBlock(..) => {} } visitor.visit_block(function_body, env) @@ -531,18 +527,18 @@ pub fn walk_ty_method<E: Clone, V: Visitor<E>>(visitor: &mut V, } pub fn walk_trait_method<E: Clone, V: Visitor<E>>(visitor: &mut V, - trait_method: &trait_method, + trait_method: &TraitMethod, env: E) { match *trait_method { - required(ref method_type) => { + Required(ref method_type) => { visitor.visit_ty_method(method_type, env) } - provided(method) => walk_method_helper(visitor, method, env), + Provided(method) => walk_method_helper(visitor, method, env), } } pub fn walk_struct_def<E: Clone, V: Visitor<E>>(visitor: &mut V, - struct_definition: &struct_def, + struct_definition: &StructDef, _: Ident, _: &Generics, _: NodeId, @@ -553,10 +549,10 @@ pub fn walk_struct_def<E: Clone, V: Visitor<E>>(visitor: &mut V, } pub fn walk_struct_field<E: Clone, V: Visitor<E>>(visitor: &mut V, - struct_field: &struct_field, + struct_field: &StructField, env: E) { match struct_field.node.kind { - named_field(name, _) => { + NamedField(name, _) => { visitor.visit_ident(struct_field.span, name, env.clone()) } _ => {} @@ -609,7 +605,7 @@ pub fn walk_exprs<E: Clone, V: Visitor<E>>(visitor: &mut V, } } -pub fn walk_mac<E, V: Visitor<E>>(_: &mut V, _: &mac, _: E) { +pub fn walk_mac<E, V: Visitor<E>>(_: &mut V, _: &Mac, _: E) { // Empty! } @@ -686,7 +682,7 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en } } ExprFnBlock(function_declaration, body) => { - visitor.visit_fn(&fk_fn_block, + visitor.visit_fn(&FkFnBlock, function_declaration, body, expression.span, @@ -694,7 +690,7 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en env.clone()) } ExprProc(function_declaration, body) => { - visitor.visit_fn(&fk_fn_block, + visitor.visit_fn(&FkFnBlock, function_declaration, body, expression.span, |
