From 74190853373c7963d933e2fb5c2ac2f761fdbc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Mon, 2 Sep 2013 03:45:37 +0200 Subject: [PATCH] Modernized a few more types in syntax::ast --- src/librustc/front/config.rs | 8 +- src/librustc/front/test.rs | 30 +- src/librustc/metadata/csearch.rs | 70 +-- src/librustc/metadata/decoder.rs | 94 ++-- src/librustc/metadata/encoder.rs | 30 +- src/librustc/metadata/tydecode.rs | 14 +- src/librustc/metadata/tyencode.rs | 8 +- src/librustc/middle/astencode.rs | 116 ++--- src/librustc/middle/borrowck/check_loans.rs | 58 +-- .../borrowck/gather_loans/gather_moves.rs | 6 +- .../middle/borrowck/gather_loans/lifetime.rs | 10 +- .../middle/borrowck/gather_loans/mod.rs | 52 +- .../borrowck/gather_loans/restrictions.rs | 10 +- src/librustc/middle/borrowck/mod.rs | 26 +- src/librustc/middle/borrowck/move_data.rs | 6 +- src/librustc/middle/cfg/construct.rs | 148 +++--- src/librustc/middle/check_const.rs | 78 +-- src/librustc/middle/check_loop.rs | 14 +- src/librustc/middle/check_match.rs | 146 +++--- src/librustc/middle/const_eval.rs | 206 ++++---- src/librustc/middle/dataflow.rs | 112 ++-- src/librustc/middle/effect.rs | 20 +- src/librustc/middle/freevars.rs | 10 +- src/librustc/middle/kind.rs | 34 +- src/librustc/middle/lang_items.rs | 98 ++-- src/librustc/middle/lint.rs | 84 +-- src/librustc/middle/liveness.rs | 196 +++---- src/librustc/middle/mem_categorization.rs | 166 +++--- src/librustc/middle/moves.rs | 112 ++-- src/librustc/middle/pat_util.rs | 34 +- src/librustc/middle/privacy.rs | 50 +- src/librustc/middle/reachable.rs | 8 +- src/librustc/middle/region.rs | 40 +- src/librustc/middle/resolve.rs | 318 ++++++------ src/librustc/middle/stack_check.rs | 12 +- src/librustc/middle/trans/_match.rs | 198 +++---- src/librustc/middle/trans/asm.rs | 2 +- src/librustc/middle/trans/base.rs | 84 +-- src/librustc/middle/trans/callee.rs | 70 +-- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/common.rs | 22 +- src/librustc/middle/trans/consts.rs | 116 ++--- src/librustc/middle/trans/context.rs | 12 +- src/librustc/middle/trans/controlflow.rs | 22 +- src/librustc/middle/trans/datum.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 120 ++--- src/librustc/middle/trans/expr.rs | 256 ++++----- src/librustc/middle/trans/glue.rs | 8 +- src/librustc/middle/trans/inline.rs | 4 +- src/librustc/middle/trans/meth.rs | 24 +- src/librustc/middle/trans/monomorphize.rs | 4 +- src/librustc/middle/trans/reflect.rs | 7 +- src/librustc/middle/trans/tvec.rs | 40 +- src/librustc/middle/trans/type_of.rs | 2 +- src/librustc/middle/trans/type_use.rs | 56 +- src/librustc/middle/ty.rs | 402 +++++++-------- src/librustc/middle/typeck/astconv.rs | 34 +- src/librustc/middle/typeck/check/_match.rs | 68 +-- src/librustc/middle/typeck/check/demand.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 62 +-- src/librustc/middle/typeck/check/mod.rs | 338 ++++++------ src/librustc/middle/typeck/check/regionck.rs | 206 ++++---- src/librustc/middle/typeck/check/vtable.rs | 36 +- src/librustc/middle/typeck/check/writeback.rs | 20 +- src/librustc/middle/typeck/coherence.rs | 32 +- src/librustc/middle/typeck/collect.rs | 14 +- src/librustc/middle/typeck/infer/coercion.rs | 6 +- src/librustc/middle/typeck/infer/glb.rs | 16 +- src/librustc/middle/typeck/infer/lub.rs | 4 +- src/librustc/middle/typeck/infer/mod.rs | 6 +- src/librustc/middle/typeck/infer/sub.rs | 4 +- src/librustc/middle/typeck/mod.rs | 16 +- src/librustc/util/common.rs | 18 +- src/librustc/util/ppaux.rs | 30 +- src/librusti/program.rs | 10 +- src/librusti/rusti.rs | 8 +- src/librusti/utils.rs | 4 +- src/libsyntax/ast.rs | 326 ++++++------ src/libsyntax/ast_map.rs | 32 +- src/libsyntax/ast_util.rs | 298 +++++------ src/libsyntax/ext/asm.rs | 8 +- src/libsyntax/ext/base.rs | 12 +- src/libsyntax/ext/build.rs | 364 ++++++------- src/libsyntax/ext/bytes.rs | 2 +- src/libsyntax/ext/concat_idents.rs | 4 +- src/libsyntax/ext/deriving/clone.rs | 4 +- src/libsyntax/ext/deriving/cmp/eq.rs | 6 +- src/libsyntax/ext/deriving/cmp/ord.rs | 12 +- src/libsyntax/ext/deriving/cmp/totaleq.rs | 4 +- src/libsyntax/ext/deriving/cmp/totalord.rs | 6 +- src/libsyntax/ext/deriving/decodable.rs | 6 +- src/libsyntax/ext/deriving/encodable.rs | 8 +- src/libsyntax/ext/deriving/generic.rs | 118 ++--- src/libsyntax/ext/deriving/iter_bytes.rs | 6 +- src/libsyntax/ext/deriving/rand.rs | 12 +- src/libsyntax/ext/deriving/to_str.rs | 8 +- src/libsyntax/ext/deriving/ty.rs | 10 +- src/libsyntax/ext/deriving/zero.rs | 4 +- src/libsyntax/ext/expand.rs | 102 ++-- src/libsyntax/ext/fmt.rs | 26 +- src/libsyntax/ext/ifmt.rs | 32 +- src/libsyntax/ext/log_syntax.rs | 4 +- src/libsyntax/ext/quote.rs | 34 +- src/libsyntax/ext/source_util.rs | 2 +- src/libsyntax/fold.rs | 228 ++++----- src/libsyntax/oldvisit.rs | 144 +++--- src/libsyntax/parse/classify.rs | 40 +- src/libsyntax/parse/mod.rs | 38 +- src/libsyntax/parse/obsolete.rs | 8 +- src/libsyntax/parse/parser.rs | 484 +++++++++--------- src/libsyntax/parse/token.rs | 44 +- src/libsyntax/print/pprust.rs | 202 ++++---- src/libsyntax/util/parser_testing.rs | 6 +- src/libsyntax/visit.rs | 156 +++--- 114 files changed, 3808 insertions(+), 3803 deletions(-) diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 026532c89c329..2a5c3ae0f4f05 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -116,12 +116,12 @@ fn fold_item_underscore(cx: @Context, item: &ast::item_, fold::noop_fold_item_underscore(&item, fld) } -fn filter_stmt(cx: @Context, stmt: @ast::stmt) -> - Option<@ast::stmt> { +fn filter_stmt(cx: @Context, stmt: @ast::Stmt) -> + Option<@ast::Stmt> { match stmt.node { - ast::stmt_decl(decl, _) => { + ast::StmtDecl(decl, _) => { match decl.node { - ast::decl_item(item) => { + ast::DeclItem(item) => { if item_in_cfg(cx, item) { option::Some(stmt) } else { option::None } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index e0914bcec6eaa..63491c3d41395 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -441,7 +441,7 @@ fn is_extra(cx: &TestCtxt) -> bool { } } -fn mk_test_descs(cx: &TestCtxt) -> @ast::expr { +fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr { debug!("building test vector from %u tests", cx.testfns.len()); let mut descs = ~[]; for test in cx.testfns.iter() { @@ -449,21 +449,21 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::expr { } let sess = cx.sess; - let inner_expr = @ast::expr { + let inner_expr = @ast::Expr { id: sess.next_node_id(), - node: ast::expr_vec(descs, ast::m_imm), + node: ast::ExprVec(descs, ast::MutImmutable), span: dummy_sp(), }; - @ast::expr { + @ast::Expr { id: sess.next_node_id(), - node: ast::expr_vstore(inner_expr, ast::expr_vstore_slice), + node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice), span: dummy_sp(), } } #[cfg(stage0)] -fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { +fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr { let span = test.span; let path = test.path.clone(); @@ -474,17 +474,17 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { let name_lit: ast::lit = nospan(ast::lit_str(ast_util::path_name_i(path).to_managed())); - let name_expr = @ast::expr { + let name_expr = @ast::Expr { id: cx.sess.next_node_id(), - node: ast::expr_lit(@name_lit), + node: ast::ExprLit(@name_lit), span: span }; let fn_path = path_node_global(path); - let fn_expr = @ast::expr { + let fn_expr = @ast::Expr { id: cx.sess.next_node_id(), - node: ast::expr_path(fn_path), + node: ast::ExprPath(fn_path), span: span, }; @@ -519,7 +519,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { e } #[cfg(not(stage0))] -fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { +fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr { let span = test.span; let path = test.path.clone(); @@ -528,17 +528,17 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { let name_lit: ast::lit = nospan(ast::lit_str(ast_util::path_name_i(path).to_managed())); - let name_expr = @ast::expr { + let name_expr = @ast::Expr { id: cx.sess.next_node_id(), - node: ast::expr_lit(@name_lit), + node: ast::ExprLit(@name_lit), span: span }; let fn_path = path_node_global(path); - let fn_expr = @ast::expr { + let fn_expr = @ast::Expr { id: cx.sess.next_node_id(), - node: ast::expr_path(fn_path), + node: ast::ExprPath(fn_path), span: span, }; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index a1a07d8bf3f84..bc7cba46c6b1d 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -26,16 +26,16 @@ use syntax::diagnostic::expect; pub struct StaticMethodInfo { ident: ast::Ident, - def_id: ast::def_id, + def_id: ast::DefId, purity: ast::purity } -pub fn get_symbol(cstore: @mut cstore::CStore, def: ast::def_id) -> ~str { +pub fn get_symbol(cstore: @mut cstore::CStore, def: ast::DefId) -> ~str { let cdata = cstore::get_crate_data(cstore, def.crate).data; return decoder::get_symbol(cdata, def.node); } -pub fn get_type_param_count(cstore: @mut cstore::CStore, def: ast::def_id) +pub fn get_type_param_count(cstore: @mut cstore::CStore, def: ast::DefId) -> uint { let cdata = cstore::get_crate_data(cstore, def.crate).data; return decoder::get_type_param_count(cdata, def.node); @@ -51,7 +51,7 @@ pub fn each_lang_item(cstore: @mut cstore::CStore, /// Iterates over each child of the given item. pub fn each_child_of_item(cstore: @mut cstore::CStore, - def_id: ast::def_id, + def_id: ast::DefId, callback: &fn(decoder::DefLike, ast::Ident)) { let crate_data = cstore::get_crate_data(cstore, def_id.crate); let get_crate_data: decoder::GetCrateDataCb = |cnum| { @@ -79,7 +79,7 @@ pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore, callback) } -pub fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> 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(cstore, def.crate); let path = decoder::get_item_path(cdata, def.node); @@ -92,14 +92,14 @@ pub fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path { pub enum found_ast { found(ast::inlined_item), - found_parent(ast::def_id, ast::inlined_item), + found_parent(ast::DefId, ast::inlined_item), not_found, } // Finds the AST for this item in the crate metadata, if any. If the item was // not marked for inlining, then the AST will not be present and hence none // will be returned. -pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::def_id, +pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::DefId, decode_inlined_item: decoder::decode_inlined_item) -> found_ast { let cstore = tcx.cstore; @@ -108,7 +108,7 @@ pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::def_id, decode_inlined_item) } -pub fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) +pub fn get_enum_variants(tcx: ty::ctxt, def: ast::DefId) -> ~[@ty::VariantInfo] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); @@ -116,19 +116,19 @@ pub fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) } /// Returns information about the given implementation. -pub fn get_impl(tcx: ty::ctxt, impl_def_id: ast::def_id) +pub fn get_impl(tcx: ty::ctxt, impl_def_id: ast::DefId) -> ty::Impl { let cdata = cstore::get_crate_data(tcx.cstore, impl_def_id.crate); decoder::get_impl(tcx.cstore.intr, cdata, impl_def_id.node, tcx) } -pub fn get_method(tcx: ty::ctxt, def: ast::def_id) -> ty::Method { +pub fn get_method(tcx: ty::ctxt, def: ast::DefId) -> ty::Method { let cdata = cstore::get_crate_data(tcx.cstore, def.crate); decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx) } pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore, - def: ast::def_id) + def: ast::DefId) -> (ast::Ident, ast::explicit_self_) { let cdata = cstore::get_crate_data(cstore, def.crate); @@ -136,74 +136,74 @@ pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore, } pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore, - def: ast::def_id) -> ~[ast::def_id] { + def: ast::DefId) -> ~[ast::DefId] { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_trait_method_def_ids(cdata, def.node) } pub fn get_provided_trait_methods(tcx: ty::ctxt, - def: ast::def_id) + def: ast::DefId) -> ~[@ty::Method] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx) } -pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[@ty::TraitRef] { +pub fn get_supertraits(tcx: ty::ctxt, def: ast::DefId) -> ~[@ty::TraitRef] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_supertraits(cdata, def.node, tcx) } -pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::def_id) +pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::DefId) -> Option { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_type_name_if_impl(cdata, def.node) } pub fn get_static_methods_if_impl(cstore: @mut cstore::CStore, - def: ast::def_id) + def: ast::DefId) -> Option<~[StaticMethodInfo]> { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_static_methods_if_impl(cstore.intr, cdata, def.node) } pub fn get_item_attrs(cstore: @mut cstore::CStore, - def_id: ast::def_id, + def_id: ast::DefId, f: &fn(~[@ast::MetaItem])) { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::get_item_attrs(cdata, def_id.node, f) } pub fn get_struct_fields(cstore: @mut cstore::CStore, - def: ast::def_id) + def: ast::DefId) -> ~[ty::field_ty] { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_struct_fields(cstore.intr, cdata, def.node) } pub fn get_type(tcx: ty::ctxt, - def: ast::def_id) + def: ast::DefId) -> ty::ty_param_bounds_and_ty { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_type(cdata, def.node, tcx) } -pub fn get_trait_def(tcx: ty::ctxt, def: ast::def_id) -> ty::TraitDef { +pub fn get_trait_def(tcx: ty::ctxt, def: ast::DefId) -> ty::TraitDef { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_trait_def(cdata, def.node, tcx) } pub fn get_region_param(cstore: @mut metadata::cstore::CStore, - def: ast::def_id) -> Option { + def: ast::DefId) -> Option { let cdata = cstore::get_crate_data(cstore, def.crate); return decoder::get_region_param(cdata, def.node); } -pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, - def: ast::def_id) -> ty::ty_param_bounds_and_ty { +pub fn get_field_type(tcx: ty::ctxt, class_id: ast::DefId, + def: ast::DefId) -> ty::ty_param_bounds_and_ty { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, class_id.crate); let all_items = reader::get_doc(reader::Doc(cdata.data), tag_items); @@ -229,7 +229,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, // Given a def_id for an impl, return the trait it implements, // if there is one. pub fn get_impl_trait(tcx: ty::ctxt, - def: ast::def_id) -> Option<@ty::TraitRef> { + def: ast::DefId) -> Option<@ty::TraitRef> { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_impl_trait(cdata, def.node, tcx) @@ -237,22 +237,22 @@ pub fn get_impl_trait(tcx: ty::ctxt, // Given a def_id for an impl, return information about its vtables pub fn get_impl_vtables(tcx: ty::ctxt, - def: ast::def_id) -> typeck::impl_res { + def: ast::DefId) -> typeck::impl_res { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_impl_vtables(cdata, def.node, tcx) } pub fn get_impl_method(cstore: @mut cstore::CStore, - def: ast::def_id, + def: ast::DefId, mname: ast::Ident) - -> Option { + -> Option { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_impl_method(cstore.intr, cdata, def.node, mname) } pub fn get_item_visibility(cstore: @mut cstore::CStore, - def_id: ast::def_id) + def_id: ast::DefId) -> ast::visibility { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::get_item_visibility(cdata, def_id.node) @@ -267,21 +267,21 @@ pub fn get_link_args_for_crate(cstore: @mut cstore::CStore, pub fn each_impl(cstore: @mut cstore::CStore, crate_num: ast::CrateNum, - callback: &fn(ast::def_id)) { + callback: &fn(ast::DefId)) { let cdata = cstore::get_crate_data(cstore, crate_num); decoder::each_impl(cdata, callback) } pub fn each_implementation_for_type(cstore: @mut cstore::CStore, - def_id: ast::def_id, - callback: &fn(ast::def_id)) { + def_id: ast::DefId, + callback: &fn(ast::DefId)) { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::each_implementation_for_type(cdata, def_id.node, callback) } pub fn each_implementation_for_trait(cstore: @mut cstore::CStore, - def_id: ast::def_id, - callback: &fn(ast::def_id)) { + def_id: ast::DefId, + callback: &fn(ast::DefId)) { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::each_implementation_for_trait(cdata, def_id.node, callback) } @@ -290,9 +290,9 @@ pub fn each_implementation_for_trait(cstore: @mut cstore::CStore, /// default method or an implementation of a trait method), returns the ID of /// the trait that the method belongs to. Otherwise, returns `None`. pub fn get_trait_of_method(cstore: @mut cstore::CStore, - def_id: ast::def_id, + def_id: ast::DefId, tcx: ty::ctxt) - -> Option { + -> Option { let cdata = cstore::get_crate_data(cstore, def_id.crate); decoder::get_trait_of_method(cdata, def_id.node, tcx) } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 0200ca49bad9a..c15327f4e2115 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -177,7 +177,7 @@ fn item_symbol(item: ebml::Doc) -> ~str { reader::get_doc(item, tag_items_data_item_symbol).as_str() } -fn item_parent_item(d: ebml::Doc) -> Option { +fn item_parent_item(d: ebml::Doc) -> Option { let mut ret = None; do reader::tagged_docs(d, tag_items_data_parent_item) |did| { ret = Some(reader::with_doc_data(did, parse_def_id)); @@ -187,17 +187,17 @@ fn item_parent_item(d: ebml::Doc) -> Option { } fn item_reqd_and_translated_parent_item(cnum: ast::CrateNum, - d: ebml::Doc) -> ast::def_id { + d: ebml::Doc) -> ast::DefId { let trait_did = item_parent_item(d).expect("item without parent"); - ast::def_id { crate: cnum, node: trait_did.node } + ast::DefId { crate: cnum, node: trait_did.node } } -fn item_def_id(d: ebml::Doc, cdata: Cmd) -> ast::def_id { +fn item_def_id(d: ebml::Doc, cdata: Cmd) -> ast::DefId { let tagdoc = reader::get_doc(d, tag_def_id); return translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id)); } -fn get_provided_source(d: ebml::Doc, cdata: Cmd) -> Option { +fn get_provided_source(d: ebml::Doc, cdata: Cmd) -> Option { do reader::maybe_get_doc(d, tag_item_method_provided_source).map_move |doc| { translate_def_id(cdata, reader::with_doc_data(doc, parse_def_id)) } @@ -235,7 +235,7 @@ fn doc_transformed_self_ty(doc: ebml::Doc, } } -pub fn item_type(_item_id: ast::def_id, item: ebml::Doc, +pub fn item_type(_item_id: ast::DefId, item: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::t { doc_type(item, tcx, cdata) } @@ -278,12 +278,12 @@ fn item_ty_param_count(item: ebml::Doc) -> uint { n } -fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> ~[ast::def_id] { - let mut ids: ~[ast::def_id] = ~[]; +fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> ~[ast::DefId] { + let mut ids: ~[ast::DefId] = ~[]; let v = tag_items_data_item_variant; do reader::tagged_docs(item, v) |p| { let ext = reader::with_doc_data(p, parse_def_id); - ids.push(ast::def_id { crate: cdata.cnum, node: ext.node }); + ids.push(ast::DefId { crate: cdata.cnum, node: ext.node }); true }; return ids; @@ -321,16 +321,16 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::Ident { } } -fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum) +fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum) -> DefLike { let fam = item_family(item); match fam { - ImmStatic => DlDef(ast::def_static(did, false)), - MutStatic => DlDef(ast::def_static(did, true)), - Struct => DlDef(ast::def_struct(did)), - UnsafeFn => DlDef(ast::def_fn(did, ast::unsafe_fn)), - Fn => DlDef(ast::def_fn(did, ast::impure_fn)), - ForeignFn => DlDef(ast::def_fn(did, ast::extern_fn)), + 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)), StaticMethod | UnsafeStaticMethod => { let purity = if fam == UnsafeStaticMethod { ast::unsafe_fn } else { ast::impure_fn }; @@ -347,26 +347,26 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum) ast::FromImpl(item_reqd_and_translated_parent_item(cnum, item)) }; - DlDef(ast::def_static_method(did, provenance, purity)) + DlDef(ast::DefStaticMethod(did, provenance, purity)) } - Type | ForeignType => DlDef(ast::def_ty(did)), - Mod => DlDef(ast::def_mod(did)), - ForeignMod => DlDef(ast::def_foreign_mod(did)), + Type | ForeignType => DlDef(ast::DefTy(did)), + Mod => DlDef(ast::DefMod(did)), + ForeignMod => DlDef(ast::DefForeignMod(did)), Variant => { let enum_did = item_reqd_and_translated_parent_item(cnum, item); - DlDef(ast::def_variant(enum_did, did)) + DlDef(ast::DefVariant(enum_did, did)) } - Trait => DlDef(ast::def_trait(did)), - Enum => DlDef(ast::def_ty(did)), + Trait => DlDef(ast::DefTrait(did)), + Enum => DlDef(ast::DefTy(did)), Impl => DlImpl(did), PublicField | PrivateField | InheritedField => DlField, } } -pub fn lookup_def(cnum: ast::CrateNum, data: @~[u8], did_: ast::def_id) -> - ast::def { +pub fn lookup_def(cnum: ast::CrateNum, data: @~[u8], did_: ast::DefId) -> + ast::Def { let item = lookup_item(did_.node, data); - let did = ast::def_id { crate: cnum, node: did_.node }; + let did = ast::DefId { crate: cnum, node: did_.node }; // We treat references to enums as references to types. return def_like_to_def(item_to_def_like(item, did, cnum)); } @@ -402,7 +402,7 @@ pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) -> ty::ty_param_bounds_and_ty { let item = lookup_item(id, cdata.data); - let t = item_type(ast::def_id { crate: cdata.cnum, node: id }, item, tcx, + let t = item_type(ast::DefId { crate: cdata.cnum, node: id }, item, tcx, cdata); let tp_defs = if family_has_type_params(item_family(item)) { item_ty_param_defs(item, tcx, cdata, tag_items_data_item_ty_param_bounds) @@ -452,7 +452,7 @@ pub fn get_impl_vtables(cdata: Cmd, pub fn get_impl_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, - name: ast::Ident) -> Option { + name: ast::Ident) -> Option { let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let mut found = None; do reader::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| { @@ -471,12 +471,12 @@ pub fn get_symbol(data: @~[u8], id: ast::NodeId) -> ~str { // Something that a name can resolve to. pub enum DefLike { - DlDef(ast::def), - DlImpl(ast::def_id), + DlDef(ast::Def), + DlImpl(ast::DefId), DlField } -fn def_like_to_def(def_like: DefLike) -> ast::def { +fn def_like_to_def(def_like: DefLike) -> ast::Def { match def_like { DlDef(def) => return def, DlImpl(*) => fail!("found impl in def_like_to_def"), @@ -528,7 +528,7 @@ impl<'self> EachItemContext<'self> { fn process_item_and_pop_name(&mut self, doc: ebml::Doc, - def_id: ast::def_id, + def_id: ast::DefId, old_len: uint) -> bool { let def_like = item_to_def_like(doc, def_id, self.cdata.cnum); @@ -578,7 +578,7 @@ impl<'self> EachItemContext<'self> { continue } - fn each_item_of_module(&mut self, def_id: ast::def_id) -> bool { + fn each_item_of_module(&mut self, def_id: ast::DefId) -> bool { // This item might not be in this crate. If it's not, look it up. let items = if def_id.crate == self.cdata.cnum { reader::get_doc(reader::Doc(self.cdata.data), tag_items) @@ -910,7 +910,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, let mut disr_val = 0; for did in variant_ids.iter() { let item = find_item(did.node, items); - let ctor_ty = item_type(ast::def_id { crate: cdata.cnum, node: id}, + let ctor_ty = item_type(ast::DefId { crate: cdata.cnum, node: id}, item, tcx, cdata); let name = item_name(intr, item); let arg_tys = match ty::get(ctor_ty).sty { @@ -937,10 +937,10 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, } fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ { - fn get_mutability(ch: u8) -> ast::mutability { + fn get_mutability(ch: u8) -> ast::Mutability { match ch as char { - 'i' => ast::m_imm, - 'm' => ast::m_mutbl, + 'i' => ast::MutImmutable, + 'm' => ast::MutMutable, _ => fail!("unknown mutability character: `%c`", ch as char), } } @@ -983,7 +983,7 @@ pub fn get_impl(intr: @ident_interner, cdata: Cmd, impl_id: ast::NodeId, let data = cdata.data; let impl_item = lookup_item(impl_id, data); ty::Impl { - did: ast::def_id { + did: ast::DefId { crate: cdata.cnum, node: impl_id, }, @@ -1043,7 +1043,7 @@ pub fn get_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, } pub fn get_trait_method_def_ids(cdata: Cmd, - id: ast::NodeId) -> ~[ast::def_id] { + id: ast::NodeId) -> ~[ast::DefId] { let data = cdata.data; let item = lookup_item(id, data); let mut result = ~[]; @@ -1236,7 +1236,7 @@ fn read_path(d: ebml::Doc) -> (~str, uint) { } } -fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str { +fn describe_def(items: ebml::Doc, id: ast::DefId) -> ~str { if id.crate != ast::LOCAL_CRATE { return ~"external"; } let it = match maybe_find_item(id.node, items) { Some(it) => it, @@ -1419,13 +1419,13 @@ pub fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], // external crates - if those types further refer to types in other crates // then we must translate the crate number from that encoded in the external // crate to the correct local crate number. -pub fn translate_def_id(cdata: Cmd, did: ast::def_id) -> ast::def_id { +pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId { if did.crate == ast::LOCAL_CRATE { - return ast::def_id { crate: cdata.cnum, node: did.node }; + return ast::DefId { crate: cdata.cnum, node: did.node }; } match cdata.cnum_map.find(&did.crate) { - option::Some(&n) => ast::def_id { crate: n, node: did.node }, + option::Some(&n) => ast::DefId { crate: n, node: did.node }, option::None => fail!("didn't find a crate in the cnum_map") } } @@ -1440,7 +1440,7 @@ pub fn get_link_args_for_crate(cdata: Cmd) -> ~[~str] { result } -pub fn each_impl(cdata: Cmd, callback: &fn(ast::def_id)) { +pub fn each_impl(cdata: Cmd, callback: &fn(ast::DefId)) { let impls_doc = reader::get_doc(reader::Doc(cdata.data), tag_impls); let _ = do reader::tagged_docs(impls_doc, tag_impls_impl) |impl_doc| { callback(item_def_id(impl_doc, cdata)); @@ -1450,7 +1450,7 @@ pub fn each_impl(cdata: Cmd, callback: &fn(ast::def_id)) { pub fn each_implementation_for_type(cdata: Cmd, id: ast::NodeId, - callback: &fn(ast::def_id)) { + callback: &fn(ast::DefId)) { let item_doc = lookup_item(id, cdata.data); do reader::tagged_docs(item_doc, tag_items_data_item_inherent_impl) |impl_doc| { @@ -1462,7 +1462,7 @@ pub fn each_implementation_for_type(cdata: Cmd, pub fn each_implementation_for_trait(cdata: Cmd, id: ast::NodeId, - callback: &fn(ast::def_id)) { + callback: &fn(ast::DefId)) { let item_doc = lookup_item(id, cdata.data); let _ = do reader::tagged_docs(item_doc, @@ -1475,7 +1475,7 @@ pub fn each_implementation_for_trait(cdata: Cmd, } pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) - -> Option { + -> Option { let item_doc = lookup_item(id, cdata.data); let parent_item_id = match item_parent_item(item_doc) { None => return None, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index d2ad788964994..1b469676773c0 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -113,7 +113,7 @@ fn encode_impl_type_basename(ecx: &EncodeContext, ecx.tcx.sess.str_of(name)); } -pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: def_id) { +pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: DefId) { ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); } @@ -180,7 +180,7 @@ fn encode_family(ebml_w: &mut writer::Encoder, c: char) { ebml_w.end_tag(); } -pub fn def_to_str(did: def_id) -> ~str { +pub fn def_to_str(did: DefId) -> ~str { fmt!("%d:%d", did.crate, did.node) } @@ -209,7 +209,7 @@ fn encode_bounds_and_type(ebml_w: &mut writer::Encoder, encode_type(ecx, ebml_w, tpt.ty); } -fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: def_id) { +fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: DefId) { ebml_w.start_tag(tag_items_data_item_variant); let s = def_to_str(vid); ebml_w.writer.write(s.as_bytes()); @@ -300,7 +300,7 @@ fn encode_disr_val(_: &EncodeContext, ebml_w.end_tag(); } -fn encode_parent_item(ebml_w: &mut writer::Encoder, id: def_id) { +fn encode_parent_item(ebml_w: &mut writer::Encoder, id: DefId) { ebml_w.start_tag(tag_items_data_parent_item); let s = def_to_str(id); ebml_w.writer.write(s.as_bytes()); @@ -319,7 +319,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext, let mut disr_val = 0; let mut i = 0; let vi = ty::enum_variants(ecx.tcx, - ast::def_id { crate: LOCAL_CRATE, node: id }); + ast::DefId { crate: LOCAL_CRATE, node: id }); for variant in variants.iter() { let def_id = local_def(variant.node.id); index.push(entry {val: variant.node.id as i64, @@ -378,7 +378,7 @@ fn encode_path(ecx: &EncodeContext, fn encode_reexported_static_method(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, exp: &middle::resolve::Export2, - method_def_id: def_id, + method_def_id: DefId, method_ident: Ident) { debug!("(encode reexported static method) %s::%s", exp.name, ecx.tcx.sess.str_of(method_ident)); @@ -638,10 +638,10 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic ebml_w.end_tag(); fn encode_mutability(ebml_w: &writer::Encoder, - m: ast::mutability) { + m: ast::Mutability) { match m { - m_imm => ebml_w.writer.write(&[ 'i' as u8 ]), - m_mutbl => ebml_w.writer.write(&[ 'm' as u8 ]), + MutImmutable => ebml_w.writer.write(&[ 'i' as u8 ]), + MutMutable => ebml_w.writer.write(&[ 'm' as u8 ]), } } } @@ -653,7 +653,7 @@ fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) { } fn encode_provided_source(ebml_w: &mut writer::Encoder, - source_opt: Option) { + source_opt: Option) { for source in source_opt.iter() { ebml_w.start_tag(tag_item_method_provided_source); let s = def_to_str(*source); @@ -805,7 +805,7 @@ fn should_inline(attrs: &[Attribute]) -> bool { // Encodes the inherent implementations of a structure, enumeration, or trait. fn encode_inherent_implementations(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - def_id: def_id) { + def_id: DefId) { match ecx.tcx.inherent_impls.find(&def_id) { None => {} Some(&implementations) => { @@ -821,7 +821,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext, // Encodes the implementations of a trait defined in this crate. fn encode_extension_implementations(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, - trait_def_id: def_id) { + trait_def_id: DefId) { match ecx.tcx.trait_impls.find(&trait_def_id) { None => {} Some(&implementations) => { @@ -856,7 +856,7 @@ fn encode_info_for_item(ecx: &EncodeContext, add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, def_id); - if m == ast::m_mutbl { + if m == ast::MutMutable { encode_family(ebml_w, 'b'); } else { encode_family(ebml_w, 'c'); @@ -1223,7 +1223,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext, ebml_w.end_tag(); } -fn my_visit_expr(_e:@expr) { } +fn my_visit_expr(_e:@Expr) { } fn my_visit_item(i:@item, items: ast_map::map, ebml_w:&writer::Encoder, ecx_ptr:*int, index: @mut ~[entry]) { @@ -1272,7 +1272,7 @@ struct EncodeVisitor { } impl visit::Visitor<()> for EncodeVisitor { - fn visit_expr(&mut self, ex:@expr, _:()) { + fn visit_expr(&mut self, ex:@Expr, _:()) { visit::walk_expr(self, ex, ()); my_visit_expr(ex); } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 3e520522ba5ad..036c66cca8463 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -51,7 +51,7 @@ pub enum DefIdSource { TypeParameter } type conv_did<'self> = - &'self fn(source: DefIdSource, ast::def_id) -> ast::def_id; + &'self fn(source: DefIdSource, ast::DefId) -> ast::DefId; pub struct PState<'self> { data: &'self [u8], @@ -422,10 +422,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { } } -fn parse_mutability(st: &mut PState) -> ast::mutability { +fn parse_mutability(st: &mut PState) -> ast::Mutability { match peek(st) { - 'm' => { next(st); ast::m_mutbl } - _ => { ast::m_imm } + 'm' => { next(st); ast::MutMutable } + _ => { ast::MutImmutable } } } @@ -435,7 +435,7 @@ fn parse_mt(st: &mut PState, conv: conv_did) -> ty::mt { } fn parse_def(st: &mut PState, source: DefIdSource, - conv: conv_did) -> ast::def_id { + conv: conv_did) -> ast::DefId { return conv(source, scan(st, |c| { c == '|' }, parse_def_id)); } @@ -535,7 +535,7 @@ fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig { } // Rust metadata parsing -pub fn parse_def_id(buf: &[u8]) -> ast::def_id { +pub fn parse_def_id(buf: &[u8]) -> ast::DefId { let mut colon_idx = 0u; let len = buf.len(); while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } @@ -557,7 +557,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { None => fail!("internal error: parse_def_id: id expected, but found %?", def_part) }; - ast::def_id { crate: crate_num, node: def_num } + ast::DefId { crate: crate_num, node: def_num } } pub fn parse_type_param_def_data(data: &[u8], start: uint, diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index d00928dd3db74..86821200796b9 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -26,7 +26,7 @@ use syntax::print::pprust::*; pub struct ctxt { diag: @mut span_handler, // Def -> str Callback: - ds: @fn(def_id) -> ~str, + ds: @fn(DefId) -> ~str, // The type context. tcx: ty::ctxt, abbrevs: abbrev_ctxt @@ -95,10 +95,10 @@ pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) { } } -fn enc_mutability(w: @io::Writer, mt: ast::mutability) { +fn enc_mutability(w: @io::Writer, mt: ast::Mutability) { match mt { - m_imm => (), - m_mutbl => w.write_char('m'), + MutImmutable => (), + MutMutable => w.write_char('m'), } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index faf4ac76a039d..f6645b1c1d1e6 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -72,7 +72,7 @@ trait tr { } trait tr_intern { - fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; + fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::DefId; } // ______________________________________________________________________ @@ -179,7 +179,7 @@ impl ExtendedDecodeContext { assert!(!self.from_id_range.empty()); (id - self.from_id_range.min + self.to_id_range.min) } - pub fn tr_def_id(&self, did: ast::def_id) -> ast::def_id { + pub fn tr_def_id(&self, did: ast::DefId) -> ast::DefId { /*! * Translates an EXTERNAL def-id, converting the crate number * from the one used in the encoded data to the current crate @@ -203,7 +203,7 @@ impl ExtendedDecodeContext { decoder::translate_def_id(self.dcx.cdata, did) } - pub fn tr_intern_def_id(&self, did: ast::def_id) -> ast::def_id { + pub fn tr_intern_def_id(&self, did: ast::DefId) -> ast::DefId { /*! * Translates an INTERNAL def-id, meaning a def-id that is * known to refer to some part of the item currently being @@ -212,21 +212,21 @@ impl ExtendedDecodeContext { */ assert_eq!(did.crate, ast::LOCAL_CRATE); - ast::def_id { crate: ast::LOCAL_CRATE, node: self.tr_id(did.node) } + ast::DefId { crate: ast::LOCAL_CRATE, node: self.tr_id(did.node) } } pub fn tr_span(&self, _span: Span) -> Span { codemap::dummy_sp() // FIXME (#1972): handle span properly } } -impl tr_intern for ast::def_id { - fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { +impl tr_intern for ast::DefId { + fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::DefId { xcx.tr_intern_def_id(*self) } } -impl tr for ast::def_id { - fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { +impl tr for ast::DefId { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::DefId { xcx.tr_def_id(*self) } } @@ -238,30 +238,30 @@ impl tr for Span { } trait def_id_encoder_helpers { - fn emit_def_id(&mut self, did: ast::def_id); + fn emit_def_id(&mut self, did: ast::DefId); } impl def_id_encoder_helpers for S { - fn emit_def_id(&mut self, did: ast::def_id) { + fn emit_def_id(&mut self, did: ast::DefId) { did.encode(self) } } trait def_id_decoder_helpers { - fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id; + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::DefId; fn read_def_id_noxcx(&mut self, - cdata: @cstore::crate_metadata) -> ast::def_id; + cdata: @cstore::crate_metadata) -> ast::DefId; } impl def_id_decoder_helpers for D { - fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id { - let did: ast::def_id = Decodable::decode(self); + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::DefId { + let did: ast::DefId = Decodable::decode(self); did.tr(xcx) } fn read_def_id_noxcx(&mut self, - cdata: @cstore::crate_metadata) -> ast::def_id { - let did: ast::def_id = Decodable::decode(self); + cdata: @cstore::crate_metadata) -> ast::DefId { + let did: ast::DefId = Decodable::decode(self); decoder::translate_def_id(cdata, did) } } @@ -301,12 +301,12 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { fn drop_nested_items(blk: &ast::Block, fld: @fold::ast_fold) -> ast::Block { let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| { match stmt.node { - ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | - ast::stmt_decl(@codemap::Spanned { node: ast::decl_local(_), span: _}, _) + ast::StmtExpr(_, _) | ast::StmtSemi(_, _) | + ast::StmtDecl(@codemap::Spanned { node: ast::DeclLocal(_), span: _}, _) => Some(*stmt), - ast::stmt_decl(@codemap::Spanned { node: ast::decl_item(_), span: _}, _) + ast::StmtDecl(@codemap::Spanned { node: ast::DeclItem(_), span: _}, _) => None, - ast::stmt_mac(*) => fail!("unexpanded macro in astencode") + ast::StmtMac(*) => fail!("unexpanded macro in astencode") } }.collect(); let blk_sans_items = ast::Block { @@ -360,22 +360,22 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) // ______________________________________________________________________ // Encoding and decoding of ast::def -fn encode_def(ebml_w: &mut writer::Encoder, def: ast::def) { +fn encode_def(ebml_w: &mut writer::Encoder, def: ast::Def) { def.encode(ebml_w) } -fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { +fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::Def { let mut dsr = reader::Decoder(doc); - let def: ast::def = Decodable::decode(&mut dsr); + let def: ast::Def = Decodable::decode(&mut dsr); def.tr(xcx) } -impl tr for ast::def { - fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def { +impl tr for ast::Def { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::Def { match *self { - ast::def_fn(did, p) => ast::def_fn(did.tr(xcx), p), - ast::def_static_method(did, wrapped_did2, p) => { - ast::def_static_method(did.tr(xcx), + ast::DefFn(did, p) => ast::DefFn(did.tr(xcx), p), + ast::DefStaticMethod(did, wrapped_did2, p) => { + ast::DefStaticMethod(did.tr(xcx), match wrapped_did2 { ast::FromTrait(did2) => { ast::FromTrait(did2.tr(xcx)) @@ -386,37 +386,37 @@ impl tr for ast::def { }, p) } - ast::def_method(did0, did1) => { - ast::def_method(did0.tr(xcx), did1.map(|did1| did1.tr(xcx))) + ast::DefMethod(did0, did1) => { + ast::DefMethod(did0.tr(xcx), did1.map(|did1| did1.tr(xcx))) } - ast::def_self_ty(nid) => { ast::def_self_ty(xcx.tr_id(nid)) } - ast::def_self(nid) => { ast::def_self(xcx.tr_id(nid)) } - ast::def_mod(did) => { ast::def_mod(did.tr(xcx)) } - ast::def_foreign_mod(did) => { ast::def_foreign_mod(did.tr(xcx)) } - ast::def_static(did, m) => { ast::def_static(did.tr(xcx), m) } - ast::def_arg(nid, b) => { ast::def_arg(xcx.tr_id(nid), b) } - ast::def_local(nid, b) => { ast::def_local(xcx.tr_id(nid), b) } - ast::def_variant(e_did, v_did) => { - ast::def_variant(e_did.tr(xcx), v_did.tr(xcx)) + ast::DefSelfTy(nid) => { ast::DefSelfTy(xcx.tr_id(nid)) } + ast::DefSelf(nid) => { ast::DefSelf(xcx.tr_id(nid)) } + ast::DefMod(did) => { ast::DefMod(did.tr(xcx)) } + ast::DefForeignMod(did) => { ast::DefForeignMod(did.tr(xcx)) } + ast::DefStatic(did, m) => { ast::DefStatic(did.tr(xcx), m) } + ast::DefArg(nid, b) => { ast::DefArg(xcx.tr_id(nid), b) } + ast::DefLocal(nid, b) => { ast::DefLocal(xcx.tr_id(nid), b) } + ast::DefVariant(e_did, v_did) => { + ast::DefVariant(e_did.tr(xcx), v_did.tr(xcx)) }, - ast::def_trait(did) => ast::def_trait(did.tr(xcx)), - ast::def_ty(did) => ast::def_ty(did.tr(xcx)), - ast::def_prim_ty(p) => ast::def_prim_ty(p), - ast::def_ty_param(did, v) => ast::def_ty_param(did.tr(xcx), v), - ast::def_binding(nid, bm) => ast::def_binding(xcx.tr_id(nid), bm), - ast::def_use(did) => ast::def_use(did.tr(xcx)), - ast::def_upvar(nid1, def, nid2, nid3) => { - ast::def_upvar(xcx.tr_id(nid1), + ast::DefTrait(did) => ast::DefTrait(did.tr(xcx)), + ast::DefTy(did) => ast::DefTy(did.tr(xcx)), + ast::DefPrimTy(p) => ast::DefPrimTy(p), + ast::DefTyParam(did, v) => ast::DefTyParam(did.tr(xcx), v), + ast::DefBinding(nid, bm) => ast::DefBinding(xcx.tr_id(nid), bm), + ast::DefUse(did) => ast::DefUse(did.tr(xcx)), + ast::DefUpvar(nid1, def, nid2, nid3) => { + ast::DefUpvar(xcx.tr_id(nid1), @(*def).tr(xcx), xcx.tr_id(nid2), xcx.tr_id(nid3)) } - ast::def_struct(did) => ast::def_struct(did.tr(xcx)), - ast::def_region(nid) => ast::def_region(xcx.tr_id(nid)), - ast::def_typaram_binder(nid) => { - ast::def_typaram_binder(xcx.tr_id(nid)) + ast::DefStruct(did) => ast::DefStruct(did.tr(xcx)), + ast::DefRegion(nid) => ast::DefRegion(xcx.tr_id(nid)), + ast::DefTyParamBinder(nid) => { + ast::DefTyParamBinder(xcx.tr_id(nid)) } - ast::def_label(nid) => ast::def_label(xcx.tr_id(nid)) + ast::DefLabel(nid) => ast::DefLabel(xcx.tr_id(nid)) } } } @@ -914,7 +914,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext, } } - let lid = ast::def_id { crate: ast::LOCAL_CRATE, node: id }; + let lid = ast::DefId { crate: ast::LOCAL_CRATE, node: id }; { let r = tcx.tcache.find(&lid); for &tpbt in r.iter() { @@ -1012,8 +1012,8 @@ trait ebml_decoder_decoder_helpers { fn convert_def_id(&mut self, xcx: @ExtendedDecodeContext, source: DefIdSource, - did: ast::def_id) - -> ast::def_id; + did: ast::DefId) + -> ast::DefId; // Versions of the type reading functions that don't need the full // ExtendedDecodeContext. @@ -1122,8 +1122,8 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { fn convert_def_id(&mut self, xcx: @ExtendedDecodeContext, source: tydecode::DefIdSource, - did: ast::def_id) - -> ast::def_id { + did: ast::DefId) + -> ast::DefId { /*! * * Converts a def-id that appears in a type. The correct @@ -1192,7 +1192,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, } c::tag_table_tcache => { let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); - let lid = ast::def_id { crate: ast::LOCAL_CRATE, node: id }; + let lid = ast::DefId { crate: ast::LOCAL_CRATE, node: id }; dcx.tcx.tcache.insert(lid, tpbt); } c::tag_table_param_defs => { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 029080ed26540..8cfb2bad57f3b 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -23,7 +23,7 @@ use mc = middle::mem_categorization; use middle::borrowck::*; use middle::moves; use middle::ty; -use syntax::ast::{m_imm, m_mutbl}; +use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; @@ -43,7 +43,7 @@ struct CheckLoanCtxt<'self> { struct CheckLoanVisitor; impl<'self> Visitor> for CheckLoanVisitor { - fn visit_expr<'a>(&mut self, ex:@ast::expr, e:CheckLoanCtxt<'a>) { + fn visit_expr<'a>(&mut self, ex:@ast::Expr, e:CheckLoanCtxt<'a>) { check_loans_in_expr(self, ex, e); } fn visit_local(&mut self, l:@ast::Local, e:CheckLoanCtxt) { @@ -52,7 +52,7 @@ impl<'self> Visitor> for CheckLoanVisitor { fn visit_block(&mut self, b:&ast::Block, e:CheckLoanCtxt) { check_loans_in_block(self, b, e); } - fn visit_pat(&mut self, p:@ast::pat, e:CheckLoanCtxt) { + fn visit_pat(&mut self, p:@ast::Pat, e:CheckLoanCtxt) { check_loans_in_pat(self, p, e); } fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl, @@ -332,7 +332,7 @@ impl<'self> CheckLoanCtxt<'self> { }; } - pub fn check_assignment(&self, expr: @ast::expr) { + pub fn check_assignment(&self, expr: @ast::Expr) { // We don't use cat_expr() here because we don't want to treat // auto-ref'd parameters in overloaded operators as rvalues. let cmt = match self.bccx.tcx.adjustments.find(&expr.id) { @@ -432,7 +432,7 @@ impl<'self> CheckLoanCtxt<'self> { } fn check_for_aliasable_mutable_writes(this: &CheckLoanCtxt, - expr: @ast::expr, + expr: @ast::Expr, cmt: mc::cmt) -> bool { //! Safety checks related to writes to aliasable, mutable locations @@ -440,13 +440,13 @@ impl<'self> CheckLoanCtxt<'self> { debug!("check_for_aliasable_mutable_writes(cmt=%s, guarantor=%s)", cmt.repr(this.tcx()), guarantor.repr(this.tcx())); match guarantor.cat { - mc::cat_deref(b, _, mc::region_ptr(m_mutbl, _)) => { + mc::cat_deref(b, _, mc::region_ptr(MutMutable, _)) => { // Statically prohibit writes to `&mut` when aliasable check_for_aliasability_violation(this, expr, b); } - mc::cat_deref(_, deref_count, mc::gc_ptr(ast::m_mutbl)) => { + mc::cat_deref(_, deref_count, mc::gc_ptr(ast::MutMutable)) => { // Dynamically check writes to `@mut` let key = root_map_key { @@ -464,13 +464,13 @@ impl<'self> CheckLoanCtxt<'self> { } fn check_for_aliasability_violation(this: &CheckLoanCtxt, - expr: @ast::expr, + expr: @ast::Expr, cmt: mc::cmt) -> bool { let mut cmt = cmt; loop { match cmt.cat { - mc::cat_deref(b, _, mc::region_ptr(m_mutbl, _)) | + mc::cat_deref(b, _, mc::region_ptr(MutMutable, _)) | mc::cat_downcast(b) | mc::cat_stack_upvar(b) | mc::cat_deref(b, _, mc::uniq_ptr) | @@ -488,7 +488,7 @@ impl<'self> CheckLoanCtxt<'self> { mc::cat_deref(_, _, mc::unsafe_ptr(*)) | mc::cat_static_item(*) | mc::cat_deref(_, _, mc::gc_ptr(_)) | - mc::cat_deref(_, _, mc::region_ptr(m_imm, _)) => { + mc::cat_deref(_, _, mc::region_ptr(MutImmutable, _)) => { // Aliasability is independent of base cmt match cmt.freely_aliasable() { None => { @@ -509,7 +509,7 @@ impl<'self> CheckLoanCtxt<'self> { fn check_for_assignment_to_restricted_or_frozen_location( this: &CheckLoanCtxt, - expr: @ast::expr, + expr: @ast::Expr, cmt: mc::cmt) -> bool { //! Check for assignments that violate the terms of an @@ -612,7 +612,7 @@ impl<'self> CheckLoanCtxt<'self> { // with inherited mutability and with `&mut` // pointers. LpExtend(lp_base, mc::McInherited, _) | - LpExtend(lp_base, _, LpDeref(mc::region_ptr(ast::m_mutbl, _))) => { + LpExtend(lp_base, _, LpDeref(mc::region_ptr(ast::MutMutable, _))) => { loan_path = lp_base; } @@ -643,7 +643,7 @@ impl<'self> CheckLoanCtxt<'self> { } pub fn report_illegal_mutation(&self, - expr: @ast::expr, + expr: @ast::Expr, loan_path: &LoanPath, loan: &Loan) { self.bccx.span_err( @@ -656,9 +656,9 @@ impl<'self> CheckLoanCtxt<'self> { self.bccx.loan_path_to_str(loan_path))); } - fn check_move_out_from_expr(&self, expr: @ast::expr) { + fn check_move_out_from_expr(&self, expr: @ast::Expr) { match expr.node { - ast::expr_fn_block(*) => { + ast::ExprFnBlock(*) => { // moves due to capture clauses are checked // in `check_loans_in_fn`, so that we can // give a better error message @@ -710,11 +710,11 @@ impl<'self> CheckLoanCtxt<'self> { } pub fn check_call(&self, - _expr: @ast::expr, - _callee: Option<@ast::expr>, + _expr: @ast::Expr, + _callee: Option<@ast::Expr>, _callee_id: ast::NodeId, _callee_span: Span, - _args: &[@ast::expr]) { + _args: &[@ast::Expr]) { // NB: This call to check for conflicting loans is not truly // necessary, because the callee_id never issues new loans. // However, I added it for consistency and lest the system @@ -795,7 +795,7 @@ fn check_loans_in_local<'a>(vt: &mut CheckLoanVisitor, } fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor, - expr: @ast::expr, + expr: @ast::Expr, this: CheckLoanCtxt<'a>) { visit::walk_expr(vt, expr, this); @@ -806,8 +806,8 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor, this.check_move_out_from_expr(expr); match expr.node { - ast::expr_self | - ast::expr_path(*) => { + ast::ExprSelf | + ast::ExprPath(*) => { if !this.move_data.is_assignee(expr.id) { let cmt = this.bccx.cat_expr_unadjusted(expr); debug!("path cmt=%s", cmt.repr(this.tcx())); @@ -817,18 +817,18 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor, } } } - ast::expr_assign(dest, _) | - ast::expr_assign_op(_, _, dest, _) => { + ast::ExprAssign(dest, _) | + ast::ExprAssignOp(_, _, dest, _) => { this.check_assignment(dest); } - ast::expr_call(f, ref args, _) => { + ast::ExprCall(f, ref args, _) => { this.check_call(expr, Some(f), f.id, f.span, *args); } - ast::expr_method_call(callee_id, _, _, _, ref args, _) => { + ast::ExprMethodCall(callee_id, _, _, _, ref args, _) => { this.check_call(expr, None, callee_id, expr.span, *args); } - ast::expr_index(callee_id, _, rval) | - ast::expr_binary(callee_id, _, _, rval) + ast::ExprIndex(callee_id, _, rval) | + ast::ExprBinary(callee_id, _, _, rval) if this.bccx.method_map.contains_key(&expr.id) => { this.check_call(expr, None, @@ -836,7 +836,7 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor, expr.span, [rval]); } - ast::expr_unary(callee_id, _, _) | ast::expr_index(callee_id, _, _) + ast::ExprUnary(callee_id, _, _) | ast::ExprIndex(callee_id, _, _) if this.bccx.method_map.contains_key(&expr.id) => { this.check_call(expr, None, @@ -849,7 +849,7 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor, } fn check_loans_in_pat<'a>(vt: &mut CheckLoanVisitor, - pat: @ast::pat, + pat: @ast::Pat, this: CheckLoanCtxt<'a>) { this.check_for_conflicting_loans(pat.id); diff --git a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs index c25655803a48c..4b12fa202d4ad 100644 --- a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs @@ -33,7 +33,7 @@ pub fn gather_decl(bccx: @BorrowckCtxt, pub fn gather_move_from_expr(bccx: @BorrowckCtxt, move_data: &mut MoveData, - move_expr: @ast::expr, + move_expr: @ast::Expr, cmt: mc::cmt) { gather_move_from_expr_or_pat(bccx, move_data, move_expr.id, MoveExpr(move_expr), cmt); @@ -41,7 +41,7 @@ pub fn gather_move_from_expr(bccx: @BorrowckCtxt, pub fn gather_move_from_pat(bccx: @BorrowckCtxt, move_data: &mut MoveData, - move_pat: @ast::pat, + move_pat: @ast::Pat, cmt: mc::cmt) { gather_move_from_expr_or_pat(bccx, move_data, move_pat.id, MovePat(move_pat), cmt); @@ -68,7 +68,7 @@ fn gather_move_from_expr_or_pat(bccx: @BorrowckCtxt, pub fn gather_captures(bccx: @BorrowckCtxt, move_data: &mut MoveData, - closure_expr: @ast::expr) { + closure_expr: @ast::Expr) { let captured_vars = bccx.capture_map.get(&closure_expr.id); for captured_var in captured_vars.iter() { match captured_var.mode { diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index 1776e041c834f..1b94ac06c8eb1 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -15,7 +15,7 @@ use middle::borrowck::*; use mc = middle::mem_categorization; use middle::ty; -use syntax::ast::{m_imm, m_mutbl}; +use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap::Span; use util::ppaux::{note_and_explain_region}; @@ -90,7 +90,7 @@ impl GuaranteeLifetimeContext { // L-Deref-Managed-Imm-User-Root let omit_root = ( - ptr_mutbl == m_imm && + ptr_mutbl == MutImmutable && self.bccx.is_subregion_of(self.loan_region, base_scope) && self.is_rvalue_or_immutable(base) && !self.is_moved(base) @@ -187,7 +187,7 @@ impl GuaranteeLifetimeContext { cmt_deref: mc::cmt, cmt_base: mc::cmt, derefs: uint, - ptr_mutbl: ast::mutability, + ptr_mutbl: ast::Mutability, discr_scope: Option) { debug!("check_root(cmt_deref=%s, cmt_base=%s, derefs=%?, ptr_mutbl=%?, \ discr_scope=%?)", @@ -235,8 +235,8 @@ impl GuaranteeLifetimeContext { // we need to dynamically mark it to prevent incompatible // borrows from happening later. let opt_dyna = match ptr_mutbl { - m_imm => None, - m_mutbl => { + MutImmutable => None, + MutMutable => { match self.loan_mutbl { MutableMutability => Some(DynaMut), ImmutableMutability | ConstMutability => Some(DynaImm) diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 43bb278c94900..be033de4e41b5 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -32,7 +32,7 @@ use syntax::codemap::Span; use syntax::print::pprust; use syntax::visit; use syntax::visit::Visitor; -use syntax::ast::{expr, fn_kind, fn_decl, Block, NodeId, stmt, pat, Local}; +use syntax::ast::{Expr, fn_kind, fn_decl, Block, NodeId, Stmt, Pat, Local}; mod lifetime; mod restrictions; @@ -76,7 +76,7 @@ struct GatherLoanCtxt { struct GatherLoanVisitor; impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor { - fn visit_expr(&mut self, ex:@expr, e:@mut GatherLoanCtxt) { + fn visit_expr(&mut self, ex:@Expr, e:@mut GatherLoanCtxt) { gather_loans_in_expr(self, ex, e); } fn visit_block(&mut self, b:&Block, e:@mut GatherLoanCtxt) { @@ -86,10 +86,10 @@ impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor { s:Span, n:NodeId, e:@mut GatherLoanCtxt) { gather_loans_in_fn(self, fk, fd, b, s, n, e); } - fn visit_stmt(&mut self, s:@stmt, e:@mut GatherLoanCtxt) { + fn visit_stmt(&mut self, s:@Stmt, e:@mut GatherLoanCtxt) { add_stmt_to_map(self, s, e); } - fn visit_pat(&mut self, p:@pat, e:@mut GatherLoanCtxt) { + fn visit_pat(&mut self, p:@Pat, e:@mut GatherLoanCtxt) { add_pat_to_id_range(self, p, e); } fn visit_local(&mut self, l:@Local, e:@mut GatherLoanCtxt) { @@ -117,7 +117,7 @@ pub fn gather_loans(bccx: @BorrowckCtxt, } fn add_pat_to_id_range(v: &mut GatherLoanVisitor, - p: @ast::pat, + p: @ast::Pat, this: @mut GatherLoanCtxt) { // NB: This visitor function just adds the pat ids into the id // range. We gather loans that occur in patterns using the @@ -196,7 +196,7 @@ fn gather_loans_in_local(v: &mut GatherLoanVisitor, fn gather_loans_in_expr(v: &mut GatherLoanVisitor, - ex: @ast::expr, + ex: @ast::Expr, this: @mut GatherLoanCtxt) { let bccx = this.bccx; let tcx = bccx.tcx; @@ -230,7 +230,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, // Special checks for various kinds of expressions: match ex.node { - ast::expr_addr_of(mutbl, base) => { + ast::ExprAddrOf(mutbl, base) => { let base_cmt = this.bccx.cat_expr(base); // make sure that the thing we are pointing out stays valid @@ -244,7 +244,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, visit::walk_expr(v, ex, this); } - ast::expr_assign(l, _) | ast::expr_assign_op(_, _, l, _) => { + ast::ExprAssign(l, _) | ast::ExprAssignOp(_, _, l, _) => { let l_cmt = this.bccx.cat_expr(l); match opt_loan_path(l_cmt) { Some(l_lp) => { @@ -261,7 +261,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, visit::walk_expr(v, ex, this); } - ast::expr_match(ex_v, ref arms) => { + ast::ExprMatch(ex_v, ref arms) => { let cmt = this.bccx.cat_expr(ex_v); for arm in arms.iter() { for pat in arm.pats.iter() { @@ -271,8 +271,8 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, visit::walk_expr(v, ex, this); } - ast::expr_index(_, _, arg) | - ast::expr_binary(_, _, _, arg) + ast::ExprIndex(_, _, arg) | + ast::ExprBinary(_, _, _, arg) if this.bccx.method_map.contains_key(&ex.id) => { // Arguments in method calls are always passed by ref. // @@ -290,7 +290,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, } // see explanation attached to the `root_ub` field: - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { // during the condition, can only root for the condition this.push_repeating_id(cond.id); v.visit_expr(cond, this); @@ -303,13 +303,13 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor, } // see explanation attached to the `root_ub` field: - ast::expr_loop(ref body, _) => { + ast::ExprLoop(ref body, _) => { this.push_repeating_id(body.id); visit::walk_expr(v, ex, this); this.pop_repeating_id(body.id); } - ast::expr_fn_block(*) => { + ast::ExprFnBlock(*) => { gather_moves::gather_captures(this.bccx, this.move_data, ex); visit::walk_expr(v, ex, this); } @@ -333,7 +333,7 @@ impl GatherLoanCtxt { } pub fn guarantee_adjustments(&mut self, - expr: @ast::expr, + expr: @ast::Expr, adjustment: &ty::AutoAdjustment) { debug!("guarantee_adjustments(expr=%s, adjustment=%?)", expr.repr(self.tcx()), adjustment); @@ -668,7 +668,7 @@ impl GatherLoanCtxt { fn gather_pat(&mut self, discr_cmt: mc::cmt, - root_pat: @ast::pat, + root_pat: @ast::Pat, arm_match_ids: Option<(ast::NodeId, ast::NodeId)>) { /*! * Walks patterns, examining the bindings to determine if they @@ -678,9 +678,9 @@ impl GatherLoanCtxt { do self.bccx.cat_pattern(discr_cmt, root_pat) |cmt, pat| { match pat.node { - ast::pat_ident(bm, _, _) if self.pat_is_binding(pat) => { + ast::PatIdent(bm, _, _) if self.pat_is_binding(pat) => { match bm { - ast::bind_by_ref(mutbl) => { + ast::BindByRef(mutbl) => { // ref x or ref x @ p --- creates a ptr which must // remain valid for the scope of the match @@ -715,7 +715,7 @@ impl GatherLoanCtxt { loan_mutability, scope_r); } - ast::bind_infer => { + ast::BindInfer => { // No borrows here, but there may be moves if self.bccx.is_move(pat.id) { gather_moves::gather_move_from_pat( @@ -725,7 +725,7 @@ impl GatherLoanCtxt { } } - ast::pat_vec(_, Some(slice_pat), _) => { + ast::PatVec(_, Some(slice_pat), _) => { // The `slice_pat` here creates a slice into the // original vector. This is effectively a borrow of // the elements of the vector being matched. @@ -768,8 +768,8 @@ impl GatherLoanCtxt { } } - pub fn vec_slice_info(&self, pat: @ast::pat, slice_ty: ty::t) - -> (ast::mutability, ty::Region) { + pub fn vec_slice_info(&self, pat: @ast::Pat, slice_ty: ty::t) + -> (ast::Mutability, ty::Region) { /*! * * In a pattern like [a, b, ..c], normally `c` has slice type, @@ -795,11 +795,11 @@ impl GatherLoanCtxt { } } - pub fn pat_is_variant_or_struct(&self, pat: @ast::pat) -> bool { + pub fn pat_is_variant_or_struct(&self, pat: @ast::Pat) -> bool { pat_util::pat_is_variant_or_struct(self.bccx.tcx.def_map, pat) } - pub fn pat_is_binding(&self, pat: @ast::pat) -> bool { + pub fn pat_is_binding(&self, pat: @ast::Pat) -> bool { pat_util::pat_is_binding(self.bccx.tcx.def_map, pat) } } @@ -807,10 +807,10 @@ impl GatherLoanCtxt { // Setting up info that preserve needs. // This is just the most convenient place to do it. fn add_stmt_to_map(v: &mut GatherLoanVisitor, - stmt: @ast::stmt, + stmt: @ast::Stmt, this: @mut GatherLoanCtxt) { match stmt.node { - ast::stmt_expr(_, id) | ast::stmt_semi(_, id) => { + ast::StmtExpr(_, id) | ast::StmtSemi(_, id) => { this.bccx.stmt_map.insert(id); } _ => () diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index 33b90cbe57316..16ee45b2c68e8 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -15,7 +15,7 @@ use std::vec; use middle::borrowck::*; use mc = middle::mem_categorization; use middle::ty; -use syntax::ast::{m_imm, m_mutbl}; +use syntax::ast::{MutImmutable, MutMutable}; use syntax::codemap::Span; pub enum RestrictionResult { @@ -115,13 +115,13 @@ impl RestrictionsContext { mc::cat_copied_upvar(*) | // FIXME(#2152) allow mutation of upvars mc::cat_static_item(*) | - mc::cat_deref(_, _, mc::region_ptr(m_imm, _)) | - mc::cat_deref(_, _, mc::gc_ptr(m_imm)) => { + mc::cat_deref(_, _, mc::region_ptr(MutImmutable, _)) | + mc::cat_deref(_, _, mc::gc_ptr(MutImmutable)) => { // R-Deref-Imm-Borrowed Safe } - mc::cat_deref(cmt_base, _, pk @ mc::gc_ptr(m_mutbl)) => { + mc::cat_deref(cmt_base, _, pk @ mc::gc_ptr(MutMutable)) => { // R-Deref-Managed-Borrowed // // Technically, no restrictions are *necessary* here. @@ -169,7 +169,7 @@ impl RestrictionsContext { } } - mc::cat_deref(cmt_base, _, pk @ mc::region_ptr(m_mutbl, _)) => { + mc::cat_deref(cmt_base, _, pk @ mc::region_ptr(MutMutable, _)) => { // Because an `&mut` pointer does not inherit its // mutability, we can only prevent mutation or prevent // freezing if it is not aliased. Therefore, in such diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 0c182286b069d..986b3956410bc 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -249,11 +249,11 @@ pub enum LoanMutability { } impl LoanMutability { - pub fn from_ast_mutability(ast_mutability: ast::mutability) + pub fn from_ast_mutability(ast_mutability: ast::Mutability) -> LoanMutability { match ast_mutability { - ast::m_imm => ImmutableMutability, - ast::m_mutbl => MutableMutability, + ast::MutImmutable => ImmutableMutability, + ast::MutMutable => MutableMutability, } } } @@ -487,16 +487,16 @@ impl BorrowckCtxt { self.moves_map.contains(&id) } - pub fn cat_expr(&self, expr: @ast::expr) -> mc::cmt { + pub fn cat_expr(&self, expr: @ast::Expr) -> mc::cmt { mc::cat_expr(self.tcx, self.method_map, expr) } - pub fn cat_expr_unadjusted(&self, expr: @ast::expr) -> mc::cmt { + pub fn cat_expr_unadjusted(&self, expr: @ast::Expr) -> mc::cmt { mc::cat_expr_unadjusted(self.tcx, self.method_map, expr) } pub fn cat_expr_autoderefd(&self, - expr: @ast::expr, + expr: @ast::Expr, adj: @ty::AutoAdjustment) -> mc::cmt { match *adj { @@ -518,7 +518,7 @@ impl BorrowckCtxt { id: ast::NodeId, span: Span, ty: ty::t, - def: ast::def) + def: ast::Def) -> mc::cmt { mc::cat_def(self.tcx, self.method_map, id, span, ty, def) } @@ -536,8 +536,8 @@ impl BorrowckCtxt { pub fn cat_pattern(&self, cmt: mc::cmt, - pat: @ast::pat, - op: &fn(mc::cmt, @ast::pat)) { + pat: @ast::Pat, + op: &fn(mc::cmt, @ast::Pat)) { let mc = self.mc_ctxt(); mc.cat_pattern(cmt, pat, op); } @@ -691,7 +691,7 @@ impl BorrowckCtxt { span, fmt!("%s in an aliasable location", prefix)); } - mc::AliasableManaged(ast::m_mutbl) => { + mc::AliasableManaged(ast::MutMutable) => { // FIXME(#6269) reborrow @mut to &mut self.tcx.sess.span_err( span, @@ -825,10 +825,10 @@ impl BorrowckCtxt { mutbl.to_str() } - pub fn mut_to_keyword(&self, mutbl: ast::mutability) -> &'static str { + pub fn mut_to_keyword(&self, mutbl: ast::Mutability) -> &'static str { match mutbl { - ast::m_imm => "", - ast::m_mutbl => "mut", + ast::MutImmutable => "", + ast::MutMutable => "mut", } } } diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 353a06a759e69..d7423fddd76a0 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -108,9 +108,9 @@ pub struct MovePath { pub enum MoveKind { Declared, // When declared, variables start out "moved". - MoveExpr(@ast::expr), // Expression or binding that moves a variable - MovePat(@ast::pat), // By-move binding - Captured(@ast::expr), // Closure creation that moves a value + MoveExpr(@ast::Expr), // Expression or binding that moves a variable + MovePat(@ast::Pat), // By-move binding + Captured(@ast::Expr), // Closure creation that moves a value } pub struct Move { diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index a8de2c9e77325..c6341abe3a6bd 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -62,67 +62,67 @@ impl CFGBuilder { self.add_node(blk.id, [expr_exit]) } - fn stmt(&mut self, stmt: @ast::stmt, pred: CFGIndex) -> CFGIndex { + fn stmt(&mut self, stmt: @ast::Stmt, pred: CFGIndex) -> CFGIndex { match stmt.node { - ast::stmt_decl(decl, _) => { + ast::StmtDecl(decl, _) => { self.decl(decl, pred) } - ast::stmt_expr(expr, _) | ast::stmt_semi(expr, _) => { + ast::StmtExpr(expr, _) | ast::StmtSemi(expr, _) => { self.expr(expr, pred) } - ast::stmt_mac(*) => { + ast::StmtMac(*) => { self.tcx.sess.span_bug(stmt.span, "unexpanded macro"); } } } - fn decl(&mut self, decl: @ast::decl, pred: CFGIndex) -> CFGIndex { + fn decl(&mut self, decl: @ast::Decl, pred: CFGIndex) -> CFGIndex { match decl.node { - ast::decl_local(local) => { + ast::DeclLocal(local) => { let init_exit = self.opt_expr(local.init, pred); self.pat(local.pat, init_exit) } - ast::decl_item(_) => { + ast::DeclItem(_) => { pred } } } - fn pat(&mut self, pat: @ast::pat, pred: CFGIndex) -> CFGIndex { + fn pat(&mut self, pat: @ast::Pat, pred: CFGIndex) -> CFGIndex { match pat.node { - ast::pat_ident(_, _, None) | - ast::pat_enum(_, None) | - ast::pat_lit(*) | - ast::pat_range(*) | - ast::pat_wild => { + ast::PatIdent(_, _, None) | + ast::PatEnum(_, None) | + ast::PatLit(*) | + ast::PatRange(*) | + ast::PatWild => { self.add_node(pat.id, [pred]) } - ast::pat_box(subpat) | - ast::pat_uniq(subpat) | - ast::pat_region(subpat) | - ast::pat_ident(_, _, Some(subpat)) => { + ast::PatBox(subpat) | + ast::PatUniq(subpat) | + ast::PatRegion(subpat) | + ast::PatIdent(_, _, Some(subpat)) => { let subpat_exit = self.pat(subpat, pred); self.add_node(pat.id, [subpat_exit]) } - ast::pat_enum(_, Some(ref subpats)) | - ast::pat_tup(ref subpats) => { + ast::PatEnum(_, Some(ref subpats)) | + ast::PatTup(ref subpats) => { let pats_exit = self.pats_all(subpats.iter().map(|p| *p), pred); self.add_node(pat.id, [pats_exit]) } - ast::pat_struct(_, ref subpats, _) => { + ast::PatStruct(_, ref subpats, _) => { let pats_exit = self.pats_all(subpats.iter().map(|f| f.pat), pred); self.add_node(pat.id, [pats_exit]) } - ast::pat_vec(ref pre, ref vec, ref post) => { + ast::PatVec(ref pre, ref vec, ref post) => { let pre_exit = self.pats_all(pre.iter().map(|p| *p), pred); let vec_exit = @@ -134,7 +134,7 @@ impl CFGBuilder { } } - fn pats_all>(&mut self, + fn pats_all>(&mut self, pats: I, pred: CFGIndex) -> CFGIndex { //! Handles case where all of the patterns must match. @@ -143,7 +143,7 @@ impl CFGBuilder { } fn pats_any(&mut self, - pats: &[@ast::pat], + pats: &[@ast::Pat], pred: CFGIndex) -> CFGIndex { //! Handles case where just one of the patterns must match. @@ -159,14 +159,14 @@ impl CFGBuilder { } } - fn expr(&mut self, expr: @ast::expr, pred: CFGIndex) -> CFGIndex { + fn expr(&mut self, expr: @ast::Expr, pred: CFGIndex) -> CFGIndex { match expr.node { - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { let blk_exit = self.block(blk, pred); self.add_node(expr.id, [blk_exit]) } - ast::expr_if(cond, ref then, None) => { + ast::ExprIf(cond, ref then, None) => { // // [pred] // | @@ -186,7 +186,7 @@ impl CFGBuilder { self.add_node(expr.id, [cond_exit, then_exit]) // 3,4 } - ast::expr_if(cond, ref then, Some(otherwise)) => { + ast::ExprIf(cond, ref then, Some(otherwise)) => { // // [pred] // | @@ -207,7 +207,7 @@ impl CFGBuilder { self.add_node(expr.id, [then_exit, else_exit]) // 4, 5 } - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { // // [pred] // | @@ -239,9 +239,9 @@ impl CFGBuilder { expr_exit } - ast::expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - ast::expr_loop(ref body, _) => { + ast::ExprLoop(ref body, _) => { // // [pred] // | @@ -269,7 +269,7 @@ impl CFGBuilder { expr_exit } - ast::expr_match(discr, ref arms) => { + ast::ExprMatch(discr, ref arms) => { // // [pred] // | @@ -306,7 +306,7 @@ impl CFGBuilder { expr_exit } - ast::expr_binary(_, op, l, r) if ast_util::lazy_binop(op) => { + ast::ExprBinary(_, op, l, r) if ast_util::lazy_binop(op) => { // // [pred] // | @@ -326,7 +326,7 @@ impl CFGBuilder { self.add_node(expr.id, [l_exit, r_exit]) // 3,4 } - ast::expr_ret(v) => { + ast::ExprRet(v) => { let v_exit = self.opt_expr(v, pred); let loop_scope = self.loop_scopes[0]; self.add_exiting_edge(expr, v_exit, @@ -334,99 +334,99 @@ impl CFGBuilder { self.add_node(expr.id, []) } - ast::expr_break(label) => { + ast::ExprBreak(label) => { let loop_scope = self.find_scope(expr, label); self.add_exiting_edge(expr, pred, loop_scope, loop_scope.break_index); self.add_node(expr.id, []) } - ast::expr_again(label) => { + ast::ExprAgain(label) => { let loop_scope = self.find_scope(expr, label); self.add_exiting_edge(expr, pred, loop_scope, loop_scope.continue_index); self.add_node(expr.id, []) } - ast::expr_vec(ref elems, _) => { + ast::ExprVec(ref elems, _) => { self.straightline(expr, pred, *elems) } - ast::expr_call(func, ref args, _) => { + ast::ExprCall(func, ref args, _) => { self.call(expr, pred, func, *args) } - ast::expr_method_call(_, rcvr, _, _, ref args, _) => { + ast::ExprMethodCall(_, rcvr, _, _, ref args, _) => { self.call(expr, pred, rcvr, *args) } - ast::expr_index(_, l, r) | - ast::expr_binary(_, _, l, r) if self.is_method_call(expr) => { + ast::ExprIndex(_, l, r) | + ast::ExprBinary(_, _, l, r) if self.is_method_call(expr) => { self.call(expr, pred, l, [r]) } - ast::expr_unary(_, _, e) if self.is_method_call(expr) => { + ast::ExprUnary(_, _, e) if self.is_method_call(expr) => { self.call(expr, pred, e, []) } - ast::expr_tup(ref exprs) => { + ast::ExprTup(ref exprs) => { self.straightline(expr, pred, *exprs) } - ast::expr_struct(_, ref fields, base) => { + ast::ExprStruct(_, ref fields, base) => { let base_exit = self.opt_expr(base, pred); - let field_exprs: ~[@ast::expr] = + let field_exprs: ~[@ast::Expr] = fields.iter().map(|f| f.expr).collect(); self.straightline(expr, base_exit, field_exprs) } - ast::expr_repeat(elem, count, _) => { + ast::ExprRepeat(elem, count, _) => { self.straightline(expr, pred, [elem, count]) } - ast::expr_assign(l, r) | - ast::expr_assign_op(_, _, l, r) => { + ast::ExprAssign(l, r) | + ast::ExprAssignOp(_, _, l, r) => { self.straightline(expr, pred, [r, l]) } - ast::expr_log(l, r) | - ast::expr_index(_, l, r) | - ast::expr_binary(_, _, l, r) => { // NB: && and || handled earlier + ast::ExprLog(l, r) | + ast::ExprIndex(_, l, r) | + ast::ExprBinary(_, _, l, r) => { // NB: && and || handled earlier self.straightline(expr, pred, [l, r]) } - ast::expr_addr_of(_, e) | - ast::expr_do_body(e) | - ast::expr_cast(e, _) | - ast::expr_unary(_, _, e) | - ast::expr_paren(e) | - ast::expr_vstore(e, _) | - ast::expr_field(e, _, _) => { + ast::ExprAddrOf(_, e) | + ast::ExprDoBody(e) | + ast::ExprCast(e, _) | + ast::ExprUnary(_, _, e) | + ast::ExprParen(e) | + ast::ExprVstore(e, _) | + ast::ExprField(e, _, _) => { self.straightline(expr, pred, [e]) } - ast::expr_mac(*) | - ast::expr_inline_asm(*) | - ast::expr_self | - ast::expr_fn_block(*) | - ast::expr_lit(*) | - ast::expr_path(*) => { + ast::ExprMac(*) | + ast::ExprInlineAsm(*) | + ast::ExprSelf | + ast::ExprFnBlock(*) | + ast::ExprLit(*) | + ast::ExprPath(*) => { self.straightline(expr, pred, []) } } } fn call(&mut self, - call_expr: @ast::expr, + call_expr: @ast::Expr, pred: CFGIndex, - func_or_rcvr: @ast::expr, - args: &[@ast::expr]) -> CFGIndex { + func_or_rcvr: @ast::Expr, + args: &[@ast::Expr]) -> CFGIndex { let func_or_rcvr_exit = self.expr(func_or_rcvr, pred); self.straightline(call_expr, func_or_rcvr_exit, args) } fn exprs(&mut self, - exprs: &[@ast::expr], + exprs: &[@ast::Expr], pred: CFGIndex) -> CFGIndex { //! Constructs graph for `exprs` evaluated in order @@ -434,7 +434,7 @@ impl CFGBuilder { } fn opt_expr(&mut self, - opt_expr: Option<@ast::expr>, + opt_expr: Option<@ast::Expr>, pred: CFGIndex) -> CFGIndex { //! Constructs graph for `opt_expr` evaluated, if Some @@ -442,9 +442,9 @@ impl CFGBuilder { } fn straightline(&mut self, - expr: @ast::expr, + expr: @ast::Expr, pred: CFGIndex, - subexprs: &[@ast::expr]) -> CFGIndex { + subexprs: &[@ast::Expr]) -> CFGIndex { //! Handles case of an expression that evaluates `subexprs` in order let subexprs_exit = self.exprs(subexprs, pred); @@ -473,7 +473,7 @@ impl CFGBuilder { } fn add_exiting_edge(&mut self, - from_expr: @ast::expr, + from_expr: @ast::Expr, from_index: CFGIndex, to_loop: LoopScope, to_index: CFGIndex) { @@ -487,7 +487,7 @@ impl CFGBuilder { } fn find_scope(&self, - expr: @ast::expr, + expr: @ast::Expr, label: Option) -> LoopScope { match label { None => { @@ -496,7 +496,7 @@ impl CFGBuilder { Some(_) => { match self.tcx.def_map.find(&expr.id) { - Some(&ast::def_label(loop_id)) => { + Some(&ast::DefLabel(loop_id)) => { for l in self.loop_scopes.iter() { if l.loop_id == loop_id { return *l; @@ -517,7 +517,7 @@ impl CFGBuilder { } } - fn is_method_call(&self, expr: &ast::expr) -> bool { + fn is_method_call(&self, expr: &ast::Expr) -> bool { self.method_map.contains_key(&expr.id) } } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 6a4570474f037..1ef3b6b7869a5 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -33,10 +33,10 @@ impl Visitor for CheckCrateVisitor { 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) { + fn visit_pat(&mut self, p:@Pat, env:bool) { check_pat(self, p, env); } - fn visit_expr(&mut self, ex:@expr, env:bool) { + fn visit_expr(&mut self, ex:@Expr, env:bool) { check_expr(self, self.sess, self.def_map, self.method_map, self.tcx, ex, env); } @@ -81,23 +81,23 @@ pub fn check_item(v: &mut CheckCrateVisitor, } } -pub fn check_pat(v: &mut CheckCrateVisitor, p: @pat, _is_const: bool) { - fn is_str(e: @expr) -> bool { +pub fn check_pat(v: &mut CheckCrateVisitor, p: @Pat, _is_const: bool) { + fn is_str(e: @Expr) -> bool { match e.node { - expr_vstore( - @expr { node: expr_lit(@codemap::Spanned { + ExprVstore( + @Expr { node: ExprLit(@codemap::Spanned { node: lit_str(_), _}), _ }, - expr_vstore_uniq + ExprVstoreUniq ) => true, _ => false } } match p.node { // Let through plain ~-string literals here - pat_lit(a) => if !is_str(a) { v.visit_expr(a, true); }, - pat_range(a, b) => { + PatLit(a) => if !is_str(a) { v.visit_expr(a, true); }, + PatRange(a, b) => { if !is_str(a) { v.visit_expr(a, true); } if !is_str(b) { v.visit_expr(b, true); } } @@ -110,25 +110,25 @@ pub fn check_expr(v: &mut CheckCrateVisitor, def_map: resolve::DefMap, method_map: typeck::method_map, tcx: ty::ctxt, - e: @expr, + e: @Expr, is_const: bool) { if is_const { match e.node { - expr_unary(_, deref, _) => { } - expr_unary(_, box(_), _) | expr_unary(_, uniq, _) => { + ExprUnary(_, UnDeref, _) => { } + ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) => { sess.span_err(e.span, "disallowed operator in constant expression"); return; } - expr_lit(@codemap::Spanned {node: lit_str(_), _}) => { } - expr_binary(*) | expr_unary(*) => { + ExprLit(@codemap::Spanned {node: lit_str(_), _}) => { } + ExprBinary(*) | ExprUnary(*) => { if method_map.contains_key(&e.id) { sess.span_err(e.span, "user-defined operators are not \ allowed in constant expressions"); } } - expr_lit(_) => (), - expr_cast(_, _) => { + ExprLit(_) => (), + ExprCast(_, _) => { let ety = ty::expr_ty(tcx, e); if !ty::type_is_numeric(ety) && !ty::type_is_unsafe_ptr(ety) { sess.span_err(e.span, ~"can not cast to `" + @@ -136,7 +136,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor, "` in a constant expression"); } } - expr_path(ref pth) => { + ExprPath(ref pth) => { // NB: In the future you might wish to relax this slightly // to handle on-demand instantiation of functions via // foo:: in a const. Currently that is only done on @@ -147,10 +147,10 @@ pub fn check_expr(v: &mut CheckCrateVisitor, items without type parameters"); } match def_map.find(&e.id) { - Some(&def_static(*)) | - Some(&def_fn(_, _)) | - Some(&def_variant(_, _)) | - Some(&def_struct(_)) => { } + Some(&DefStatic(*)) | + Some(&DefFn(_, _)) | + Some(&DefVariant(_, _)) | + Some(&DefStruct(_)) => { } Some(&def) => { debug!("(checking const) found bad def: %?", def); @@ -164,10 +164,10 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } } } - expr_call(callee, _, NoSugar) => { + ExprCall(callee, _, NoSugar) => { match def_map.find(&callee.id) { - Some(&def_struct(*)) => {} // OK. - Some(&def_variant(*)) => {} // OK. + Some(&DefStruct(*)) => {} // OK. + Some(&DefVariant(*)) => {} // OK. _ => { sess.span_err( e.span, @@ -176,17 +176,17 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } } } - expr_paren(e) => { check_expr(v, sess, def_map, method_map, + ExprParen(e) => { check_expr(v, sess, def_map, method_map, tcx, e, is_const); } - expr_vstore(_, expr_vstore_slice) | - expr_vec(_, m_imm) | - expr_addr_of(m_imm, _) | - expr_field(*) | - expr_index(*) | - expr_tup(*) | - expr_repeat(*) | - expr_struct(*) => { } - expr_addr_of(*) => { + ExprVstore(_, ExprVstoreSlice) | + ExprVec(_, MutImmutable) | + ExprAddrOf(MutImmutable, _) | + ExprField(*) | + ExprIndex(*) | + ExprTup(*) | + ExprRepeat(*) | + ExprStruct(*) => { } + ExprAddrOf(*) => { sess.span_err( e.span, "borrowed pointers in constants may only refer to \ @@ -200,7 +200,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } } match e.node { - expr_lit(@codemap::Spanned {node: lit_int(v, t), _}) => { + ExprLit(@codemap::Spanned {node: lit_int(v, t), _}) => { if t != ty_char { if (v as u64) > ast_util::int_ty_max( if t == ty_i { sess.targ_cfg.int_type } else { t }) { @@ -208,7 +208,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor, } } } - expr_lit(@codemap::Spanned {node: lit_uint(v, t), _}) => { + ExprLit(@codemap::Spanned {node: lit_uint(v, t), _}) => { if v > ast_util::uint_ty_max( if t == ty_u { sess.targ_cfg.uint_type } else { t }) { sess.span_err(e.span, "literal out of range for its type"); @@ -258,10 +258,10 @@ impl Visitor for CheckItemRecursionVisitor { env.idstack.pop(); } - fn visit_expr(&mut self, e: @expr, env: env) { + fn visit_expr(&mut self, e: @Expr, env: env) { match e.node { - expr_path(*) => match env.def_map.find(&e.id) { - Some(&def_static(def_id, _)) if ast_util::is_local(def_id) => + ExprPath(*) => match env.def_map.find(&e.id) { + Some(&DefStatic(def_id, _)) if ast_util::is_local(def_id) => match env.ast_map.get_copy(&def_id.node) { ast_map::node_item(it, _) => { self.visit_item(it, env); diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index 35705dff6ef98..cc3511aa51f28 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -39,30 +39,30 @@ impl Visitor for CheckLoopVisitor { }); } - fn visit_expr(&mut self, e:@expr, cx:Context) { + fn visit_expr(&mut self, e:@Expr, cx:Context) { match e.node { - expr_while(e, ref b) => { + ExprWhile(e, ref b) => { self.visit_expr(e, cx); self.visit_block(b, Context { in_loop: true,.. cx }); } - expr_loop(ref b, _) => { + ExprLoop(ref b, _) => { self.visit_block(b, Context { in_loop: true,.. cx }); } - expr_fn_block(_, ref b) => { + ExprFnBlock(_, ref b) => { self.visit_block(b, Context { in_loop: false, can_ret: false }); } - expr_break(_) => { + ExprBreak(_) => { if !cx.in_loop { self.tcx.sess.span_err(e.span, "`break` outside of loop"); } } - expr_again(_) => { + ExprAgain(_) => { if !cx.in_loop { self.tcx.sess.span_err(e.span, "`loop` outside of loop"); } } - expr_ret(oe) => { + ExprRet(oe) => { if !cx.can_ret { self.tcx.sess.span_err(e.span, "`return` in block function"); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 1996f84591465..14a4601e4155c 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -39,7 +39,7 @@ struct CheckMatchVisitor { } impl Visitor<()> for CheckMatchVisitor { - fn visit_expr(&mut self, ex:@expr, e:()) { + fn visit_expr(&mut self, ex:@Expr, e:()) { check_expr(self, self.cx, ex, e); } fn visit_local(&mut self, l:@Local, e:()) { @@ -66,11 +66,11 @@ pub fn check_crate(tcx: ty::ctxt, pub fn check_expr(v: &mut CheckMatchVisitor, cx: @MatchCheckCtxt, - ex: @expr, + ex: @Expr, s: ()) { visit::walk_expr(v, ex, s); match ex.node { - expr_match(scrut, ref arms) => { + ExprMatch(scrut, ref arms) => { // First, check legality of move bindings. for arm in arms.iter() { check_legality_of_move_bindings(cx, @@ -103,7 +103,7 @@ pub fn check_expr(v: &mut CheckMatchVisitor, } _ => { /* We assume only enum types can be uninhabited */ } } - let arms = arms.iter().filter_map(unguarded_pat).collect::<~[~[@pat]]>().concat_vec(); + let arms = arms.iter().filter_map(unguarded_pat).collect::<~[~[@Pat]]>().concat_vec(); if arms.is_empty() { cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns"); } else { @@ -115,15 +115,15 @@ pub fn check_expr(v: &mut CheckMatchVisitor, } // Check for unreachable patterns -pub fn check_arms(cx: &MatchCheckCtxt, arms: &[arm]) { +pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) { let mut seen = ~[]; for arm in arms.iter() { for pat in arm.pats.iter() { // Check that we do not match against a static NaN (#6804) - let pat_matches_nan: &fn(@pat) -> bool = |p| { + let pat_matches_nan: &fn(@Pat) -> bool = |p| { match cx.tcx.def_map.find(&p.id) { - Some(&def_static(did, false)) => { + Some(&DefStatic(did, false)) => { let const_expr = lookup_const_by_id(cx.tcx, did).unwrap(); match eval_const_expr(cx.tcx, const_expr) { const_float(f) if f.is_NaN() => true, @@ -153,14 +153,14 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[arm]) { } } -pub fn raw_pat(p: @pat) -> @pat { +pub fn raw_pat(p: @Pat) -> @Pat { match p.node { - pat_ident(_, _, Some(s)) => { raw_pat(s) } + PatIdent(_, _, Some(s)) => { raw_pat(s) } _ => { p } } } -pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@pat]) { +pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) { assert!((!pats.is_empty())); let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) { not_useful => { @@ -208,14 +208,14 @@ pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@pat]) { cx.tcx.sess.span_err(sp, msg); } -pub type matrix = ~[~[@pat]]; +pub type matrix = ~[~[@Pat]]; pub enum useful { useful(ty::t, ctor), useful_, not_useful } #[deriving(Eq)] pub enum ctor { single, - variant(def_id), + variant(DefId), val(const_val), range(const_val, const_val), vec(uint) @@ -234,7 +234,7 @@ pub enum ctor { // Note: is_useful doesn't work on empty types, as the paper notes. // So it assumes that v is non-empty. -pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful { +pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful { if m.len() == 0u { return useful_; } if m[0].len() == 0u { return not_useful; } let real_pat = match m.iter().find(|r| r[0].id != 0) { @@ -276,7 +276,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful { ty::ty_unboxed_vec(*) | ty::ty_evec(*) => { let max_len = do m.rev_iter().fold(0) |max_len, r| { match r[0].node { - pat_vec(ref before, _, ref after) => { + PatVec(ref before, _, ref after) => { num::max(before.len() + after.len(), max_len) } _ => max_len @@ -315,7 +315,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful { pub fn is_useful_specialized(cx: &MatchCheckCtxt, m: &matrix, - v: &[@pat], + v: &[@Pat], ctor: ctor, arity: uint, lty: ty::t) @@ -329,34 +329,34 @@ pub fn is_useful_specialized(cx: &MatchCheckCtxt, } } -pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @pat) -> Option { +pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option { let pat = raw_pat(p); match pat.node { - pat_wild => { None } - pat_ident(_, _, _) | pat_enum(_, _) => { + PatWild => { None } + PatIdent(_, _, _) | PatEnum(_, _) => { match cx.tcx.def_map.find(&pat.id) { - Some(&def_variant(_, id)) => Some(variant(id)), - Some(&def_static(did, false)) => { + Some(&DefVariant(_, id)) => Some(variant(id)), + Some(&DefStatic(did, false)) => { let const_expr = lookup_const_by_id(cx.tcx, did).unwrap(); Some(val(eval_const_expr(cx.tcx, const_expr))) } _ => None } } - pat_lit(expr) => { Some(val(eval_const_expr(cx.tcx, expr))) } - pat_range(lo, hi) => { + PatLit(expr) => { Some(val(eval_const_expr(cx.tcx, expr))) } + PatRange(lo, hi) => { Some(range(eval_const_expr(cx.tcx, lo), eval_const_expr(cx.tcx, hi))) } - pat_struct(*) => { + PatStruct(*) => { match cx.tcx.def_map.find(&pat.id) { - Some(&def_variant(_, id)) => Some(variant(id)), + Some(&DefVariant(_, id)) => Some(variant(id)), _ => Some(single) } } - pat_box(_) | pat_uniq(_) | pat_tup(_) | pat_region(*) => { + PatBox(_) | PatUniq(_) | PatTup(_) | PatRegion(*) => { Some(single) } - pat_vec(ref before, slice, ref after) => { + PatVec(ref before, slice, ref after) => { match slice { Some(_) => None, None => Some(vec(before.len() + after.len())) @@ -365,13 +365,13 @@ pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @pat) -> Option { } } -pub fn is_wild(cx: &MatchCheckCtxt, p: @pat) -> bool { +pub fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool { let pat = raw_pat(p); match pat.node { - pat_wild => { true } - pat_ident(_, _, _) => { + PatWild => { true } + PatIdent(_, _, _) => { match cx.tcx.def_map.find(&pat.id) { - Some(&def_variant(_, _)) | Some(&def_static(*)) => { false } + Some(&DefVariant(_, _)) | Some(&DefStatic(*)) => { false } _ => { true } } } @@ -432,7 +432,7 @@ pub fn missing_ctor(cx: &MatchCheckCtxt, let mut wrong = false; for r in m.iter() { match r[0].node { - pat_vec(ref before, ref slice, ref after) => { + PatVec(ref before, ref slice, ref after) => { let count = before.len() + after.len(); if (count < n && slice.is_none()) || count > n { wrong = true; @@ -455,7 +455,7 @@ pub fn missing_ctor(cx: &MatchCheckCtxt, // Find the lengths and slices of all vector patterns. let vec_pat_lens = do m.iter().filter_map |r| { match r[0].node { - pat_vec(ref before, ref slice, ref after) => { + PatVec(ref before, ref slice, ref after) => { Some((before.len() + after.len(), slice.is_some())) } _ => None @@ -527,34 +527,34 @@ pub fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint { } } -pub fn wild() -> @pat { - @pat {id: 0, node: pat_wild, span: dummy_sp()} +pub fn wild() -> @Pat { + @Pat {id: 0, node: PatWild, span: dummy_sp()} } pub fn specialize(cx: &MatchCheckCtxt, - r: &[@pat], + r: &[@Pat], ctor_id: &ctor, arity: uint, left_ty: ty::t) - -> Option<~[@pat]> { + -> Option<~[@Pat]> { // Sad, but I can't get rid of this easily let r0 = (*raw_pat(r[0])).clone(); match r0 { - pat{id: pat_id, node: n, span: pat_span} => + Pat{id: pat_id, node: n, span: pat_span} => match n { - pat_wild => { + PatWild => { Some(vec::append(vec::from_elem(arity, wild()), r.tail())) } - pat_ident(_, _, _) => { + PatIdent(_, _, _) => { match cx.tcx.def_map.find(&pat_id) { - Some(&def_variant(_, id)) => { + Some(&DefVariant(_, id)) => { if variant(id) == *ctor_id { Some(r.tail().to_owned()) } else { None } } - Some(&def_static(did, _)) => { + Some(&DefStatic(did, _)) => { let const_expr = lookup_const_by_id(cx.tcx, did).unwrap(); let e_v = eval_const_expr(cx.tcx, const_expr); @@ -602,9 +602,9 @@ pub fn specialize(cx: &MatchCheckCtxt, } } } - pat_enum(_, args) => { + PatEnum(_, args) => { match cx.tcx.def_map.get_copy(&pat_id) { - def_static(did, _) => { + DefStatic(did, _) => { let const_expr = lookup_const_by_id(cx.tcx, did).unwrap(); let e_v = eval_const_expr(cx.tcx, const_expr); @@ -639,17 +639,17 @@ pub fn specialize(cx: &MatchCheckCtxt, None } } - def_variant(_, id) if variant(id) == *ctor_id => { + DefVariant(_, id) if variant(id) == *ctor_id => { let args = match args { Some(args) => args, None => vec::from_elem(arity, wild()) }; Some(vec::append(args, r.tail())) } - def_variant(_, _) => None, + DefVariant(_, _) => None, - def_fn(*) | - def_struct(*) => { + DefFn(*) | + DefStruct(*) => { // FIXME #4731: Is this right? --pcw let new_args; match args { @@ -661,10 +661,10 @@ pub fn specialize(cx: &MatchCheckCtxt, _ => None } } - pat_struct(_, ref flds, _) => { + PatStruct(_, ref flds, _) => { // Is this a struct or an enum variant? match cx.tcx.def_map.get_copy(&pat_id) { - def_variant(_, variant_id) => { + DefVariant(_, variant_id) => { if variant(variant_id) == *ctor_id { // FIXME #4731: Is this right? --pcw let args = flds.map(|ty_field| { @@ -709,11 +709,11 @@ pub fn specialize(cx: &MatchCheckCtxt, } } } - pat_tup(args) => Some(vec::append(args, r.tail())), - pat_box(a) | pat_uniq(a) | pat_region(a) => { + PatTup(args) => Some(vec::append(args, r.tail())), + PatBox(a) | PatUniq(a) | PatRegion(a) => { Some(vec::append(~[a], r.tail())) } - pat_lit(expr) => { + PatLit(expr) => { let e_v = eval_const_expr(cx.tcx, expr); let match_ = match *ctor_id { val(ref v) => { @@ -743,7 +743,7 @@ pub fn specialize(cx: &MatchCheckCtxt, }; if match_ { Some(r.tail().to_owned()) } else { None } } - pat_range(lo, hi) => { + PatRange(lo, hi) => { let (c_lo, c_hi) = match *ctor_id { val(ref v) => (*v, *v), range(ref lo, ref hi) => (*lo, *hi), @@ -767,7 +767,7 @@ pub fn specialize(cx: &MatchCheckCtxt, } } } - pat_vec(before, slice, after) => { + PatVec(before, slice, after) => { match *ctor_id { vec(_) => { let num_elements = before.len() + after.len(); @@ -797,7 +797,7 @@ pub fn specialize(cx: &MatchCheckCtxt, } } -pub fn default(cx: &MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> { +pub fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> { if is_wild(cx, r[0]) { Some(r.tail().to_owned()) } else { None } } @@ -833,39 +833,39 @@ pub fn check_fn(v: &mut CheckMatchVisitor, } } -pub fn is_refutable(cx: &MatchCheckCtxt, pat: &pat) -> bool { +pub fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool { match cx.tcx.def_map.find(&pat.id) { - Some(&def_variant(enum_id, _)) => { + Some(&DefVariant(enum_id, _)) => { if ty::enum_variants(cx.tcx, enum_id).len() != 1u { return true; } } - Some(&def_static(*)) => return true, + Some(&DefStatic(*)) => return true, _ => () } match pat.node { - pat_box(sub) | pat_uniq(sub) | pat_region(sub) | - pat_ident(_, _, Some(sub)) => { + PatBox(sub) | PatUniq(sub) | PatRegion(sub) | + PatIdent(_, _, Some(sub)) => { is_refutable(cx, sub) } - pat_wild | pat_ident(_, _, None) => { false } - pat_lit(@expr {node: expr_lit(@Spanned { node: lit_nil, _}), _}) => { + PatWild | PatIdent(_, _, None) => { false } + PatLit(@Expr {node: ExprLit(@Spanned { node: lit_nil, _}), _}) => { // "()" false } - pat_lit(_) | pat_range(_, _) => { true } - pat_struct(_, ref fields, _) => { + PatLit(_) | PatRange(_, _) => { true } + PatStruct(_, ref fields, _) => { fields.iter().any(|f| is_refutable(cx, f.pat)) } - pat_tup(ref elts) => { + PatTup(ref elts) => { elts.iter().any(|elt| is_refutable(cx, *elt)) } - pat_enum(_, Some(ref args)) => { + PatEnum(_, Some(ref args)) => { args.iter().any(|a| is_refutable(cx, *a)) } - pat_enum(_,_) => { false } - pat_vec(*) => { true } + PatEnum(_,_) => { false } + PatVec(*) => { true } } } @@ -873,7 +873,7 @@ pub fn is_refutable(cx: &MatchCheckCtxt, pat: &pat) -> bool { pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, has_guard: bool, - pats: &[@pat]) { + pats: &[@Pat]) { let tcx = cx.tcx; let def_map = tcx.def_map; let mut by_ref_span = None; @@ -881,10 +881,10 @@ pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, for pat in pats.iter() { do pat_bindings(def_map, *pat) |bm, id, span, _path| { match bm { - bind_by_ref(_) => { + BindByRef(_) => { by_ref_span = Some(span); } - bind_infer => { + BindInfer => { if cx.moves_map.contains(&id) { any_by_move = true; } @@ -893,7 +893,7 @@ pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, } } - let check_move: &fn(@pat, Option<@pat>) = |p, sub| { + let check_move: &fn(@Pat, Option<@Pat>) = |p, sub| { // check legality of moving out of the enum // x @ Foo(*) is legal, but x @ Foo(y) isn't. @@ -921,7 +921,7 @@ pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, do walk_pat(*pat) |p| { if pat_is_binding(def_map, p) { match p.node { - pat_ident(_, _, sub) => { + PatIdent(_, _, sub) => { if cx.moves_map.contains(&p.id) { check_move(p, sub); } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 2e8d0d351d997..be09dde322b33 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -75,7 +75,7 @@ pub fn join_all>(mut cs: It) -> constness { cs.fold(integral_const, |a, b| join(a, b)) } -pub fn classify(e: &expr, +pub fn classify(e: &Expr, tcx: ty::ctxt) -> constness { let did = ast_util::local_def(e.id); @@ -84,7 +84,7 @@ pub fn classify(e: &expr, None => { let cn = match e.node { - ast::expr_lit(lit) => { + ast::ExprLit(lit) => { match lit.node { ast::lit_str(*) | ast::lit_float(*) => general_const, @@ -92,39 +92,39 @@ pub fn classify(e: &expr, } } - ast::expr_unary(_, _, inner) | - ast::expr_paren(inner) => { + ast::ExprUnary(_, _, inner) | + ast::ExprParen(inner) => { classify(inner, tcx) } - ast::expr_binary(_, _, a, b) => { + ast::ExprBinary(_, _, a, b) => { join(classify(a, tcx), classify(b, tcx)) } - ast::expr_tup(ref es) | - ast::expr_vec(ref es, ast::m_imm) => { + ast::ExprTup(ref es) | + ast::ExprVec(ref es, ast::MutImmutable) => { join_all(es.iter().map(|e| classify(*e, tcx))) } - ast::expr_vstore(e, vstore) => { + ast::ExprVstore(e, vstore) => { match vstore { - ast::expr_vstore_slice => classify(e, tcx), - ast::expr_vstore_uniq | - ast::expr_vstore_box | - ast::expr_vstore_mut_box | - ast::expr_vstore_mut_slice => non_const + ast::ExprVstoreSlice => classify(e, tcx), + ast::ExprVstoreUniq | + ast::ExprVstoreBox | + ast::ExprVstoreMutBox | + ast::ExprVstoreMutSlice => non_const } } - ast::expr_struct(_, ref fs, None) => { + ast::ExprStruct(_, ref fs, None) => { let cs = do fs.iter().map |f| { classify(f.expr, tcx) }; join_all(cs) } - ast::expr_cast(base, _) => { + ast::ExprCast(base, _) => { let ty = ty::expr_ty(tcx, e); let base = classify(base, tcx); if ty::type_is_integral(ty) { @@ -136,26 +136,26 @@ pub fn classify(e: &expr, } } - ast::expr_field(base, _, _) => { + ast::ExprField(base, _, _) => { classify(base, tcx) } - ast::expr_index(_, base, idx) => { + ast::ExprIndex(_, base, idx) => { join(classify(base, tcx), classify(idx, tcx)) } - ast::expr_addr_of(ast::m_imm, base) => { + ast::ExprAddrOf(ast::MutImmutable, base) => { classify(base, tcx) } // FIXME: (#3728) we can probably do something CCI-ish // surrounding nonlocal constants. But we don't yet. - ast::expr_path(_) => { + ast::ExprPath(_) => { lookup_constness(tcx, e) } - ast::expr_repeat(*) => general_const, + ast::ExprRepeat(*) => general_const, _ => non_const }; @@ -165,10 +165,10 @@ pub fn classify(e: &expr, } } -pub fn lookup_const(tcx: ty::ctxt, e: &expr) -> Option<@expr> { +pub fn lookup_const(tcx: ty::ctxt, e: &Expr) -> Option<@Expr> { match tcx.def_map.find(&e.id) { - Some(&ast::def_static(def_id, false)) => lookup_const_by_id(tcx, def_id), - Some(&ast::def_variant(enum_def, variant_def)) => lookup_variant_by_id(tcx, + Some(&ast::DefStatic(def_id, false)) => lookup_const_by_id(tcx, def_id), + Some(&ast::DefVariant(enum_def, variant_def)) => lookup_variant_by_id(tcx, enum_def, variant_def), _ => None @@ -176,10 +176,10 @@ pub fn lookup_const(tcx: ty::ctxt, e: &expr) -> Option<@expr> { } pub fn lookup_variant_by_id(tcx: ty::ctxt, - enum_def: ast::def_id, - variant_def: ast::def_id) - -> Option<@expr> { - fn variant_expr(variants: &[ast::variant], id: ast::NodeId) -> Option<@expr> { + enum_def: ast::DefId, + variant_def: ast::DefId) + -> Option<@Expr> { + fn variant_expr(variants: &[ast::variant], id: ast::NodeId) -> Option<@Expr> { for variant in variants.iter() { if variant.node.id == id { return variant.node.disr_expr; @@ -225,13 +225,13 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt, } pub fn lookup_const_by_id(tcx: ty::ctxt, - def_id: ast::def_id) - -> Option<@expr> { + def_id: ast::DefId) + -> Option<@Expr> { if ast_util::is_local(def_id) { match tcx.items.find(&def_id.node) { None => None, Some(&ast_map::node_item(it, _)) => match it.node { - item_static(_, ast::m_imm, const_expr) => Some(const_expr), + item_static(_, ast::MutImmutable, const_expr) => Some(const_expr), _ => None }, Some(_) => None @@ -247,7 +247,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, 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::m_imm, const_expr) => Some(const_expr), + item_static(_, ast::MutImmutable, const_expr) => Some(const_expr), _ => None }, _ => None @@ -255,7 +255,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, } } -pub fn lookup_constness(tcx: ty::ctxt, e: &expr) -> constness { +pub fn lookup_constness(tcx: ty::ctxt, e: &Expr) -> constness { match lookup_const(tcx, e) { Some(rhs) => { let ty = ty::expr_ty(tcx, rhs); @@ -272,7 +272,7 @@ pub fn lookup_constness(tcx: ty::ctxt, e: &expr) -> constness { struct ConstEvalVisitor { tcx: ty::ctxt } impl Visitor<()> for ConstEvalVisitor { - fn visit_expr_post(&mut self, e:@expr, _:()) { + fn visit_expr_post(&mut self, e:@Expr, _:()) { classify(e, self.tcx); } } @@ -296,19 +296,19 @@ pub enum const_val { const_bool(bool) } -pub fn eval_const_expr(tcx: middle::ty::ctxt, e: &expr) -> const_val { +pub fn eval_const_expr(tcx: middle::ty::ctxt, e: &Expr) -> const_val { match eval_const_expr_partial(&tcx, e) { Ok(r) => r, Err(s) => tcx.sess.span_fatal(e.span, s) } } -pub fn eval_const_expr_partial(tcx: &T, e: &expr) +pub fn eval_const_expr_partial(tcx: &T, e: &Expr) -> Result { use middle::ty; fn fromb(b: bool) -> Result { Ok(const_int(b as i64)) } match e.node { - expr_unary(_, neg, inner) => { + ExprUnary(_, UnNeg, inner) => { match eval_const_expr_partial(tcx, inner) { Ok(const_float(f)) => Ok(const_float(-f)), Ok(const_int(i)) => Ok(const_int(-i)), @@ -318,7 +318,7 @@ pub fn eval_const_expr_partial(tcx: &T, e: &expr) ref err => ((*err).clone()) } } - expr_unary(_, not, inner) => { + ExprUnary(_, UnNot, inner) => { match eval_const_expr_partial(tcx, inner) { Ok(const_int(i)) => Ok(const_int(!i)), Ok(const_uint(i)) => Ok(const_uint(!i)), @@ -326,100 +326,100 @@ pub fn eval_const_expr_partial(tcx: &T, e: &expr) _ => Err(~"Not on float or string") } } - expr_binary(_, op, a, b) => { + ExprBinary(_, op, a, b) => { match (eval_const_expr_partial(tcx, a), eval_const_expr_partial(tcx, b)) { (Ok(const_float(a)), Ok(const_float(b))) => { match op { - add => Ok(const_float(a + b)), - subtract => Ok(const_float(a - b)), - mul => Ok(const_float(a * b)), - div => Ok(const_float(a / b)), - rem => Ok(const_float(a % b)), - eq => fromb(a == b), - lt => fromb(a < b), - le => fromb(a <= b), - ne => fromb(a != b), - ge => fromb(a >= b), - gt => fromb(a > b), + BiAdd => Ok(const_float(a + b)), + BiSub => Ok(const_float(a - b)), + BiMul => Ok(const_float(a * b)), + BiDiv => Ok(const_float(a / b)), + BiRem => Ok(const_float(a % b)), + BiEq => fromb(a == b), + BiLt => fromb(a < b), + BiLe => fromb(a <= b), + BiNe => fromb(a != b), + BiGe => fromb(a >= b), + BiGt => fromb(a > b), _ => Err(~"Can't do this op on floats") } } (Ok(const_int(a)), Ok(const_int(b))) => { match op { - add => Ok(const_int(a + b)), - subtract => Ok(const_int(a - b)), - mul => Ok(const_int(a * b)), - div if b == 0 => Err(~"attempted to divide by zero"), - div => Ok(const_int(a / b)), - rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), - rem => Ok(const_int(a % b)), - and | bitand => Ok(const_int(a & b)), - or | bitor => Ok(const_int(a | b)), - bitxor => Ok(const_int(a ^ b)), - shl => Ok(const_int(a << b)), - shr => Ok(const_int(a >> b)), - eq => fromb(a == b), - lt => fromb(a < b), - le => fromb(a <= b), - ne => fromb(a != b), - ge => fromb(a >= b), - gt => fromb(a > b) + BiAdd => Ok(const_int(a + b)), + BiSub => Ok(const_int(a - b)), + BiMul => Ok(const_int(a * b)), + BiDiv if b == 0 => Err(~"attempted to divide by zero"), + BiDiv => Ok(const_int(a / b)), + BiRem if b == 0 => Err(~"attempted remainder with a divisor of zero"), + BiRem => Ok(const_int(a % b)), + BiAnd | BiBitAnd => Ok(const_int(a & b)), + BiOr | BiBitOr => Ok(const_int(a | b)), + BiBitXor => Ok(const_int(a ^ b)), + BiShl => Ok(const_int(a << b)), + BiShr => Ok(const_int(a >> b)), + BiEq => fromb(a == b), + BiLt => fromb(a < b), + BiLe => fromb(a <= b), + BiNe => fromb(a != b), + BiGe => fromb(a >= b), + BiGt => fromb(a > b) } } (Ok(const_uint(a)), Ok(const_uint(b))) => { match op { - add => Ok(const_uint(a + b)), - subtract => Ok(const_uint(a - b)), - mul => Ok(const_uint(a * b)), - div if b == 0 => Err(~"attempted to divide by zero"), - div => Ok(const_uint(a / b)), - rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), - rem => Ok(const_uint(a % b)), - and | bitand => Ok(const_uint(a & b)), - or | bitor => Ok(const_uint(a | b)), - bitxor => Ok(const_uint(a ^ b)), - shl => Ok(const_uint(a << b)), - shr => Ok(const_uint(a >> b)), - eq => fromb(a == b), - lt => fromb(a < b), - le => fromb(a <= b), - ne => fromb(a != b), - ge => fromb(a >= b), - gt => fromb(a > b), + BiAdd => Ok(const_uint(a + b)), + BiSub => Ok(const_uint(a - b)), + BiMul => Ok(const_uint(a * b)), + BiDiv if b == 0 => Err(~"attempted to divide by zero"), + BiDiv => Ok(const_uint(a / b)), + BiRem if b == 0 => Err(~"attempted remainder with a divisor of zero"), + BiRem => Ok(const_uint(a % b)), + BiAnd | BiBitAnd => Ok(const_uint(a & b)), + BiOr | BiBitOr => Ok(const_uint(a | b)), + BiBitXor => Ok(const_uint(a ^ b)), + BiShl => Ok(const_uint(a << b)), + BiShr => Ok(const_uint(a >> b)), + BiEq => fromb(a == b), + BiLt => fromb(a < b), + BiLe => fromb(a <= b), + BiNe => fromb(a != b), + BiGe => fromb(a >= b), + BiGt => fromb(a > b), } } // shifts can have any integral type as their rhs (Ok(const_int(a)), Ok(const_uint(b))) => { match op { - shl => Ok(const_int(a << b)), - shr => Ok(const_int(a >> b)), + BiShl => Ok(const_int(a << b)), + BiShr => Ok(const_int(a >> b)), _ => Err(~"Can't do this op on an int and uint") } } (Ok(const_uint(a)), Ok(const_int(b))) => { match op { - shl => Ok(const_uint(a << b)), - shr => Ok(const_uint(a >> b)), + BiShl => Ok(const_uint(a << b)), + BiShr => Ok(const_uint(a >> b)), _ => Err(~"Can't do this op on a uint and int") } } (Ok(const_bool(a)), Ok(const_bool(b))) => { Ok(const_bool(match op { - and => a && b, - or => a || b, - bitxor => a ^ b, - bitand => a & b, - bitor => a | b, - eq => a == b, - ne => a != b, + BiAnd => a && b, + BiOr => a || b, + BiBitXor => a ^ b, + BiBitAnd => a & b, + BiBitOr => a | b, + BiEq => a == b, + BiNe => a != b, _ => return Err(~"Can't do this op on bools") })) } _ => Err(~"Bad operands for binary") } } - expr_cast(base, _) => { + ExprCast(base, _) => { let ety = tcx.expr_ty(e); let base = eval_const_expr_partial(tcx, base); match base { @@ -455,16 +455,16 @@ pub fn eval_const_expr_partial(tcx: &T, e: &expr) } } } - expr_path(_) => { + ExprPath(_) => { match lookup_const(tcx.ty_ctxt(), e) { Some(actual_e) => eval_const_expr_partial(&tcx.ty_ctxt(), actual_e), None => Err(~"Non-constant path in constant expr") } } - expr_lit(lit) => Ok(lit_to_const(lit)), + ExprLit(lit) => Ok(lit_to_const(lit)), // If we have a vstore, just keep going; it has to be a string - expr_vstore(e, _) => eval_const_expr_partial(tcx, e), - expr_paren(e) => eval_const_expr_partial(tcx, e), + ExprVstore(e, _) => eval_const_expr_partial(tcx, e), + ExprParen(e) => eval_const_expr_partial(tcx, e), _ => Err(~"Unsupported constant expr") } } @@ -497,11 +497,11 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option { } } -pub fn compare_lit_exprs(tcx: middle::ty::ctxt, a: &expr, b: &expr) -> Option { +pub fn compare_lit_exprs(tcx: middle::ty::ctxt, a: &Expr, b: &Expr) -> Option { compare_const_vals(&eval_const_expr(tcx, a), &eval_const_expr(tcx, b)) } -pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: &expr, b: &expr) -> Option { +pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: &Expr, b: &Expr) -> Option { compare_lit_exprs(tcx, a, b).map_move(|val| val == 0) } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 42dae2017bc8b..b392351c2f293 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -390,40 +390,40 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn walk_stmt(&mut self, - stmt: @ast::stmt, + stmt: @ast::Stmt, in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { match stmt.node { - ast::stmt_decl(decl, _) => { + ast::StmtDecl(decl, _) => { self.walk_decl(decl, in_out, loop_scopes); } - ast::stmt_expr(expr, _) | ast::stmt_semi(expr, _) => { + ast::StmtExpr(expr, _) | ast::StmtSemi(expr, _) => { self.walk_expr(expr, in_out, loop_scopes); } - ast::stmt_mac(*) => { + ast::StmtMac(*) => { self.tcx().sess.span_bug(stmt.span, "unexpanded macro"); } } } fn walk_decl(&mut self, - decl: @ast::decl, + decl: @ast::Decl, in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { match decl.node { - ast::decl_local(local) => { + ast::DeclLocal(local) => { self.walk_opt_expr(local.init, in_out, loop_scopes); self.walk_pat(local.pat, in_out, loop_scopes); } - ast::decl_item(_) => {} + ast::DeclItem(_) => {} } } fn walk_expr(&mut self, - expr: @ast::expr, + expr: @ast::Expr, in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { debug!("DataFlowContext::walk_expr(expr=%s, in_out=%s)", @@ -432,7 +432,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { self.merge_with_entry_set(expr.id, in_out); match expr.node { - ast::expr_fn_block(ref decl, ref body) => { + ast::ExprFnBlock(ref decl, ref body) => { if self.dfcx.oper.walk_closures() { // In the absence of once fns, we must assume that // every function body will execute more than @@ -521,7 +521,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } } - ast::expr_if(cond, ref then, els) => { + ast::ExprIf(cond, ref then, els) => { // // (cond) // | @@ -544,7 +544,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { join_bits(&self.dfcx.oper, then_bits, in_out); } - ast::expr_while(cond, ref blk) => { + ast::ExprWhile(cond, ref blk) => { // // (expr) <--+ // | | @@ -570,9 +570,9 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { copy_bits(new_loop_scope.break_bits, in_out); } - ast::expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - ast::expr_loop(ref blk, _) => { + ast::ExprLoop(ref blk, _) => { // // (expr) <--+ // | | @@ -596,7 +596,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { copy_bits(new_loop_scope.break_bits, in_out); } - ast::expr_match(discr, ref arms) => { + ast::ExprMatch(discr, ref arms) => { // // (discr) // / | \ @@ -630,100 +630,100 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } } - ast::expr_ret(o_e) => { + ast::ExprRet(o_e) => { self.walk_opt_expr(o_e, in_out, loop_scopes); self.reset(in_out); } - ast::expr_break(label) => { + ast::ExprBreak(label) => { let scope = self.find_scope(expr, label, loop_scopes); self.break_from_to(expr, scope, in_out); self.reset(in_out); } - ast::expr_again(label) => { + ast::ExprAgain(label) => { let scope = self.find_scope(expr, label, loop_scopes); self.pop_scopes(expr, scope, in_out); self.add_to_entry_set(scope.loop_id, reslice(in_out)); self.reset(in_out); } - ast::expr_assign(l, r) | - ast::expr_assign_op(_, _, l, r) => { + ast::ExprAssign(l, r) | + ast::ExprAssignOp(_, _, l, r) => { self.walk_expr(r, in_out, loop_scopes); self.walk_expr(l, in_out, loop_scopes); } - ast::expr_vec(ref exprs, _) => { + ast::ExprVec(ref exprs, _) => { self.walk_exprs(*exprs, in_out, loop_scopes) } - ast::expr_repeat(l, r, _) => { + ast::ExprRepeat(l, r, _) => { self.walk_expr(l, in_out, loop_scopes); self.walk_expr(r, in_out, loop_scopes); } - ast::expr_struct(_, ref fields, with_expr) => { + ast::ExprStruct(_, ref fields, with_expr) => { for field in fields.iter() { self.walk_expr(field.expr, in_out, loop_scopes); } self.walk_opt_expr(with_expr, in_out, loop_scopes); } - ast::expr_call(f, ref args, _) => { + ast::ExprCall(f, ref args, _) => { self.walk_call(f.id, expr.id, f, *args, in_out, loop_scopes); } - ast::expr_method_call(callee_id, rcvr, _, _, ref args, _) => { + ast::ExprMethodCall(callee_id, rcvr, _, _, ref args, _) => { self.walk_call(callee_id, expr.id, rcvr, *args, in_out, loop_scopes); } - ast::expr_index(callee_id, l, r) | - ast::expr_binary(callee_id, _, l, r) if self.is_method_call(expr) => { + ast::ExprIndex(callee_id, l, r) | + ast::ExprBinary(callee_id, _, l, r) if self.is_method_call(expr) => { self.walk_call(callee_id, expr.id, l, [r], in_out, loop_scopes); } - ast::expr_unary(callee_id, _, e) if self.is_method_call(expr) => { + ast::ExprUnary(callee_id, _, e) if self.is_method_call(expr) => { self.walk_call(callee_id, expr.id, e, [], in_out, loop_scopes); } - ast::expr_tup(ref exprs) => { + ast::ExprTup(ref exprs) => { self.walk_exprs(*exprs, in_out, loop_scopes); } - ast::expr_binary(_, op, l, r) if ast_util::lazy_binop(op) => { + ast::ExprBinary(_, op, l, r) if ast_util::lazy_binop(op) => { self.walk_expr(l, in_out, loop_scopes); let temp = reslice(in_out).to_owned(); self.walk_expr(r, in_out, loop_scopes); join_bits(&self.dfcx.oper, temp, in_out); } - ast::expr_log(l, r) | - ast::expr_index(_, l, r) | - ast::expr_binary(_, _, l, r) => { + ast::ExprLog(l, r) | + ast::ExprIndex(_, l, r) | + ast::ExprBinary(_, _, l, r) => { self.walk_exprs([l, r], in_out, loop_scopes); } - ast::expr_lit(*) | - ast::expr_path(*) | - ast::expr_self => { + ast::ExprLit(*) | + ast::ExprPath(*) | + ast::ExprSelf => { } - ast::expr_addr_of(_, e) | - ast::expr_do_body(e) | - ast::expr_cast(e, _) | - ast::expr_unary(_, _, e) | - ast::expr_paren(e) | - ast::expr_vstore(e, _) | - ast::expr_field(e, _, _) => { + ast::ExprAddrOf(_, e) | + ast::ExprDoBody(e) | + ast::ExprCast(e, _) | + ast::ExprUnary(_, _, e) | + ast::ExprParen(e) | + ast::ExprVstore(e, _) | + ast::ExprField(e, _, _) => { self.walk_expr(e, in_out, loop_scopes); } - ast::expr_inline_asm(ref inline_asm) => { + ast::ExprInlineAsm(ref inline_asm) => { for &(_, expr) in inline_asm.inputs.iter() { self.walk_expr(expr, in_out, loop_scopes); } @@ -732,11 +732,11 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } } - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { self.walk_block(blk, in_out, loop_scopes); } - ast::expr_mac(*) => { + ast::ExprMac(*) => { self.tcx().sess.span_bug(expr.span, "unexpanded macro"); } } @@ -745,7 +745,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn pop_scopes(&mut self, - from_expr: @ast::expr, + from_expr: @ast::Expr, to_scope: &mut LoopScope, in_out: &mut [uint]) { //! Whenever you have a `break` or a `loop` statement, flow @@ -779,7 +779,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn break_from_to(&mut self, - from_expr: @ast::expr, + from_expr: @ast::Expr, to_scope: &mut LoopScope, in_out: &mut [uint]) { self.pop_scopes(from_expr, to_scope, in_out); @@ -792,7 +792,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn walk_exprs(&mut self, - exprs: &[@ast::expr], + exprs: &[@ast::Expr], in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { for &expr in exprs.iter() { @@ -801,7 +801,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn walk_opt_expr(&mut self, - opt_expr: Option<@ast::expr>, + opt_expr: Option<@ast::Expr>, in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { for &expr in opt_expr.iter() { @@ -812,8 +812,8 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { fn walk_call(&mut self, _callee_id: ast::NodeId, call_id: ast::NodeId, - arg0: @ast::expr, - args: &[@ast::expr], + arg0: @ast::Expr, + args: &[@ast::Expr], in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { self.walk_expr(arg0, in_out, loop_scopes); @@ -831,7 +831,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn walk_pat(&mut self, - pat: @ast::pat, + pat: @ast::Pat, in_out: &mut [uint], _loop_scopes: &mut ~[LoopScope]) { debug!("DataFlowContext::walk_pat(pat=%s, in_out=%s)", @@ -846,7 +846,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn walk_pat_alternatives(&mut self, - pats: &[@ast::pat], + pats: &[@ast::Pat], in_out: &mut [uint], loop_scopes: &mut ~[LoopScope]) { if pats.len() == 1 { @@ -866,7 +866,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { } fn find_scope<'a>(&self, - expr: @ast::expr, + expr: @ast::Expr, label: Option, loop_scopes: &'a mut ~[LoopScope]) -> &'a mut LoopScope { let index = match label { @@ -877,7 +877,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { Some(_) => { match self.tcx().def_map.find(&expr.id) { - Some(&ast::def_label(loop_id)) => { + Some(&ast::DefLabel(loop_id)) => { match loop_scopes.iter().position(|l| l.loop_id == loop_id) { Some(i) => i, None => { @@ -900,7 +900,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> { &mut loop_scopes[index] } - fn is_method_call(&self, expr: @ast::expr) -> bool { + fn is_method_call(&self, expr: @ast::Expr) -> bool { self.dfcx.method_map.contains_key(&expr.id) } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 825f53c9e4287..160b03132e06f 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -16,14 +16,14 @@ use middle::ty; use middle::typeck::method_map; use util::ppaux; -use syntax::ast::{deref, expr_call, expr_inline_asm, expr_method_call}; -use syntax::ast::{expr_unary, unsafe_fn, expr_path}; +use syntax::ast::{UnDeref, ExprCall, ExprInlineAsm, ExprMethodCall}; +use syntax::ast::{ExprUnary, unsafe_fn, ExprPath}; use syntax::ast; use syntax::codemap::Span; use syntax::visit::{fk_item_fn, fk_method}; use syntax::visit; use syntax::visit::{Visitor,fn_kind}; -use syntax::ast::{fn_decl,Block,NodeId,expr}; +use syntax::ast::{fn_decl,Block,NodeId,Expr}; #[deriving(Eq)] enum UnsafeContext { @@ -112,10 +112,10 @@ impl Visitor<()> for EffectCheckVisitor { self.context.unsafe_context = old_unsafe_context } - fn visit_expr(&mut self, expr:@expr, _:()) { + fn visit_expr(&mut self, expr:@Expr, _:()) { match expr.node { - expr_method_call(callee_id, _, _, _, _, _) => { + ExprMethodCall(callee_id, _, _, _, _, _) => { let base_type = ty::node_id_to_type(self.tcx, callee_id); debug!("effect: method call case, base type is %s", ppaux::ty_to_str(self.tcx, base_type)); @@ -124,7 +124,7 @@ impl Visitor<()> for EffectCheckVisitor { "invocation of unsafe method") } } - expr_call(base, _, _) => { + ExprCall(base, _, _) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: call case, base type is %s", ppaux::ty_to_str(self.tcx, base_type)); @@ -132,7 +132,7 @@ impl Visitor<()> for EffectCheckVisitor { self.require_unsafe(expr.span, "call to unsafe function") } } - expr_unary(_, deref, base) => { + ExprUnary(_, UnDeref, base) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: unary case, base type is %s", ppaux::ty_to_str(self.tcx, base_type)); @@ -144,12 +144,12 @@ impl Visitor<()> for EffectCheckVisitor { _ => {} } } - expr_inline_asm(*) => { + ExprInlineAsm(*) => { self.require_unsafe(expr.span, "use of inline assembly") } - expr_path(*) => { + ExprPath(*) => { match ty::resolve_expr(self.tcx, expr) { - ast::def_static(_, true) => { + ast::DefStatic(_, true) => { self.require_unsafe(expr.span, "use of mutable static") } _ => {} diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 0968ebc22df8f..ea6ff90634a00 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -26,7 +26,7 @@ use syntax::ast::{item}; // (The def_upvar will already have been stripped). #[deriving(Encodable, Decodable)] pub struct freevar_entry { - def: ast::def, //< The variable being accessed free. + def: ast::Def, //< The variable being accessed free. span: Span //< First span where it is accessed (there can be multiple) } pub type freevar_info = @~[@freevar_entry]; @@ -44,13 +44,13 @@ impl Visitor for CollectFreevarsVisitor { // ignore_item } - fn visit_expr(&mut self, expr:@ast::expr, depth:int) { + fn visit_expr(&mut self, expr:@ast::Expr, depth:int) { match expr.node { - ast::expr_fn_block(*) => { + ast::ExprFnBlock(*) => { visit::walk_expr(self, expr, depth + 1) } - ast::expr_path(*) | ast::expr_self => { + ast::ExprPath(*) | ast::ExprSelf => { let mut i = 0; match self.def_map.find(&expr.id) { None => fail!("path not found"), @@ -58,7 +58,7 @@ impl Visitor for CollectFreevarsVisitor { let mut def = df; while i < depth { match def { - ast::def_upvar(_, inner, _, _) => { def = *inner; } + ast::DefUpvar(_, inner, _, _) => { def = *inner; } _ => break } i += 1; diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 0beb3d2506476..d3b94e9f7c6f9 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -61,7 +61,7 @@ struct KindAnalysisVisitor; impl Visitor for KindAnalysisVisitor { - fn visit_expr(&mut self, ex:@expr, e:Context) { + fn visit_expr(&mut self, ex:@Expr, e:Context) { check_expr(self, ex, e); } @@ -92,7 +92,7 @@ pub fn check_crate(tcx: ty::ctxt, fn check_struct_safe_for_destructor(cx: Context, span: Span, - struct_did: def_id) { + struct_did: DefId) { let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did); if !struct_tpt.generics.has_type_params() { let struct_ty = ty::mk_struct(cx.tcx, struct_did, ty::substs { @@ -260,7 +260,7 @@ fn check_fn( visit::walk_fn(v, fk, decl, body, sp, fn_id, cx); } -pub fn check_expr(v: &mut KindAnalysisVisitor, e: @expr, cx: Context) { +pub fn check_expr(v: &mut KindAnalysisVisitor, e: @Expr, cx: Context) { debug!("kind::check_expr(%s)", expr_to_str(e, cx.tcx.sess.intr())); // Handle any kind bounds on type parameters @@ -272,7 +272,7 @@ pub fn check_expr(v: &mut KindAnalysisVisitor, e: @expr, cx: Context) { let r = cx.tcx.node_type_substs.find(&type_parameter_id); for ts in r.iter() { let type_param_defs = match e.node { - expr_path(_) => { + ExprPath(_) => { let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&e.id)); ty::lookup_item_type(cx.tcx, did).generics.type_param_defs } @@ -301,11 +301,11 @@ pub fn check_expr(v: &mut KindAnalysisVisitor, e: @expr, cx: Context) { } match e.node { - expr_unary(_, box(_), interior) => { + ExprUnary(_, UnBox(_), interior) => { let interior_type = ty::expr_ty(cx.tcx, interior); let _ = check_durable(cx.tcx, interior_type, interior.span); } - expr_cast(source, _) => { + ExprCast(source, _) => { check_cast_for_escaping_regions(cx, source, e); match ty::get(ty::expr_ty(cx.tcx, e)).sty { ty::ty_trait(_, _, _, _, bounds) => { @@ -315,7 +315,7 @@ pub fn check_expr(v: &mut KindAnalysisVisitor, e: @expr, cx: Context) { _ => { } } } - expr_repeat(element, count_expr, _) => { + ExprRepeat(element, count_expr, _) => { let count = ty::eval_repeat_count(&cx.tcx, count_expr); if count > 1 { let element_ty = ty::expr_ty(cx.tcx, element); @@ -412,11 +412,11 @@ pub fn check_trait_cast_bounds(cx: Context, sp: Span, ty: ty::t, } } -fn is_nullary_variant(cx: Context, ex: @expr) -> bool { +fn is_nullary_variant(cx: Context, ex: @Expr) -> bool { match ex.node { - expr_path(_) => { + ExprPath(_) => { match cx.tcx.def_map.get_copy(&ex.id) { - def_variant(edid, vdid) => { + DefVariant(edid, vdid) => { ty::enum_variant_with_id(cx.tcx, edid, vdid).args.is_empty() } _ => false @@ -426,18 +426,18 @@ fn is_nullary_variant(cx: Context, ex: @expr) -> bool { } } -fn check_imm_free_var(cx: Context, def: def, sp: Span) { +fn check_imm_free_var(cx: Context, def: Def, sp: Span) { match def { - def_local(_, is_mutbl) => { + DefLocal(_, is_mutbl) => { if is_mutbl { cx.tcx.sess.span_err( sp, "mutable variables cannot be implicitly captured"); } } - def_arg(*) => { /* ok */ } - def_upvar(_, def1, _, _) => { check_imm_free_var(cx, *def1, sp); } - def_binding(*) | def_self(*) => { /*ok*/ } + DefArg(*) => { /* ok */ } + DefUpvar(_, def1, _, _) => { check_imm_free_var(cx, *def1, sp); } + DefBinding(*) | DefSelf(*) => { /*ok*/ } _ => { cx.tcx.sess.span_bug( sp, @@ -515,8 +515,8 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: Span) -> bool { /// FIXME(#5723)---This code should probably move into regionck. pub fn check_cast_for_escaping_regions( cx: Context, - source: &expr, - target: &expr) + source: &Expr, + target: &Expr) { // Determine what type we are casting to; if it is not an trait, then no // worries. diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 47e2937ca8a8a..c8e1a46fa7854 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -24,7 +24,7 @@ use driver::session::Session; use metadata::csearch::each_lang_item; use metadata::cstore::iter_crate_data; use middle::ty::{BuiltinBound, BoundFreeze, BoundSend, BoundSized}; -use syntax::ast::{Crate, def_id, MetaItem}; +use syntax::ast::{Crate, DefId, MetaItem}; use syntax::ast_util::local_def; use syntax::attr::AttrMetaMethods; use syntax::ast::{item}; @@ -83,7 +83,7 @@ pub enum LangItem { } pub struct LanguageItems { - items: [Option, ..41] + items: [Option, ..41] } impl LanguageItems { @@ -93,7 +93,7 @@ impl LanguageItems { } } - pub fn each_item(&self, f: &fn(Option, uint) -> bool) -> bool { + pub fn each_item(&self, f: &fn(Option, uint) -> bool) -> bool { self.items.iter().enumerate().advance(|(i, &item)| f(item, i)) } @@ -151,7 +151,7 @@ impl LanguageItems { // FIXME #4621: Method macros sure would be nice here. - pub fn require(&self, it: LangItem) -> Result { + pub fn require(&self, it: LangItem) -> Result { match self.items[it as uint] { Some(id) => Ok(id), None => Err(fmt!("requires `%s` lang_item", @@ -159,7 +159,7 @@ impl LanguageItems { } } - pub fn to_builtin_kind(&self, id: def_id) -> Option { + pub fn to_builtin_kind(&self, id: DefId) -> Option { if Some(id) == self.freeze_trait() { Some(BoundFreeze) } else if Some(id) == self.send_trait() { @@ -171,128 +171,128 @@ impl LanguageItems { } } - pub fn freeze_trait(&self) -> Option { + pub fn freeze_trait(&self) -> Option { self.items[FreezeTraitLangItem as uint] } - pub fn send_trait(&self) -> Option { + pub fn send_trait(&self) -> Option { self.items[SendTraitLangItem as uint] } - pub fn sized_trait(&self) -> Option { + pub fn sized_trait(&self) -> Option { self.items[SizedTraitLangItem as uint] } - pub fn drop_trait(&self) -> Option { + pub fn drop_trait(&self) -> Option { self.items[DropTraitLangItem as uint] } - pub fn add_trait(&self) -> Option { + pub fn add_trait(&self) -> Option { self.items[AddTraitLangItem as uint] } - pub fn sub_trait(&self) -> Option { + pub fn sub_trait(&self) -> Option { self.items[SubTraitLangItem as uint] } - pub fn mul_trait(&self) -> Option { + pub fn mul_trait(&self) -> Option { self.items[MulTraitLangItem as uint] } - pub fn div_trait(&self) -> Option { + pub fn div_trait(&self) -> Option { self.items[DivTraitLangItem as uint] } - pub fn rem_trait(&self) -> Option { + pub fn rem_trait(&self) -> Option { self.items[RemTraitLangItem as uint] } - pub fn neg_trait(&self) -> Option { + pub fn neg_trait(&self) -> Option { self.items[NegTraitLangItem as uint] } - pub fn not_trait(&self) -> Option { + pub fn not_trait(&self) -> Option { self.items[NotTraitLangItem as uint] } - pub fn bitxor_trait(&self) -> Option { + pub fn bitxor_trait(&self) -> Option { self.items[BitXorTraitLangItem as uint] } - pub fn bitand_trait(&self) -> Option { + pub fn bitand_trait(&self) -> Option { self.items[BitAndTraitLangItem as uint] } - pub fn bitor_trait(&self) -> Option { + pub fn bitor_trait(&self) -> Option { self.items[BitOrTraitLangItem as uint] } - pub fn shl_trait(&self) -> Option { + pub fn shl_trait(&self) -> Option { self.items[ShlTraitLangItem as uint] } - pub fn shr_trait(&self) -> Option { + pub fn shr_trait(&self) -> Option { self.items[ShrTraitLangItem as uint] } - pub fn index_trait(&self) -> Option { + pub fn index_trait(&self) -> Option { self.items[IndexTraitLangItem as uint] } - pub fn eq_trait(&self) -> Option { + pub fn eq_trait(&self) -> Option { self.items[EqTraitLangItem as uint] } - pub fn ord_trait(&self) -> Option { + pub fn ord_trait(&self) -> Option { self.items[OrdTraitLangItem as uint] } - pub fn str_eq_fn(&self) -> Option { + pub fn str_eq_fn(&self) -> Option { self.items[StrEqFnLangItem as uint] } - pub fn uniq_str_eq_fn(&self) -> Option { + pub fn uniq_str_eq_fn(&self) -> Option { self.items[UniqStrEqFnLangItem as uint] } - pub fn log_type_fn(&self) -> Option { + pub fn log_type_fn(&self) -> Option { self.items[LogTypeFnLangItem as uint] } - pub fn fail_fn(&self) -> Option { + pub fn fail_fn(&self) -> Option { self.items[FailFnLangItem as uint] } - pub fn fail_bounds_check_fn(&self) -> Option { + pub fn fail_bounds_check_fn(&self) -> Option { self.items[FailBoundsCheckFnLangItem as uint] } - pub fn exchange_malloc_fn(&self) -> Option { + pub fn exchange_malloc_fn(&self) -> Option { self.items[ExchangeMallocFnLangItem as uint] } - pub fn closure_exchange_malloc_fn(&self) -> Option { + pub fn closure_exchange_malloc_fn(&self) -> Option { self.items[ClosureExchangeMallocFnLangItem as uint] } - pub fn exchange_free_fn(&self) -> Option { + pub fn exchange_free_fn(&self) -> Option { self.items[ExchangeFreeFnLangItem as uint] } - pub fn malloc_fn(&self) -> Option { + pub fn malloc_fn(&self) -> Option { self.items[MallocFnLangItem as uint] } - pub fn free_fn(&self) -> Option { + pub fn free_fn(&self) -> Option { self.items[FreeFnLangItem as uint] } - pub fn borrow_as_imm_fn(&self) -> Option { + pub fn borrow_as_imm_fn(&self) -> Option { self.items[BorrowAsImmFnLangItem as uint] } - pub fn borrow_as_mut_fn(&self) -> Option { + pub fn borrow_as_mut_fn(&self) -> Option { self.items[BorrowAsMutFnLangItem as uint] } - pub fn return_to_mut_fn(&self) -> Option { + pub fn return_to_mut_fn(&self) -> Option { self.items[ReturnToMutFnLangItem as uint] } - pub fn check_not_borrowed_fn(&self) -> Option { + pub fn check_not_borrowed_fn(&self) -> Option { self.items[CheckNotBorrowedFnLangItem as uint] } - pub fn strdup_uniq_fn(&self) -> Option { + pub fn strdup_uniq_fn(&self) -> Option { self.items[StrDupUniqFnLangItem as uint] } - pub fn record_borrow_fn(&self) -> Option { + pub fn record_borrow_fn(&self) -> Option { self.items[RecordBorrowFnLangItem as uint] } - pub fn unrecord_borrow_fn(&self) -> Option { + pub fn unrecord_borrow_fn(&self) -> Option { self.items[UnrecordBorrowFnLangItem as uint] } - pub fn start_fn(&self) -> Option { + pub fn start_fn(&self) -> Option { self.items[StartFnLangItem as uint] } - pub fn ty_desc(&self) -> Option { + pub fn ty_desc(&self) -> Option { self.items[TyDescStructLangItem as uint] } - pub fn ty_visitor(&self) -> Option { + pub fn ty_visitor(&self) -> Option { self.items[TyVisitorTraitLangItem as uint] } - pub fn opaque(&self) -> Option { + pub fn opaque(&self) -> Option { self.items[OpaqueStructLangItem as uint] } } @@ -388,7 +388,7 @@ impl<'self> LanguageItemCollector<'self> { } pub fn match_and_collect_meta_item(&mut self, - item_def_id: def_id, + item_def_id: DefId, meta_item: &MetaItem) { match meta_item.name_str_pair() { Some((key, value)) => { @@ -398,7 +398,7 @@ impl<'self> LanguageItemCollector<'self> { } } - pub fn collect_item(&mut self, item_index: uint, item_def_id: def_id) { + pub fn collect_item(&mut self, item_index: uint, item_def_id: DefId) { // Check for duplicates. match self.items.items[item_index] { Some(original_def_id) if original_def_id != item_def_id => { @@ -415,7 +415,7 @@ impl<'self> LanguageItemCollector<'self> { } pub fn match_and_collect_item(&mut self, - item_def_id: def_id, + item_def_id: DefId, key: &str, value: @str) { if "lang" != key { @@ -448,7 +448,7 @@ impl<'self> LanguageItemCollector<'self> { do iter_crate_data(crate_store) |crate_number, _crate_metadata| { do each_lang_item(crate_store, crate_number) |node_id, item_index| { - let def_id = def_id { crate: crate_number, node: node_id }; + let def_id = DefId { crate: crate_number, node: node_id }; self.collect_item(item_index, def_id); true }; diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 1ad6e409fc364..596fd05b26276 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -674,12 +674,12 @@ impl Visitor<@mut Context> for WhileTrueLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut Context) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) { match e.node { - ast::expr_while(cond, _) => { + ast::ExprWhile(cond, _) => { match cond.node { - ast::expr_lit(@codemap::Spanned { + ast::ExprLit(@codemap::Spanned { node: ast::lit_bool(true), _}) => { cx.span_lint(while_true, e.span, @@ -725,24 +725,24 @@ impl SubitemStoppableVisitor for TypeLimitsLintVisitor { } impl TypeLimitsLintVisitor { - fn is_valid(&mut self, binop: ast::binop, v: T, + fn is_valid(&mut self, binop: ast::BinOp, v: T, min: T, max: T) -> bool { match binop { - ast::lt => v <= max, - ast::le => v < max, - ast::gt => v >= min, - ast::ge => v > min, - ast::eq | ast::ne => v >= min && v <= max, + ast::BiLt => v <= max, + ast::BiLe => v < max, + ast::BiGt => v >= min, + ast::BiGe => v > min, + ast::BiEq | ast::BiNe => v >= min && v <= max, _ => fail!() } } - fn rev_binop(&mut self, binop: ast::binop) -> ast::binop { + fn rev_binop(&mut self, binop: ast::BinOp) -> ast::BinOp { match binop { - ast::lt => ast::gt, - ast::le => ast::ge, - ast::gt => ast::lt, - ast::ge => ast::le, + ast::BiLt => ast::BiGt, + ast::BiLe => ast::BiGe, + ast::BiGt => ast::BiLt, + ast::BiGe => ast::BiLe, _ => binop } } @@ -772,13 +772,13 @@ impl TypeLimitsLintVisitor { fn check_limits(&mut self, cx: &Context, - binop: ast::binop, - l: @ast::expr, - r: @ast::expr) + binop: ast::BinOp, + l: @ast::Expr, + r: @ast::Expr) -> bool { let (lit, expr, swap) = match (&l.node, &r.node) { - (&ast::expr_lit(_), _) => (l, r, true), - (_, &ast::expr_lit(_)) => (r, l, false), + (&ast::ExprLit(_), _) => (l, r, true), + (_, &ast::ExprLit(_)) => (r, l, false), _ => return true }; // Normalize the binop so that the literal is always on the RHS in @@ -792,7 +792,7 @@ impl TypeLimitsLintVisitor { ty::ty_int(int_ty) => { let (min, max) = self.int_ty_range(int_ty); let lit_val: i64 = match lit.node { - ast::expr_lit(@li) => match li.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, @@ -805,7 +805,7 @@ impl TypeLimitsLintVisitor { ty::ty_uint(uint_ty) => { let (min, max): (u64, u64) = self.uint_ty_range(uint_ty); let lit_val: u64 = match lit.node { - ast::expr_lit(@li) => match li.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, @@ -819,10 +819,10 @@ impl TypeLimitsLintVisitor { } } - fn is_comparison(&mut self, binop: ast::binop) -> bool { + fn is_comparison(&mut self, binop: ast::BinOp) -> bool { match binop { - ast::eq | ast::lt | ast::le | - ast::ne | ast::ge | ast::gt => true, + ast::BiEq | ast::BiLt | ast::BiLe | + ast::BiNe | ast::BiGe | ast::BiGt => true, _ => false } } @@ -838,10 +838,10 @@ impl Visitor<@mut Context> for TypeLimitsLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut Context) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) { match e.node { - ast::expr_binary(_, ref binop, l, r) => { + ast::ExprBinary(_, ref binop, l, r) => { if self.is_comparison(*binop) && !self.check_limits(cx, *binop, l, r) { cx.span_lint(type_limits, e.span, @@ -865,12 +865,12 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) { match ty.node { ast::ty_path(_, _, id) => { match cx.tcx.def_map.get_copy(&id) { - ast::def_prim_ty(ast::ty_int(ast::ty_i)) => { + ast::DefPrimTy(ast::ty_int(ast::ty_i)) => { 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::def_prim_ty(ast::ty_uint(ast::ty_u)) => { + ast::DefPrimTy(ast::ty_uint(ast::ty_u)) => { cx.span_lint(ctypes, ty.span, "found rust type `uint` in foreign module, while \ libc::c_uint or libc::c_ulong should be used"); @@ -979,7 +979,7 @@ impl Visitor<@mut Context> for HeapLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut Context) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) { let ty = ty::expr_ty(cx.tcx, e); check_type(cx, e.span, ty); visit::walk_expr(self, e, cx); @@ -1010,10 +1010,10 @@ impl Visitor<@mut Context> for PathStatementLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_stmt(&mut self, s:@ast::stmt, cx:@mut Context) { + fn visit_stmt(&mut self, s:@ast::Stmt, cx:@mut Context) { match s.node { - ast::stmt_semi( - @ast::expr { node: ast::expr_path(_), _ }, + ast::StmtSemi( + @ast::Expr { node: ast::ExprPath(_), _ }, _ ) => { cx.span_lint(path_statement, s.span, @@ -1073,7 +1073,7 @@ fn check_item_non_camel_case_types(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::m_imm, _) => { + ast::item_static(_, 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 @@ -1103,10 +1103,10 @@ impl Visitor<@mut Context> for UnusedUnsafeLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut Context) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) { match e.node { - ast::expr_block(ref blk) if blk.rules == ast::UnsafeBlock => { + ast::ExprBlock(ref blk) if blk.rules == ast::UnsafeBlock => { if !cx.tcx.used_unsafe.contains(&blk.id) { cx.span_lint(unused_unsafe, blk.span, "unnecessary `unsafe` block"); @@ -1127,7 +1127,7 @@ fn lint_unused_unsafe() -> @mut OuterLint { struct UnusedMutLintVisitor { stopping_on_items: bool } impl UnusedMutLintVisitor { - fn check_pat(&mut self, cx: &Context, p: @ast::pat) { + fn check_pat(&mut self, cx: &Context, p: @ast::Pat) { let mut used = false; let mut bindings = 0; do pat_util::pat_bindings(cx.tcx.def_map, p) |_, id, _, _| { @@ -1229,7 +1229,7 @@ impl Visitor<@mut Context> for UnnecessaryAllocationLintVisitor { self.OVERRIDE_visit_fn(fk, fd, b, s, n, e); } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut Context) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) { self.check(cx, e); visit::walk_expr(self, e, cx); } @@ -1238,14 +1238,14 @@ impl Visitor<@mut Context> for UnnecessaryAllocationLintVisitor { impl UnnecessaryAllocationLintVisitor { // Warn if string and vector literals with sigils are immediately borrowed. // Those can have the sigil removed. - fn check(&mut self, cx: &Context, e: &ast::expr) { + fn check(&mut self, cx: &Context, e: &ast::Expr) { match e.node { - ast::expr_vstore(e2, ast::expr_vstore_uniq) | - ast::expr_vstore(e2, ast::expr_vstore_box) => { + ast::ExprVstore(e2, ast::ExprVstoreUniq) | + ast::ExprVstore(e2, ast::ExprVstoreBox) => { match e2.node { - ast::expr_lit(@codemap::Spanned{ + ast::ExprLit(@codemap::Spanned{ node: ast::lit_str(*), _}) | - ast::expr_vec(*) => {} + ast::ExprVec(*) => {} _ => return } } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index cbfab25f13371..27a155403ed0f 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -158,8 +158,8 @@ impl Visitor<@mut IrMaps> for LivenessVisitor { visit_fn(self, fk, fd, b, s, n, e); } fn visit_local(&mut self, l:@Local, e:@mut IrMaps) { visit_local(self, l, e); } - fn visit_expr(&mut self, ex:@expr, e:@mut IrMaps) { visit_expr(self, ex, e); } - fn visit_arm(&mut self, a:&arm, e:@mut IrMaps) { visit_arm(self, a, e); } + fn visit_expr(&mut self, ex:@Expr, e:@mut IrMaps) { visit_expr(self, ex, e); } + fn visit_arm(&mut self, a:&Arm, e:@mut IrMaps) { visit_arm(self, a, e); } } pub fn check_crate(tcx: ty::ctxt, @@ -220,7 +220,7 @@ struct CaptureInfo { } enum LocalKind { - FromMatch(binding_mode), + FromMatch(BindingMode), FromLetWithInitializer, FromLetNoInitializer } @@ -331,7 +331,7 @@ impl IrMaps { self.capture_info_map.insert(node_id, @cs); } - pub fn captures(&mut self, expr: &expr) -> @~[CaptureInfo] { + pub fn captures(&mut self, expr: &Expr) -> @~[CaptureInfo] { match self.capture_info_map.find(&expr.id) { Some(&caps) => caps, None => { @@ -354,10 +354,10 @@ impl Visitor<@Liveness> for ErrorCheckVisitor { fn visit_local(&mut self, l:@Local, e:@Liveness) { check_local(self, l, e); } - fn visit_expr(&mut self, ex:@expr, e:@Liveness) { + fn visit_expr(&mut self, ex:@Expr, e:@Liveness) { check_expr(self, ex, e); } - fn visit_arm(&mut self, a:&arm, e:@Liveness) { + fn visit_arm(&mut self, a:&Arm, e:@Liveness) { check_arm(self, a, e); } } @@ -449,7 +449,7 @@ fn visit_local(v: &mut LivenessVisitor, local: @Local, this: @mut IrMaps) { visit::walk_local(v, local, this); } -fn visit_arm(v: &mut LivenessVisitor, arm: &arm, this: @mut IrMaps) { +fn visit_arm(v: &mut LivenessVisitor, arm: &Arm, this: @mut IrMaps) { let def_map = this.tcx.def_map; for pat in arm.pats.iter() { do pat_util::pat_bindings(def_map, *pat) |bm, p_id, sp, path| { @@ -468,10 +468,10 @@ fn visit_arm(v: &mut LivenessVisitor, arm: &arm, this: @mut IrMaps) { visit::walk_arm(v, arm, this); } -fn visit_expr(v: &mut LivenessVisitor, expr: @expr, this: @mut IrMaps) { +fn visit_expr(v: &mut LivenessVisitor, expr: @Expr, this: @mut IrMaps) { match expr.node { // live nodes required for uses or definitions of variables: - expr_path(_) | expr_self => { + ExprPath(_) | ExprSelf => { let def = this.tcx.def_map.get_copy(&expr.id); debug!("expr %d: path that leads to %?", expr.id, def); if moves::moved_variable_node_id_from_def(def).is_some() { @@ -479,7 +479,7 @@ fn visit_expr(v: &mut LivenessVisitor, expr: @expr, this: @mut IrMaps) { } visit::walk_expr(v, expr, this); } - expr_fn_block(*) => { + ExprFnBlock(*) => { // Interesting control flow (for loops can contain labeled // breaks or continues) this.add_live_node_for_node(expr.id, ExprNode(expr.span)); @@ -514,25 +514,25 @@ fn visit_expr(v: &mut LivenessVisitor, expr: @expr, this: @mut IrMaps) { } // live nodes required for interesting control flow: - expr_if(*) | expr_match(*) | expr_while(*) | expr_loop(*) => { + ExprIf(*) | ExprMatch(*) | ExprWhile(*) | ExprLoop(*) => { this.add_live_node_for_node(expr.id, ExprNode(expr.span)); visit::walk_expr(v, expr, this); } - expr_for_loop(*) => fail!("non-desugared expr_for_loop"), - expr_binary(_, op, _, _) if ast_util::lazy_binop(op) => { + ExprForLoop(*) => fail!("non-desugared expr_for_loop"), + ExprBinary(_, op, _, _) if ast_util::lazy_binop(op) => { this.add_live_node_for_node(expr.id, ExprNode(expr.span)); visit::walk_expr(v, expr, this); } // otherwise, live nodes are not required: - expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) | - expr_call(*) | expr_method_call(*) | expr_tup(*) | expr_log(*) | - expr_binary(*) | expr_addr_of(*) | - expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_break(_) | - expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) | - expr_assign(*) | expr_assign_op(*) | expr_mac(*) | - expr_struct(*) | expr_repeat(*) | expr_paren(*) | - expr_inline_asm(*) => { + ExprIndex(*) | ExprField(*) | ExprVstore(*) | ExprVec(*) | + ExprCall(*) | ExprMethodCall(*) | ExprTup(*) | ExprLog(*) | + ExprBinary(*) | ExprAddrOf(*) | + ExprDoBody(*) | ExprCast(*) | ExprUnary(*) | ExprBreak(_) | + ExprAgain(_) | ExprLit(_) | ExprRet(*) | ExprBlock(*) | + ExprAssign(*) | ExprAssignOp(*) | ExprMac(*) | + ExprStruct(*) | ExprRepeat(*) | ExprParen(*) | + ExprInlineAsm(*) => { visit::walk_expr(v, expr, this); } } @@ -618,9 +618,9 @@ impl Liveness { } } - pub fn variable_from_path(&self, expr: &expr) -> Option { + pub fn variable_from_path(&self, expr: &Expr) -> Option { match expr.node { - expr_path(_) => { + ExprPath(_) => { let def = self.tcx.def_map.get_copy(&expr.id); do moves::moved_variable_node_id_from_def(def).map_move |rdef| { self.variable(rdef, expr.span) @@ -650,7 +650,7 @@ impl Liveness { } pub fn pat_bindings(&self, - pat: @pat, + pat: @Pat, f: &fn(LiveNode, Variable, Span, NodeId)) { let def_map = self.tcx.def_map; do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| { @@ -661,7 +661,7 @@ impl Liveness { } pub fn arm_pats_bindings(&self, - pats: &[@pat], + pats: &[@Pat], f: &fn(LiveNode, Variable, Span, NodeId)) { // only consider the first pattern; any later patterns must have // the same bindings, and we also consider the first pattern to be @@ -671,12 +671,12 @@ impl Liveness { } } - pub fn define_bindings_in_pat(&self, pat: @pat, succ: LiveNode) + pub fn define_bindings_in_pat(&self, pat: @Pat, succ: LiveNode) -> LiveNode { self.define_bindings_in_arm_pats([pat], succ) } - pub fn define_bindings_in_arm_pats(&self, pats: &[@pat], succ: LiveNode) + pub fn define_bindings_in_arm_pats(&self, pats: &[@Pat], succ: LiveNode) -> LiveNode { let mut succ = succ; do self.arm_pats_bindings(pats) |ln, var, _sp, _id| { @@ -764,7 +764,7 @@ impl Liveness { Some(_) => // Refers to a labeled loop. Use the results of resolve // to find with one match self.tcx.def_map.find(&id) { - Some(&def_label(loop_id)) => loop_id, + Some(&DefLabel(loop_id)) => loop_id, _ => self.tcx.sess.span_bug(sp, "Label on break/loop \ doesn't refer to a loop") }, @@ -945,30 +945,30 @@ impl Liveness { } } - pub fn propagate_through_stmt(&self, stmt: &stmt, succ: LiveNode) + pub fn propagate_through_stmt(&self, stmt: &Stmt, succ: LiveNode) -> LiveNode { match stmt.node { - stmt_decl(decl, _) => { + StmtDecl(decl, _) => { return self.propagate_through_decl(decl, succ); } - stmt_expr(expr, _) | stmt_semi(expr, _) => { + StmtExpr(expr, _) | StmtSemi(expr, _) => { return self.propagate_through_expr(expr, succ); } - stmt_mac(*) => { + StmtMac(*) => { self.tcx.sess.span_bug(stmt.span, "unexpanded macro"); } } } - pub fn propagate_through_decl(&self, decl: &decl, succ: LiveNode) + pub fn propagate_through_decl(&self, decl: &Decl, succ: LiveNode) -> LiveNode { match decl.node { - decl_local(ref local) => { + DeclLocal(ref local) => { self.propagate_through_local(*local, succ) } - decl_item(_) => succ, + DeclItem(_) => succ, } } @@ -992,7 +992,7 @@ impl Liveness { self.define_bindings_in_pat(local.pat, succ) } - pub fn propagate_through_exprs(&self, exprs: &[@expr], succ: LiveNode) + pub fn propagate_through_exprs(&self, exprs: &[@Expr], succ: LiveNode) -> LiveNode { do exprs.rev_iter().fold(succ) |succ, expr| { self.propagate_through_expr(*expr, succ) @@ -1000,7 +1000,7 @@ impl Liveness { } pub fn propagate_through_opt_expr(&self, - opt_expr: Option<@expr>, + opt_expr: Option<@Expr>, succ: LiveNode) -> LiveNode { do opt_expr.iter().fold(succ) |succ, expr| { @@ -1008,7 +1008,7 @@ impl Liveness { } } - pub fn propagate_through_expr(&self, expr: @expr, succ: LiveNode) + pub fn propagate_through_expr(&self, expr: @Expr, succ: LiveNode) -> LiveNode { debug!("propagate_through_expr: %s", expr_to_str(expr, self.tcx.sess.intr())); @@ -1016,15 +1016,15 @@ impl Liveness { match expr.node { // Interesting cases with control flow or which gen/kill - expr_path(_) | expr_self => { + ExprPath(_) | ExprSelf => { self.access_path(expr, succ, ACC_READ | ACC_USE) } - expr_field(e, _, _) => { + ExprField(e, _, _) => { self.propagate_through_expr(e, succ) } - expr_fn_block(_, ref blk) => { + ExprFnBlock(_, ref blk) => { debug!("%s is an expr_fn_block", expr_to_str(expr, self.tcx.sess.intr())); @@ -1047,7 +1047,7 @@ impl Liveness { }) } - expr_if(cond, ref then, els) => { + ExprIf(cond, ref then, els) => { // // (cond) // | @@ -1069,19 +1069,19 @@ impl Liveness { self.propagate_through_expr(cond, ln) } - expr_while(cond, ref blk) => { + ExprWhile(cond, ref blk) => { self.propagate_through_loop(expr, Some(cond), blk, succ) } - expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ExprForLoop(*) => fail!("non-desugared expr_for_loop"), // Note that labels have been resolved, so we don't need to look // at the label ident - expr_loop(ref blk, _) => { + ExprLoop(ref blk, _) => { self.propagate_through_loop(expr, None, blk, succ) } - expr_match(e, ref arms) => { + ExprMatch(e, ref arms) => { // // (e) // | @@ -1112,12 +1112,12 @@ impl Liveness { self.propagate_through_expr(e, ln) } - expr_ret(o_e) => { + ExprRet(o_e) => { // ignore succ and subst exit_ln: self.propagate_through_opt_expr(o_e, self.s.exit_ln) } - expr_break(opt_label) => { + ExprBreak(opt_label) => { // Find which label this break jumps to let sc = self.find_loop_scope(opt_label, expr.id, expr.span); @@ -1131,7 +1131,7 @@ impl Liveness { } } - expr_again(opt_label) => { + ExprAgain(opt_label) => { // Find which label this expr continues to let sc = self.find_loop_scope(opt_label, expr.id, expr.span); @@ -1145,7 +1145,7 @@ impl Liveness { } } - expr_assign(l, r) => { + ExprAssign(l, r) => { // see comment on lvalues in // propagate_through_lvalue_components() let succ = self.write_lvalue(l, succ, ACC_WRITE); @@ -1153,7 +1153,7 @@ impl Liveness { self.propagate_through_expr(r, succ) } - expr_assign_op(_, _, l, r) => { + ExprAssignOp(_, _, l, r) => { // see comment on lvalues in // propagate_through_lvalue_components() let succ = self.write_lvalue(l, succ, ACC_WRITE|ACC_READ); @@ -1163,27 +1163,27 @@ impl Liveness { // Uninteresting cases: just propagate in rev exec order - expr_vstore(expr, _) => { + ExprVstore(expr, _) => { self.propagate_through_expr(expr, succ) } - expr_vec(ref exprs, _) => { + ExprVec(ref exprs, _) => { self.propagate_through_exprs(*exprs, succ) } - expr_repeat(element, count, _) => { + ExprRepeat(element, count, _) => { let succ = self.propagate_through_expr(count, succ); self.propagate_through_expr(element, succ) } - expr_struct(_, ref fields, with_expr) => { + ExprStruct(_, ref fields, with_expr) => { let succ = self.propagate_through_opt_expr(with_expr, succ); do fields.rev_iter().fold(succ) |succ, field| { self.propagate_through_expr(field.expr, succ) } } - expr_call(f, ref args, _) => { + ExprCall(f, ref args, _) => { // calling a fn with bot return type means that the fn // will fail, and hence the successors can be ignored let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f)); @@ -1193,7 +1193,7 @@ impl Liveness { self.propagate_through_expr(f, succ) } - expr_method_call(callee_id, rcvr, _, _, ref args, _) => { + ExprMethodCall(callee_id, rcvr, _, _, ref args, _) => { // calling a method with bot return type means that the method // will fail, and hence the successors can be ignored let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx, callee_id)); @@ -1203,11 +1203,11 @@ impl Liveness { self.propagate_through_expr(rcvr, succ) } - expr_tup(ref exprs) => { + ExprTup(ref exprs) => { self.propagate_through_exprs(*exprs, succ) } - expr_binary(_, op, l, r) if ast_util::lazy_binop(op) => { + ExprBinary(_, op, l, r) if ast_util::lazy_binop(op) => { let r_succ = self.propagate_through_expr(r, succ); let ln = self.live_node(expr.id, expr.span); @@ -1217,21 +1217,21 @@ impl Liveness { self.propagate_through_expr(l, ln) } - expr_log(l, r) | - expr_index(_, l, r) | - expr_binary(_, _, l, r) => { + ExprLog(l, r) | + ExprIndex(_, l, r) | + ExprBinary(_, _, l, r) => { self.propagate_through_exprs([l, r], succ) } - expr_addr_of(_, e) | - expr_do_body(e) | - expr_cast(e, _) | - expr_unary(_, _, e) | - expr_paren(e) => { + ExprAddrOf(_, e) | + ExprDoBody(e) | + ExprCast(e, _) | + ExprUnary(_, _, e) | + ExprParen(e) => { self.propagate_through_expr(e, succ) } - expr_inline_asm(ref ia) =>{ + ExprInlineAsm(ref ia) =>{ let succ = do ia.inputs.rev_iter().fold(succ) |succ, &(_, expr)| { self.propagate_through_expr(expr, succ) }; @@ -1240,22 +1240,22 @@ impl Liveness { } } - expr_lit(*) => { + ExprLit(*) => { succ } - expr_block(ref blk) => { + ExprBlock(ref blk) => { self.propagate_through_block(blk, succ) } - expr_mac(*) => { + ExprMac(*) => { self.tcx.sess.span_bug(expr.span, "unexpanded macro"); } } } pub fn propagate_through_lvalue_components(&self, - expr: @expr, + expr: @Expr, succ: LiveNode) -> LiveNode { // # Lvalues @@ -1308,17 +1308,17 @@ impl Liveness { // just ignore such cases and treat them as reads. match expr.node { - expr_path(_) => succ, - expr_field(e, _, _) => self.propagate_through_expr(e, succ), + ExprPath(_) => succ, + ExprField(e, _, _) => self.propagate_through_expr(e, succ), _ => self.propagate_through_expr(expr, succ) } } // see comment on propagate_through_lvalue() - pub fn write_lvalue(&self, expr: &expr, succ: LiveNode, acc: uint) + pub fn write_lvalue(&self, expr: &Expr, succ: LiveNode, acc: uint) -> LiveNode { match expr.node { - expr_path(_) => self.access_path(expr, succ, acc), + ExprPath(_) => self.access_path(expr, succ, acc), // We do not track other lvalues, so just propagate through // to their subcomponents. Also, it may happen that @@ -1328,7 +1328,7 @@ impl Liveness { } } - pub fn access_path(&self, expr: &expr, succ: LiveNode, acc: uint) + pub fn access_path(&self, expr: &Expr, succ: LiveNode, acc: uint) -> LiveNode { let def = self.tcx.def_map.get_copy(&expr.id); match moves::moved_variable_node_id_from_def(def) { @@ -1346,8 +1346,8 @@ impl Liveness { } pub fn propagate_through_loop(&self, - expr: &expr, - cond: Option<@expr>, + expr: &Expr, + cond: Option<@Expr>, body: &Block, succ: LiveNode) -> LiveNode { @@ -1452,29 +1452,29 @@ fn check_local(vt: &mut ErrorCheckVisitor, local: @Local, this: @Liveness) { visit::walk_local(vt, local, this); } -fn check_arm(vt: &mut ErrorCheckVisitor, arm: &arm, this: @Liveness) { +fn check_arm(vt: &mut ErrorCheckVisitor, arm: &Arm, this: @Liveness) { do this.arm_pats_bindings(arm.pats) |ln, var, sp, id| { this.warn_about_unused(sp, id, ln, var); } visit::walk_arm(vt, arm, this); } -fn check_expr(vt: &mut ErrorCheckVisitor, expr: @expr, this: @Liveness) { +fn check_expr(vt: &mut ErrorCheckVisitor, expr: @Expr, this: @Liveness) { match expr.node { - expr_assign(l, r) => { + ExprAssign(l, r) => { this.check_lvalue(l, vt); vt.visit_expr(r, this); visit::walk_expr(vt, expr, this); } - expr_assign_op(_, _, l, _) => { + ExprAssignOp(_, _, l, _) => { this.check_lvalue(l, vt); visit::walk_expr(vt, expr, this); } - expr_inline_asm(ref ia) => { + ExprInlineAsm(ref ia) => { for &(_, input) in ia.inputs.iter() { vt.visit_expr(input, this); } @@ -1482,7 +1482,7 @@ fn check_expr(vt: &mut ErrorCheckVisitor, expr: @expr, this: @Liveness) { // Output operands must be lvalues for &(_, out) in ia.outputs.iter() { match out.node { - expr_addr_of(_, inner) => { + ExprAddrOf(_, inner) => { this.check_lvalue(inner, vt); } _ => {} @@ -1494,17 +1494,17 @@ fn check_expr(vt: &mut ErrorCheckVisitor, expr: @expr, this: @Liveness) { } // no correctness conditions related to liveness - expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) | - expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) | - expr_vstore(*) | expr_vec(*) | expr_tup(*) | expr_log(*) | - expr_binary(*) | expr_do_body(*) | - expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) | - expr_again(*) | expr_lit(_) | expr_block(*) | - expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) | - expr_paren(*) | expr_fn_block(*) | expr_path(*) | expr_self(*) => { + ExprCall(*) | ExprMethodCall(*) | ExprIf(*) | ExprMatch(*) | + ExprWhile(*) | ExprLoop(*) | ExprIndex(*) | ExprField(*) | + ExprVstore(*) | ExprVec(*) | ExprTup(*) | ExprLog(*) | + ExprBinary(*) | ExprDoBody(*) | + ExprCast(*) | ExprUnary(*) | ExprRet(*) | ExprBreak(*) | + ExprAgain(*) | ExprLit(_) | ExprBlock(*) | + ExprMac(*) | ExprAddrOf(*) | ExprStruct(*) | ExprRepeat(*) | + ExprParen(*) | ExprFnBlock(*) | ExprPath(*) | ExprSelf(*) => { visit::walk_expr(vt, expr, this); } - expr_for_loop(*) => fail!("non-desugared expr_for_loop") + ExprForLoop(*) => fail!("non-desugared expr_for_loop") } } @@ -1549,11 +1549,11 @@ impl Liveness { } } - pub fn check_lvalue(@self, expr: @expr, vt: &mut ErrorCheckVisitor) { + pub fn check_lvalue(@self, expr: @Expr, vt: &mut ErrorCheckVisitor) { match expr.node { - expr_path(_) => { + ExprPath(_) => { match self.tcx.def_map.get_copy(&expr.id) { - def_local(nid, _) => { + DefLocal(nid, _) => { // Assignment to an immutable variable or argument: only legal // if there is no later assignment. If this local is actually // mutable, then check for a reassignment to flag the mutability @@ -1630,7 +1630,7 @@ impl Liveness { } } - pub fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @pat) { + pub fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @Pat) { do self.pat_bindings(pat) |ln, var, sp, id| { if !self.warn_about_unused(sp, id, ln, var) { self.warn_about_dead_assign(sp, id, ln, var); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 1fc670312f0c6..0171712c0823a 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -52,7 +52,7 @@ use middle::typeck; use util::ppaux::{ty_to_str, region_ptr_to_str, Repr}; use util::common::indenter; -use syntax::ast::{m_imm, m_mutbl}; +use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap::Span; use syntax::print::pprust; @@ -84,9 +84,9 @@ pub struct CopiedUpvar { #[deriving(Eq, IterBytes)] pub enum PointerKind { uniq_ptr, - gc_ptr(ast::mutability), - region_ptr(ast::mutability, ty::Region), - unsafe_ptr(ast::mutability) + gc_ptr(ast::Mutability), + region_ptr(ast::Mutability, ty::Region), + unsafe_ptr(ast::Mutability) } // We use the term "interior" to mean "something reachable from the @@ -174,7 +174,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option { ty::ty_estr(ty::vstore_slice(r)) | ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil, region: r, _}) => { - Some(deref_ptr(region_ptr(ast::m_imm, r))) + Some(deref_ptr(region_ptr(ast::MutImmutable, r))) } ty::ty_box(ref mt) | @@ -188,7 +188,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option { ty::ty_estr(ty::vstore_box) | ty::ty_closure(ty::ClosureTy {sigil: ast::ManagedSigil, _}) => { - Some(deref_ptr(gc_ptr(ast::m_imm))) + Some(deref_ptr(gc_ptr(ast::MutImmutable))) } ty::ty_ptr(ref mt) => { @@ -222,7 +222,7 @@ pub fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind { pub fn cat_expr(tcx: ty::ctxt, method_map: typeck::method_map, - expr: @ast::expr) + expr: @ast::Expr) -> cmt { let mcx = &mem_categorization_ctxt { tcx: tcx, method_map: method_map @@ -232,7 +232,7 @@ pub fn cat_expr(tcx: ty::ctxt, pub fn cat_expr_unadjusted(tcx: ty::ctxt, method_map: typeck::method_map, - expr: @ast::expr) + expr: @ast::Expr) -> cmt { let mcx = &mem_categorization_ctxt { tcx: tcx, method_map: method_map @@ -243,7 +243,7 @@ pub fn cat_expr_unadjusted(tcx: ty::ctxt, pub fn cat_expr_autoderefd( tcx: ty::ctxt, method_map: typeck::method_map, - expr: @ast::expr, + expr: @ast::Expr, autoderefs: uint) -> cmt { let mcx = &mem_categorization_ctxt { @@ -258,7 +258,7 @@ pub fn cat_def( expr_id: ast::NodeId, expr_span: Span, expr_ty: ty::t, - def: ast::def) -> cmt { + def: ast::Def) -> cmt { let mcx = &mem_categorization_ctxt { tcx: tcx, method_map: method_map @@ -271,12 +271,12 @@ pub trait ast_node { fn span(&self) -> Span; } -impl ast_node for @ast::expr { +impl ast_node for @ast::Expr { fn id(&self) -> ast::NodeId { self.id } fn span(&self) -> Span { self.span } } -impl ast_node for @ast::pat { +impl ast_node for @ast::Pat { fn id(&self) -> ast::NodeId { self.id } fn span(&self) -> Span { self.span } } @@ -293,10 +293,10 @@ impl ToStr for MutabilityCategory { } impl MutabilityCategory { - pub fn from_mutbl(m: ast::mutability) -> MutabilityCategory { + pub fn from_mutbl(m: ast::Mutability) -> MutabilityCategory { match m { - m_imm => McImmutable, - m_mutbl => McDeclared + MutImmutable => McImmutable, + MutMutable => McDeclared } } @@ -331,15 +331,15 @@ impl MutabilityCategory { } impl mem_categorization_ctxt { - pub fn expr_ty(&self, expr: @ast::expr) -> ty::t { + pub fn expr_ty(&self, expr: @ast::Expr) -> ty::t { ty::expr_ty(self.tcx, expr) } - pub fn pat_ty(&self, pat: @ast::pat) -> ty::t { + pub fn pat_ty(&self, pat: @ast::Pat) -> ty::t { ty::node_id_to_type(self.tcx, pat.id) } - pub fn cat_expr(&self, expr: @ast::expr) -> cmt { + pub fn cat_expr(&self, expr: @ast::Expr) -> cmt { match self.tcx.adjustments.find(&expr.id) { None => { // No adjustments. @@ -373,7 +373,7 @@ impl mem_categorization_ctxt { } } - pub fn cat_expr_autoderefd(&self, expr: @ast::expr, autoderefs: uint) + pub fn cat_expr_autoderefd(&self, expr: @ast::Expr, autoderefs: uint) -> cmt { let mut cmt = self.cat_expr_unadjusted(expr); for deref in range(1u, autoderefs + 1) { @@ -382,13 +382,13 @@ impl mem_categorization_ctxt { return cmt; } - pub fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt { + pub fn cat_expr_unadjusted(&self, expr: @ast::Expr) -> cmt { debug!("cat_expr: id=%d expr=%s", expr.id, pprust::expr_to_str(expr, self.tcx.sess.intr())); let expr_ty = self.expr_ty(expr); match expr.node { - ast::expr_unary(_, ast::deref, e_base) => { + ast::ExprUnary(_, ast::UnDeref, e_base) => { if self.method_map.contains_key(&expr.id) { return self.cat_rvalue_node(expr, expr_ty); } @@ -397,7 +397,7 @@ impl mem_categorization_ctxt { self.cat_deref(expr, base_cmt, 0) } - ast::expr_field(base, f_name, _) => { + ast::ExprField(base, f_name, _) => { // Method calls are now a special syntactic form, // so `a.b` should always be a field. assert!(!self.method_map.contains_key(&expr.id)); @@ -406,7 +406,7 @@ impl mem_categorization_ctxt { self.cat_field(expr, base_cmt, f_name, self.expr_ty(expr)) } - ast::expr_index(_, base, _) => { + ast::ExprIndex(_, base, _) => { if self.method_map.contains_key(&expr.id) { return self.cat_rvalue_node(expr, expr_ty); } @@ -415,28 +415,28 @@ impl mem_categorization_ctxt { self.cat_index(expr, base_cmt, 0) } - ast::expr_path(_) | ast::expr_self => { + ast::ExprPath(_) | ast::ExprSelf => { let def = self.tcx.def_map.get_copy(&expr.id); self.cat_def(expr.id, expr.span, expr_ty, def) } - ast::expr_paren(e) => self.cat_expr_unadjusted(e), - - ast::expr_addr_of(*) | ast::expr_call(*) | - ast::expr_assign(*) | ast::expr_assign_op(*) | - ast::expr_fn_block(*) | ast::expr_ret(*) | - ast::expr_do_body(*) | ast::expr_unary(*) | - ast::expr_method_call(*) | ast::expr_cast(*) | ast::expr_vstore(*) | - ast::expr_vec(*) | ast::expr_tup(*) | ast::expr_if(*) | - ast::expr_log(*) | ast::expr_binary(*) | ast::expr_while(*) | - ast::expr_block(*) | ast::expr_loop(*) | ast::expr_match(*) | - ast::expr_lit(*) | ast::expr_break(*) | ast::expr_mac(*) | - ast::expr_again(*) | ast::expr_struct(*) | ast::expr_repeat(*) | - ast::expr_inline_asm(*) => { + ast::ExprParen(e) => self.cat_expr_unadjusted(e), + + ast::ExprAddrOf(*) | ast::ExprCall(*) | + ast::ExprAssign(*) | ast::ExprAssignOp(*) | + ast::ExprFnBlock(*) | ast::ExprRet(*) | + ast::ExprDoBody(*) | ast::ExprUnary(*) | + ast::ExprMethodCall(*) | ast::ExprCast(*) | ast::ExprVstore(*) | + ast::ExprVec(*) | ast::ExprTup(*) | ast::ExprIf(*) | + ast::ExprLog(*) | ast::ExprBinary(*) | ast::ExprWhile(*) | + ast::ExprBlock(*) | ast::ExprLoop(*) | ast::ExprMatch(*) | + ast::ExprLit(*) | ast::ExprBreak(*) | ast::ExprMac(*) | + ast::ExprAgain(*) | ast::ExprStruct(*) | ast::ExprRepeat(*) | + ast::ExprInlineAsm(*) => { return self.cat_rvalue_node(expr, expr_ty); } - ast::expr_for_loop(*) => fail!("non-desugared expr_for_loop") + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop") } } @@ -444,16 +444,16 @@ impl mem_categorization_ctxt { id: ast::NodeId, span: Span, expr_ty: ty::t, - def: ast::def) + def: ast::Def) -> cmt { match def { - ast::def_fn(*) | ast::def_static_method(*) | ast::def_mod(_) | - ast::def_foreign_mod(_) | ast::def_static(_, false) | - ast::def_use(_) | ast::def_variant(*) | - ast::def_trait(_) | ast::def_ty(_) | ast::def_prim_ty(_) | - ast::def_ty_param(*) | ast::def_struct(*) | - ast::def_typaram_binder(*) | ast::def_region(_) | - ast::def_label(_) | ast::def_self_ty(*) | ast::def_method(*) => { + ast::DefFn(*) | ast::DefStaticMethod(*) | ast::DefMod(_) | + ast::DefForeignMod(_) | ast::DefStatic(_, false) | + ast::DefUse(_) | ast::DefVariant(*) | + ast::DefTrait(_) | ast::DefTy(_) | ast::DefPrimTy(_) | + ast::DefTyParam(*) | ast::DefStruct(*) | + ast::DefTyParamBinder(*) | ast::DefRegion(_) | + ast::DefLabel(_) | ast::DefSelfTy(*) | ast::DefMethod(*) => { @cmt_ { id:id, span:span, @@ -463,7 +463,7 @@ impl mem_categorization_ctxt { } } - ast::def_static(_, true) => { + ast::DefStatic(_, true) => { @cmt_ { id:id, span:span, @@ -473,7 +473,7 @@ impl mem_categorization_ctxt { } } - ast::def_arg(vid, mutbl) => { + ast::DefArg(vid, mutbl) => { // Idea: make this could be rewritten to model by-ref // stuff as `&const` and `&mut`? @@ -488,7 +488,7 @@ impl mem_categorization_ctxt { } } - ast::def_self(self_id) => { + ast::DefSelf(self_id) => { @cmt_ { id:id, span:span, @@ -498,7 +498,7 @@ impl mem_categorization_ctxt { } } - ast::def_upvar(upvar_id, inner, fn_node_id, _) => { + ast::DefUpvar(upvar_id, inner, fn_node_id, _) => { let ty = ty::node_id_to_type(self.tcx, fn_node_id); match ty::get(ty).sty { ty::ty_closure(ref closure_ty) => { @@ -549,7 +549,7 @@ impl mem_categorization_ctxt { } } - ast::def_local(vid, mutbl) => { + ast::DefLocal(vid, mutbl) => { let m = if mutbl {McDeclared} else {McImmutable}; @cmt_ { id:id, @@ -560,7 +560,7 @@ impl mem_categorization_ctxt { } } - ast::def_binding(vid, _) => { + ast::DefBinding(vid, _) => { // by-value/by-ref bindings are local variables @cmt_ { id:id, @@ -602,11 +602,11 @@ impl mem_categorization_ctxt { /// or if the container is mutable. pub fn inherited_mutability(&self, base_m: MutabilityCategory, - interior_m: ast::mutability) + interior_m: ast::Mutability) -> MutabilityCategory { match interior_m { - m_imm => base_m.inherit(), - m_mutbl => McDeclared + MutImmutable => base_m.inherit(), + MutMutable => McDeclared } } @@ -824,8 +824,8 @@ impl mem_categorization_ctxt { pub fn cat_pattern(&self, cmt: cmt, - pat: @ast::pat, - op: &fn(cmt, @ast::pat)) { + pat: @ast::Pat, + op: &fn(cmt, @ast::Pat)) { // Here, `cmt` is the categorization for the value being // matched and pat is the pattern it is being matched against. // @@ -879,16 +879,16 @@ impl mem_categorization_ctxt { op(cmt, pat); match pat.node { - ast::pat_wild => { + ast::PatWild => { // _ } - ast::pat_enum(_, None) => { + ast::PatEnum(_, None) => { // variant(*) } - ast::pat_enum(_, Some(ref subpats)) => { + ast::PatEnum(_, Some(ref subpats)) => { match self.tcx.def_map.find(&pat.id) { - Some(&ast::def_variant(enum_did, _)) => { + Some(&ast::DefVariant(enum_did, _)) => { // variant(x, y, z) let downcast_cmt = { @@ -910,8 +910,8 @@ impl mem_categorization_ctxt { self.cat_pattern(subcmt, subpat, |x,y| op(x,y)); } } - Some(&ast::def_fn(*)) | - Some(&ast::def_struct(*)) => { + Some(&ast::DefFn(*)) | + Some(&ast::DefStruct(*)) => { for (i, &subpat) in subpats.iter().enumerate() { let subpat_ty = self.pat_ty(subpat); // see (*) let cmt_field = @@ -921,7 +921,7 @@ impl mem_categorization_ctxt { self.cat_pattern(cmt_field, subpat, |x,y| op(x,y)); } } - Some(&ast::def_static(*)) => { + Some(&ast::DefStatic(*)) => { for &subpat in subpats.iter() { self.cat_pattern(cmt, subpat, |x,y| op(x,y)); } @@ -934,15 +934,15 @@ impl mem_categorization_ctxt { } } - ast::pat_ident(_, _, Some(subpat)) => { + ast::PatIdent(_, _, Some(subpat)) => { self.cat_pattern(cmt, subpat, op); } - ast::pat_ident(_, _, None) => { + ast::PatIdent(_, _, None) => { // nullary variant or identifier: ignore } - ast::pat_struct(_, ref field_pats, _) => { + ast::PatStruct(_, ref field_pats, _) => { // {f1: p1, ..., fN: pN} for fp in field_pats.iter() { let field_ty = self.pat_ty(fp.pat); // see (*) @@ -951,7 +951,7 @@ impl mem_categorization_ctxt { } } - ast::pat_tup(ref subpats) => { + ast::PatTup(ref subpats) => { // (p1, ..., pN) for (i, &subpat) in subpats.iter().enumerate() { let subpat_ty = self.pat_ty(subpat); // see (*) @@ -963,14 +963,14 @@ impl mem_categorization_ctxt { } } - ast::pat_box(subpat) | ast::pat_uniq(subpat) | - ast::pat_region(subpat) => { + ast::PatBox(subpat) | ast::PatUniq(subpat) | + ast::PatRegion(subpat) => { // @p1, ~p1 let subcmt = self.cat_deref(pat, cmt, 0); self.cat_pattern(subcmt, subpat, op); } - ast::pat_vec(ref before, slice, ref after) => { + ast::PatVec(ref before, slice, ref after) => { let elt_cmt = self.cat_index(pat, cmt, 0); for &before_pat in before.iter() { self.cat_pattern(elt_cmt, before_pat, |x,y| op(x,y)); @@ -985,16 +985,16 @@ impl mem_categorization_ctxt { } } - ast::pat_lit(_) | ast::pat_range(_, _) => { + ast::PatLit(_) | ast::PatRange(_, _) => { /*always ok*/ } } } - pub fn mut_to_str(&self, mutbl: ast::mutability) -> ~str { + pub fn mut_to_str(&self, mutbl: ast::Mutability) -> ~str { match mutbl { - m_mutbl => ~"mutable", - m_imm => ~"immutable" + MutMutable => ~"mutable", + MutImmutable => ~"immutable" } } @@ -1060,24 +1060,24 @@ pub fn field_mutbl(tcx: ty::ctxt, base_ty: ty::t, f_name: ast::Ident, node_id: ast::NodeId) - -> Option { + -> Option { // Need to refactor so that struct/enum fields can be treated uniformly. match ty::get(base_ty).sty { ty::ty_struct(did, _) => { let r = ty::lookup_struct_fields(tcx, did); for fld in r.iter() { if fld.ident == f_name { - return Some(ast::m_imm); + return Some(ast::MutImmutable); } } } ty::ty_enum(*) => { match tcx.def_map.get_copy(&node_id) { - ast::def_variant(_, variant_id) => { + ast::DefVariant(_, variant_id) => { let r = ty::lookup_struct_fields(tcx, variant_id); for fld in r.iter() { if fld.ident == f_name { - return Some(ast::m_imm); + return Some(ast::MutImmutable); } } } @@ -1091,8 +1091,8 @@ pub fn field_mutbl(tcx: ty::ctxt, } pub enum AliasableReason { - AliasableManaged(ast::mutability), - AliasableBorrowed(ast::mutability), + AliasableManaged(ast::Mutability), + AliasableBorrowed(ast::Mutability), AliasableOther } @@ -1145,7 +1145,7 @@ impl cmt_ { cat_arg(_) | cat_self(*) | cat_deref(_, _, unsafe_ptr(*)) | // of course it is aliasable, but... - cat_deref(_, _, region_ptr(m_mutbl, _)) => { + cat_deref(_, _, region_ptr(MutMutable, _)) => { None } @@ -1158,7 +1158,7 @@ impl cmt_ { Some(AliasableManaged(m)) } - cat_deref(_, _, region_ptr(m @ m_imm, _)) => { + cat_deref(_, _, region_ptr(m @ MutImmutable, _)) => { Some(AliasableBorrowed(m)) } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 8ba2c38250f65..ba05ab1f3c3cd 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -152,7 +152,7 @@ pub enum CaptureMode { #[deriving(Encodable, Decodable)] pub struct CaptureVar { - def: def, // Variable being accessed free + def: Def, // Variable being accessed free span: Span, // Location of an access to this variable mode: CaptureMode // How variable is being accessed } @@ -197,7 +197,7 @@ impl visit::Visitor for ComputeModesVisitor { b:&Block, s:Span, n:NodeId, e:VisitContext) { compute_modes_for_fn(*self, fk, fd, b, s, n, e); } - fn visit_expr(&mut self, ex:@expr, e:VisitContext) { + fn visit_expr(&mut self, ex:@Expr, e:VisitContext) { compute_modes_for_expr(*self, ex, e); } fn visit_local(&mut self, l:@Local, e:VisitContext) { @@ -223,12 +223,12 @@ pub fn compute_moves(tcx: ty::ctxt, return visit_cx.move_maps; } -pub fn moved_variable_node_id_from_def(def: def) -> Option { +pub fn moved_variable_node_id_from_def(def: Def) -> Option { match def { - def_binding(nid, _) | - def_arg(nid, _) | - def_local(nid, _) | - def_self(nid) => Some(nid), + DefBinding(nid, _) | + DefArg(nid, _) | + DefLocal(nid, _) | + DefSelf(nid) => Some(nid), _ => None } @@ -261,20 +261,20 @@ fn compute_modes_for_fn(v: ComputeModesVisitor, } fn compute_modes_for_expr(v: ComputeModesVisitor, - expr: @expr, + expr: @Expr, cx: VisitContext) { cx.consume_expr(expr, v); } impl VisitContext { - pub fn consume_exprs(&self, exprs: &[@expr], visitor: ComputeModesVisitor) { + pub fn consume_exprs(&self, exprs: &[@Expr], visitor: ComputeModesVisitor) { for expr in exprs.iter() { self.consume_expr(*expr, visitor); } } - pub fn consume_expr(&self, expr: @expr, visitor: ComputeModesVisitor) { + pub fn consume_expr(&self, expr: @Expr, visitor: ComputeModesVisitor) { /*! * Indicates that the value of `expr` will be consumed, * meaning either copied or moved depending on its type. @@ -311,7 +311,7 @@ impl VisitContext { } pub fn use_expr(&self, - expr: @expr, + expr: @Expr, expr_mode: UseMode, visitor: ComputeModesVisitor) { /*! @@ -336,7 +336,7 @@ impl VisitContext { debug!("comp_mode = %?", comp_mode); match expr.node { - expr_path(*) | expr_self => { + ExprPath(*) | ExprSelf => { match comp_mode { Move => { let def = self.tcx.def_map.get_copy(&expr.id); @@ -349,7 +349,7 @@ impl VisitContext { } } - expr_unary(_, deref, base) => { // *base + ExprUnary(_, UnDeref, base) => { // *base if !self.use_overloaded_operator( expr, base, [], visitor) { @@ -358,12 +358,12 @@ impl VisitContext { } } - expr_field(base, _, _) => { // base.f + ExprField(base, _, _) => { // base.f // Moving out of base.f moves out of base. self.use_expr(base, comp_mode, visitor); } - expr_index(_, lhs, rhs) => { // lhs[rhs] + ExprIndex(_, lhs, rhs) => { // lhs[rhs] if !self.use_overloaded_operator( expr, lhs, [rhs], visitor) { @@ -372,7 +372,7 @@ impl VisitContext { } } - expr_call(callee, ref args, _) => { // callee(args) + ExprCall(callee, ref args, _) => { // callee(args) // Figure out whether the called function is consumed. let mode = match ty::get(ty::expr_ty(self.tcx, callee)).sty { ty::ty_closure(ref cty) => { @@ -397,14 +397,14 @@ impl VisitContext { self.use_fn_args(callee.id, *args, visitor); } - expr_method_call(callee_id, rcvr, _, _, ref args, _) => { // callee.m(args) + ExprMethodCall(callee_id, rcvr, _, _, ref args, _) => { // callee.m(args) // Implicit self is equivalent to & mode, but every // other kind should be + mode. self.use_receiver(rcvr, visitor); self.use_fn_args(callee_id, *args, visitor); } - expr_struct(_, ref fields, opt_with) => { + ExprStruct(_, ref fields, opt_with) => { for field in fields.iter() { self.consume_expr(field.expr, visitor); } @@ -441,11 +441,11 @@ impl VisitContext { } } - expr_tup(ref exprs) => { + ExprTup(ref exprs) => { self.consume_exprs(*exprs, visitor); } - expr_if(cond_expr, ref then_blk, opt_else_expr) => { + ExprIf(cond_expr, ref then_blk, opt_else_expr) => { self.consume_expr(cond_expr, visitor); self.consume_block(then_blk, visitor); for else_expr in opt_else_expr.iter() { @@ -453,7 +453,7 @@ impl VisitContext { } } - expr_match(discr, ref arms) => { + ExprMatch(discr, ref arms) => { // We must do this first so that `arms_have_by_move_bindings` // below knows which bindings are moves. for arm in arms.iter() { @@ -466,42 +466,42 @@ impl VisitContext { self.use_expr(discr, Read, visitor); } - expr_paren(base) => { + ExprParen(base) => { // Note: base is not considered a *component* here, so // use `expr_mode` not `comp_mode`. self.use_expr(base, expr_mode, visitor); } - expr_vec(ref exprs, _) => { + ExprVec(ref exprs, _) => { self.consume_exprs(*exprs, visitor); } - expr_addr_of(_, base) => { // &base + ExprAddrOf(_, base) => { // &base self.use_expr(base, Read, visitor); } - expr_inline_asm(*) | - expr_break(*) | - expr_again(*) | - expr_lit(*) => {} + ExprInlineAsm(*) | + ExprBreak(*) | + ExprAgain(*) | + ExprLit(*) => {} - expr_loop(ref blk, _) => { + ExprLoop(ref blk, _) => { self.consume_block(blk, visitor); } - expr_log(a_expr, b_expr) => { + ExprLog(a_expr, b_expr) => { self.consume_expr(a_expr, visitor); self.use_expr(b_expr, Read, visitor); } - expr_while(cond_expr, ref blk) => { + ExprWhile(cond_expr, ref blk) => { self.consume_expr(cond_expr, visitor); self.consume_block(blk, visitor); } - expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - expr_unary(_, _, lhs) => { + ExprUnary(_, _, lhs) => { if !self.use_overloaded_operator( expr, lhs, [], visitor) { @@ -509,7 +509,7 @@ impl VisitContext { } } - expr_binary(_, _, lhs, rhs) => { + ExprBinary(_, _, lhs, rhs) => { if !self.use_overloaded_operator( expr, lhs, [rhs], visitor) { @@ -518,26 +518,26 @@ impl VisitContext { } } - expr_block(ref blk) => { + ExprBlock(ref blk) => { self.consume_block(blk, visitor); } - expr_ret(ref opt_expr) => { + ExprRet(ref opt_expr) => { for expr in opt_expr.iter() { self.consume_expr(*expr, visitor); } } - expr_assign(lhs, rhs) => { + ExprAssign(lhs, rhs) => { self.use_expr(lhs, Read, visitor); self.consume_expr(rhs, visitor); } - expr_cast(base, _) => { + ExprCast(base, _) => { self.consume_expr(base, visitor); } - expr_assign_op(_, _, lhs, rhs) => { + ExprAssignOp(_, _, lhs, rhs) => { // FIXME(#4712) --- Overloaded operators? // // if !self.use_overloaded_operator( @@ -548,16 +548,16 @@ impl VisitContext { // } } - expr_repeat(base, count, _) => { + ExprRepeat(base, count, _) => { self.consume_expr(base, visitor); self.consume_expr(count, visitor); } - expr_do_body(base) => { + ExprDoBody(base) => { self.use_expr(base, comp_mode, visitor); } - expr_fn_block(ref decl, ref body) => { + ExprFnBlock(ref decl, ref body) => { for a in decl.inputs.iter() { self.use_pat(a.pat); } @@ -566,11 +566,11 @@ impl VisitContext { self.consume_block(body, visitor); } - expr_vstore(base, _) => { + ExprVstore(base, _) => { self.use_expr(base, comp_mode, visitor); } - expr_mac(*) => { + ExprMac(*) => { self.tcx.sess.span_bug( expr.span, "macro expression remains after expansion"); @@ -579,9 +579,9 @@ impl VisitContext { } pub fn use_overloaded_operator(&self, - expr: &expr, - receiver_expr: @expr, - arg_exprs: &[@expr], + expr: &Expr, + receiver_expr: @Expr, + arg_exprs: &[@Expr], visitor: ComputeModesVisitor) -> bool { if !self.method_map.contains_key(&expr.id) { @@ -599,7 +599,7 @@ impl VisitContext { return true; } - pub fn consume_arm(&self, arm: &arm, visitor: ComputeModesVisitor) { + pub fn consume_arm(&self, arm: &Arm, visitor: ComputeModesVisitor) { for pat in arm.pats.iter() { self.use_pat(*pat); } @@ -611,7 +611,7 @@ impl VisitContext { self.consume_block(&arm.body, visitor); } - pub fn use_pat(&self, pat: @pat) { + pub fn use_pat(&self, pat: @Pat) { /*! * * Decides whether each binding in a pattern moves the value @@ -620,8 +620,8 @@ impl VisitContext { do pat_bindings(self.tcx.def_map, pat) |bm, id, _span, path| { let binding_moves = match bm { - bind_by_ref(_) => false, - bind_infer => { + BindByRef(_) => false, + BindInfer => { let pat_ty = ty::node_id_to_type(self.tcx, id); debug!("pattern %? %s type is %s", id, @@ -641,14 +641,14 @@ impl VisitContext { } pub fn use_receiver(&self, - receiver_expr: @expr, + receiver_expr: @Expr, visitor: ComputeModesVisitor) { self.use_fn_arg(receiver_expr, visitor); } pub fn use_fn_args(&self, _: NodeId, - arg_exprs: &[@expr], + arg_exprs: &[@Expr], visitor: ComputeModesVisitor) { //! Uses the argument expressions. for arg_expr in arg_exprs.iter() { @@ -656,15 +656,15 @@ impl VisitContext { } } - pub fn use_fn_arg(&self, arg_expr: @expr, visitor: ComputeModesVisitor) { + pub fn use_fn_arg(&self, arg_expr: @Expr, visitor: ComputeModesVisitor) { //! Uses the argument. self.consume_expr(arg_expr, visitor) } pub fn arms_have_by_move_bindings(&self, moves_map: MovesMap, - arms: &[arm]) - -> Option<@pat> { + arms: &[Arm]) + -> Option<@Pat> { let mut ret = None; for arm in arms.iter() { for &pat in arm.pats.iter() { diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index a41ab09fdbb79..acdadacc083e2 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -20,7 +20,7 @@ pub type PatIdMap = HashMap; // This is used because same-named variables in alternative patterns need to // use the NodeId of their namesake in the first pattern. -pub fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap { +pub fn pat_id_map(dm: resolve::DefMap, pat: @Pat) -> PatIdMap { let mut map = HashMap::new(); do pat_bindings(dm, pat) |_bm, p_id, _s, n| { map.insert(path_to_ident(n), p_id); @@ -28,11 +28,11 @@ pub fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap { map } -pub fn pat_is_variant_or_struct(dm: resolve::DefMap, pat: &pat) -> bool { +pub fn pat_is_variant_or_struct(dm: resolve::DefMap, pat: &Pat) -> bool { match pat.node { - pat_enum(_, _) | pat_ident(_, _, None) | pat_struct(*) => { + PatEnum(_, _) | PatIdent(_, _, None) | PatStruct(*) => { match dm.find(&pat.id) { - Some(&def_variant(*)) | Some(&def_struct(*)) => true, + Some(&DefVariant(*)) | Some(&DefStruct(*)) => true, _ => false } } @@ -40,11 +40,11 @@ pub fn pat_is_variant_or_struct(dm: resolve::DefMap, pat: &pat) -> bool { } } -pub fn pat_is_const(dm: resolve::DefMap, pat: &pat) -> bool { +pub fn pat_is_const(dm: resolve::DefMap, pat: &Pat) -> bool { match pat.node { - pat_ident(_, _, None) | pat_enum(*) => { + PatIdent(_, _, None) | PatEnum(*) => { match dm.find(&pat.id) { - Some(&def_static(_, false)) => true, + Some(&DefStatic(_, false)) => true, _ => false } } @@ -52,9 +52,9 @@ pub fn pat_is_const(dm: resolve::DefMap, pat: &pat) -> bool { } } -pub fn pat_is_binding(dm: resolve::DefMap, pat: @pat) -> bool { +pub fn pat_is_binding(dm: resolve::DefMap, pat: @Pat) -> bool { match pat.node { - pat_ident(*) => { + PatIdent(*) => { !pat_is_variant_or_struct(dm, pat) && !pat_is_const(dm, pat) } @@ -62,19 +62,19 @@ pub fn pat_is_binding(dm: resolve::DefMap, pat: @pat) -> bool { } } -pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool { +pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @Pat) -> bool { match pat.node { - pat_ident(*) => pat_is_binding(dm, pat), - pat_wild => true, + PatIdent(*) => pat_is_binding(dm, pat), + PatWild => true, _ => false } } -pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, - it: &fn(binding_mode, NodeId, Span, &Path)) { +pub fn pat_bindings(dm: resolve::DefMap, pat: @Pat, + it: &fn(BindingMode, NodeId, Span, &Path)) { do walk_pat(pat) |p| { match p.node { - pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => { + PatIdent(binding_mode, ref pth, _) if pat_is_binding(dm, p) => { it(binding_mode, p.id, p.span, pth); } _ => {} @@ -83,7 +83,7 @@ pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, }; } -pub fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[NodeId] { +pub fn pat_binding_ids(dm: resolve::DefMap, pat: @Pat) -> ~[NodeId] { let mut found = ~[]; pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) ); return found; @@ -91,7 +91,7 @@ pub fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[NodeId] { /// Checks if the pattern contains any patterns that bind something to /// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(*)`. -pub fn pat_contains_bindings(dm: resolve::DefMap, pat: @pat) -> bool { +pub fn pat_contains_bindings(dm: resolve::DefMap, pat: @Pat) -> bool { let mut contains_bindings = false; do walk_pat(pat) |p| { if pat_is_binding(dm, p) { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 5c7ab126c9160..04fceb3e8e3cd 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -18,12 +18,12 @@ use middle::typeck::{method_map, method_origin, method_param}; use middle::typeck::{method_static, method_object}; use std::util::ignore; -use syntax::ast::{decl_item, def, def_fn, def_id, def_static_method}; -use syntax::ast::{def_variant, expr_field, expr_method_call, expr_path}; -use syntax::ast::{expr_struct, expr_unary, Ident, inherited, item_enum}; +use syntax::ast::{DeclItem, Def, DefFn, DefId, DefStaticMethod}; +use syntax::ast::{DefVariant, ExprField, ExprMethodCall, ExprPath}; +use syntax::ast::{ExprStruct, ExprUnary, Ident, inherited, item_enum}; use syntax::ast::{item_foreign_mod, item_fn, item_impl, item_struct}; -use syntax::ast::{item_trait, LOCAL_CRATE, NodeId, pat_struct, Path}; -use syntax::ast::{private, provided, public, required, stmt_decl, visibility}; +use syntax::ast::{item_trait, LOCAL_CRATE, NodeId, PatStruct, Path}; +use syntax::ast::{private, provided, public, required, StmtDecl, visibility}; use syntax::ast; use syntax::ast_map::{node_foreign_item, node_item, node_method}; use syntax::ast_map::{node_trait_method}; @@ -35,7 +35,7 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::visit; use syntax::visit::Visitor; -use syntax::ast::{_mod,expr,item,Block,pat}; +use syntax::ast::{_mod,Expr,item,Block,Pat}; struct PrivacyVisitor { tcx: ty::ctxt, @@ -79,7 +79,7 @@ impl PrivacyVisitor { } // Checks that an enum variant is in scope - fn check_variant(&mut self, span: Span, enum_id: ast::def_id) { + fn check_variant(&mut self, span: Span, enum_id: ast::DefId) { let variant_info = ty::enum_variants(self.tcx, enum_id)[0]; let parental_privacy = if is_local(enum_id) { let parent_vis = ast_map::node_item_query(self.tcx.items, @@ -109,7 +109,7 @@ impl PrivacyVisitor { // Returns true if a crate-local method is private and false otherwise. fn method_is_private(&mut self, span: Span, method_id: NodeId) -> bool { - let check = |vis: visibility, container_id: def_id| { + let check = |vis: visibility, container_id: DefId| { let mut is_private = false; if vis == private { is_private = true; @@ -203,7 +203,7 @@ impl PrivacyVisitor { } // Checks that a private field is in scope. - fn check_field(&mut self, span: Span, id: ast::def_id, ident: ast::Ident) { + fn check_field(&mut self, span: Span, id: ast::DefId, ident: ast::Ident) { let fields = ty::lookup_struct_fields(self.tcx, id); for field in fields.iter() { if field.ident != ident { loop; } @@ -216,7 +216,7 @@ impl PrivacyVisitor { } // Given the ID of a method, checks to ensure it's in scope. - fn check_method_common(&mut self, span: Span, method_id: def_id, name: &Ident) { + fn check_method_common(&mut self, span: Span, method_id: DefId, name: &Ident) { // If the method is a default method, we need to use the def_id of // the default implementation. // Having to do this this is really unfortunate. @@ -245,16 +245,16 @@ impl PrivacyVisitor { } // Checks that a private path is in scope. - fn check_path(&mut self, span: Span, def: def, path: &Path) { + fn check_path(&mut self, span: Span, def: Def, path: &Path) { debug!("checking path"); match def { - def_static_method(method_id, _, _) => { + DefStaticMethod(method_id, _, _) => { debug!("found static method def, checking it"); self.check_method_common(span, method_id, &path.segments.last().identifier) } - def_fn(def_id, _) => { + DefFn(def_id, _) => { if def_id.crate == LOCAL_CRATE { if self.local_item_is_private(span, def_id.node) && !self.privileged_items.iter().any(|x| x == &def_id.node) { @@ -371,9 +371,9 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { let mut n_added = 0; for stmt in block.stmts.iter() { match stmt.node { - stmt_decl(decl, _) => { + StmtDecl(decl, _) => { match decl.node { - decl_item(item) => { + DeclItem(item) => { self.add_privileged_item(item, &mut n_added); } _ => {} @@ -391,10 +391,10 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { } - fn visit_expr<'mm>(&mut self, expr:@expr, method_map:&'mm method_map) { + fn visit_expr<'mm>(&mut self, expr:@Expr, method_map:&'mm method_map) { match expr.node { - expr_field(base, ident, _) => { + ExprField(base, ident, _) => { // Method calls are now a special syntactic form, // so `a.b` should always be a field. assert!(!method_map.contains_key(&expr.id)); @@ -412,7 +412,7 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { _ => {} } } - expr_method_call(_, base, ident, _, _, _) => { + ExprMethodCall(_, base, ident, _, _, _) => { // Ditto match ty::get(ty::type_autoderef(self.tcx, ty::expr_ty(self.tcx, base))).sty { @@ -436,10 +436,10 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { _ => {} } } - expr_path(ref path) => { + ExprPath(ref path) => { self.check_path(expr.span, self.tcx.def_map.get_copy(&expr.id), path); } - expr_struct(_, ref fields, _) => { + ExprStruct(_, ref fields, _) => { match ty::get(ty::expr_ty(self.tcx, expr)).sty { ty_struct(id, _) => { if id.crate != LOCAL_CRATE || @@ -455,7 +455,7 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { if id.crate != LOCAL_CRATE || !self.privileged_items.iter().any(|x| x == &(id.node)) { match self.tcx.def_map.get_copy(&expr.id) { - def_variant(_, variant_id) => { + DefVariant(_, variant_id) => { for field in (*fields).iter() { debug!("(privacy checking) \ checking field in \ @@ -481,7 +481,7 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { } } } - expr_unary(_, ast::deref, operand) => { + ExprUnary(_, ast::UnDeref, operand) => { // In *e, we need to check that if e's type is an // enum type t, then t's first variant is public or // privileged. (We can assume it has only one variant @@ -503,10 +503,10 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { } - fn visit_pat<'mm>(&mut self, pattern:@pat, method_map:&'mm method_map) { + fn visit_pat<'mm>(&mut self, pattern:@Pat, method_map:&'mm method_map) { match pattern.node { - pat_struct(_, ref fields, _) => { + PatStruct(_, ref fields, _) => { match ty::get(ty::pat_ty(self.tcx, pattern)).sty { ty_struct(id, _) => { if id.crate != LOCAL_CRATE || @@ -522,7 +522,7 @@ impl<'self> Visitor<&'self method_map> for PrivacyVisitor { if enum_id.crate != LOCAL_CRATE || !self.privileged_items.iter().any(|x| x == &enum_id.node) { match self.tcx.def_map.find(&pattern.id) { - Some(&def_variant(_, variant_id)) => { + Some(&DefVariant(_, variant_id)) => { for field in fields.iter() { debug!("(privacy checking) \ checking field in \ diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index b6a4ac49391a3..07ec4bc27fb41 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -205,10 +205,10 @@ struct MarkSymbolVisitor { impl Visitor<()> for MarkSymbolVisitor { - fn visit_expr(&mut self, expr:@expr, _:()) { + fn visit_expr(&mut self, expr:@Expr, _:()) { match expr.node { - expr_path(_) => { + ExprPath(_) => { let def = match self.tcx.def_map.find(&expr.id) { Some(&def) => def, None => { @@ -225,7 +225,7 @@ impl Visitor<()> for MarkSymbolVisitor { } self.reachable_symbols.insert(def_id.node); } - expr_method_call(*) => { + ExprMethodCall(*) => { match self.method_map.find(&expr.id) { Some(&typeck::method_map_entry { origin: typeck::method_static(def_id), @@ -283,7 +283,7 @@ impl ReachableContext { // Returns true if the given def ID represents a local item that is // eligible for inlining and false otherwise. - fn def_id_represents_local_inlined_item(tcx: ty::ctxt, def_id: def_id) + fn def_id_represents_local_inlined_item(tcx: ty::ctxt, def_id: DefId) -> bool { if def_id.crate != LOCAL_CRATE { return false diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2d503029256cd..c4e20137271d3 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -36,7 +36,7 @@ use syntax::parse::token; use syntax::parse::token::special_idents; 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::ast::{Block,item,fn_decl,NodeId,Arm,Pat,Stmt,Expr,Local}; use syntax::ast::{Ty,TypeMethod,struct_field}; /** @@ -340,13 +340,13 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, } fn resolve_arm(visitor: &mut RegionResolutionVisitor, - arm: &ast::arm, + arm: &ast::Arm, cx: Context) { visit::walk_arm(visitor, arm, cx); } fn resolve_pat(visitor: &mut RegionResolutionVisitor, - pat: @ast::pat, + pat: @ast::Pat, cx: Context) { assert_eq!(cx.var_parent, cx.parent); parent_to_expr(cx, pat.id, pat.span); @@ -354,32 +354,32 @@ fn resolve_pat(visitor: &mut RegionResolutionVisitor, } fn resolve_stmt(visitor: &mut RegionResolutionVisitor, - stmt: @ast::stmt, + stmt: @ast::Stmt, cx: Context) { match stmt.node { - ast::stmt_decl(*) => { + ast::StmtDecl(*) => { visit::walk_stmt(visitor, stmt, cx); } - ast::stmt_expr(_, stmt_id) | - ast::stmt_semi(_, stmt_id) => { + ast::StmtExpr(_, stmt_id) | + ast::StmtSemi(_, stmt_id) => { parent_to_expr(cx, stmt_id, stmt.span); let expr_cx = Context {parent: Some(stmt_id), ..cx}; visit::walk_stmt(visitor, stmt, expr_cx); } - ast::stmt_mac(*) => cx.sess.bug("unexpanded macro") + ast::StmtMac(*) => cx.sess.bug("unexpanded macro") } } fn resolve_expr(visitor: &mut RegionResolutionVisitor, - expr: @ast::expr, + expr: @ast::Expr, cx: Context) { parent_to_expr(cx, expr.id, expr.span); let mut new_cx = cx; new_cx.parent = Some(expr.id); match expr.node { - ast::expr_assign_op(*) | ast::expr_index(*) | ast::expr_binary(*) | - ast::expr_unary(*) | ast::expr_call(*) | ast::expr_method_call(*) => { + ast::ExprAssignOp(*) | ast::ExprIndex(*) | ast::ExprBinary(*) | + ast::ExprUnary(*) | ast::ExprCall(*) | ast::ExprMethodCall(*) => { // FIXME(#6268) Nested method calls // // The lifetimes for a call or method call look as follows: @@ -400,7 +400,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, // parent_to_expr(new_cx, expr.callee_id); } - ast::expr_match(*) => { + ast::ExprMatch(*) => { new_cx.var_parent = Some(expr.id); } @@ -485,16 +485,16 @@ impl Visitor for RegionResolutionVisitor { fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, cx:Context) { resolve_fn(self, fk, fd, b, s, n, cx); } - fn visit_arm(&mut self, a:&arm, cx:Context) { + fn visit_arm(&mut self, a:&Arm, cx:Context) { resolve_arm(self, a, cx); } - fn visit_pat(&mut self, p:@pat, cx:Context) { + fn visit_pat(&mut self, p:@Pat, cx:Context) { resolve_pat(self, p, cx); } - fn visit_stmt(&mut self, s:@stmt, cx:Context) { + fn visit_stmt(&mut self, s:@Stmt, cx:Context) { resolve_stmt(self, s, cx); } - fn visit_expr(&mut self, ex:@expr, cx:Context) { + fn visit_expr(&mut self, ex:@Expr, cx:Context) { resolve_expr(self, ex, cx); } fn visit_local(&mut self, l:@Local, cx:Context) { @@ -823,9 +823,9 @@ fn determine_rp_in_ty(visitor: &mut DetermineRpVisitor, match ty.node { ast::ty_path(ref path, _, id) => { match cx.def_map.find(&id) { - Some(&ast::def_ty(did)) | - Some(&ast::def_trait(did)) | - Some(&ast::def_struct(did)) => { + Some(&ast::DefTy(did)) | + Some(&ast::DefTrait(did)) | + Some(&ast::DefStruct(did)) => { if did.crate == ast::LOCAL_CRATE { if cx.region_is_relevant(&path.segments.last().lifetime) { cx.add_dep(did.node); @@ -890,7 +890,7 @@ fn determine_rp_in_ty(visitor: &mut DetermineRpVisitor, mt: &ast::mt, cx: @mut DetermineRpCtxt) { // mutability is invariant - if mt.mutbl == ast::m_mutbl { + if mt.mutbl == ast::MutMutable { do cx.with_ambient_variance(rv_invariant) { visitor.visit_ty(mt.ty, cx); } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 05545862f9008..ddf358841f76c 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -43,18 +43,18 @@ use std::hashmap::{HashMap, HashSet}; use std::util; // Definition mapping -pub type DefMap = @mut HashMap; +pub type DefMap = @mut HashMap; pub struct binding_info { span: Span, - binding_mode: binding_mode, + binding_mode: BindingMode, } // Map from the name in a pattern to its binding mode. pub type BindingMap = HashMap; // Trait method resolution -pub type TraitMap = HashMap; +pub type TraitMap = HashMap; // A summary of the generics on a trait. struct TraitGenerics { @@ -68,7 +68,7 @@ pub type ExportMap2 = @mut HashMap; pub struct Export2 { name: @str, // The name of the target. - def_id: def_id, // The definition of the target. + def_id: DefId, // The definition of the target. reexport: bool, // Whether this is a reexport. } @@ -120,8 +120,8 @@ impl NamespaceResult { pub enum NameDefinition { NoNameDefinition, //< The name was unbound. - ChildNameDefinition(def), //< The name identifies an immediate child. - ImportNameDefinition(def) //< The name identifies an import. + ChildNameDefinition(Def), //< The name identifies an immediate child. + ImportNameDefinition(Def) //< The name identifies an import. } #[deriving(Eq)] @@ -143,13 +143,13 @@ impl Visitor<()> for ResolveVisitor { fn visit_item(&mut self, item:@item, _:()) { self.resolver.resolve_item(item, self); } - fn visit_arm(&mut self, arm:&arm, _:()) { + fn visit_arm(&mut self, arm:&Arm, _:()) { self.resolver.resolve_arm(arm, self); } fn visit_block(&mut self, block:&Block, _:()) { self.resolver.resolve_block(block, self); } - fn visit_expr(&mut self, expr:@expr, _:()) { + fn visit_expr(&mut self, expr:@Expr, _:()) { self.resolver.resolve_expr(expr, self); } fn visit_local(&mut self, local:@Local, _:()) { @@ -293,8 +293,8 @@ enum NameSearchType { } pub enum BareIdentifierPatternResolution { - FoundStructOrEnumVariant(def), - FoundConst(def), + FoundStructOrEnumVariant(Def), + FoundConst(Def), BareIdentifierPatternUnresolved } @@ -442,7 +442,7 @@ pub enum ModuleKind { /// One node in the tree of modules. pub struct Module { parent_link: ParentLink, - def_id: Option, + def_id: Option, kind: ModuleKind, children: @mut HashMap, @@ -485,7 +485,7 @@ pub struct Module { impl Module { pub fn new(parent_link: ParentLink, - def_id: Option, + def_id: Option, kind: ModuleKind, external: bool) -> Module { @@ -514,14 +514,14 @@ impl Module { pub struct TypeNsDef { privacy: Privacy, module_def: Option<@mut Module>, - type_def: Option, + type_def: Option, type_span: Option } // Records a possibly-private value definition. pub struct ValueNsDef { privacy: Privacy, - def: def, + def: Def, value_span: Option, } @@ -544,7 +544,7 @@ impl NameBindings { pub fn define_module(@mut self, privacy: Privacy, parent_link: ParentLink, - def_id: Option, + def_id: Option, kind: ModuleKind, external: bool, sp: Span) { @@ -574,7 +574,7 @@ impl NameBindings { pub fn set_module_kind(@mut self, privacy: Privacy, parent_link: ParentLink, - def_id: Option, + def_id: Option, kind: ModuleKind, external: bool, _sp: Span) { @@ -609,7 +609,7 @@ impl NameBindings { } /// Records a type definition. - pub fn define_type(@mut self, privacy: Privacy, def: def, sp: Span) { + pub fn define_type(@mut self, privacy: Privacy, def: Def, sp: Span) { // Merges the type with the existing type def or creates a new one. match self.type_def { None => { @@ -632,7 +632,7 @@ impl NameBindings { } /// Records a value definition. - pub fn define_value(@mut self, privacy: Privacy, def: def, sp: Span) { + pub fn define_value(@mut self, privacy: Privacy, def: Def, sp: Span) { self.value_def = Some(ValueNsDef { privacy: privacy, def: def, value_span: Some(sp) }); } @@ -678,7 +678,7 @@ impl NameBindings { } } - pub fn def_for_namespace(&self, namespace: Namespace) -> Option { + pub fn def_for_namespace(&self, namespace: Namespace) -> Option { match namespace { TypeNS => { match self.type_def { @@ -690,7 +690,7 @@ impl NameBindings { match type_def.module_def { Some(module) => { match module.def_id { - Some(did) => Some(def_mod(did)), + Some(did) => Some(DefMod(did)), None => None, } } @@ -814,7 +814,7 @@ pub fn Resolver(session: Session, graph_root.define_module(Public, NoParentLink, - Some(def_id { crate: 0, node: 0 }), + Some(DefId { crate: 0, node: 0 }), NormalModuleKind, false, crate.span); @@ -873,8 +873,8 @@ pub struct Resolver { graph_root: @mut NameBindings, - method_map: @mut HashMap>, - structs: HashSet, + method_map: @mut HashMap>, + structs: HashSet, // The number of imports that are currently unresolved. unresolved_imports: uint, @@ -897,7 +897,7 @@ pub struct Resolver { xray_context: XrayFlag, // The trait that the current context can refer to. - current_trait_refs: Option<~[def_id]>, + current_trait_refs: Option<~[DefId]>, // The ident for the keyword "self". self_ident: Ident, @@ -1071,7 +1071,7 @@ impl Resolver { } ForbidDuplicateTypes => { match child.def_for_namespace(TypeNS) { - Some(def_mod(_)) | None => {} + Some(DefMod(_)) | None => {} Some(_) => duplicate_type = TypeError } Some(TypeNS) @@ -1085,7 +1085,7 @@ impl Resolver { ForbidDuplicateTypesAndValues => { let mut n = None; match child.def_for_namespace(TypeNS) { - Some(def_mod(_)) | None => {} + Some(DefMod(_)) | None => {} Some(_) => { n = Some(TypeNS); duplicate_type = TypeError; @@ -1131,9 +1131,9 @@ impl Resolver { // Check each statement. for statement in block.stmts.iter() { match statement.node { - stmt_decl(declaration, _) => { + StmtDecl(declaration, _) => { match declaration.node { - decl_item(_) => { + DeclItem(_) => { return true; } _ => { @@ -1177,7 +1177,7 @@ impl Resolver { self.add_child(ident, parent, ForbidDuplicateModules, sp); let parent_link = self.get_parent_link(new_parent, ident); - let def_id = def_id { crate: 0, node: item.id }; + let def_id = DefId { crate: 0, node: item.id }; name_bindings.define_module(privacy, parent_link, Some(def_id), @@ -1200,7 +1200,7 @@ impl Resolver { let parent_link = self.get_parent_link(new_parent, ident); - let def_id = def_id { crate: 0, node: item.id }; + let def_id = DefId { crate: 0, node: item.id }; name_bindings.define_module(privacy, parent_link, Some(def_id), @@ -1223,16 +1223,16 @@ impl Resolver { item_static(_, m, _) => { let (name_bindings, _) = self.add_child(ident, parent, ForbidDuplicateValues, sp); - let mutbl = m == ast::m_mutbl; + let mutbl = m == ast::MutMutable; name_bindings.define_value - (privacy, def_static(local_def(item.id), mutbl), sp); + (privacy, DefStatic(local_def(item.id), mutbl), sp); } item_fn(_, purity, _, _, _) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateValues, sp); - let def = def_fn(local_def(item.id), purity); + let def = DefFn(local_def(item.id), purity); name_bindings.define_value(privacy, def, sp); visit::walk_item(visitor, item, new_parent); } @@ -1243,7 +1243,7 @@ impl Resolver { self.add_child(ident, parent, ForbidDuplicateTypes, sp); name_bindings.define_type - (privacy, def_ty(local_def(item.id)), sp); + (privacy, DefTy(local_def(item.id)), sp); } item_enum(ref enum_definition, _) => { @@ -1251,7 +1251,7 @@ impl Resolver { self.add_child(ident, parent, ForbidDuplicateTypes, sp); name_bindings.define_type - (privacy, def_ty(local_def(item.id)), sp); + (privacy, DefTy(local_def(item.id)), sp); for variant in (*enum_definition).variants.iter() { self.build_reduced_graph_for_variant( @@ -1275,12 +1275,12 @@ impl Resolver { let (name_bindings, new_parent) = self.add_child(ident, parent, forbid, sp); // Define a name in the type namespace. - name_bindings.define_type(privacy, def_ty(local_def(item.id)), sp); + name_bindings.define_type(privacy, DefTy(local_def(item.id)), sp); // If this is a newtype or unit-like struct, define a name // in the value namespace as well do ctor_id.while_some |cid| { - name_bindings.define_value(privacy, def_struct(local_def(cid)), sp); + name_bindings.define_value(privacy, DefStruct(local_def(cid)), sp); None } @@ -1351,7 +1351,7 @@ impl Resolver { sty_static => { // Static methods become // `def_static_method`s. - def_static_method(local_def(method.id), + DefStaticMethod(local_def(method.id), FromImpl(local_def( item.id)), method.purity) @@ -1359,7 +1359,7 @@ impl Resolver { _ => { // Non-static methods become // `def_method`s. - def_method(local_def(method.id), None) + DefMethod(local_def(method.id), None) } }; @@ -1404,13 +1404,13 @@ impl Resolver { let def = match ty_m.explicit_self.node { sty_static => { // Static methods become `def_static_method`s. - def_static_method(local_def(ty_m.id), + DefStaticMethod(local_def(ty_m.id), FromTrait(local_def(item.id)), ty_m.purity) } _ => { // Non-static methods become `def_method`s. - def_method(local_def(ty_m.id), + DefMethod(local_def(ty_m.id), Some(local_def(item.id))) } }; @@ -1442,7 +1442,7 @@ impl Resolver { } } - name_bindings.define_type(privacy, def_trait(def_id), sp); + name_bindings.define_type(privacy, DefTrait(def_id), sp); visit::walk_item(visitor, item, new_parent); } @@ -1456,7 +1456,7 @@ impl Resolver { // type and/or value namespaces. pub fn build_reduced_graph_for_variant(@mut self, variant: &variant, - item_id: def_id, + item_id: DefId, parent_privacy: Privacy, parent: ReducedGraphParent, _: &mut BuildReducedGraphVisitor) { @@ -1474,7 +1474,7 @@ impl Resolver { let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues, variant.span); child.define_value(privacy, - def_variant(item_id, + DefVariant(item_id, local_def(variant.node.id)), variant.span); } @@ -1482,7 +1482,7 @@ impl Resolver { let (child, _) = self.add_child(ident, parent, ForbidDuplicateTypesAndValues, variant.span); child.define_type(privacy, - def_variant(item_id, + DefVariant(item_id, local_def(variant.node.id)), variant.span); self.structs.insert(local_def(variant.node.id)); @@ -1573,7 +1573,7 @@ impl Resolver { match find_extern_mod_stmt_cnum(self.session.cstore, node_id) { Some(crate_id) => { - let def_id = def_id { crate: crate_id, node: 0 }; + let def_id = DefId { crate: crate_id, node: 0 }; let parent_link = ModuleParentLink (self.get_module_from_parent(parent), name); let external_module = @mut Module::new(parent_link, @@ -1607,7 +1607,7 @@ impl Resolver { match foreign_item.node { foreign_item_fn(_, ref generics) => { - let def = def_fn(local_def(foreign_item.id), unsafe_fn); + let def = DefFn(local_def(foreign_item.id), unsafe_fn); name_bindings.define_value(Public, def, foreign_item.span); do self.with_type_parameter_rib( @@ -1618,7 +1618,7 @@ impl Resolver { } } foreign_item_static(_, m) => { - let def = def_static(local_def(foreign_item.id), m); + let def = DefStatic(local_def(foreign_item.id), m); name_bindings.define_value(Public, def, foreign_item.span); visit::walk_foreign_item(visitor, foreign_item, new_parent); @@ -1655,7 +1655,7 @@ impl Resolver { } fn handle_external_def(@mut self, - def: def, + def: Def, visibility: ast::visibility, child_name_bindings: @mut NameBindings, final_ident: &str, @@ -1663,8 +1663,8 @@ impl Resolver { new_parent: ReducedGraphParent) { let privacy = visibility_to_privacy(visibility); match def { - def_mod(def_id) | def_foreign_mod(def_id) | def_struct(def_id) | - def_ty(def_id) => { + DefMod(def_id) | DefForeignMod(def_id) | DefStruct(def_id) | + DefTy(def_id) => { match child_name_bindings.type_def { Some(TypeNsDef { module_def: Some(module_def), _ }) => { debug!("(building reduced graph for external crate) \ @@ -1690,8 +1690,8 @@ impl Resolver { } match def { - def_mod(_) | def_foreign_mod(_) => {} - def_variant(*) => { + DefMod(_) | DefForeignMod(_) => {} + DefVariant(*) => { debug!("(building reduced graph for external crate) building \ variant %s", final_ident); @@ -1700,12 +1700,12 @@ impl Resolver { let privacy = variant_visibility_to_privacy(visibility, true); child_name_bindings.define_value(privacy, def, dummy_sp()); } - def_fn(*) | def_static_method(*) | def_static(*) => { + DefFn(*) | DefStaticMethod(*) | DefStatic(*) => { debug!("(building reduced graph for external \ crate) building value (fn/static) %s", final_ident); child_name_bindings.define_value(privacy, def, dummy_sp()); } - def_trait(def_id) => { + DefTrait(def_id) => { debug!("(building reduced graph for external \ crate) building type %s", final_ident); @@ -1751,13 +1751,13 @@ impl Resolver { true, dummy_sp()) } - def_ty(_) => { + DefTy(_) => { debug!("(building reduced graph for external \ crate) building type %s", final_ident); child_name_bindings.define_type(privacy, def, dummy_sp()); } - def_struct(def_id) => { + DefStruct(def_id) => { debug!("(building reduced graph for external \ crate) building type and value for %s", final_ident); @@ -1767,13 +1767,13 @@ impl Resolver { } self.structs.insert(def_id); } - def_method(*) => { + DefMethod(*) => { // Ignored; handled elsewhere. } - def_self(*) | def_arg(*) | def_local(*) | - def_prim_ty(*) | def_ty_param(*) | def_binding(*) | - def_use(*) | def_upvar(*) | def_region(*) | - def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { + DefSelf(*) | DefArg(*) | DefLocal(*) | + DefPrimTy(*) | DefTyParam(*) | DefBinding(*) | + DefUse(*) | DefUpvar(*) | DefRegion(*) | + DefTyParamBinder(*) | DefLabel(*) | DefSelfTy(*) => { fail!("didn't expect `%?`", def); } } @@ -1788,7 +1788,7 @@ impl Resolver { DlDef(def) => { // Add the new child item, if necessary. match def { - def_foreign_mod(def_id) => { + DefForeignMod(def_id) => { // Foreign modules have no names. Recur and populate // eagerly. do csearch::each_child_of_item(self.session.cstore, @@ -1889,7 +1889,7 @@ impl Resolver { new_parent, OverwriteDuplicates, dummy_sp()); - let def = def_fn( + let def = DefFn( static_method_info.def_id, static_method_info.purity); method_name_bindings.define_value( @@ -3395,16 +3395,16 @@ impl Resolver { let is_ty_param; match def_like { - DlDef(d @ def_local(*)) | DlDef(d @ def_upvar(*)) | - DlDef(d @ def_arg(*)) | DlDef(d @ def_binding(*)) => { + DlDef(d @ DefLocal(*)) | DlDef(d @ DefUpvar(*)) | + DlDef(d @ DefArg(*)) | DlDef(d @ DefBinding(*)) => { def = d; is_ty_param = false; } - DlDef(d @ def_ty_param(*)) => { + DlDef(d @ DefTyParam(*)) => { def = d; is_ty_param = true; } - DlDef(d @ def_self(*)) + DlDef(d @ DefSelf(*)) if allow_capturing_self == DontAllowCapturingSelf => { def = d; is_ty_param = false; @@ -3422,7 +3422,7 @@ impl Resolver { } FunctionRibKind(function_id, body_id) => { if !is_ty_param { - def = def_upvar(def_id_of_def(def).node, + def = DefUpvar(def_id_of_def(def).node, @def, function_id, body_id); @@ -3432,9 +3432,9 @@ impl Resolver { // If the def is a ty param, and came from the parent // item, it's ok match def { - def_ty_param(did, _) + DefTyParam(did, _) if self.def_map.find(&did.node).map_move(|x| *x) - == Some(def_typaram_binder(item_id)) => { + == Some(DefTyParamBinder(item_id)) => { // ok } _ => { @@ -3592,7 +3592,7 @@ impl Resolver { let self_type_rib = @Rib::new(NormalRibKind); self.type_ribs.push(self_type_rib); self_type_rib.bindings.insert(self.type_self_ident, - DlDef(def_self_ty(item.id))); + DlDef(DefSelfTy(item.id))); // Create a new rib for the trait-wide type parameters. do self.with_type_parameter_rib @@ -3726,13 +3726,13 @@ impl Resolver { let name = type_parameter.ident; debug!("with_type_parameter_rib: %d %d", node_id, type_parameter.id); - let def_like = DlDef(def_ty_param + let def_like = DlDef(DefTyParam (local_def(type_parameter.id), index + initial_index)); // Associate this type parameter with // the item that bound it self.record_def(type_parameter.id, - def_typaram_binder(node_id)); + DefTyParamBinder(node_id)); function_type_rib.bindings.insert(name, def_like); } } @@ -3801,7 +3801,7 @@ impl Resolver { // Nothing to do. } HasSelfBinding(self_node_id) => { - let def_like = DlDef(def_self(self_node_id)); + let def_like = DlDef(DefSelf(self_node_id)); *function_value_rib.self_binding = Some(def_like); } } @@ -4064,7 +4064,7 @@ impl Resolver { None, visitor); } - pub fn binding_mode_map(@mut self, pat: @pat) -> BindingMap { + pub fn binding_mode_map(@mut self, pat: @Pat) -> BindingMap { let mut result = HashMap::new(); do pat_bindings(self.def_map, pat) |binding_mode, _id, sp, path| { let ident = path_to_ident(path); @@ -4075,7 +4075,7 @@ impl Resolver { return result; } - pub fn check_consistent_bindings(@mut self, arm: &arm) { + pub fn check_consistent_bindings(@mut self, arm: &Arm) { if arm.pats.len() == 0 { return; } let map_0 = self.binding_mode_map(arm.pats[0]); for (i, p) in arm.pats.iter().enumerate() { @@ -4114,7 +4114,7 @@ impl Resolver { } } - pub fn resolve_arm(@mut self, arm: &arm, visitor: &mut ResolveVisitor) { + pub fn resolve_arm(@mut self, arm: &Arm, visitor: &mut ResolveVisitor) { self.value_ribs.push(@Rib::new(NormalRibKind)); let bindings_list = @mut HashMap::new(); @@ -4178,7 +4178,7 @@ impl Resolver { Some(&primitive_type) => { result_def = - Some(def_prim_ty(primitive_type)); + Some(DefPrimTy(primitive_type)); if path.segments .iter() @@ -4267,7 +4267,7 @@ impl Resolver { } pub fn resolve_pattern(@mut self, - pattern: @pat, + pattern: @Pat, mode: PatternBindingMode, mutability: Mutability, // Maps idents to the node ID for the (outermost) @@ -4277,7 +4277,7 @@ impl Resolver { let pat_id = pattern.id; do walk_pat(pattern) |pattern| { match pattern.node { - pat_ident(binding_mode, ref path, _) + PatIdent(binding_mode, ref path, _) if !path.global && path.segments.len() == 1 => { // The meaning of pat_ident with no type parameters @@ -4340,15 +4340,15 @@ impl Resolver { // For pattern arms, we must use // `def_binding` definitions. - def_binding(pattern.id, binding_mode) + DefBinding(pattern.id, binding_mode) } LocalIrrefutableMode => { // But for locals, we use `def_local`. - def_local(pattern.id, is_mutable) + DefLocal(pattern.id, is_mutable) } ArgumentIrrefutableMode => { // And for function arguments, `def_arg`. - def_arg(pattern.id, is_mutable) + DefArg(pattern.id, is_mutable) } }; @@ -4406,14 +4406,14 @@ impl Resolver { } } - pat_ident(binding_mode, ref path, _) => { + PatIdent(binding_mode, ref path, _) => { // This must be an enum variant, struct, or constant. match self.resolve_path(pat_id, path, ValueNS, false, visitor) { - Some(def @ def_variant(*)) | - Some(def @ def_struct(*)) => { + Some(def @ DefVariant(*)) | + Some(def @ DefStruct(*)) => { self.record_def(pattern.id, def); } - Some(def @ def_static(*)) => { + Some(def @ DefStatic(*)) => { self.enforce_default_binding_mode( pattern, binding_mode, @@ -4441,13 +4441,13 @@ impl Resolver { } } - pat_enum(ref path, _) => { + PatEnum(ref path, _) => { // This must be an enum variant, struct or const. match self.resolve_path(pat_id, path, ValueNS, false, visitor) { - Some(def @ def_fn(*)) | - Some(def @ def_variant(*)) | - Some(def @ def_struct(*)) | - Some(def @ def_static(*)) => { + Some(def @ DefFn(*)) | + Some(def @ DefVariant(*)) | + Some(def @ DefStruct(*)) | + Some(def @ DefStatic(*)) => { self.record_def(pattern.id, def); } Some(_) => { @@ -4461,8 +4461,12 @@ impl Resolver { } None => { self.resolve_error(path.span, - "unresolved enum variant, \ - struct or const"); + fmt!("unresolved enum variant, \ + struct or const `%s`", + self.session + .str_of(path.segments + .last() + .identifier))); } } @@ -4474,27 +4478,27 @@ impl Resolver { } } - pat_lit(expr) => { + PatLit(expr) => { self.resolve_expr(expr, visitor); } - pat_range(first_expr, last_expr) => { + PatRange(first_expr, last_expr) => { self.resolve_expr(first_expr, visitor); self.resolve_expr(last_expr, visitor); } - pat_struct(ref path, _, _) => { + PatStruct(ref path, _, _) => { match self.resolve_path(pat_id, path, TypeNS, false, visitor) { - Some(def_ty(class_id)) + Some(DefTy(class_id)) if self.structs.contains(&class_id) => { - let class_def = def_struct(class_id); + let class_def = DefStruct(class_id); self.record_def(pattern.id, class_def); } - Some(definition @ def_struct(class_id)) => { + Some(definition @ DefStruct(class_id)) => { assert!(self.structs.contains(&class_id)); self.record_def(pattern.id, definition); } - Some(definition @ def_variant(_, variant_id)) + Some(definition @ DefVariant(_, variant_id)) if self.structs.contains(&variant_id) => { self.record_def(pattern.id, definition); } @@ -4532,10 +4536,10 @@ impl Resolver { } Some(def) => { match def.def { - def @ def_variant(*) | def @ def_struct(*) => { + def @ DefVariant(*) | def @ DefStruct(*) => { return FoundStructOrEnumVariant(def); } - def @ def_static(_, false) => { + def @ DefStatic(_, false) => { return FoundConst(def); } _ => { @@ -4564,7 +4568,7 @@ impl Resolver { namespace: Namespace, check_ribs: bool, visitor: &mut ResolveVisitor) - -> Option { + -> Option { // First, resolve the types. for ty in path.segments.iter().flat_map(|s| s.types.iter()) { self.resolve_type(ty, visitor); @@ -4608,7 +4612,7 @@ impl Resolver { namespace: Namespace, check_ribs: bool, span: Span) - -> Option { + -> Option { if check_ribs { match self.resolve_identifier_in_local_ribs(identifier, namespace, @@ -4692,7 +4696,7 @@ impl Resolver { match module.def_id { None => {} // Continue. Some(def_id) => { - return ChildNameDefinition(def_mod(def_id)); + return ChildNameDefinition(DefMod(def_id)); } } } @@ -4719,7 +4723,7 @@ impl Resolver { path: &Path, xray: XrayFlag, namespace: Namespace) - -> Option { + -> Option { let module_path_idents = self.intern_module_part_of_path(path); let containing_module; @@ -4785,7 +4789,7 @@ impl Resolver { path: &Path, xray: XrayFlag, namespace: Namespace) - -> Option { + -> Option { let module_path_idents = self.intern_module_part_of_path(path); let root_module = self.graph_root.get_module(); @@ -4832,7 +4836,7 @@ impl Resolver { ident: Ident, namespace: Namespace, span: Span) - -> Option { + -> Option { // Check the local set of ribs. let search_result; match namespace { @@ -4862,7 +4866,7 @@ impl Resolver { } pub fn resolve_self_value_in_local_ribs(@mut self, span: Span) - -> Option { + -> Option { // FIXME #4950: This should not use a while loop. let ribs = &mut self.value_ribs; let mut i = ribs.len(); @@ -4897,7 +4901,7 @@ impl Resolver { pub fn resolve_item_by_identifier_in_lexical_scope(@mut self, ident: Ident, namespace: Namespace) - -> Option { + -> Option { // Check the items. match self.resolve_item_in_lexical_scope(self.current_module, ident, @@ -5014,7 +5018,7 @@ impl Resolver { return false; } - pub fn resolve_expr(@mut self, expr: @expr, visitor: &mut ResolveVisitor) { + pub fn resolve_expr(@mut self, expr: @Expr, visitor: &mut ResolveVisitor) { // First, record candidate traits for this expression if it could // result in the invocation of a method call. @@ -5025,7 +5029,7 @@ impl Resolver { // The interpretation of paths depends on whether the path has // multiple elements in it or not. - expr_path(ref path) => { + ExprPath(ref path) => { // This is a local path in the value namespace. Walk through // scopes looking for it. @@ -5038,7 +5042,7 @@ impl Resolver { // First-class methods are not supported yet; error // out here. match def { - def_method(*) => { + DefMethod(*) => { self.resolve_error(expr.span, "first-class methods \ are not supported"); @@ -5068,7 +5072,7 @@ impl Resolver { // structs, which wouldn't result in this error.) match self.with_no_errors(|| self.resolve_path(expr.id, path, TypeNS, false, visitor)) { - Some(def_ty(struct_id)) + Some(DefTy(struct_id)) if self.structs.contains(&struct_id) => { self.resolve_error(expr.span, fmt!("`%s` is a structure name, but this expression \ @@ -5102,7 +5106,7 @@ impl Resolver { visit::walk_expr(visitor, expr, ()); } - expr_fn_block(ref fn_decl, ref block) => { + ExprFnBlock(ref fn_decl, ref block) => { self.resolve_function(FunctionRibKind(expr.id, block.id), Some(fn_decl), NoTypeParameters, @@ -5111,15 +5115,15 @@ impl Resolver { visitor); } - expr_struct(ref path, _, _) => { + ExprStruct(ref path, _, _) => { // Resolve the path to the structure it goes to. match self.resolve_path(expr.id, path, TypeNS, false, visitor) { - Some(def_ty(class_id)) | Some(def_struct(class_id)) + Some(DefTy(class_id)) | Some(DefStruct(class_id)) if self.structs.contains(&class_id) => { - let class_def = def_struct(class_id); + let class_def = DefStruct(class_id); self.record_def(expr.id, class_def); } - Some(definition @ def_variant(_, class_id)) + Some(definition @ DefVariant(_, class_id)) if self.structs.contains(&class_id) => { self.record_def(expr.id, definition); } @@ -5136,11 +5140,11 @@ impl Resolver { visit::walk_expr(visitor, expr, ()); } - expr_loop(_, Some(label)) => { + ExprLoop(_, Some(label)) => { do self.with_label_rib { { let this = &mut *self; - let def_like = DlDef(def_label(expr.id)); + let def_like = DlDef(DefLabel(expr.id)); let rib = this.label_ribs[this.label_ribs.len() - 1]; rib.bindings.insert(label, def_like); } @@ -5149,9 +5153,9 @@ impl Resolver { } } - expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - expr_break(Some(label)) | expr_again(Some(label)) => { + ExprBreak(Some(label)) | ExprAgain(Some(label)) => { match self.search_ribs(self.label_ribs, label, expr.span, DontAllowCapturingSelf) { None => @@ -5160,7 +5164,7 @@ impl Resolver { `%s`", self.session.str_of( label))), - Some(DlDef(def @ def_label(_))) => { + Some(DlDef(def @ DefLabel(_))) => { self.record_def(expr.id, def) } Some(_) => { @@ -5171,7 +5175,7 @@ impl Resolver { } } - expr_self => { + ExprSelf => { match self.resolve_self_value_in_local_ribs(expr.span) { None => { self.resolve_error(expr.span, @@ -5189,9 +5193,9 @@ impl Resolver { } pub fn record_candidate_traits_for_expr_if_necessary(@mut self, - expr: @expr) { + expr: @Expr) { match expr.node { - expr_field(_, ident, _) => { + ExprField(_, ident, _) => { // FIXME(#6890): Even though you can't treat a method like a // field, we need to add any trait methods we find that match // the field name so that we can do some nice error reporting @@ -5199,71 +5203,71 @@ impl Resolver { let traits = self.search_for_traits_containing_method(ident); self.trait_map.insert(expr.id, @mut traits); } - expr_method_call(_, _, ident, _, _, _) => { + ExprMethodCall(_, _, ident, _, _, _) => { debug!("(recording candidate traits for expr) recording \ traits for %d", expr.id); let traits = self.search_for_traits_containing_method(ident); self.trait_map.insert(expr.id, @mut traits); } - expr_binary(_, add, _, _) | expr_assign_op(_, add, _, _) => { + ExprBinary(_, BiAdd, _, _) | ExprAssignOp(_, BiAdd, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.add_trait()); } - expr_binary(_, subtract, _, _) | expr_assign_op(_, subtract, _, _) => { + ExprBinary(_, BiSub, _, _) | ExprAssignOp(_, BiSub, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.sub_trait()); } - expr_binary(_, mul, _, _) | expr_assign_op(_, mul, _, _) => { + ExprBinary(_, BiMul, _, _) | ExprAssignOp(_, BiMul, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.mul_trait()); } - expr_binary(_, div, _, _) | expr_assign_op(_, div, _, _) => { + ExprBinary(_, BiDiv, _, _) | ExprAssignOp(_, BiDiv, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.div_trait()); } - expr_binary(_, rem, _, _) | expr_assign_op(_, rem, _, _) => { + ExprBinary(_, BiRem, _, _) | ExprAssignOp(_, BiRem, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.rem_trait()); } - expr_binary(_, bitxor, _, _) | expr_assign_op(_, bitxor, _, _) => { + ExprBinary(_, BiBitXor, _, _) | ExprAssignOp(_, BiBitXor, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.bitxor_trait()); } - expr_binary(_, bitand, _, _) | expr_assign_op(_, bitand, _, _) => { + ExprBinary(_, BiBitAnd, _, _) | ExprAssignOp(_, BiBitAnd, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.bitand_trait()); } - expr_binary(_, bitor, _, _) | expr_assign_op(_, bitor, _, _) => { + ExprBinary(_, BiBitOr, _, _) | ExprAssignOp(_, BiBitOr, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.bitor_trait()); } - expr_binary(_, shl, _, _) | expr_assign_op(_, shl, _, _) => { + ExprBinary(_, BiShl, _, _) | ExprAssignOp(_, BiShl, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.shl_trait()); } - expr_binary(_, shr, _, _) | expr_assign_op(_, shr, _, _) => { + ExprBinary(_, BiShr, _, _) | ExprAssignOp(_, BiShr, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.shr_trait()); } - expr_binary(_, lt, _, _) | expr_binary(_, le, _, _) | - expr_binary(_, ge, _, _) | expr_binary(_, gt, _, _) => { + ExprBinary(_, BiLt, _, _) | ExprBinary(_, BiLe, _, _) | + ExprBinary(_, BiGe, _, _) | ExprBinary(_, BiGt, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.ord_trait()); } - expr_binary(_, eq, _, _) | expr_binary(_, ne, _, _) => { + ExprBinary(_, BiEq, _, _) | ExprBinary(_, BiNe, _, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.eq_trait()); } - expr_unary(_, neg, _) => { + ExprUnary(_, UnNeg, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.neg_trait()); } - expr_unary(_, not, _) => { + ExprUnary(_, UnNot, _) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.not_trait()); } - expr_index(*) => { + ExprIndex(*) => { self.add_fixed_trait_for_expr(expr.id, self.lang_items.index_trait()); } @@ -5274,7 +5278,7 @@ impl Resolver { } pub fn search_for_traits_containing_method(@mut self, name: Ident) - -> ~[def_id] { + -> ~[DefId] { debug!("(searching for traits containing method) looking for '%s'", self.session.str_of(name)); @@ -5305,7 +5309,7 @@ impl Resolver { match child_name_bindings.def_for_namespace(TypeNS) { Some(def) => { match def { - def_trait(trait_def_id) => { + DefTrait(trait_def_id) => { if candidate_traits.contains(&trait_def_id) { self.add_trait_info( &mut found_traits, @@ -5333,7 +5337,7 @@ impl Resolver { match target.bindings.def_for_namespace(TypeNS) { Some(def) => { match def { - def_trait(trait_def_id) => { + DefTrait(trait_def_id) => { if candidate_traits.contains(&trait_def_id) { self.add_trait_info( &mut found_traits, @@ -5374,8 +5378,8 @@ impl Resolver { } pub fn add_trait_info(&self, - found_traits: &mut ~[def_id], - trait_def_id: def_id, + found_traits: &mut ~[DefId], + trait_def_id: DefId, name: Ident) { debug!("(adding trait info) found trait %d:%d for method '%s'", trait_def_id.crate, @@ -5386,7 +5390,7 @@ impl Resolver { pub fn add_fixed_trait_for_expr(@mut self, expr_id: NodeId, - trait_id: Option) { + trait_id: Option) { match trait_id { Some(trait_id) => { self.trait_map.insert(expr_id, @mut ~[trait_id]); @@ -5395,18 +5399,18 @@ impl Resolver { } } - pub fn record_def(@mut self, node_id: NodeId, def: def) { + pub fn record_def(@mut self, node_id: NodeId, def: Def) { debug!("(recording def) recording %? for %?", def, node_id); self.def_map.insert(node_id, def); } pub fn enforce_default_binding_mode(@mut self, - pat: @pat, - pat_binding_mode: binding_mode, + pat: @Pat, + pat_binding_mode: BindingMode, descr: &str) { match pat_binding_mode { - bind_infer => {} - bind_by_ref(*) => { + BindInfer => {} + BindByRef(*) => { self.resolve_error( pat.span, fmt!("cannot use `ref` binding mode with %s", diff --git a/src/librustc/middle/stack_check.rs b/src/librustc/middle/stack_check.rs index 1f64038e43fdc..569c6dfde0cab 100644 --- a/src/librustc/middle/stack_check.rs +++ b/src/librustc/middle/stack_check.rs @@ -42,7 +42,7 @@ impl Visitor for StackCheckVisitor { b:&ast::Block, s:Span, n:ast::NodeId, e:Context) { stack_check_fn(*self, fk, fd, b, s, n, e); } - fn visit_expr(&mut self, ex:@ast::expr, e:Context) { + fn visit_expr(&mut self, ex:@ast::Expr, e:Context) { stack_check_expr(*self, ex, e); } } @@ -121,13 +121,13 @@ fn stack_check_fn<'a>(v: StackCheckVisitor, } fn stack_check_expr<'a>(v: StackCheckVisitor, - expr: @ast::expr, + expr: @ast::Expr, cx: Context) { debug!("stack_check_expr(safe_stack=%b, expr=%s)", cx.safe_stack, expr.repr(cx.tcx)); if !cx.safe_stack { match expr.node { - ast::expr_call(callee, _, _) => { + ast::ExprCall(callee, _, _) => { let callee_ty = ty::expr_ty(cx.tcx, callee); debug!("callee_ty=%s", callee_ty.repr(cx.tcx)); match ty::get(callee_ty).sty { @@ -146,13 +146,13 @@ fn stack_check_expr<'a>(v: StackCheckVisitor, visit::walk_expr(&mut v, expr, cx); } -fn call_to_extern_fn(cx: Context, callee: @ast::expr) { +fn call_to_extern_fn(cx: Context, callee: @ast::Expr) { // Permit direct calls to extern fns that are annotated with // #[rust_stack]. This is naturally a horrible pain to achieve. match callee.node { - ast::expr_path(*) => { + ast::ExprPath(*) => { match cx.tcx.def_map.find(&callee.id) { - Some(&ast::def_fn(id, _)) if id.crate == ast::LOCAL_CRATE => { + Some(&ast::DefFn(id, _)) if id.crate == ast::LOCAL_CRATE => { match cx.tcx.items.find(&id.node) { Some(&ast_map::node_foreign_item(item, _, _, _)) => { if attr::contains_name(item.attrs, "rust_stack") { diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index e42700fea76fd..ad0ab95ebf0f1 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -231,8 +231,8 @@ use syntax::codemap::{Span, dummy_sp}; // expression. enum Lit { UnitLikeStructLit(ast::NodeId), // the node ID of the pattern - ExprLit(@ast::expr), - ConstLit(ast::def_id), // the def ID of the constant + ExprLit(@ast::Expr), + ConstLit(ast::DefId), // the def ID of the constant } #[deriving(Eq)] @@ -246,7 +246,7 @@ pub enum VecLenOpt { enum Opt { lit(Lit), var(ty::Disr, @adt::Repr), - range(@ast::expr, @ast::expr), + range(@ast::Expr, @ast::Expr), vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint)) } @@ -347,7 +347,7 @@ fn variant_opt(bcx: @mut Block, pat_id: ast::NodeId) -> Opt { let ccx = bcx.ccx(); match ccx.tcx.def_map.get_copy(&pat_id) { - ast::def_variant(enum_id, var_id) => { + ast::DefVariant(enum_id, var_id) => { let variants = ty::enum_variants(ccx.tcx, enum_id); for v in (*variants).iter() { if var_id == v.id { @@ -357,8 +357,8 @@ fn variant_opt(bcx: @mut Block, pat_id: ast::NodeId) } ::std::util::unreachable(); } - ast::def_fn(*) | - ast::def_struct(_) => { + ast::DefFn(*) | + ast::DefStruct(_) => { return lit(UnitLikeStructLit(pat_id)); } _ => { @@ -395,7 +395,7 @@ type BindingsMap = HashMap; #[deriving(Clone)] struct ArmData<'self> { bodycx: @mut Block, - arm: &'self ast::arm, + arm: &'self ast::Arm, bindings_map: @BindingsMap } @@ -407,7 +407,7 @@ struct ArmData<'self> { */ #[deriving(Clone)] struct Match<'self> { - pats: ~[@ast::pat], + pats: ~[@ast::Pat], data: ArmData<'self>, bound_ptrs: ~[(Ident, ValueRef)] } @@ -426,7 +426,7 @@ impl<'self> Repr for Match<'self> { fn has_nested_bindings(m: &[Match], col: uint) -> bool { for br in m.iter() { match br.pats[col].node { - ast::pat_ident(_, _, Some(_)) => return true, + ast::PatIdent(_, _, Some(_)) => return true, _ => () } } @@ -447,7 +447,7 @@ fn expand_nested_bindings<'r>(bcx: @mut Block, do m.map |br| { match br.pats[col].node { - ast::pat_ident(_, ref path, Some(inner)) => { + ast::PatIdent(_, ref path, Some(inner)) => { let pats = vec::append( br.pats.slice(0u, col).to_owned(), vec::append(~[inner], @@ -467,7 +467,7 @@ fn expand_nested_bindings<'r>(bcx: @mut Block, } } -fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) { +fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) { if !pat_is_binding_or_wild(bcx.tcx().def_map, p) { bcx.sess().span_bug( p.span, @@ -476,7 +476,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) { } } -type enter_pat<'self> = &'self fn(@ast::pat) -> Option<~[@ast::pat]>; +type enter_pat<'self> = &'self fn(@ast::Pat) -> Option<~[@ast::Pat]>; fn enter_match<'r>(bcx: @mut Block, dm: DefMap, @@ -504,7 +504,7 @@ fn enter_match<'r>(bcx: @mut Block, let this = br.pats[col]; let mut bound_ptrs = br.bound_ptrs.clone(); match this.node { - ast::pat_ident(_, ref path, None) => { + ast::PatIdent(_, ref path, None) => { if pat_is_binding(dm, this) { bound_ptrs.push((path_to_ident(path), val)); } @@ -544,8 +544,8 @@ fn enter_default<'r>(bcx: @mut Block, // Collect all of the matches that can match against anything. let matches = do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_wild | ast::pat_tup(_) => Some(~[]), - ast::pat_ident(_, _, None) if pat_is_binding(dm, p) => Some(~[]), + ast::PatWild | ast::PatTup(_) => Some(~[]), + ast::PatIdent(_, _, None) if pat_is_binding(dm, p) => Some(~[]), _ => None } }; @@ -613,12 +613,12 @@ fn enter_opt<'r>(bcx: @mut Block, let _indenter = indenter(); let tcx = bcx.tcx(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; let mut i = 0; do enter_match(bcx, tcx.def_map, m, col, val) |p| { let answer = match p.node { - ast::pat_enum(*) | - ast::pat_ident(_, _, None) if pat_is_const(tcx.def_map, p) => { + ast::PatEnum(*) | + ast::PatIdent(_, _, None) if pat_is_const(tcx.def_map, p) => { let const_def = tcx.def_map.get_copy(&p.id); let const_def_id = ast_util::def_id_of_def(const_def); if opt_eq(tcx, &lit(ConstLit(const_def_id)), opt) { @@ -627,7 +627,7 @@ fn enter_opt<'r>(bcx: @mut Block, None } } - ast::pat_enum(_, ref subpats) => { + ast::PatEnum(_, ref subpats) => { if opt_eq(tcx, &variant_opt(bcx, p.id), opt) { // XXX: Must we clone? match *subpats { @@ -638,7 +638,7 @@ fn enter_opt<'r>(bcx: @mut Block, None } } - ast::pat_ident(_, _, None) + ast::PatIdent(_, _, None) if pat_is_variant_or_struct(tcx.def_map, p) => { if opt_eq(tcx, &variant_opt(bcx, p.id), opt) { Some(~[]) @@ -646,18 +646,18 @@ fn enter_opt<'r>(bcx: @mut Block, None } } - ast::pat_lit(l) => { + ast::PatLit(l) => { if opt_eq(tcx, &lit(ExprLit(l)), opt) {Some(~[])} else {None} } - ast::pat_range(l1, l2) => { + ast::PatRange(l1, l2) => { if opt_eq(tcx, &range(l1, l2), opt) {Some(~[])} else {None} } - ast::pat_struct(_, ref field_pats, _) => { + ast::PatStruct(_, ref field_pats, _) => { if opt_eq(tcx, &variant_opt(bcx, p.id), opt) { // Look up the struct variant ID. let struct_id; match tcx.def_map.get_copy(&p.id) { - ast::def_variant(_, found_struct_id) => { + ast::DefVariant(_, found_struct_id) => { struct_id = found_struct_id; } _ => { @@ -681,7 +681,7 @@ fn enter_opt<'r>(bcx: @mut Block, None } } - ast::pat_vec(ref before, slice, ref after) => { + ast::PatVec(ref before, slice, ref after) => { let (lo, hi) = match *opt { vec_len(_, _, (lo, hi)) => (lo, hi), _ => tcx.sess.span_bug(p.span, @@ -746,10 +746,10 @@ fn enter_rec_or_struct<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_struct(_, ref fpats, _) => { + ast::PatStruct(_, ref fpats, _) => { let mut pats = ~[]; for fname in fields.iter() { match fpats.iter().find(|p| p.ident == *fname) { @@ -781,10 +781,10 @@ fn enter_tup<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_tup(ref elts) => Some((*elts).clone()), + ast::PatTup(ref elts) => Some((*elts).clone()), _ => { assert_is_binding_or_wild(bcx, p); Some(vec::from_elem(n_elts, dummy)) @@ -807,10 +807,10 @@ fn enter_tuple_struct<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_enum(_, Some(ref elts)) => Some((*elts).clone()), + ast::PatEnum(_, Some(ref elts)) => Some((*elts).clone()), _ => { assert_is_binding_or_wild(bcx, p); Some(vec::from_elem(n_elts, dummy)) @@ -832,10 +832,10 @@ fn enter_box<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_box(sub) => { + ast::PatBox(sub) => { Some(~[sub]) } _ => { @@ -859,10 +859,10 @@ fn enter_uniq<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; + let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_uniq(sub) => { + ast::PatUniq(sub) => { Some(~[sub]) } _ => { @@ -886,10 +886,10 @@ fn enter_region<'r>(bcx: @mut Block, bcx.val_to_str(val)); let _indenter = indenter(); - let dummy = @ast::pat { id: 0, node: ast::pat_wild, span: dummy_sp() }; + let dummy = @ast::Pat { id: 0, node: ast::PatWild, span: dummy_sp() }; do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_region(sub) => { + ast::PatRegion(sub) => { Some(~[sub]) } _ => { @@ -930,48 +930,48 @@ fn get_options(bcx: @mut Block, m: &[Match], col: uint) -> ~[Opt] { for (i, br) in m.iter().enumerate() { let cur = br.pats[col]; match cur.node { - ast::pat_lit(l) => { + ast::PatLit(l) => { add_to_set(ccx.tcx, &mut found, lit(ExprLit(l))); } - ast::pat_ident(*) => { + ast::PatIdent(*) => { // This is one of: an enum variant, a unit-like struct, or a // variable binding. match ccx.tcx.def_map.find(&cur.id) { - Some(&ast::def_variant(*)) => { + Some(&ast::DefVariant(*)) => { add_to_set(ccx.tcx, &mut found, variant_opt(bcx, cur.id)); } - Some(&ast::def_struct(*)) => { + Some(&ast::DefStruct(*)) => { add_to_set(ccx.tcx, &mut found, lit(UnitLikeStructLit(cur.id))); } - Some(&ast::def_static(const_did, false)) => { + Some(&ast::DefStatic(const_did, false)) => { add_to_set(ccx.tcx, &mut found, lit(ConstLit(const_did))); } _ => {} } } - ast::pat_enum(*) | ast::pat_struct(*) => { + ast::PatEnum(*) | ast::PatStruct(*) => { // This could be one of: a tuple-like enum variant, a // struct-like enum variant, or a struct. match ccx.tcx.def_map.find(&cur.id) { - Some(&ast::def_fn(*)) | - Some(&ast::def_variant(*)) => { + Some(&ast::DefFn(*)) | + Some(&ast::DefVariant(*)) => { add_to_set(ccx.tcx, &mut found, variant_opt(bcx, cur.id)); } - Some(&ast::def_static(const_did, false)) => { + Some(&ast::DefStatic(const_did, false)) => { add_to_set(ccx.tcx, &mut found, lit(ConstLit(const_did))); } _ => {} } } - ast::pat_range(l1, l2) => { + ast::PatRange(l1, l2) => { add_to_set(ccx.tcx, &mut found, range(l1, l2)); } - ast::pat_vec(ref before, slice, ref after) => { + ast::PatVec(ref before, slice, ref after) => { let (len, vec_opt) = match slice { None => (before.len(), vec_len_eq), Some(_) => (before.len() + after.len(), @@ -1050,7 +1050,7 @@ fn extract_vec_elems(bcx: @mut Block, ); let slice_len = Sub(bcx, len, slice_len_offset); let slice_ty = ty::mk_evec(bcx.tcx(), - ty::mt {ty: vt.unit_ty, mutbl: ast::m_imm}, + ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable}, ty::vstore_slice(ty::re_static) ); let scratch = scratch_datum(bcx, slice_ty, "", false); @@ -1081,7 +1081,7 @@ fn collect_record_or_struct_fields(bcx: @mut Block, let mut found = false; for br in m.iter() { match br.pats[col].node { - ast::pat_struct(_, ref fs, _) => { + ast::PatStruct(_, ref fs, _) => { match ty::get(node_id_type(bcx, br.pats[col].id)).sty { ty::ty_struct(*) => { extend(&mut fields, *fs); @@ -1099,7 +1099,7 @@ fn collect_record_or_struct_fields(bcx: @mut Block, return None; } - fn extend(idents: &mut ~[ast::Ident], field_pats: &[ast::field_pat]) { + fn extend(idents: &mut ~[ast::Ident], field_pats: &[ast::FieldPat]) { for field_pat in field_pats.iter() { let field_ident = field_pat.ident; if !idents.iter().any(|x| *x == field_ident) { @@ -1152,29 +1152,29 @@ macro_rules! any_pat ( ) fn any_box_pat(m: &[Match], col: uint) -> bool { - any_pat!(m, ast::pat_box(_)) + any_pat!(m, ast::PatBox(_)) } fn any_uniq_pat(m: &[Match], col: uint) -> bool { - any_pat!(m, ast::pat_uniq(_)) + any_pat!(m, ast::PatUniq(_)) } fn any_region_pat(m: &[Match], col: uint) -> bool { - any_pat!(m, ast::pat_region(_)) + any_pat!(m, ast::PatRegion(_)) } fn any_tup_pat(m: &[Match], col: uint) -> bool { - any_pat!(m, ast::pat_tup(_)) + any_pat!(m, ast::PatTup(_)) } fn any_tuple_struct_pat(bcx: @mut Block, m: &[Match], col: uint) -> bool { do m.iter().any |br| { let pat = br.pats[col]; match pat.node { - ast::pat_enum(_, Some(_)) => { + ast::PatEnum(_, Some(_)) => { match bcx.tcx().def_map.find(&pat.id) { - Some(&ast::def_fn(*)) | - Some(&ast::def_struct(*)) => true, + Some(&ast::DefFn(*)) | + Some(&ast::DefStruct(*)) => true, _ => false } } @@ -1186,10 +1186,10 @@ fn any_tuple_struct_pat(bcx: @mut Block, m: &[Match], col: uint) -> bool { type mk_fail = @fn() -> BasicBlockRef; fn pick_col(m: &[Match]) -> uint { - fn score(p: &ast::pat) -> uint { + fn score(p: &ast::Pat) -> uint { match p.node { - ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u, - ast::pat_ident(_, _, Some(p)) => score(p), + ast::PatLit(_) | ast::PatEnum(_, _) | ast::PatRange(_, _) => 1u, + ast::PatIdent(_, _, Some(p)) => score(p), _ => 0u } } @@ -1227,7 +1227,7 @@ fn compare_values(cx: @mut Block, -> Result { let _icx = push_ctxt("compare_values"); if ty::type_is_scalar(rhs_t) { - let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::eq); + let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq); return rslt(rs.bcx, rs.val); } @@ -1341,7 +1341,7 @@ fn insert_lllocals(bcx: @mut Block, } fn compile_guard(bcx: @mut Block, - guard_expr: @ast::expr, + guard_expr: @ast::Expr, data: &ArmData, m: &[Match], vals: &[ValueRef], @@ -1659,7 +1659,7 @@ fn compile_submatch_continue(mut bcx: @mut Block, Result {bcx, val}) => { compare_scalar_types( bcx, test_val, val, - t, ast::ge) + t, ast::BiGe) } range_result( Result {val: vbegin, _}, @@ -1667,11 +1667,11 @@ fn compile_submatch_continue(mut bcx: @mut Block, let Result {bcx, val: llge} = compare_scalar_types( bcx, test_val, - vbegin, t, ast::ge); + vbegin, t, ast::BiGe); let Result {bcx, val: llle} = compare_scalar_types( bcx, test_val, vend, - t, ast::le); + t, ast::BiLe); rslt(bcx, And(bcx, llge, llle)) } } @@ -1689,14 +1689,14 @@ fn compile_submatch_continue(mut bcx: @mut Block, Result {bcx, val}) => { let value = compare_scalar_values( bcx, test_val, val, - signed_int, ast::eq); + signed_int, ast::BiEq); rslt(bcx, value) } lower_bound( Result {bcx, val: val}) => { let value = compare_scalar_values( bcx, test_val, val, - signed_int, ast::ge); + signed_int, ast::BiGe); rslt(bcx, value) } range_result( @@ -1705,11 +1705,11 @@ fn compile_submatch_continue(mut bcx: @mut Block, let llge = compare_scalar_values( bcx, test_val, - vbegin, signed_int, ast::ge); + vbegin, signed_int, ast::BiGe); let llle = compare_scalar_values( bcx, test_val, vend, - signed_int, ast::le); + signed_int, ast::BiLe); rslt(bcx, And(bcx, llge, llle)) } } @@ -1768,9 +1768,9 @@ fn compile_submatch_continue(mut bcx: @mut Block, } pub fn trans_match(bcx: @mut Block, - match_expr: &ast::expr, - discr_expr: @ast::expr, - arms: &[ast::arm], + match_expr: &ast::Expr, + discr_expr: @ast::Expr, + arms: &[ast::Arm], dest: Dest) -> @mut Block { let _icx = push_ctxt("match::trans_match"); do with_scope(bcx, match_expr.info(), "match") |bcx| { @@ -1778,7 +1778,7 @@ pub fn trans_match(bcx: @mut Block, } } -fn create_bindings_map(bcx: @mut Block, pat: @ast::pat) -> BindingsMap { +fn create_bindings_map(bcx: @mut Block, pat: @ast::Pat) -> BindingsMap { // Create the bindings map, which is a mapping from each binding name // to an alloca() that will be the value for that local variable. // Note that we use the names because each binding will have many ids @@ -1794,7 +1794,7 @@ fn create_bindings_map(bcx: @mut Block, pat: @ast::pat) -> BindingsMap { let llmatch; let trmode; match bm { - ast::bind_infer => { + ast::BindInfer => { // in this case, the final type of the variable will be T, // but during matching we need to store a *T as explained // above @@ -1802,7 +1802,7 @@ fn create_bindings_map(bcx: @mut Block, pat: @ast::pat) -> BindingsMap { trmode = TrByValue(alloca(bcx, llvariable_ty, bcx.ident(ident))); } - ast::bind_by_ref(_) => { + ast::BindByRef(_) => { llmatch = alloca(bcx, llvariable_ty, bcx.ident(ident)); trmode = TrByRef; } @@ -1819,8 +1819,8 @@ fn create_bindings_map(bcx: @mut Block, pat: @ast::pat) -> BindingsMap { } fn trans_match_inner(scope_cx: @mut Block, - discr_expr: @ast::expr, - arms: &[ast::arm], + discr_expr: @ast::Expr, + arms: &[ast::Arm], dest: Dest) -> @mut Block { let _icx = push_ctxt("match::trans_match_inner"); let mut bcx = scope_cx; @@ -1909,8 +1909,8 @@ enum IrrefutablePatternBindingMode { } pub fn store_local(bcx: @mut Block, - pat: @ast::pat, - opt_init_expr: Option<@ast::expr>) + pat: @ast::Pat, + opt_init_expr: Option<@ast::Expr>) -> @mut Block { /*! * Generates code for a local variable declaration like @@ -1962,7 +1962,7 @@ pub fn store_local(bcx: @mut Block, } }; - fn create_dummy_locals(mut bcx: @mut Block, pat: @ast::pat) -> @mut Block { + fn create_dummy_locals(mut bcx: @mut Block, pat: @ast::Pat) -> @mut Block { // create dummy memory for the variables if we have no // value to store into them immediately let tcx = bcx.tcx(); @@ -1976,7 +1976,7 @@ pub fn store_local(bcx: @mut Block, } pub fn store_arg(mut bcx: @mut Block, - pat: @ast::pat, + pat: @ast::Pat, llval: ValueRef) -> @mut Block { /*! @@ -2037,7 +2037,7 @@ fn mk_binding_alloca(mut bcx: @mut Block, } fn bind_irrefutable_pat(bcx: @mut Block, - pat: @ast::pat, + pat: @ast::Pat, val: ValueRef, binding_mode: IrrefutablePatternBindingMode) -> @mut Block { @@ -2077,7 +2077,7 @@ fn bind_irrefutable_pat(bcx: @mut Block, let tcx = bcx.tcx(); let ccx = bcx.ccx(); match pat.node { - ast::pat_ident(pat_binding_mode, ref path, inner) => { + ast::PatIdent(pat_binding_mode, ref path, inner) => { if pat_is_binding(tcx.def_map, pat) { // Allocate the stack slot where the value of this // binding will live and place it into the appropriate @@ -2086,7 +2086,7 @@ fn bind_irrefutable_pat(bcx: @mut Block, bcx, pat.id, path, binding_mode, |bcx, variable_ty, llvariable_val| { match pat_binding_mode { - ast::bind_infer => { + ast::BindInfer => { // By value binding: move the value that `val` // points at into the binding's stack slot. let datum = Datum {val: val, @@ -2095,7 +2095,7 @@ fn bind_irrefutable_pat(bcx: @mut Block, datum.store_to(bcx, INIT, llvariable_val) } - ast::bind_by_ref(_) => { + ast::BindByRef(_) => { // By ref binding: the value of the variable // is the pointer `val` itself. Store(bcx, val, llvariable_val); @@ -2109,9 +2109,9 @@ fn bind_irrefutable_pat(bcx: @mut Block, bcx = bind_irrefutable_pat(bcx, inner_pat, val, binding_mode); } } - ast::pat_enum(_, ref sub_pats) => { + ast::PatEnum(_, ref sub_pats) => { match bcx.tcx().def_map.find(&pat.id) { - Some(&ast::def_variant(enum_id, var_id)) => { + Some(&ast::DefVariant(enum_id, var_id)) => { let repr = adt::represent_node(bcx, pat.id); let vinfo = ty::enum_variant_with_id(ccx.tcx, enum_id, @@ -2127,8 +2127,8 @@ fn bind_irrefutable_pat(bcx: @mut Block, } } } - Some(&ast::def_fn(*)) | - Some(&ast::def_struct(*)) => { + Some(&ast::DefFn(*)) | + Some(&ast::DefStruct(*)) => { match *sub_pats { None => { // This is a unit-like struct. Nothing to do here. @@ -2145,14 +2145,14 @@ fn bind_irrefutable_pat(bcx: @mut Block, } } } - Some(&ast::def_static(_, false)) => { + Some(&ast::DefStatic(_, false)) => { } _ => { // Nothing to do here. } } } - ast::pat_struct(_, ref fields, _) => { + ast::PatStruct(_, ref fields, _) => { let tcx = bcx.tcx(); let pat_ty = node_id_type(bcx, pat.id); let pat_repr = adt::represent_type(bcx.ccx(), pat_ty); @@ -2165,14 +2165,14 @@ fn bind_irrefutable_pat(bcx: @mut Block, } } } - ast::pat_tup(ref elems) => { + ast::PatTup(ref elems) => { let repr = adt::represent_node(bcx, pat.id); for (i, elem) in elems.iter().enumerate() { let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i); bcx = bind_irrefutable_pat(bcx, *elem, fldptr, binding_mode); } } - ast::pat_box(inner) | ast::pat_uniq(inner) => { + ast::PatBox(inner) | ast::PatUniq(inner) => { let pat_ty = node_id_type(bcx, pat.id); let llbox = Load(bcx, val); let unboxed = match ty::get(pat_ty).sty { @@ -2181,23 +2181,23 @@ fn bind_irrefutable_pat(bcx: @mut Block, }; bcx = bind_irrefutable_pat(bcx, inner, unboxed, binding_mode); } - ast::pat_region(inner) => { + ast::PatRegion(inner) => { let loaded_val = Load(bcx, val); bcx = bind_irrefutable_pat(bcx, inner, loaded_val, binding_mode); } - ast::pat_vec(*) => { + ast::PatVec(*) => { bcx.tcx().sess.span_bug( pat.span, fmt!("vector patterns are never irrefutable!")); } - ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) => () + ast::PatWild | ast::PatLit(_) | ast::PatRange(_, _) => () } return bcx; } -fn simple_identifier<'a>(pat: &'a ast::pat) -> Option<&'a ast::Path> { +fn simple_identifier<'a>(pat: &'a ast::Pat) -> Option<&'a ast::Path> { match pat.node { - ast::pat_ident(ast::bind_infer, ref path, None) => { + ast::PatIdent(ast::BindInfer, ref path, None) => { Some(path) } _ => { diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index 3400da75b9e5e..de4ea331041f2 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -46,7 +46,7 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block { })); let e = match out.node { - ast::expr_addr_of(_, e) => e, + ast::ExprAddrOf(_, e) => e, _ => fail!("Expression must be addr of") }; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 79440b03d761f..251ce697d535a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -292,7 +292,7 @@ pub fn malloc_raw_dyn(bcx: @mut Block, let _icx = push_ctxt("malloc_raw"); let ccx = bcx.ccx(); - fn require_alloc_fn(bcx: @mut Block, t: ty::t, it: LangItem) -> ast::def_id { + fn require_alloc_fn(bcx: @mut Block, t: ty::t, it: LangItem) -> ast::DefId { let li = &bcx.tcx().lang_items; match li.require(it) { Ok(id) => id, @@ -498,8 +498,8 @@ pub fn note_unique_llvm_symbol(ccx: &mut CrateContext, sym: @str) { pub fn get_res_dtor(ccx: @mut CrateContext, - did: ast::def_id, - parent_id: ast::def_id, + did: ast::DefId, + parent_id: ast::DefId, substs: &[ty::t]) -> ValueRef { let _icx = push_ctxt("trans_res_dtor"); @@ -559,7 +559,7 @@ pub fn compare_scalar_types(cx: @mut Block, lhs: ValueRef, rhs: ValueRef, t: ty::t, - op: ast::binop) + op: ast::BinOp) -> Result { let f = |a| compare_scalar_values(cx, lhs, rhs, a, op); @@ -590,7 +590,7 @@ pub fn compare_scalar_values(cx: @mut Block, lhs: ValueRef, rhs: ValueRef, nt: scalar_type, - op: ast::binop) + op: ast::BinOp) -> ValueRef { let _icx = push_ctxt("compare_scalar_values"); fn die(cx: @mut Block) -> ! { @@ -602,44 +602,44 @@ pub fn compare_scalar_values(cx: @mut Block, // We don't need to do actual comparisons for nil. // () == () holds but () < () does not. match op { - ast::eq | ast::le | ast::ge => return C_i1(true), - ast::ne | ast::lt | ast::gt => return C_i1(false), + ast::BiEq | ast::BiLe | ast::BiGe => return C_i1(true), + ast::BiNe | ast::BiLt | ast::BiGt => return C_i1(false), // refinements would be nice _ => die(cx) } } floating_point => { let cmp = match op { - ast::eq => lib::llvm::RealOEQ, - ast::ne => lib::llvm::RealUNE, - ast::lt => lib::llvm::RealOLT, - ast::le => lib::llvm::RealOLE, - ast::gt => lib::llvm::RealOGT, - ast::ge => lib::llvm::RealOGE, + ast::BiEq => lib::llvm::RealOEQ, + ast::BiNe => lib::llvm::RealUNE, + ast::BiLt => lib::llvm::RealOLT, + ast::BiLe => lib::llvm::RealOLE, + ast::BiGt => lib::llvm::RealOGT, + ast::BiGe => lib::llvm::RealOGE, _ => die(cx) }; return FCmp(cx, cmp, lhs, rhs); } signed_int => { let cmp = match op { - ast::eq => lib::llvm::IntEQ, - ast::ne => lib::llvm::IntNE, - ast::lt => lib::llvm::IntSLT, - ast::le => lib::llvm::IntSLE, - ast::gt => lib::llvm::IntSGT, - ast::ge => lib::llvm::IntSGE, + ast::BiEq => lib::llvm::IntEQ, + ast::BiNe => lib::llvm::IntNE, + ast::BiLt => lib::llvm::IntSLT, + ast::BiLe => lib::llvm::IntSLE, + ast::BiGt => lib::llvm::IntSGT, + ast::BiGe => lib::llvm::IntSGE, _ => die(cx) }; return ICmp(cx, cmp, lhs, rhs); } unsigned_int => { let cmp = match op { - ast::eq => lib::llvm::IntEQ, - ast::ne => lib::llvm::IntNE, - ast::lt => lib::llvm::IntULT, - ast::le => lib::llvm::IntULE, - ast::gt => lib::llvm::IntUGT, - ast::ge => lib::llvm::IntUGE, + ast::BiEq => lib::llvm::IntEQ, + ast::BiNe => lib::llvm::IntNE, + ast::BiLt => lib::llvm::IntULT, + ast::BiLe => lib::llvm::IntULE, + ast::BiGt => lib::llvm::IntUGT, + ast::BiGe => lib::llvm::IntUGE, _ => die(cx) }; return ICmp(cx, cmp, lhs, rhs); @@ -750,21 +750,21 @@ pub fn iter_structural_ty(cx: @mut Block, av: ValueRef, t: ty::t, return cx; } -pub fn cast_shift_expr_rhs(cx: @mut Block, op: ast::binop, +pub fn cast_shift_expr_rhs(cx: @mut Block, op: ast::BinOp, lhs: ValueRef, rhs: ValueRef) -> ValueRef { cast_shift_rhs(op, lhs, rhs, |a,b| Trunc(cx, a, b), |a,b| ZExt(cx, a, b)) } -pub fn cast_shift_const_rhs(op: ast::binop, +pub fn cast_shift_const_rhs(op: ast::BinOp, lhs: ValueRef, rhs: ValueRef) -> ValueRef { cast_shift_rhs(op, lhs, rhs, |a, b| unsafe { llvm::LLVMConstTrunc(a, b.to_ref()) }, |a, b| unsafe { llvm::LLVMConstZExt(a, b.to_ref()) }) } -pub fn cast_shift_rhs(op: ast::binop, +pub fn cast_shift_rhs(op: ast::BinOp, lhs: ValueRef, rhs: ValueRef, trunc: &fn(ValueRef, Type) -> ValueRef, zext: &fn(ValueRef, Type) -> ValueRef) @@ -791,9 +791,9 @@ pub fn cast_shift_rhs(op: ast::binop, } } -pub fn fail_if_zero(cx: @mut Block, span: Span, divrem: ast::binop, +pub fn fail_if_zero(cx: @mut Block, span: Span, divrem: ast::BinOp, rhs: ValueRef, rhs_t: ty::t) -> @mut Block { - let text = if divrem == ast::div { + let text = if divrem == ast::BiDiv { @"attempted to divide by zero" } else { @"attempted remainder with a divisor of zero" @@ -821,7 +821,7 @@ pub fn null_env_ptr(ccx: &CrateContext) -> ValueRef { C_null(Type::opaque_box(ccx).ptr_to()) } -pub fn trans_external_path(ccx: &mut CrateContext, did: ast::def_id, t: ty::t) +pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) -> ValueRef { let name = csearch::get_symbol(ccx.sess.cstore, did); match ty::get(t).sty { @@ -1088,7 +1088,7 @@ pub fn trans_trace(bcx: @mut Block, sp_opt: Option, trace_str: @str) { pub fn ignore_lhs(_bcx: @mut Block, local: &ast::Local) -> bool { match local.pat.node { - ast::pat_wild => true, _ => false + ast::PatWild => true, _ => false } } @@ -1113,7 +1113,7 @@ pub fn init_local(bcx: @mut Block, local: &ast::Local) -> @mut Block { _match::store_local(bcx, local.pat, local.init) } -pub fn trans_stmt(cx: @mut Block, s: &ast::stmt) -> @mut Block { +pub fn trans_stmt(cx: @mut Block, s: &ast::Stmt) -> @mut Block { let _icx = push_ctxt("trans_stmt"); debug!("trans_stmt(%s)", stmt_to_str(s, cx.tcx().sess.intr())); @@ -1124,22 +1124,22 @@ pub fn trans_stmt(cx: @mut Block, s: &ast::stmt) -> @mut Block { let mut bcx = cx; match s.node { - ast::stmt_expr(e, _) | ast::stmt_semi(e, _) => { + ast::StmtExpr(e, _) | ast::StmtSemi(e, _) => { bcx = expr::trans_into(cx, e, expr::Ignore); } - ast::stmt_decl(d, _) => { + ast::StmtDecl(d, _) => { match d.node { - ast::decl_local(ref local) => { + ast::DeclLocal(ref local) => { bcx = init_local(bcx, *local); if cx.sess().opts.extra_debuginfo && fcx_has_nonzero_span(bcx.fcx) { debuginfo::create_local_var_metadata(bcx, *local); } } - ast::decl_item(i) => trans_item(cx.fcx.ccx, i) + ast::DeclItem(i) => trans_item(cx.fcx.ccx, i) } } - ast::stmt_mac(*) => cx.tcx().sess.bug("unexpanded macro") + ast::StmtMac(*) => cx.tcx().sess.bug("unexpanded macro") } return bcx; @@ -1444,9 +1444,9 @@ pub fn with_scope_datumblock(bcx: @mut Block, opt_node_info: Option, pub fn block_locals(b: &ast::Block, it: &fn(@ast::Local)) { for s in b.stmts.iter() { match s.node { - ast::stmt_decl(d, _) => { + ast::StmtDecl(d, _) => { match d.node { - ast::decl_local(ref local) => it(*local), + ast::DeclLocal(ref local) => it(*local), _ => {} /* fall through */ } } @@ -2231,7 +2231,7 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) { // 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 if attr::contains_name(item.attrs, "static_assert") { - if m == ast::m_mutbl { + if m == ast::MutMutable { ccx.sess.span_fatal(expr.span, "cannot have static_assert on a mutable \ static"); @@ -2488,7 +2488,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { // LLVM type is not fully determined by the Rust type. let v = consts::const_expr(ccx, expr); ccx.const_values.insert(id, v); - exprt = (m == ast::m_mutbl || i.vis == ast::public); + exprt = (m == ast::MutMutable || i.vis == ast::public); unsafe { let llty = llvm::LLVMTypeOf(v); diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 9502e02c27945..14be9bc2873c3 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -77,13 +77,13 @@ pub struct Callee { data: CalleeData } -pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee { +pub fn trans(bcx: @mut Block, expr: @ast::Expr) -> Callee { let _icx = push_ctxt("trans_callee"); debug!("callee::trans(expr=%s)", expr.repr(bcx.tcx())); // pick out special kinds of expressions that can be called: match expr.node { - ast::expr_path(_) => { + ast::ExprPath(_) => { return trans_def(bcx, bcx.def(expr.id), expr); } _ => {} @@ -92,7 +92,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee { // any other expressions are closures: return datum_callee(bcx, expr); - fn datum_callee(bcx: @mut Block, expr: @ast::expr) -> Callee { + fn datum_callee(bcx: @mut Block, expr: @ast::Expr) -> Callee { let DatumBlock {bcx, datum} = expr::trans_to_datum(bcx, expr); match ty::get(datum.ty).sty { ty::ty_bare_fn(*) => { @@ -115,42 +115,42 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee { return Callee {bcx: bcx, data: Fn(fd)}; } - fn trans_def(bcx: @mut Block, def: ast::def, ref_expr: @ast::expr) -> Callee { + fn trans_def(bcx: @mut Block, def: ast::Def, ref_expr: @ast::Expr) -> Callee { match def { - ast::def_fn(did, _) | - ast::def_static_method(did, ast::FromImpl(_), _) => { + ast::DefFn(did, _) | + ast::DefStaticMethod(did, ast::FromImpl(_), _) => { fn_callee(bcx, trans_fn_ref(bcx, did, ref_expr.id)) } - ast::def_static_method(impl_did, + ast::DefStaticMethod(impl_did, ast::FromTrait(trait_did), _) => { fn_callee(bcx, meth::trans_static_method_callee(bcx, impl_did, trait_did, ref_expr.id)) } - ast::def_variant(tid, vid) => { + ast::DefVariant(tid, vid) => { // nullary variants are not callable assert!(ty::enum_variant_with_id(bcx.tcx(), tid, vid).args.len() > 0u); fn_callee(bcx, trans_fn_ref(bcx, vid, ref_expr.id)) } - ast::def_struct(def_id) => { + ast::DefStruct(def_id) => { fn_callee(bcx, trans_fn_ref(bcx, def_id, ref_expr.id)) } - ast::def_static(*) | - ast::def_arg(*) | - ast::def_local(*) | - ast::def_binding(*) | - ast::def_upvar(*) | - ast::def_self(*) => { + ast::DefStatic(*) | + ast::DefArg(*) | + ast::DefLocal(*) | + ast::DefBinding(*) | + ast::DefUpvar(*) | + ast::DefSelf(*) => { datum_callee(bcx, ref_expr) } - ast::def_mod(*) | ast::def_foreign_mod(*) | ast::def_trait(*) | - ast::def_ty(*) | ast::def_prim_ty(*) | - ast::def_use(*) | ast::def_typaram_binder(*) | - ast::def_region(*) | ast::def_label(*) | ast::def_ty_param(*) | - ast::def_self_ty(*) | ast::def_method(*) => { + ast::DefMod(*) | ast::DefForeignMod(*) | ast::DefTrait(*) | + ast::DefTy(*) | ast::DefPrimTy(*) | + ast::DefUse(*) | ast::DefTyParamBinder(*) | + ast::DefRegion(*) | ast::DefLabel(*) | ast::DefTyParam(*) | + ast::DefSelfTy(*) | ast::DefMethod(*) => { bcx.tcx().sess.span_bug( ref_expr.span, fmt!("Cannot translate def %? \ @@ -161,14 +161,14 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee { } pub fn trans_fn_ref_to_callee(bcx: @mut Block, - def_id: ast::def_id, + def_id: ast::DefId, ref_id: ast::NodeId) -> Callee { Callee {bcx: bcx, data: Fn(trans_fn_ref(bcx, def_id, ref_id))} } pub fn trans_fn_ref(bcx: @mut Block, - def_id: ast::def_id, + def_id: ast::DefId, ref_id: ast::NodeId) -> FnData { /*! * @@ -188,7 +188,7 @@ pub fn trans_fn_ref(bcx: @mut Block, pub fn trans_fn_ref_with_vtables_to_callee( bcx: @mut Block, - def_id: ast::def_id, + def_id: ast::DefId, ref_id: ast::NodeId, type_params: &[ty::t], vtables: Option) @@ -199,7 +199,7 @@ pub fn trans_fn_ref_with_vtables_to_callee( } fn resolve_default_method_vtables(bcx: @mut Block, - impl_id: ast::def_id, + impl_id: ast::DefId, method: &ty::Method, substs: &ty::substs, impl_vtables: Option) @@ -242,7 +242,7 @@ fn resolve_default_method_vtables(bcx: @mut Block, pub fn trans_fn_ref_with_vtables( bcx: @mut Block, // - def_id: ast::def_id, // def id of fn + def_id: ast::DefId, // def id of fn ref_id: ast::NodeId, // node id of use of fn; may be zero if N/A type_params: &[ty::t], // values for fn's ty params vtables: Option) // vtables for the call @@ -447,8 +447,8 @@ pub fn trans_fn_ref_with_vtables( // Translating calls pub fn trans_call(in_cx: @mut Block, - call_ex: @ast::expr, - f: @ast::expr, + call_ex: @ast::Expr, + f: @ast::Expr, args: CallArgs, id: ast::NodeId, dest: expr::Dest) @@ -465,9 +465,9 @@ pub fn trans_call(in_cx: @mut Block, } pub fn trans_method_call(in_cx: @mut Block, - call_ex: @ast::expr, + call_ex: @ast::Expr, callee_id: ast::NodeId, - rcvr: @ast::expr, + rcvr: @ast::Expr, args: CallArgs, dest: expr::Dest) -> @mut Block { @@ -503,7 +503,7 @@ pub fn trans_method_call(in_cx: @mut Block, } pub fn trans_lang_call(bcx: @mut Block, - did: ast::def_id, + did: ast::DefId, args: &[ValueRef], dest: Option) -> Result { @@ -530,7 +530,7 @@ pub fn trans_lang_call(bcx: @mut Block, } pub fn trans_lang_call_with_type_params(bcx: @mut Block, - did: ast::def_id, + did: ast::DefId, args: &[ValueRef], type_params: &[ty::t], dest: expr::Dest) @@ -576,11 +576,11 @@ impl Visitor<@mut bool> for CalleeTranslationVisitor { fn visit_item(&mut self, _:@ast::item, _:@mut bool) { } - fn visit_expr(&mut self, e:@ast::expr, cx:@mut bool) { + fn visit_expr(&mut self, e:@ast::Expr, cx:@mut bool) { if !*cx { match e.node { - ast::expr_ret(_) => *cx = true, + ast::ExprRet(_) => *cx = true, _ => visit::walk_expr(self, e, cx), } } @@ -757,7 +757,7 @@ pub fn trans_call_inner(in_cx: @mut Block, } pub enum CallArgs<'self> { - ArgExprs(&'self [@ast::expr]), + ArgExprs(&'self [@ast::Expr]), ArgVals(&'self [ValueRef]) } @@ -815,7 +815,7 @@ pub enum AutorefArg { pub fn trans_arg_expr(bcx: @mut Block, formal_arg_ty: ty::t, self_mode: ty::SelfMode, - arg_expr: @ast::expr, + arg_expr: @ast::Expr, temp_cleanups: &mut ~[ValueRef], autoref_arg: AutorefArg) -> Result { let _icx = push_ctxt("trans_arg_expr"); diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 422394716b479..645f81577668e 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -208,7 +208,7 @@ pub fn store_environment(bcx: @mut Block, // tuple. This could be a ptr in uniq or a box or on stack, // whatever. let cbox_ty = tuplify_box_ty(tcx, cdata_ty); - let cboxptr_ty = ty::mk_ptr(tcx, ty::mt {ty:cbox_ty, mutbl:ast::m_imm}); + let cboxptr_ty = ty::mk_ptr(tcx, ty::mt {ty:cbox_ty, mutbl:ast::MutImmutable}); let llboxptr_ty = type_of(ccx, cboxptr_ty); // If there are no bound values, no point in allocating anything. diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 9b608d1266950..25d64e65b19bb 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -484,7 +484,7 @@ pub trait get_node_info { fn info(&self) -> Option; } -impl get_node_info for ast::expr { +impl get_node_info for ast::Expr { fn info(&self) -> Option { Some(NodeInfo {id: self.id, callee_id: self.get_callee_id(), @@ -500,7 +500,7 @@ impl get_node_info for ast::Block { } } -impl get_node_info for Option<@ast::expr> { +impl get_node_info for Option<@ast::Expr> { fn info(&self) -> Option { self.chain_ref(|s| s.info()) } @@ -570,19 +570,19 @@ impl Block { ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr()) } - pub fn expr_to_str(&self, e: @ast::expr) -> ~str { + pub fn expr_to_str(&self, e: @ast::Expr) -> ~str { e.repr(self.tcx()) } - pub fn expr_is_lval(&self, e: &ast::expr) -> bool { + pub fn expr_is_lval(&self, e: &ast::Expr) -> bool { ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e) } - pub fn expr_kind(&self, e: &ast::expr) -> ty::ExprKind { + pub fn expr_kind(&self, e: &ast::Expr) -> ty::ExprKind { ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e) } - pub fn def(&self, nid: ast::NodeId) -> ast::def { + pub fn def(&self, nid: ast::NodeId) -> ast::Def { match self.tcx().def_map.find(&nid) { Some(&v) => v, None => { @@ -681,7 +681,7 @@ pub fn block_parent(cx: @mut Block) -> @mut Block { pub fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let ptr = ty::mk_ptr( tcx, - ty::mt {ty: ty::mk_i8(), mutbl: ast::m_imm} + ty::mt {ty: ty::mk_i8(), mutbl: ast::MutImmutable} ); return ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_type(tcx), ptr, ptr, @@ -920,7 +920,7 @@ pub fn mono_data_classify(t: ty::t) -> MonoDataClass { #[deriving(Eq,IterBytes)] pub struct mono_id_ { - def: ast::def_id, + def: ast::DefId, params: ~[mono_param_id] } @@ -979,11 +979,11 @@ pub fn node_id_type(bcx: @mut Block, id: ast::NodeId) -> ty::t { monomorphize_type(bcx, t) } -pub fn expr_ty(bcx: @mut Block, ex: &ast::expr) -> ty::t { +pub fn expr_ty(bcx: @mut Block, ex: &ast::Expr) -> ty::t { node_id_type(bcx, ex.id) } -pub fn expr_ty_adjusted(bcx: @mut Block, ex: &ast::expr) -> ty::t { +pub fn expr_ty_adjusted(bcx: @mut Block, ex: &ast::Expr) -> ty::t { let tcx = bcx.tcx(); let t = ty::expr_ty_adjusted(tcx, ex); monomorphize_type(bcx, t) @@ -1124,7 +1124,7 @@ pub fn bool_to_i1(bcx: @mut Block, llval: ValueRef) -> ValueRef { } pub fn langcall(bcx: @mut Block, span: Option, msg: &str, - li: LangItem) -> ast::def_id { + li: LangItem) -> ast::DefId { match bcx.tcx().lang_items.require(li) { Ok(id) => id, Err(s) => { diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 0dfce6f42c329..64cfe13553dc4 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -35,7 +35,7 @@ use std::libc::c_uint; use std::vec; use syntax::{ast, ast_util, ast_map}; -pub fn const_lit(cx: &mut CrateContext, e: &ast::expr, lit: ast::lit) +pub fn const_lit(cx: &mut CrateContext, e: &ast::Expr, lit: ast::lit) -> ValueRef { let _icx = push_ctxt("trans_lit"); match lit.node { @@ -82,7 +82,7 @@ pub fn const_ptrcast(cx: &mut CrateContext, a: ValueRef, t: Type) -> ValueRef { } } -pub fn const_vec(cx: @mut CrateContext, e: &ast::expr, es: &[@ast::expr]) +pub fn const_vec(cx: @mut CrateContext, e: &ast::Expr, es: &[@ast::Expr]) -> (ValueRef, ValueRef, Type) { unsafe { let vec_ty = ty::expr_ty(cx.tcx, e); @@ -134,7 +134,7 @@ fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool) -> (ValueRef, ty::t) { match ty::deref(cx.tcx, t, explicit) { Some(ref mt) => { - assert!(mt.mutbl != ast::m_mutbl); + assert!(mt.mutbl != ast::MutMutable); let dv = match ty::get(t).sty { ty::ty_ptr(*) | ty::ty_rptr(*) => { const_deref_ptr(cx, v) @@ -156,7 +156,7 @@ fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool) } } -pub fn get_const_val(cx: @mut CrateContext, mut def_id: ast::def_id) -> ValueRef { +pub fn get_const_val(cx: @mut CrateContext, mut def_id: ast::DefId) -> ValueRef { let contains_key = cx.const_values.contains_key(&def_id.node); if !ast_util::is_local(def_id) || !contains_key { if !ast_util::is_local(def_id) { @@ -164,9 +164,9 @@ pub fn get_const_val(cx: @mut CrateContext, mut def_id: ast::def_id) -> ValueRef } match cx.tcx.items.get_copy(&def_id.node) { ast_map::node_item(@ast::item { - node: ast::item_static(_, ast::m_imm, _), _ + node: ast::item_static(_, ast::MutImmutable, _), _ }, _) => { - trans_const(cx, ast::m_imm, def_id.node); + trans_const(cx, ast::MutImmutable, def_id.node); } _ => cx.tcx.sess.bug("expected a const to be an item") } @@ -174,7 +174,7 @@ pub fn get_const_val(cx: @mut CrateContext, mut def_id: ast::def_id) -> ValueRef cx.const_values.get_copy(&def_id.node) } -pub fn const_expr(cx: @mut CrateContext, e: @ast::expr) -> ValueRef { +pub fn const_expr(cx: @mut CrateContext, e: @ast::Expr) -> ValueRef { let mut llconst = const_expr_unadjusted(cx, e); let ety = ty::expr_ty(cx.tcx, e); let adjustment = cx.tcx.adjustments.find_copy(&e.id); @@ -208,11 +208,11 @@ pub fn const_expr(cx: @mut CrateContext, e: @ast::expr) -> ValueRef { match *autoref { ty::AutoUnsafe(m) | ty::AutoPtr(ty::re_static, m) => { - assert!(m != ast::m_mutbl); + assert!(m != ast::MutMutable); llconst = llptr; } ty::AutoBorrowVec(ty::re_static, m) => { - assert!(m != ast::m_mutbl); + assert!(m != ast::MutMutable); assert_eq!(abi::slice_elt_base, 0); assert_eq!(abi::slice_elt_len, 1); @@ -252,12 +252,12 @@ pub fn const_expr(cx: @mut CrateContext, e: @ast::expr) -> ValueRef { llconst } -fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { +fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::Expr) -> ValueRef { unsafe { let _icx = push_ctxt("const_expr"); return match e.node { - ast::expr_lit(lit) => consts::const_lit(cx, e, *lit), - ast::expr_binary(_, b, e1, e2) => { + ast::ExprLit(lit) => consts::const_lit(cx, e, *lit), + ast::ExprBinary(_, b, e1, e2) => { let te1 = const_expr(cx, e1); let te2 = const_expr(cx, e2); @@ -269,68 +269,68 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { let is_float = ty::type_is_fp(ty); let signed = ty::type_is_signed(ty); return match b { - ast::add => { + ast::BiAdd => { if is_float { llvm::LLVMConstFAdd(te1, te2) } else { llvm::LLVMConstAdd(te1, te2) } } - ast::subtract => { + ast::BiSub => { if is_float { llvm::LLVMConstFSub(te1, te2) } else { llvm::LLVMConstSub(te1, te2) } } - ast::mul => { + ast::BiMul => { if is_float { llvm::LLVMConstFMul(te1, te2) } else { llvm::LLVMConstMul(te1, te2) } } - ast::div => { + ast::BiDiv => { if is_float { llvm::LLVMConstFDiv(te1, te2) } else if signed { llvm::LLVMConstSDiv(te1, te2) } else { llvm::LLVMConstUDiv(te1, te2) } } - ast::rem => { + ast::BiRem => { if is_float { llvm::LLVMConstFRem(te1, te2) } else if signed { llvm::LLVMConstSRem(te1, te2) } else { llvm::LLVMConstURem(te1, te2) } } - ast::and => llvm::LLVMConstAnd(te1, te2), - ast::or => llvm::LLVMConstOr(te1, te2), - ast::bitxor => llvm::LLVMConstXor(te1, te2), - ast::bitand => llvm::LLVMConstAnd(te1, te2), - ast::bitor => llvm::LLVMConstOr(te1, te2), - ast::shl => llvm::LLVMConstShl(te1, te2), - ast::shr => { + ast::BiAnd => llvm::LLVMConstAnd(te1, te2), + ast::BiOr => llvm::LLVMConstOr(te1, te2), + ast::BiBitXor => llvm::LLVMConstXor(te1, te2), + ast::BiBitAnd => llvm::LLVMConstAnd(te1, te2), + ast::BiBitOr => llvm::LLVMConstOr(te1, te2), + ast::BiShl => llvm::LLVMConstShl(te1, te2), + ast::BiShr => { if signed { llvm::LLVMConstAShr(te1, te2) } else { llvm::LLVMConstLShr(te1, te2) } } - ast::eq => { + ast::BiEq => { if is_float { ConstFCmp(RealOEQ, te1, te2) } else { ConstICmp(IntEQ, te1, te2) } }, - ast::lt => { + ast::BiLt => { if is_float { ConstFCmp(RealOLT, te1, te2) } else { if signed { ConstICmp(IntSLT, te1, te2) } else { ConstICmp(IntULT, te1, te2) } } }, - ast::le => { + ast::BiLe => { if is_float { ConstFCmp(RealOLE, te1, te2) } else { if signed { ConstICmp(IntSLE, te1, te2) } else { ConstICmp(IntULE, te1, te2) } } }, - ast::ne => { + ast::BiNe => { if is_float { ConstFCmp(RealONE, te1, te2) } else { ConstICmp(IntNE, te1, te2) } }, - ast::ge => { + ast::BiGe => { if is_float { ConstFCmp(RealOGE, te1, te2) } else { if signed { ConstICmp(IntSGE, te1, te2) } else { ConstICmp(IntUGE, te1, te2) } } }, - ast::gt => { + ast::BiGt => { if is_float { ConstFCmp(RealOGT, te1, te2) } else { if signed { ConstICmp(IntSGT, te1, te2) } @@ -339,18 +339,18 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { }, }; }, - ast::expr_unary(_, u, e) => { + ast::ExprUnary(_, u, e) => { let te = const_expr(cx, e); let ty = ty::expr_ty(cx.tcx, e); let is_float = ty::type_is_fp(ty); return match u { - ast::box(_) | - ast::uniq | - ast::deref => { + ast::UnBox(_) | + ast::UnUniq | + ast::UnDeref => { let (dv, _dt) = const_deref(cx, te, ty, true); dv } - ast::not => { + ast::UnNot => { match ty::get(ty).sty { ty::ty_bool => { // Somewhat questionable, but I believe this is @@ -362,13 +362,13 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { _ => llvm::LLVMConstNot(te), } } - ast::neg => { + ast::UnNeg => { if is_float { llvm::LLVMConstFNeg(te) } else { llvm::LLVMConstNeg(te) } } } } - ast::expr_field(base, field, _) => { + ast::ExprField(base, field, _) => { let bt = ty::expr_ty_adjusted(cx.tcx, base); let brepr = adt::represent_type(cx, bt); let bv = const_expr(cx, base); @@ -378,7 +378,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { } } - ast::expr_index(_, base, index) => { + ast::ExprIndex(_, base, index) => { let bt = ty::expr_ty_adjusted(cx.tcx, base); let bv = const_expr(cx, base); let iv = match const_eval::eval_const_expr(cx.tcx, index) { @@ -423,7 +423,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { } const_get_elt(cx, arr, [iv as c_uint]) } - ast::expr_cast(base, _) => { + ast::ExprCast(base, _) => { let ety = ty::expr_ty(cx.tcx, e); let llty = type_of::type_of(cx, ety); let basety = ty::expr_ty(cx.tcx, base); @@ -477,17 +477,17 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { } } } - ast::expr_addr_of(ast::m_imm, sub) => { + ast::ExprAddrOf(ast::MutImmutable, sub) => { let e = const_expr(cx, sub); const_addr_of(cx, e) } - ast::expr_tup(ref es) => { + ast::ExprTup(ref es) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); let vals = es.map(|&e| const_expr(cx, e)); adt::trans_const(cx, repr, 0, vals) } - ast::expr_struct(_, ref fs, ref base_opt) => { + ast::ExprStruct(_, ref fs, ref base_opt) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); let tcx = cx.tcx; @@ -514,19 +514,19 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { adt::trans_const(cx, repr, discr, cs) } } - ast::expr_vec(ref es, ast::m_imm) => { + ast::ExprVec(ref es, ast::MutImmutable) => { let (v, _, _) = const_vec(cx, e, *es); v } - ast::expr_vstore(sub, ast::expr_vstore_slice) => { + ast::ExprVstore(sub, ast::ExprVstoreSlice) => { match sub.node { - ast::expr_lit(ref lit) => { + 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::expr_vec(ref es, ast::m_imm) => { + ast::ExprVec(ref es, ast::MutImmutable) => { let (cv, sz, llunitty) = const_vec(cx, e, *es); let llty = val_ty(cv); let gv = do "const".with_c_str |name| { @@ -541,7 +541,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { _ => cx.sess.span_bug(e.span, "bad const-slice expr") } } - ast::expr_repeat(elem, count, _) => { + ast::ExprRepeat(elem, count, _) => { let vec_ty = ty::expr_ty(cx.tcx, e); let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty); let llunitty = type_of::type_of(cx, unit_ty); @@ -558,13 +558,13 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { }; v } - ast::expr_path(ref pth) => { + ast::ExprPath(ref pth) => { // Assert that there are no type parameters in this path. assert!(pth.segments.iter().all(|seg| seg.types.is_empty())); let tcx = cx.tcx; match tcx.def_map.find(&e.id) { - Some(&ast::def_fn(def_id, _purity)) => { + Some(&ast::DefFn(def_id, _purity)) => { if !ast_util::is_local(def_id) { let ty = csearch::get_type(cx.tcx, def_id).ty; base::trans_external_path(cx, def_id, ty) @@ -573,10 +573,10 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { base::get_item_val(cx, def_id.node) } } - Some(&ast::def_static(def_id, false)) => { + Some(&ast::DefStatic(def_id, false)) => { get_const_val(cx, def_id) } - Some(&ast::def_variant(enum_did, variant_did)) => { + Some(&ast::DefVariant(enum_did, variant_did)) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); let vinfo = ty::enum_variant_with_id(cx.tcx, @@ -584,7 +584,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { variant_did); adt::trans_const(cx, repr, vinfo.disr_val, []) } - Some(&ast::def_struct(_)) => { + Some(&ast::DefStruct(_)) => { let ety = ty::expr_ty(cx.tcx, e); let llty = type_of::type_of(cx, ety); C_null(llty) @@ -594,16 +594,16 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { } } } - ast::expr_call(callee, ref args, _) => { + ast::ExprCall(callee, ref args, _) => { let tcx = cx.tcx; match tcx.def_map.find(&callee.id) { - Some(&ast::def_struct(_)) => { + Some(&ast::DefStruct(_)) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); let arg_vals = args.map(|a| const_expr(cx, *a)); adt::trans_const(cx, repr, 0, arg_vals) } - Some(&ast::def_variant(enum_did, variant_did)) => { + Some(&ast::DefVariant(enum_did, variant_did)) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); let vinfo = ty::enum_variant_with_id(cx.tcx, @@ -615,14 +615,14 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { _ => cx.sess.span_bug(e.span, "expected a struct or variant def") } } - ast::expr_paren(e) => { return const_expr(cx, e); } + ast::ExprParen(e) => { return const_expr(cx, e); } _ => cx.sess.span_bug(e.span, "bad constant expression type in consts::const_expr") }; } } -pub fn trans_const(ccx: @mut CrateContext, m: ast::mutability, id: ast::NodeId) { +pub fn trans_const(ccx: @mut CrateContext, m: ast::Mutability, id: ast::NodeId) { unsafe { let _icx = push_ctxt("trans_const"); let g = base::get_item_val(ccx, id); @@ -630,7 +630,7 @@ pub fn trans_const(ccx: @mut CrateContext, m: ast::mutability, id: ast::NodeId) // constant's initializer to determine its LLVM type. let v = ccx.const_values.get_copy(&id); llvm::LLVMSetInitializer(g, v); - if m != ast::m_mutbl { + if m != ast::MutMutable { llvm::LLVMSetGlobalConstant(g, True); } } diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 02659b99afcf7..e7781e93d8cec 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -53,19 +53,19 @@ pub struct CrateContext { item_symbols: HashMap, link_meta: LinkMeta, enum_sizes: HashMap, - discrims: HashMap, + discrims: HashMap, discrim_symbols: HashMap, tydescs: HashMap, // Set when running emit_tydescs to enforce that no more tydescs are // created. finished_tydescs: bool, // Track mapping of external ids to local items imported for inlining - external: HashMap>, + external: HashMap>, // Cache instances of monomorphized functions monomorphized: HashMap, - monomorphizing: HashMap, + monomorphizing: HashMap, // Cache computed type parameter uses (see type_use.rs) - type_use_cache: HashMap, + type_use_cache: HashMap, // Cache generated vtables vtables: HashMap<(ty::t, mono_id), ValueRef>, // Cache of constant strings, @@ -85,9 +85,9 @@ pub struct CrateContext { const_values: HashMap, // Cache of external const values - extern_const_values: HashMap, + extern_const_values: HashMap, - impl_method_cache: HashMap<(ast::def_id, ast::Ident), ast::def_id>, + impl_method_cache: HashMap<(ast::DefId, ast::Ident), ast::DefId>, module_data: HashMap<~str, ValueRef>, lltypes: HashMap, diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index be4fef3693478..c3d5598d234cf 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -50,9 +50,9 @@ pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Bl } pub fn trans_if(bcx: @mut Block, - cond: @ast::expr, + cond: @ast::Expr, thn: &ast::Block, - els: Option<@ast::expr>, + els: Option<@ast::Expr>, dest: expr::Dest) -> @mut Block { debug!("trans_if(bcx=%s, cond=%s, thn=%?, dest=%s)", @@ -121,14 +121,14 @@ pub fn trans_if(bcx: @mut Block, return next_bcx; // trans `else [ if { .. } ... | { .. } ]` - fn trans_if_else(else_bcx_in: @mut Block, elexpr: @ast::expr, + fn trans_if_else(else_bcx_in: @mut Block, elexpr: @ast::Expr, dest: expr::Dest) -> @mut Block { let else_bcx_out = match elexpr.node { - ast::expr_if(_, _, _) => { + ast::ExprIf(_, _, _) => { let elseif_blk = ast_util::block_from_expr(elexpr); trans_block(else_bcx_in, &elseif_blk, dest) } - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { trans_block(else_bcx_in, blk, dest) } // would be nice to have a constraint on ifs @@ -153,7 +153,7 @@ pub fn join_blocks(parent_bcx: @mut Block, in_cxs: &[@mut Block]) -> @mut Block return out; } -pub fn trans_while(bcx: @mut Block, cond: @ast::expr, body: &ast::Block) -> @mut Block { +pub fn trans_while(bcx: @mut Block, cond: @ast::Expr, body: &ast::Block) -> @mut Block { let _icx = push_ctxt("trans_while"); let next_bcx = sub_block(bcx, "while next"); @@ -206,10 +206,10 @@ pub fn trans_loop(bcx:@mut Block, return next_bcx; } -pub fn trans_log(log_ex: &ast::expr, - lvl: @ast::expr, +pub fn trans_log(log_ex: &ast::Expr, + lvl: @ast::Expr, bcx: @mut Block, - e: @ast::expr) -> @mut Block { + e: @ast::Expr) -> @mut Block { let _icx = push_ctxt("trans_log"); let ccx = bcx.ccx(); let mut bcx = bcx; @@ -334,7 +334,7 @@ pub fn trans_cont(bcx: @mut Block, label_opt: Option) -> @mut Block { return trans_break_cont(bcx, label_opt, false); } -pub fn trans_ret(bcx: @mut Block, e: Option<@ast::expr>) -> @mut Block { +pub fn trans_ret(bcx: @mut Block, e: Option<@ast::Expr>) -> @mut Block { let _icx = push_ctxt("trans_ret"); let mut bcx = bcx; let dest = match bcx.fcx.llretptr { @@ -354,7 +354,7 @@ pub fn trans_ret(bcx: @mut Block, e: Option<@ast::expr>) -> @mut Block { pub fn trans_fail_expr(bcx: @mut Block, sp_opt: Option, - fail_expr: Option<@ast::expr>) + fail_expr: Option<@ast::Expr>) -> @mut Block { let _icx = push_ctxt("trans_fail_expr"); let mut bcx = bcx; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 2fd0e38aea8c4..8ee38b950bf52 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -726,7 +726,7 @@ impl Datum { } /// expr: The deref expression. - pub fn deref(&self, bcx: @mut Block, expr: &ast::expr, derefs: uint) + pub fn deref(&self, bcx: @mut Block, expr: &ast::Expr, derefs: uint) -> DatumBlock { match self.try_deref(bcx, expr.span, expr.id, derefs, false) { (Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres }, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index b69b9b308ba44..71a9f4de4a0db 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -357,7 +357,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext, } ast_map::node_expr(ref expr) => { match expr.node { - ast::expr_fn_block(ref fn_decl, ref top_level_block) => { + ast::ExprFnBlock(ref fn_decl, ref top_level_block) => { let name = gensym_name("fn"); (name, fn_decl, // This is not quite right. It should actually inherit the generics of the @@ -864,7 +864,7 @@ fn tuple_metadata(cx: &mut CrateContext, fn enum_metadata(cx: &mut CrateContext, enum_type: ty::t, - enum_def_id: ast::def_id, + enum_def_id: ast::DefId, span: Span) -> DIType { @@ -1236,7 +1236,7 @@ fn vec_slice_metadata(cx: &mut CrateContext, assert!(slice_layout_is_correct(cx, member_llvm_types, element_type)); - let data_ptr_type = ty::mk_ptr(cx.tcx, ty::mt { ty: element_type, mutbl: ast::m_imm }); + let data_ptr_type = ty::mk_ptr(cx.tcx, ty::mt { ty: element_type, mutbl: ast::MutImmutable }); let member_type_metadata = &[type_metadata(cx, data_ptr_type, span), type_metadata(cx, ty::mk_uint(), span)]; @@ -1531,7 +1531,7 @@ fn assert_fcx_has_span(fcx: &FunctionContext) { // descriptors where necessary. These artificial scopes allow GDB to correctly handle name // shadowing. fn populate_scope_map(cx: &mut CrateContext, - arg_pats: &[@ast::pat], + arg_pats: &[@ast::Pat], fn_entry_block: Option<&ast::Block>, fn_metadata: DISubprogram, scope_map: &mut HashMap) { @@ -1608,10 +1608,10 @@ fn populate_scope_map(cx: &mut CrateContext, scope_map.insert(ast_util::stmt_id(statement), scope_stack.last().scope_metadata); match statement.node { - ast::stmt_decl(@ref decl, _) => walk_decl(cx, decl, scope_stack, scope_map), - ast::stmt_expr(@ref exp, _) | - ast::stmt_semi(@ref exp, _) => walk_expr(cx, exp, scope_stack, scope_map), - ast::stmt_mac(*) => () // ignore macros (which should be expanded anyway) + ast::StmtDecl(@ref decl, _) => walk_decl(cx, decl, scope_stack, scope_map), + ast::StmtExpr(@ref exp, _) | + ast::StmtSemi(@ref exp, _) => walk_expr(cx, exp, scope_stack, scope_map), + ast::StmtMac(*) => () // ignore macros (which should be expanded anyway) } } @@ -1621,11 +1621,11 @@ fn populate_scope_map(cx: &mut CrateContext, } fn walk_decl(cx: &mut CrateContext, - decl: &ast::decl, + decl: &ast::Decl, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { match *decl { - codemap::Spanned { node: ast::decl_local(@ref local), _ } => { + codemap::Spanned { node: ast::DeclLocal(@ref local), _ } => { scope_map.insert(local.id, scope_stack.last().scope_metadata); walk_pattern(cx, local.pat, scope_stack, scope_map); @@ -1639,7 +1639,7 @@ fn populate_scope_map(cx: &mut CrateContext, } fn walk_pattern(cx: &mut CrateContext, - pat: @ast::pat, + pat: @ast::Pat, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { @@ -1649,7 +1649,7 @@ fn populate_scope_map(cx: &mut CrateContext, // because we have to visit *all* nodes in order to put them into the scope map. The above // functions don't do that. match pat.node { - ast::pat_ident(_, ref path_ref, ref sub_pat_opt) => { + ast::PatIdent(_, ref path_ref, ref sub_pat_opt) => { // Check if this is a binding. If so we need to put it on the scope stack and maybe // introduce an articial scope @@ -1716,11 +1716,11 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::pat_wild => { + ast::PatWild => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); } - ast::pat_enum(_, ref sub_pats_opt) => { + ast::PatEnum(_, ref sub_pats_opt) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); for ref sub_pats in sub_pats_opt.iter() { @@ -1730,15 +1730,15 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::pat_struct(_, ref field_pats, _) => { + ast::PatStruct(_, ref field_pats, _) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); - for &ast::field_pat { pat: sub_pat, _ } in field_pats.iter() { + for &ast::FieldPat { pat: sub_pat, _ } in field_pats.iter() { walk_pattern(cx, sub_pat, scope_stack, scope_map); } } - ast::pat_tup(ref sub_pats) => { + ast::PatTup(ref sub_pats) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); for &sub_pat in sub_pats.iter() { @@ -1746,25 +1746,25 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::pat_box(sub_pat) | - ast::pat_uniq(sub_pat) | - ast::pat_region(sub_pat) => { + ast::PatBox(sub_pat) | + ast::PatUniq(sub_pat) | + ast::PatRegion(sub_pat) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); walk_pattern(cx, sub_pat, scope_stack, scope_map); } - ast::pat_lit(@ref exp) => { + ast::PatLit(@ref exp) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); walk_expr(cx, exp, scope_stack, scope_map); } - ast::pat_range(@ref exp1, @ref exp2) => { + ast::PatRange(@ref exp1, @ref exp2) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); walk_expr(cx, exp1, scope_stack, scope_map); walk_expr(cx, exp2, scope_stack, scope_map); } - ast::pat_vec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => { + ast::PatVec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => { scope_map.insert(pat.id, scope_stack.last().scope_metadata); for &sub_pat in front_sub_pats.iter() { @@ -1783,58 +1783,58 @@ fn populate_scope_map(cx: &mut CrateContext, } fn walk_expr(cx: &mut CrateContext, - exp: &ast::expr, + exp: &ast::Expr, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { scope_map.insert(exp.id, scope_stack.last().scope_metadata); match exp.node { - ast::expr_self | - ast::expr_lit(_) | - ast::expr_break(_) | - ast::expr_again(_) | - ast::expr_path(_) => (), - - ast::expr_vstore(@ref sub_exp, _) | - ast::expr_cast(@ref sub_exp, _) | - ast::expr_addr_of(_, @ref sub_exp) | - ast::expr_field(@ref sub_exp, _, _) | - ast::expr_paren(@ref sub_exp) => walk_expr(cx, sub_exp, scope_stack, scope_map), - - ast::expr_ret(exp_opt) => match exp_opt { + ast::ExprSelf | + ast::ExprLit(_) | + ast::ExprBreak(_) | + ast::ExprAgain(_) | + ast::ExprPath(_) => (), + + ast::ExprVstore(@ref sub_exp, _) | + ast::ExprCast(@ref sub_exp, _) | + ast::ExprAddrOf(_, @ref sub_exp) | + ast::ExprField(@ref sub_exp, _, _) | + ast::ExprParen(@ref sub_exp) => walk_expr(cx, sub_exp, scope_stack, scope_map), + + ast::ExprRet(exp_opt) => match exp_opt { Some(@ref sub_exp) => walk_expr(cx, sub_exp, scope_stack, scope_map), None => () }, - ast::expr_unary(node_id, _, @ref sub_exp) => { + ast::ExprUnary(node_id, _, @ref sub_exp) => { scope_map.insert(node_id, scope_stack.last().scope_metadata); walk_expr(cx, sub_exp, scope_stack, scope_map); } - ast::expr_assign_op(node_id, _, @ref lhs, @ref rhs) | - ast::expr_index(node_id, @ref lhs, @ref rhs) | - ast::expr_binary(node_id, _, @ref lhs, @ref rhs) => { + ast::ExprAssignOp(node_id, _, @ref lhs, @ref rhs) | + ast::ExprIndex(node_id, @ref lhs, @ref rhs) | + ast::ExprBinary(node_id, _, @ref lhs, @ref rhs) => { scope_map.insert(node_id, scope_stack.last().scope_metadata); walk_expr(cx, lhs, scope_stack, scope_map); walk_expr(cx, rhs, scope_stack, scope_map); } - ast::expr_vec(ref init_expressions, _) | - ast::expr_tup(ref init_expressions) => { + ast::ExprVec(ref init_expressions, _) | + ast::ExprTup(ref init_expressions) => { for &@ref ie in init_expressions.iter() { walk_expr(cx, ie, scope_stack, scope_map); } } - ast::expr_assign(@ref sub_exp1, @ref sub_exp2) | - ast::expr_log(@ref sub_exp1, @ref sub_exp2) | - ast::expr_repeat(@ref sub_exp1, @ref sub_exp2, _) => { + ast::ExprAssign(@ref sub_exp1, @ref sub_exp2) | + ast::ExprLog(@ref sub_exp1, @ref sub_exp2) | + ast::ExprRepeat(@ref sub_exp1, @ref sub_exp2, _) => { walk_expr(cx, sub_exp1, scope_stack, scope_map); walk_expr(cx, sub_exp2, scope_stack, scope_map); } - ast::expr_if(@ref cond_exp, ref then_block, ref opt_else_exp) => { + ast::ExprIf(@ref cond_exp, ref then_block, ref opt_else_exp) => { walk_expr(cx, cond_exp, scope_stack, scope_map); do with_new_scope(cx, then_block.span, scope_stack, scope_map) |cx, @@ -1849,7 +1849,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_while(@ref cond_exp, ref loop_body) => { + ast::ExprWhile(@ref cond_exp, ref loop_body) => { walk_expr(cx, cond_exp, scope_stack, scope_map); do with_new_scope(cx, loop_body.span, scope_stack, scope_map) |cx, @@ -1859,18 +1859,18 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_for_loop(_, _, _) => { + ast::ExprForLoop(_, _, _) => { cx.sess.span_bug(exp.span, "debuginfo::populate_scope_map() - \ Found unexpanded for-loop."); } - ast::expr_mac(_) => { + ast::ExprMac(_) => { cx.sess.span_bug(exp.span, "debuginfo::populate_scope_map() - \ Found unexpanded macro."); } - ast::expr_loop(ref block, _) | - ast::expr_block(ref block) => { + ast::ExprLoop(ref block, _) | + ast::ExprBlock(ref block) => { do with_new_scope(cx, block.span, scope_stack, scope_map) |cx, scope_stack, scope_map| { @@ -1878,7 +1878,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_fn_block(ast::fn_decl { inputs: ref inputs, _ }, ref block) => { + ast::ExprFnBlock(ast::fn_decl { inputs: ref inputs, _ }, ref block) => { do with_new_scope(cx, block.span, scope_stack, scope_map) |cx, scope_stack, scope_map| { @@ -1891,9 +1891,9 @@ fn populate_scope_map(cx: &mut CrateContext, } // ast::expr_loop_body(@ref inner_exp) | - ast::expr_do_body(@ref inner_exp) => { + ast::ExprDoBody(@ref inner_exp) => { let inner_expr_is_expr_fn_block = match *inner_exp { - ast::expr { node: ast::expr_fn_block(*), _ } => true, + ast::Expr { node: ast::ExprFnBlock(*), _ } => true, _ => false }; @@ -1905,7 +1905,7 @@ fn populate_scope_map(cx: &mut CrateContext, walk_expr(cx, inner_exp, scope_stack, scope_map); } - ast::expr_call(@ref fn_exp, ref args, _) => { + ast::ExprCall(@ref fn_exp, ref args, _) => { walk_expr(cx, fn_exp, scope_stack, scope_map); for &@ref arg_exp in args.iter() { @@ -1913,7 +1913,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_method_call(node_id, @ref receiver_exp, _, _, ref args, _) => { + ast::ExprMethodCall(node_id, @ref receiver_exp, _, _, ref args, _) => { scope_map.insert(node_id, scope_stack.last().scope_metadata); walk_expr(cx, receiver_exp, scope_stack, scope_map); @@ -1922,7 +1922,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_match(@ref discriminant_exp, ref arms) => { + ast::ExprMatch(@ref discriminant_exp, ref arms) => { walk_expr(cx, discriminant_exp, scope_stack, scope_map); // for each arm we have to first walk the pattern as these might introduce new @@ -1948,7 +1948,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_struct(_, ref fields, ref base_exp) => { + ast::ExprStruct(_, ref fields, ref base_exp) => { for &ast::Field { expr: @ref exp, _ } in fields.iter() { walk_expr(cx, exp, scope_stack, scope_map); } @@ -1959,7 +1959,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - ast::expr_inline_asm(ast::inline_asm { inputs: ref inputs, + ast::ExprInlineAsm(ast::inline_asm { inputs: ref inputs, outputs: ref outputs, _ }) => { // inputs, outputs: ~[(@str, @expr)] diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 1aedf1ab62358..91f26b25865cb 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -178,7 +178,7 @@ fn drop_and_cancel_clean(bcx: @mut Block, dat: Datum) -> @mut Block { return bcx; } -pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { +pub fn trans_to_datum(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr)); let mut bcx = bcx; @@ -249,7 +249,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { fn auto_slice(bcx: @mut Block, autoderefs: uint, - expr: &ast::expr, + expr: &ast::Expr, datum: Datum) -> DatumBlock { // This is not the most efficient thing possible; since slices // are two words it'd be better if this were compiled in @@ -266,7 +266,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { // this type may have a different region/mutability than the // real one, but it will have the same runtime representation let slice_ty = ty::mk_evec(tcx, - ty::mt { ty: unit_ty, mutbl: ast::m_imm }, + ty::mt { ty: unit_ty, mutbl: ast::MutImmutable }, ty::vstore_slice(ty::re_static)); let scratch = scratch_datum(bcx, slice_ty, "__adjust", false); @@ -275,7 +275,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { DatumBlock {bcx: bcx, datum: scratch} } - fn add_env(bcx: @mut Block, expr: &ast::expr, datum: Datum) -> DatumBlock { + fn add_env(bcx: @mut Block, expr: &ast::Expr, datum: Datum) -> DatumBlock { // This is not the most efficient thing possible; since closures // are two words it'd be better if this were compiled in // 'dest' mode, but I can't find a nice way to structure the @@ -296,7 +296,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { fn auto_slice_and_ref(bcx: @mut Block, autoderefs: uint, - expr: &ast::expr, + expr: &ast::Expr, datum: Datum) -> DatumBlock { let DatumBlock { bcx, datum } = auto_slice(bcx, autoderefs, expr, datum); auto_ref(bcx, datum) @@ -304,7 +304,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { fn auto_borrow_obj(mut bcx: @mut Block, autoderefs: uint, - expr: @ast::expr, + expr: @ast::Expr, source_datum: Datum) -> DatumBlock { let tcx = bcx.tcx(); let target_obj_ty = expr_ty_adjusted(bcx, expr); @@ -395,7 +395,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { } } -pub fn trans_into(bcx: @mut Block, expr: @ast::expr, dest: Dest) -> @mut Block { +pub fn trans_into(bcx: @mut Block, expr: @ast::Expr, dest: Dest) -> @mut Block { if bcx.tcx().adjustments.contains_key(&expr.id) { // use trans_to_datum, which is mildly less efficient but // which will perform the adjustments: @@ -453,7 +453,7 @@ pub fn trans_into(bcx: @mut Block, expr: @ast::expr, dest: Dest) -> @mut Block { }; } -fn trans_lvalue(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { +fn trans_lvalue(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { /*! * * Translates an lvalue expression, always yielding a by-ref @@ -472,7 +472,7 @@ fn trans_lvalue(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { }; } -fn trans_to_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { +fn trans_to_datum_unadjusted(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { /*! * Translates an expression into a datum. If this expression * is an rvalue, this will result in a temporary value being @@ -538,44 +538,44 @@ fn trans_to_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { } } -fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { +fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { let _icx = push_ctxt("trans_rvalue_datum_unadjusted"); trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr))); match expr.node { - ast::expr_path(_) | ast::expr_self => { + ast::ExprPath(_) | ast::ExprSelf => { return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id)); } - ast::expr_vstore(contents, ast::expr_vstore_box) | - ast::expr_vstore(contents, ast::expr_vstore_mut_box) => { + ast::ExprVstore(contents, ast::ExprVstoreBox) | + ast::ExprVstore(contents, ast::ExprVstoreMutBox) => { return tvec::trans_uniq_or_managed_vstore(bcx, heap_managed, expr, contents); } - ast::expr_vstore(contents, ast::expr_vstore_uniq) => { + ast::ExprVstore(contents, ast::ExprVstoreUniq) => { let heap = heap_for_unique(bcx, expr_ty(bcx, contents)); return tvec::trans_uniq_or_managed_vstore(bcx, heap, expr, contents); } - ast::expr_lit(lit) => { + ast::ExprLit(lit) => { return trans_immediate_lit(bcx, expr, *lit); } - ast::expr_binary(_, op, lhs, rhs) => { + ast::ExprBinary(_, op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr assert!(!bcx.ccx().maps.method_map.contains_key(&expr.id)); return trans_binary(bcx, expr, op, lhs, rhs); } - ast::expr_unary(_, op, x) => { + ast::ExprUnary(_, op, x) => { return trans_unary_datum(bcx, expr, op, x); } - ast::expr_addr_of(_, x) => { + ast::ExprAddrOf(_, x) => { return trans_addr_of(bcx, expr, x); } - ast::expr_cast(val, _) => { + ast::ExprCast(val, _) => { return trans_imm_cast(bcx, val, expr.id); } - ast::expr_paren(e) => { + ast::ExprParen(e) => { return trans_rvalue_datum_unadjusted(bcx, e); } _ => { @@ -588,7 +588,7 @@ fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBloc } } -fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::expr) -> @mut Block { +fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::Expr) -> @mut Block { let mut bcx = bcx; let _icx = push_ctxt("trans_rvalue_stmt"); @@ -599,25 +599,25 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::expr) -> @mut Block trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr))); match expr.node { - ast::expr_break(label_opt) => { + ast::ExprBreak(label_opt) => { return controlflow::trans_break(bcx, label_opt); } - ast::expr_again(label_opt) => { + ast::ExprAgain(label_opt) => { return controlflow::trans_cont(bcx, label_opt); } - ast::expr_ret(ex) => { + ast::ExprRet(ex) => { return controlflow::trans_ret(bcx, ex); } - ast::expr_log(lvl, a) => { + ast::ExprLog(lvl, a) => { return controlflow::trans_log(expr, lvl, bcx, a); } - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { return controlflow::trans_while(bcx, cond, body); } - ast::expr_loop(ref body, opt_label) => { + ast::ExprLoop(ref body, opt_label) => { return controlflow::trans_loop(bcx, body, opt_label); } - ast::expr_assign(dst, src) => { + ast::ExprAssign(dst, src) => { let src_datum = unpack_datum!( bcx, trans_to_datum(bcx, src)); let dst_datum = unpack_datum!( @@ -625,13 +625,13 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::expr) -> @mut Block return src_datum.store_to_datum( bcx, DROP_EXISTING, dst_datum); } - ast::expr_assign_op(callee_id, op, dst, src) => { + ast::ExprAssignOp(callee_id, op, dst, src) => { return trans_assign_op(bcx, expr, callee_id, op, dst, src); } - ast::expr_paren(a) => { + ast::ExprParen(a) => { return trans_rvalue_stmt_unadjusted(bcx, a); } - ast::expr_inline_asm(ref a) => { + ast::ExprInlineAsm(ref a) => { return asm::trans_inline_asm(bcx, a); } _ => { @@ -644,7 +644,7 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::expr) -> @mut Block }; } -fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, +fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::Expr, dest: Dest) -> @mut Block { let _icx = push_ctxt("trans_rvalue_dps_unadjusted"); let tcx = bcx.tcx(); @@ -652,45 +652,45 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr))); match expr.node { - ast::expr_paren(e) => { + ast::ExprParen(e) => { return trans_rvalue_dps_unadjusted(bcx, e, dest); } - ast::expr_path(_) | ast::expr_self => { + ast::ExprPath(_) | ast::ExprSelf => { return trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest); } - ast::expr_if(cond, ref thn, els) => { + ast::ExprIf(cond, ref thn, els) => { return controlflow::trans_if(bcx, cond, thn, els, dest); } - ast::expr_match(discr, ref arms) => { + ast::ExprMatch(discr, ref arms) => { return _match::trans_match(bcx, expr, discr, *arms, dest); } - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { return do base::with_scope(bcx, blk.info(), "block-expr body") |bcx| { controlflow::trans_block(bcx, blk, dest) }; } - ast::expr_struct(_, ref fields, base) => { + ast::ExprStruct(_, ref fields, base) => { return trans_rec_or_struct(bcx, (*fields), base, expr.span, expr.id, dest); } - ast::expr_tup(ref args) => { + ast::ExprTup(ref args) => { let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr)); - let numbered_fields: ~[(uint, @ast::expr)] = + let numbered_fields: ~[(uint, @ast::Expr)] = args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect(); return trans_adt(bcx, repr, 0, numbered_fields, None, dest); } - ast::expr_lit(@codemap::Spanned {node: ast::lit_str(s), _}) => { + ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s), _}) => { return tvec::trans_lit_str(bcx, expr, s, dest); } - ast::expr_vstore(contents, ast::expr_vstore_slice) | - ast::expr_vstore(contents, ast::expr_vstore_mut_slice) => { + ast::ExprVstore(contents, ast::ExprVstoreSlice) | + ast::ExprVstore(contents, ast::ExprVstoreMutSlice) => { return tvec::trans_slice_vstore(bcx, expr, contents, dest); } - ast::expr_vec(*) | ast::expr_repeat(*) => { + ast::ExprVec(*) | ast::ExprRepeat(*) => { return tvec::trans_fixed_vstore(bcx, expr, expr, dest); } - ast::expr_fn_block(ref decl, ref body) => { + ast::ExprFnBlock(ref decl, ref body) => { let expr_ty = expr_ty(bcx, expr); let sigil = ty::ty_closure_sigil(expr_ty); debug!("translating fn_block %s with type %s", @@ -699,14 +699,14 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, return closure::trans_expr_fn(bcx, sigil, decl, body, expr.id, expr.id, dest); } - ast::expr_do_body(blk) => { + ast::ExprDoBody(blk) => { return trans_into(bcx, blk, dest); } - ast::expr_call(f, ref args, _) => { + ast::ExprCall(f, ref args, _) => { return callee::trans_call( bcx, expr, f, callee::ArgExprs(*args), expr.id, dest); } - ast::expr_method_call(callee_id, rcvr, _, _, ref args, _) => { + ast::ExprMethodCall(callee_id, rcvr, _, _, ref args, _) => { return callee::trans_method_call(bcx, expr, callee_id, @@ -714,7 +714,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, callee::ArgExprs(*args), dest); } - ast::expr_binary(callee_id, _, lhs, rhs) => { + ast::ExprBinary(callee_id, _, lhs, rhs) => { // if not overloaded, would be RvalueDatumExpr return trans_overloaded_op(bcx, expr, @@ -724,7 +724,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, expr_ty(bcx, expr), dest); } - ast::expr_unary(callee_id, _, subexpr) => { + ast::ExprUnary(callee_id, _, subexpr) => { // if not overloaded, would be RvalueDatumExpr return trans_overloaded_op(bcx, expr, @@ -734,7 +734,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, expr_ty(bcx, expr), dest); } - ast::expr_index(callee_id, base, idx) => { + ast::ExprIndex(callee_id, base, idx) => { // if not overloaded, would be RvalueDatumExpr return trans_overloaded_op(bcx, expr, @@ -744,7 +744,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, expr_ty(bcx, expr), dest); } - ast::expr_cast(val, _) => { + ast::ExprCast(val, _) => { match ty::get(node_id_type(bcx, expr.id)).sty { ty::ty_trait(_, _, store, _, _) => { return meth::trans_trait_cast(bcx, val, expr.id, dest, @@ -756,7 +756,7 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, } } } - ast::expr_assign_op(callee_id, op, dst, src) => { + ast::ExprAssignOp(callee_id, op, dst, src) => { return trans_assign_op(bcx, expr, callee_id, op, dst, src); } _ => { @@ -768,8 +768,8 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr, } } -fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr, - def: ast::def, dest: Dest) -> @mut Block { +fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::Expr, + def: ast::Def, dest: Dest) -> @mut Block { let _icx = push_ctxt("trans_def_dps_unadjusted"); let ccx = bcx.ccx(); @@ -779,7 +779,7 @@ fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr, }; match def { - ast::def_variant(tid, vid) => { + ast::DefVariant(tid, vid) => { let variant_info = ty::enum_variant_with_id(ccx.tcx, tid, vid); if variant_info.args.len() > 0u { // N-ary variant. @@ -795,7 +795,7 @@ fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr, return bcx; } } - ast::def_struct(def_id) => { + ast::DefStruct(def_id) => { let ty = expr_ty(bcx, ref_expr); match ty::get(ty).sty { ty::ty_struct(did, _) if ty::has_dtor(ccx.tcx, did) => { @@ -819,17 +819,17 @@ fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr, } fn trans_def_datum_unadjusted(bcx: @mut Block, - ref_expr: &ast::expr, - def: ast::def) -> DatumBlock + ref_expr: &ast::Expr, + def: ast::Def) -> DatumBlock { let _icx = push_ctxt("trans_def_datum_unadjusted"); let fn_data = match def { - ast::def_fn(did, _) | - ast::def_static_method(did, ast::FromImpl(_), _) => { + ast::DefFn(did, _) | + ast::DefStaticMethod(did, ast::FromImpl(_), _) => { callee::trans_fn_ref(bcx, did, ref_expr.id) } - ast::def_static_method(impl_did, ast::FromTrait(trait_did), _) => { + ast::DefStaticMethod(impl_did, ast::FromTrait(trait_did), _) => { meth::trans_static_method_callee(bcx, impl_did, trait_did, @@ -853,7 +853,7 @@ fn trans_def_datum_unadjusted(bcx: @mut Block, } } -fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { +fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::Expr) -> DatumBlock { /*! * * Translates an lvalue expression, always yielding a by-ref @@ -868,19 +868,19 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr))); return match expr.node { - ast::expr_paren(e) => { + ast::ExprParen(e) => { trans_lvalue_unadjusted(bcx, e) } - ast::expr_path(_) | ast::expr_self => { + ast::ExprPath(_) | ast::ExprSelf => { trans_def_lvalue(bcx, expr, bcx.def(expr.id)) } - ast::expr_field(base, ident, _) => { + ast::ExprField(base, ident, _) => { trans_rec_field(bcx, base, ident) } - ast::expr_index(_, base, idx) => { + ast::ExprIndex(_, base, idx) => { trans_index(bcx, expr, base, idx) } - ast::expr_unary(_, ast::deref, base) => { + ast::ExprUnary(_, ast::UnDeref, base) => { let basedatum = unpack_datum!(bcx, trans_to_datum(bcx, base)); basedatum.deref(bcx, expr, 0) } @@ -893,7 +893,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { }; fn trans_rec_field(bcx: @mut Block, - base: @ast::expr, + base: @ast::Expr, field: ast::Ident) -> DatumBlock { //! Translates `base.field`. @@ -916,9 +916,9 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { } fn trans_index(bcx: @mut Block, - index_expr: &ast::expr, - base: @ast::expr, - idx: @ast::expr) -> DatumBlock { + index_expr: &ast::Expr, + base: @ast::Expr, + idx: @ast::Expr) -> DatumBlock { //! Translates `base[idx]`. let _icx = push_ctxt("trans_index"); @@ -973,18 +973,18 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { } fn trans_def_lvalue(bcx: @mut Block, - ref_expr: &ast::expr, - def: ast::def) + ref_expr: &ast::Expr, + def: ast::Def) -> DatumBlock { //! Translates a reference to a path. let _icx = push_ctxt("trans_def_lvalue"); match def { - ast::def_static(did, _) => { + ast::DefStatic(did, _) => { let const_ty = expr_ty(bcx, ref_expr); - fn get_val(bcx: @mut Block, did: ast::def_id, const_ty: ty::t) + fn get_val(bcx: @mut Block, did: ast::DefId, const_ty: ty::t) -> ValueRef { // For external constants, we don't inline. if did.crate == ast::LOCAL_CRATE { @@ -1041,11 +1041,11 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock { } } -pub fn trans_local_var(bcx: @mut Block, def: ast::def) -> Datum { +pub fn trans_local_var(bcx: @mut Block, def: ast::Def) -> Datum { let _icx = push_ctxt("trans_local_var"); return match def { - ast::def_upvar(nid, _, _, _) => { + ast::DefUpvar(nid, _, _, _) => { // Can't move upvars, so this is never a ZeroMemLastUse. let local_ty = node_id_type(bcx, nid); match bcx.fcx.llupvars.find(&nid) { @@ -1062,13 +1062,13 @@ pub fn trans_local_var(bcx: @mut Block, def: ast::def) -> Datum { } } } - ast::def_arg(nid, _) => { + ast::DefArg(nid, _) => { take_local(bcx, bcx.fcx.llargs, nid) } - ast::def_local(nid, _) | ast::def_binding(nid, _) => { + ast::DefLocal(nid, _) | ast::DefBinding(nid, _) => { take_local(bcx, bcx.fcx.lllocals, nid) } - ast::def_self(nid) => { + ast::DefSelf(nid) => { let self_info: ValSelfData = match bcx.fcx.llself { Some(ref self_info) => *self_info, None => { @@ -1137,7 +1137,7 @@ pub fn with_field_tys(tcx: ty::ctxt, } Some(node_id) => { match tcx.def_map.get_copy(&node_id) { - ast::def_variant(enum_id, variant_id) => { + ast::DefVariant(enum_id, variant_id) => { let variant_info = ty::enum_variant_with_id( tcx, enum_id, variant_id); op(variant_info.disr_val, @@ -1162,7 +1162,7 @@ pub fn with_field_tys(tcx: ty::ctxt, fn trans_rec_or_struct(bcx: @mut Block, fields: &[ast::Field], - base: Option<@ast::expr>, + base: Option<@ast::Expr>, expr_span: codemap::Span, id: ast::NodeId, dest: Dest) -> @mut Block @@ -1222,7 +1222,7 @@ fn trans_rec_or_struct(bcx: @mut Block, */ struct StructBaseInfo { /// The base expression; will be evaluated after all explicit fields. - expr: @ast::expr, + expr: @ast::Expr, /// The indices of fields to copy paired with their types. fields: ~[(uint, ty::t)] } @@ -1238,7 +1238,7 @@ struct StructBaseInfo { * which remaining fields are copied; see comments on `StructBaseInfo`. */ fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: ty::Disr, - fields: &[(uint, @ast::expr)], + fields: &[(uint, @ast::Expr)], optbase: Option, dest: Dest) -> @mut Block { let _icx = push_ctxt("trans_adt"); @@ -1285,7 +1285,7 @@ fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: ty::Disr, } -fn trans_immediate_lit(bcx: @mut Block, expr: @ast::expr, +fn trans_immediate_lit(bcx: @mut Block, expr: @ast::Expr, lit: ast::lit) -> DatumBlock { // must not be a string constant, that is a RvalueDpsExpr let _icx = push_ctxt("trans_immediate_lit"); @@ -1294,13 +1294,13 @@ fn trans_immediate_lit(bcx: @mut Block, expr: @ast::expr, } fn trans_unary_datum(bcx: @mut Block, - un_expr: &ast::expr, - op: ast::unop, - sub_expr: @ast::expr) -> DatumBlock { + un_expr: &ast::Expr, + op: ast::UnOp, + sub_expr: @ast::Expr) -> DatumBlock { let _icx = push_ctxt("trans_unary_datum"); // if deref, would be LvalueExpr - assert!(op != ast::deref); + assert!(op != ast::UnDeref); // if overloaded, would be RvalueDpsExpr assert!(!bcx.ccx().maps.method_map.contains_key(&un_expr.id)); @@ -1309,7 +1309,7 @@ fn trans_unary_datum(bcx: @mut Block, let sub_ty = expr_ty(bcx, sub_expr); return match op { - ast::not => { + ast::UnNot => { let Result {bcx, val} = trans_to_datum(bcx, sub_expr).to_result(); // If this is a boolean type, we must not use the LLVM Not @@ -1327,7 +1327,7 @@ fn trans_unary_datum(bcx: @mut Block, }; immediate_rvalue_bcx(bcx, llresult, un_ty) } - ast::neg => { + ast::UnNeg => { let Result {bcx, val} = trans_to_datum(bcx, sub_expr).to_result(); let llneg = { if ty::type_is_fp(un_ty) { @@ -1338,15 +1338,15 @@ fn trans_unary_datum(bcx: @mut Block, }; immediate_rvalue_bcx(bcx, llneg, un_ty) } - ast::box(_) => { + ast::UnBox(_) => { trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap_managed) } - ast::uniq => { + ast::UnUniq => { let heap = heap_for_unique(bcx, un_ty); trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap) } - ast::deref => { + ast::UnDeref => { bcx.sess().bug("deref expressions should have been \ translated using trans_lvalue(), not \ trans_unary_datum()") @@ -1355,7 +1355,7 @@ fn trans_unary_datum(bcx: @mut Block, fn trans_boxed_expr(bcx: @mut Block, box_ty: ty::t, - contents: @ast::expr, + contents: @ast::Expr, contents_ty: ty::t, heap: heap) -> DatumBlock { let _icx = push_ctxt("trans_boxed_expr"); @@ -1379,8 +1379,8 @@ fn trans_unary_datum(bcx: @mut Block, } } -fn trans_addr_of(bcx: @mut Block, expr: &ast::expr, - subexpr: @ast::expr) -> DatumBlock { +fn trans_addr_of(bcx: @mut Block, expr: &ast::Expr, + subexpr: @ast::Expr) -> DatumBlock { let _icx = push_ctxt("trans_addr_of"); let mut bcx = bcx; let sub_datum = unpack_datum!(bcx, trans_to_datum(bcx, subexpr)); @@ -1391,9 +1391,9 @@ fn trans_addr_of(bcx: @mut Block, expr: &ast::expr, // Important to get types for both lhs and rhs, because one might be _|_ // and the other not. fn trans_eager_binop(bcx: @mut Block, - binop_expr: &ast::expr, + binop_expr: &ast::Expr, binop_ty: ty::t, - op: ast::binop, + op: ast::BinOp, lhs_datum: &Datum, rhs_datum: &Datum) -> DatumBlock { @@ -1420,19 +1420,19 @@ fn trans_eager_binop(bcx: @mut Block, let mut bcx = bcx; let val = match op { - ast::add => { + ast::BiAdd => { if is_float { FAdd(bcx, lhs, rhs) } else { Add(bcx, lhs, rhs) } } - ast::subtract => { + ast::BiSub => { if is_float { FSub(bcx, lhs, rhs) } else { Sub(bcx, lhs, rhs) } } - ast::mul => { + ast::BiMul => { if is_float { FMul(bcx, lhs, rhs) } else { Mul(bcx, lhs, rhs) } } - ast::div => { + ast::BiDiv => { if is_float { FDiv(bcx, lhs, rhs) } else { @@ -1446,7 +1446,7 @@ fn trans_eager_binop(bcx: @mut Block, } } } - ast::rem => { + ast::BiRem => { if is_float { FRem(bcx, lhs, rhs) } else { @@ -1460,16 +1460,16 @@ fn trans_eager_binop(bcx: @mut Block, } } } - ast::bitor => Or(bcx, lhs, rhs), - ast::bitand => And(bcx, lhs, rhs), - ast::bitxor => Xor(bcx, lhs, rhs), - ast::shl => Shl(bcx, lhs, rhs), - ast::shr => { + ast::BiBitOr => Or(bcx, lhs, rhs), + ast::BiBitAnd => And(bcx, lhs, rhs), + ast::BiBitXor => Xor(bcx, lhs, rhs), + ast::BiShl => Shl(bcx, lhs, rhs), + ast::BiShr => { if signed { AShr(bcx, lhs, rhs) } else { LShr(bcx, lhs, rhs) } } - ast::eq | ast::ne | ast::lt | ast::ge | ast::le | ast::gt => { + ast::BiEq | ast::BiNe | ast::BiLt | ast::BiGe | ast::BiLe | ast::BiGt => { if ty::type_is_bot(rhs_t) { C_bool(false) } else { @@ -1494,10 +1494,10 @@ fn trans_eager_binop(bcx: @mut Block, enum lazy_binop_ty { lazy_and, lazy_or } fn trans_lazy_binop(bcx: @mut Block, - binop_expr: &ast::expr, + binop_expr: &ast::Expr, op: lazy_binop_ty, - a: @ast::expr, - b: @ast::expr) -> DatumBlock { + a: @ast::Expr, + b: @ast::Expr) -> DatumBlock { let _icx = push_ctxt("trans_lazy_binop"); let binop_ty = expr_ty(bcx, binop_expr); let bcx = bcx; @@ -1539,18 +1539,18 @@ fn trans_lazy_binop(bcx: @mut Block, } fn trans_binary(bcx: @mut Block, - binop_expr: &ast::expr, - op: ast::binop, - lhs: @ast::expr, - rhs: @ast::expr) -> DatumBlock + binop_expr: &ast::Expr, + op: ast::BinOp, + lhs: @ast::Expr, + rhs: @ast::Expr) -> DatumBlock { let _icx = push_ctxt("trans_binary"); match op { - ast::and => { + ast::BiAnd => { trans_lazy_binop(bcx, binop_expr, lazy_and, lhs, rhs) } - ast::or => { + ast::BiOr => { trans_lazy_binop(bcx, binop_expr, lazy_or, lhs, rhs) } _ => { @@ -1565,10 +1565,10 @@ fn trans_binary(bcx: @mut Block, } fn trans_overloaded_op(bcx: @mut Block, - expr: &ast::expr, + expr: &ast::Expr, callee_id: ast::NodeId, - rcvr: @ast::expr, - args: ~[@ast::expr], + rcvr: @ast::Expr, + args: ~[@ast::Expr], ret_ty: ty::t, dest: Dest) -> @mut Block { @@ -1642,7 +1642,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind { } } -fn trans_imm_cast(bcx: @mut Block, expr: @ast::expr, +fn trans_imm_cast(bcx: @mut Block, expr: @ast::Expr, id: ast::NodeId) -> DatumBlock { let _icx = push_ctxt("trans_cast"); let ccx = bcx.ccx(); @@ -1711,11 +1711,11 @@ fn trans_imm_cast(bcx: @mut Block, expr: @ast::expr, } fn trans_assign_op(bcx: @mut Block, - expr: @ast::expr, + expr: @ast::Expr, callee_id: ast::NodeId, - op: ast::binop, - dst: @ast::expr, - src: @ast::expr) -> @mut Block + op: ast::BinOp, + dst: @ast::Expr, + src: @ast::Expr) -> @mut Block { let _icx = push_ctxt("trans_assign_op"); let mut bcx = bcx; diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 9acc3018046b3..a305e3aa6b8b3 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -400,8 +400,8 @@ pub fn make_free_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block { } } -pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id, - class_did: ast::def_id, substs: &ty::substs) -> @mut Block { +pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId, + class_did: ast::DefId, substs: &ty::substs) -> @mut Block { let repr = adt::represent_type(bcx.ccx(), t); let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0); do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| { @@ -438,8 +438,8 @@ pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: } } -pub fn trans_struct_drop(mut bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id, - class_did: ast::def_id, substs: &ty::substs) -> @mut Block { +pub fn trans_struct_drop(mut bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId, + class_did: ast::DefId, substs: &ty::substs) -> @mut Block { let repr = adt::represent_type(bcx.ccx(), t); // Find and call the actual destructor diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index 3b1fd0ecb6952..cfc9c8a2e17cf 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -22,8 +22,8 @@ use syntax::ast; use syntax::ast_map::path_name; use syntax::ast_util::local_def; -pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::def_id) - -> ast::def_id { +pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId) + -> ast::DefId { let _icx = push_ctxt("maybe_instantiate_inline"); match ccx.external.find(&fn_id) { Some(&Some(node_id)) => { diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index fa10b8a8e4493..76cb943c6ed75 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -138,7 +138,7 @@ pub fn trans_method(ccx: @mut CrateContext, } pub fn trans_self_arg(bcx: @mut Block, - base: @ast::expr, + base: @ast::Expr, temp_cleanups: &mut ~[ValueRef], mentry: typeck::method_map_entry) -> Result { let _icx = push_ctxt("impl::trans_self_arg"); @@ -155,7 +155,7 @@ pub fn trans_self_arg(bcx: @mut Block, pub fn trans_method_callee(bcx: @mut Block, callee_id: ast::NodeId, - this: @ast::expr, + this: @ast::Expr, mentry: typeck::method_map_entry) -> Callee { let _icx = push_ctxt("impl::trans_method_callee"); @@ -212,8 +212,8 @@ pub fn trans_method_callee(bcx: @mut Block, } pub fn trans_static_method_callee(bcx: @mut Block, - method_id: ast::def_id, - trait_id: ast::def_id, + method_id: ast::DefId, + trait_id: ast::DefId, callee_id: ast::NodeId) -> FnData { let _icx = push_ctxt("impl::trans_static_method_callee"); @@ -293,8 +293,8 @@ pub fn trans_static_method_callee(bcx: @mut Block, } pub fn method_with_name(ccx: &mut CrateContext, - impl_id: ast::def_id, - name: ast::Ident) -> ast::def_id { + impl_id: ast::DefId, + name: ast::Ident) -> ast::DefId { let meth_id_opt = ccx.impl_method_cache.find_copy(&(impl_id, name)); match meth_id_opt { Some(m) => return m, @@ -312,9 +312,9 @@ pub fn method_with_name(ccx: &mut CrateContext, pub fn trans_monomorphized_callee(bcx: @mut Block, callee_id: ast::NodeId, - base: @ast::expr, + base: @ast::Expr, mentry: typeck::method_map_entry, - trait_id: ast::def_id, + trait_id: ast::DefId, n_method: uint, vtbl: typeck::vtable_origin) -> Callee { @@ -368,7 +368,7 @@ pub fn trans_monomorphized_callee(bcx: @mut Block, } pub fn combine_impl_and_methods_tps(bcx: @mut Block, - mth_did: ast::def_id, + mth_did: ast::DefId, callee_id: ast::NodeId, rcvr_substs: &[ty::t], rcvr_origins: typeck::vtable_res) @@ -419,7 +419,7 @@ pub fn combine_impl_and_methods_tps(bcx: @mut Block, pub fn trans_trait_callee(bcx: @mut Block, callee_id: ast::NodeId, n_method: uint, - self_expr: @ast::expr) + self_expr: @ast::Expr) -> Callee { /*! * Create a method callee where the method is coming from a trait @@ -580,7 +580,7 @@ pub fn make_vtable(ccx: &mut CrateContext, } fn emit_vtable_methods(bcx: @mut Block, - impl_id: ast::def_id, + impl_id: ast::DefId, substs: &[ty::t], vtables: typeck::vtable_res) -> ~[ValueRef] { @@ -621,7 +621,7 @@ fn emit_vtable_methods(bcx: @mut Block, } pub fn trans_trait_cast(bcx: @mut Block, - val: @ast::expr, + val: @ast::Expr, id: ast::NodeId, dest: expr::Dest, _store: ty::TraitStore) diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 162765350da07..0c0d3b7275bc5 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -35,7 +35,7 @@ use syntax::ast_map::path_name; use syntax::ast_util::local_def; pub fn monomorphic_fn(ccx: @mut CrateContext, - fn_id: ast::def_id, + fn_id: ast::DefId, real_substs: &ty::substs, vtables: Option, self_vtables: Option, @@ -296,7 +296,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext, } pub fn make_mono_id(ccx: @mut CrateContext, - item: ast::def_id, + item: ast::DefId, substs: ¶m_substs, param_uses: Option<@~[type_use::type_uses]>) -> mono_id { // FIXME (possibly #5801): Need a lot of type hints to get diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 45f2830dafee9..b83ddf27dba83 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -27,7 +27,7 @@ use util::ppaux::ty_to_str; use std::libc::c_uint; use std::option::None; use std::vec; -use syntax::ast::def_id; +use syntax::ast::DefId; use syntax::ast; use syntax::ast_map::path_name; use syntax::parse::token::special_idents; @@ -283,7 +283,8 @@ impl Reflector { let variants = ty::substd_enum_variants(ccx.tcx, did, substs); let llptrty = type_of(ccx, t).ptr_to(); let opaquety = ty::get_opaque_ty(ccx.tcx).unwrap(); - let opaqueptrty = ty::mk_ptr(ccx.tcx, ty::mt { ty: opaquety, mutbl: ast::m_imm }); + let opaqueptrty = ty::mk_ptr(ccx.tcx, ty::mt { ty: opaquety, + mutbl: ast::MutImmutable }); let make_get_disr = || { let sub_path = bcx.fcx.path + &[path_name(special_idents::anon)]; @@ -384,7 +385,7 @@ impl Reflector { pub fn emit_calls_to_trait_visit_ty(bcx: @mut Block, t: ty::t, visitor_val: ValueRef, - visitor_trait_id: def_id) + visitor_trait_id: DefId) -> @mut Block { let final = sub_block(bcx, "final"); let tydesc_ty = ty::get_tydesc_ty(bcx.ccx().tcx).unwrap(); diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 59f5c9d0723a8..e38831cd5d77e 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -158,8 +158,8 @@ impl VecTypes { } pub fn trans_fixed_vstore(bcx: @mut Block, - vstore_expr: @ast::expr, - content_expr: &ast::expr, + vstore_expr: @ast::Expr, + content_expr: &ast::Expr, dest: expr::Dest) -> @mut Block { //! @@ -187,8 +187,8 @@ pub fn trans_fixed_vstore(bcx: @mut Block, } pub fn trans_slice_vstore(bcx: @mut Block, - vstore_expr: @ast::expr, - content_expr: @ast::expr, + vstore_expr: @ast::Expr, + content_expr: @ast::Expr, dest: expr::Dest) -> @mut Block { //! @@ -205,7 +205,7 @@ pub fn trans_slice_vstore(bcx: @mut Block, // Handle the &"..." case: match content_expr.node { - ast::expr_lit(@codemap::Spanned {node: ast::lit_str(s), span: _}) => { + ast::ExprLit(@codemap::Spanned {node: ast::lit_str(s), span: _}) => { return trans_lit_str(bcx, content_expr, s, dest); } _ => {} @@ -222,7 +222,7 @@ pub fn trans_slice_vstore(bcx: @mut Block, // Arrange for the backing array to be cleaned up. let fixed_ty = ty::mk_evec(bcx.tcx(), - ty::mt {ty: vt.unit_ty, mutbl: ast::m_mutbl}, + ty::mt {ty: vt.unit_ty, mutbl: ast::MutMutable}, ty::vstore_fixed(count)); let llfixed_ty = type_of::type_of(bcx.ccx(), fixed_ty).ptr_to(); let llfixed_casted = BitCast(bcx, llfixed, llfixed_ty); @@ -246,7 +246,7 @@ pub fn trans_slice_vstore(bcx: @mut Block, } pub fn trans_lit_str(bcx: @mut Block, - lit_expr: @ast::expr, + lit_expr: @ast::Expr, str_lit: @str, dest: Dest) -> @mut Block { @@ -280,8 +280,8 @@ pub fn trans_lit_str(bcx: @mut Block, } -pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @ast::expr, - content_expr: &ast::expr) -> DatumBlock { +pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @ast::Expr, + content_expr: &ast::Expr) -> DatumBlock { //! // // @[...] or ~[...] (also @"..." or ~"...") allocate boxes in the @@ -295,7 +295,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @a match heap { heap_exchange => { match content_expr.node { - ast::expr_lit(@codemap::Spanned { + ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s), span }) => { let llptrval = C_cstr(bcx.ccx(), s); @@ -343,8 +343,8 @@ pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @a pub fn write_content(bcx: @mut Block, vt: &VecTypes, - vstore_expr: @ast::expr, - content_expr: &ast::expr, + vstore_expr: @ast::Expr, + content_expr: &ast::Expr, dest: Dest) -> @mut Block { let _icx = push_ctxt("tvec::write_content"); @@ -357,7 +357,7 @@ pub fn write_content(bcx: @mut Block, let _indenter = indenter(); match content_expr.node { - ast::expr_lit(@codemap::Spanned { node: ast::lit_str(s), _ }) => { + ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s), _ }) => { match dest { Ignore => { return bcx; @@ -371,7 +371,7 @@ pub fn write_content(bcx: @mut Block, } } } - ast::expr_vec(ref elements, _) => { + ast::ExprVec(ref elements, _) => { match dest { Ignore => { for element in elements.iter() { @@ -397,7 +397,7 @@ pub fn write_content(bcx: @mut Block, } return bcx; } - ast::expr_repeat(element, count_expr, _) => { + ast::ExprRepeat(element, count_expr, _) => { match dest { Ignore => { return expr::trans_into(bcx, element, Ignore); @@ -469,7 +469,7 @@ pub fn write_content(bcx: @mut Block, } } -pub fn vec_types_from_expr(bcx: @mut Block, vec_expr: &ast::expr) -> VecTypes { +pub fn vec_types_from_expr(bcx: @mut Block, vec_expr: &ast::Expr) -> VecTypes { let vec_ty = node_id_type(bcx, vec_expr.id); vec_types(bcx, vec_ty) } @@ -486,15 +486,15 @@ pub fn vec_types(bcx: @mut Block, vec_ty: ty::t) -> VecTypes { llunit_size: llunit_size} } -pub fn elements_required(bcx: @mut Block, content_expr: &ast::expr) -> uint { +pub fn elements_required(bcx: @mut Block, content_expr: &ast::Expr) -> uint { //! Figure out the number of elements we need to store this content match content_expr.node { - ast::expr_lit(@codemap::Spanned { node: ast::lit_str(s), _ }) => { + ast::ExprLit(@codemap::Spanned { node: ast::lit_str(s), _ }) => { s.len() }, - ast::expr_vec(ref es, _) => es.len(), - ast::expr_repeat(_, count_expr, _) => { + ast::ExprVec(ref es, _) => es.len(), + ast::ExprRepeat(_, count_expr, _) => { ty::eval_repeat_count(&bcx.tcx(), count_expr) } _ => bcx.tcx().sess.span_bug(content_expr.span, diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 6a57827e6d1c6..3fc5bcc8f7bc8 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -324,7 +324,7 @@ pub enum named_ty { a_struct, an_enum } pub fn llvm_type_name(cx: &CrateContext, what: named_ty, - did: ast::def_id, + did: ast::DefId, tps: &[ty::t]) -> ~str { let name = match what { a_struct => { "struct" } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index bf65986b5ba9b..1a51cdfb60e01 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -57,10 +57,10 @@ pub struct Context { uses: @mut ~[type_uses] } -pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint) +pub fn type_uses_for(ccx: @mut CrateContext, fn_id: DefId, n_tps: uint) -> @~[type_uses] { - fn store_type_uses(cx: Context, fn_id: def_id) -> @~[type_uses] { + fn store_type_uses(cx: Context, fn_id: DefId) -> @~[type_uses] { let Context { uses, ccx } = cx; let uses = @(*uses).clone(); // freeze ccx.type_use_cache.insert(fn_id, uses); @@ -231,7 +231,7 @@ pub fn type_needs(cx: &Context, use_: uint, ty: ty::t) { pub fn type_needs_inner(cx: &Context, use_: uint, ty: ty::t, - enums_seen: @List) { + enums_seen: @List) { do ty::maybe_walk_ty(ty) |ty| { if ty::type_has_params(ty) { match ty::get(ty).sty { @@ -311,14 +311,14 @@ pub fn mark_for_method_call(cx: &Context, e_id: NodeId, callee_id: NodeId) { } } -pub fn mark_for_expr(cx: &Context, e: &expr) { +pub fn mark_for_expr(cx: &Context, e: &Expr) { match e.node { - expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) | - expr_unary(_, box(_), _) | expr_unary(_, uniq, _) | - expr_binary(_, add, _, _) | expr_repeat(*) => { + ExprVstore(_, _) | ExprVec(_, _) | ExprStruct(*) | ExprTup(_) | + ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) | + ExprBinary(_, BiAdd, _, _) | ExprRepeat(*) => { node_type_needs(cx, use_repr, e.id); } - expr_cast(base, _) => { + ExprCast(base, _) => { let result_t = ty::node_id_to_type(cx.ccx.tcx, e.id); match ty::get(result_t).sty { ty::ty_trait(*) => { @@ -329,15 +329,15 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { _ => () } } - expr_binary(_, op, lhs, _) => { + ExprBinary(_, op, lhs, _) => { match op { - eq | lt | le | ne | ge | gt => { + BiEq | BiLt | BiLe | BiNe | BiGe | BiGt => { node_type_needs(cx, use_tydesc, lhs.id) } _ => () } } - expr_path(_) | expr_self => { + ExprPath(_) | ExprSelf => { let opt_ts = cx.ccx.tcx.node_type_substs.find_copy(&e.id); for ts in opt_ts.iter() { let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get_copy(&e.id)); @@ -347,7 +347,7 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { } } } - expr_fn_block(*) => { + ExprFnBlock(*) => { match ty::ty_closure_sigil(ty::expr_ty(cx.ccx.tcx, e)) { ast::OwnedSigil => {} ast::BorrowedSigil | ast::ManagedSigil => { @@ -358,18 +358,18 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { } } } - expr_assign(val, _) | expr_assign_op(_, _, val, _) | - expr_ret(Some(val)) => { + ExprAssign(val, _) | ExprAssignOp(_, _, val, _) | + ExprRet(Some(val)) => { node_type_needs(cx, use_repr, val.id); } - expr_index(callee_id, base, _) => { + ExprIndex(callee_id, base, _) => { // FIXME (#2537): could be more careful and not count fields after // the chosen field. let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id); type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); mark_for_method_call(cx, e.id, callee_id); } - expr_field(base, _, _) => { + ExprField(base, _, _) => { // Method calls are now a special syntactic form, // so `a.b` should always be a field. assert!(!cx.ccx.maps.method_map.contains_key(&e.id)); @@ -377,16 +377,16 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id); type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); } - expr_log(_, val) => { + ExprLog(_, val) => { node_type_needs(cx, use_tydesc, val.id); } - expr_call(f, _, _) => { + ExprCall(f, _, _) => { let r = ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)); for a in r.iter() { type_needs(cx, use_repr, *a); } } - expr_method_call(callee_id, rcvr, _, _, _, _) => { + ExprMethodCall(callee_id, rcvr, _, _, _, _) => { let base_ty = ty::node_id_to_type(cx.ccx.tcx, rcvr.id); type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); @@ -397,7 +397,7 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { mark_for_method_call(cx, e.id, callee_id); } - expr_inline_asm(ref ia) => { + ExprInlineAsm(ref ia) => { for &(_, input) in ia.inputs.iter() { node_type_needs(cx, use_repr, input.id); } @@ -406,14 +406,14 @@ pub fn mark_for_expr(cx: &Context, e: &expr) { } } - expr_paren(e) => mark_for_expr(cx, e), + ExprParen(e) => mark_for_expr(cx, e), - expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) | - expr_break(_) | expr_again(_) | expr_unary(*) | expr_lit(_) | - expr_mac(_) | expr_addr_of(*) | expr_ret(_) | expr_loop(*) | - expr_do_body(_) => (), + ExprMatch(*) | ExprBlock(_) | ExprIf(*) | ExprWhile(*) | + ExprBreak(_) | ExprAgain(_) | ExprUnary(*) | ExprLit(_) | + ExprMac(_) | ExprAddrOf(*) | ExprRet(_) | ExprLoop(*) | + ExprDoBody(_) => (), - expr_for_loop(*) => fail!("non-desugared expr_for_loop") + ExprForLoop(*) => fail!("non-desugared expr_for_loop") } } @@ -421,7 +421,7 @@ struct TypeUseVisitor; impl<'self> Visitor<&'self Context> for TypeUseVisitor { - fn visit_expr<'a>(&mut self, e:@expr, cx: &'a Context) { + fn visit_expr<'a>(&mut self, e:@Expr, cx: &'a Context) { visit::walk_expr(self, e, cx); mark_for_expr(cx, e); } @@ -431,7 +431,7 @@ impl<'self> Visitor<&'self Context> for TypeUseVisitor { node_type_needs(cx, use_repr, l.id); } - fn visit_pat<'a>(&mut self, p:@pat, cx: &'a Context) { + fn visit_pat<'a>(&mut self, p:@Pat, cx: &'a Context) { visit::walk_pat(self, p, cx); node_type_needs(cx, use_repr, p.id); } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c548b18f72c89..3266ec5c9abf4 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -62,8 +62,8 @@ pub struct field { #[deriving(Clone)] pub enum MethodContainer { - TraitContainer(ast::def_id), - ImplContainer(ast::def_id), + TraitContainer(ast::DefId), + ImplContainer(ast::DefId), } #[deriving(Clone)] @@ -74,11 +74,11 @@ pub struct Method { fty: BareFnTy, explicit_self: ast::explicit_self_, vis: ast::visibility, - def_id: ast::def_id, + def_id: ast::DefId, container: MethodContainer, // If this method is provided, we need to know where it came from - provided_source: Option + provided_source: Option } impl Method { @@ -88,9 +88,9 @@ impl Method { fty: BareFnTy, explicit_self: ast::explicit_self_, vis: ast::visibility, - def_id: ast::def_id, + def_id: ast::DefId, container: MethodContainer, - provided_source: Option) + provided_source: Option) -> Method { // Check the invariants. if explicit_self == ast::sty_static { @@ -112,7 +112,7 @@ impl Method { } } - pub fn container_id(&self) -> ast::def_id { + pub fn container_id(&self) -> ast::DefId { match self.container { TraitContainer(id) => id, ImplContainer(id) => id, @@ -121,7 +121,7 @@ impl Method { } pub struct Impl { - did: def_id, + did: DefId, ident: Ident, methods: ~[@Method] } @@ -129,7 +129,7 @@ pub struct Impl { #[deriving(Clone, Eq, IterBytes)] pub struct mt { ty: t, - mutbl: ast::mutability, + mutbl: ast::Mutability, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes, ToStr)] @@ -157,7 +157,7 @@ pub enum SelfMode { pub struct field_ty { ident: Ident, - id: def_id, + id: DefId, vis: ast::visibility, } @@ -229,22 +229,22 @@ pub struct AutoDerefRef { #[deriving(Decodable, Encodable)] pub enum AutoRef { /// Convert from T to &T - AutoPtr(Region, ast::mutability), + AutoPtr(Region, ast::Mutability), /// Convert from @[]/~[]/&[] to &[] (or str) - AutoBorrowVec(Region, ast::mutability), + AutoBorrowVec(Region, ast::Mutability), /// Convert from @[]/~[]/&[] to &&[] (or str) - AutoBorrowVecRef(Region, ast::mutability), + AutoBorrowVecRef(Region, ast::Mutability), /// Convert from @fn()/~fn()/&fn() to &fn() AutoBorrowFn(Region), /// Convert from T to *T - AutoUnsafe(ast::mutability), + AutoUnsafe(ast::Mutability), /// Convert from @Trait/~Trait/&Trait to &Trait - AutoBorrowObj(Region, ast::mutability), + AutoBorrowObj(Region, ast::Mutability), } pub type ctxt = @ctxt_; @@ -272,21 +272,21 @@ struct ctxt_ { node_type_substs: @mut HashMap, // Maps from a method to the method "descriptor" - methods: @mut HashMap, + methods: @mut HashMap, // Maps from a trait def-id to a list of the def-ids of its methods - trait_method_def_ids: @mut HashMap, + trait_method_def_ids: @mut HashMap, // A cache for the trait_methods() routine - trait_methods_cache: @mut HashMap, + trait_methods_cache: @mut HashMap, - impl_trait_cache: @mut HashMap>, + impl_trait_cache: @mut HashMap>, trait_refs: @mut HashMap, - trait_defs: @mut HashMap, + trait_defs: @mut HashMap, items: ast_map::map, - intrinsic_defs: @mut HashMap, + intrinsic_defs: @mut HashMap, freevars: freevars::freevar_map, tcache: type_cache, rcache: creader_cache, @@ -295,37 +295,37 @@ struct ctxt_ { needs_unwind_cleanup_cache: @mut HashMap, tc_cache: @mut HashMap, ast_ty_to_ty_cache: @mut HashMap, - enum_var_cache: @mut HashMap, + enum_var_cache: @mut HashMap, ty_param_defs: @mut HashMap, adjustments: @mut HashMap, normalized_cache: @mut HashMap, lang_items: middle::lang_items::LanguageItems, // A mapping of fake provided method def_ids to the default implementation - provided_method_sources: @mut HashMap, - supertraits: @mut HashMap, + provided_method_sources: @mut HashMap, + supertraits: @mut HashMap, // A mapping from the def ID of an enum or struct type to the def ID // of the method that implements its destructor. If the type is not // present in this map, it does not have a destructor. This map is // populated during the coherence phase of typechecking. - destructor_for_type: @mut HashMap, + destructor_for_type: @mut HashMap, // A method will be in this list if and only if it is a destructor. - destructors: @mut HashSet, + destructors: @mut HashSet, // Maps a trait onto a list of impls of that trait. - trait_impls: @mut HashMap, + trait_impls: @mut HashMap, // Maps a def_id of a type to a list of its inherent impls. // Contains implementations of methods that are inherent to a type. // Methods in these implementations don't need to be exported. - inherent_impls: @mut HashMap, + inherent_impls: @mut HashMap, // Maps a def_id of an impl to an Impl structure. // Note that this contains all of the impls that we know about, // including ones in other crates. It's not clear that this is the best // way to do it. - impls: @mut HashMap, + impls: @mut HashMap, // Set of used unsafe nodes (functions or blocks). Unsafe nodes not // present in this set can be warned about. @@ -341,11 +341,11 @@ struct ctxt_ { // The set of external nominal types whose implementations have been read. // This is used for lazy resolution of methods. - populated_external_types: @mut HashSet, + populated_external_types: @mut HashSet, // The set of external traits whose implementations have been read. This // is used for lazy resolution of traits. - populated_external_traits: @mut HashSet, + populated_external_traits: @mut HashSet, } pub enum tbox_flag { @@ -439,7 +439,7 @@ pub struct FnSig { #[deriving(Clone, Eq, IterBytes)] pub struct param_ty { idx: uint, - def_id: def_id + def_id: DefId } /// Representation of regions: @@ -613,7 +613,7 @@ pub enum sty { ty_uint(ast::uint_ty), ty_float(ast::float_ty), ty_estr(vstore), - ty_enum(def_id, substs), + ty_enum(DefId, substs), ty_box(mt), ty_uniq(mt), ty_evec(mt, vstore), @@ -621,12 +621,12 @@ pub enum sty { ty_rptr(Region, mt), ty_bare_fn(BareFnTy), ty_closure(ClosureTy), - ty_trait(def_id, substs, TraitStore, ast::mutability, BuiltinBounds), - ty_struct(def_id, substs), + ty_trait(DefId, substs, TraitStore, ast::Mutability, BuiltinBounds), + ty_struct(DefId, substs), ty_tup(~[t]), ty_param(param_ty), // type parameter - ty_self(def_id), /* special, implicit `self` type parameter; + ty_self(DefId), /* special, implicit `self` type parameter; * def_id is the id of the trait */ ty_infer(InferTy), // something used only during inference/typeck @@ -643,7 +643,7 @@ pub enum sty { #[deriving(Eq, IterBytes)] pub struct TraitRef { - def_id: def_id, + def_id: DefId, substs: substs } @@ -698,7 +698,7 @@ pub enum type_err { terr_integer_as_char, terr_int_mismatch(expected_found), terr_float_mismatch(expected_found), - terr_traits(expected_found), + terr_traits(expected_found), terr_builtin_bounds(expected_found), } @@ -849,7 +849,7 @@ impl ToStr for IntVarValue { #[deriving(Clone)] pub struct TypeParameterDef { ident: ast::Ident, - def_id: ast::def_id, + def_id: ast::DefId, bounds: @ParamBounds } @@ -895,9 +895,9 @@ pub struct ty_param_substs_and_ty { ty: ty::t } -type type_cache = @mut HashMap; +type type_cache = @mut HashMap; -type constness_cache = @mut HashMap; +type constness_cache = @mut HashMap; pub type node_type_table = @mut HashMap; @@ -1180,7 +1180,7 @@ pub fn mk_estr(cx: ctxt, t: vstore) -> t { mk_t(cx, ty_estr(t)) } -pub fn mk_enum(cx: ctxt, did: ast::def_id, substs: substs) -> t { +pub fn mk_enum(cx: ctxt, did: ast::DefId, substs: substs) -> t { // take a copy of substs so that we own the vectors inside mk_t(cx, ty_enum(did, substs)) } @@ -1188,13 +1188,13 @@ pub fn mk_enum(cx: ctxt, did: ast::def_id, substs: substs) -> t { pub fn mk_box(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_box(tm)) } pub fn mk_imm_box(cx: ctxt, ty: t) -> t { - mk_box(cx, mt {ty: ty, mutbl: ast::m_imm}) + mk_box(cx, mt {ty: ty, mutbl: ast::MutImmutable}) } pub fn mk_uniq(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_uniq(tm)) } pub fn mk_imm_uniq(cx: ctxt, ty: t) -> t { - mk_uniq(cx, mt {ty: ty, mutbl: ast::m_imm}) + mk_uniq(cx, mt {ty: ty, mutbl: ast::MutImmutable}) } pub fn mk_ptr(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) } @@ -1202,22 +1202,22 @@ pub fn mk_ptr(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) } pub fn mk_rptr(cx: ctxt, r: Region, tm: mt) -> t { mk_t(cx, ty_rptr(r, tm)) } pub fn mk_mut_rptr(cx: ctxt, r: Region, ty: t) -> t { - mk_rptr(cx, r, mt {ty: ty, mutbl: ast::m_mutbl}) + mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutMutable}) } pub fn mk_imm_rptr(cx: ctxt, r: Region, ty: t) -> t { - mk_rptr(cx, r, mt {ty: ty, mutbl: ast::m_imm}) + mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutImmutable}) } pub fn mk_mut_ptr(cx: ctxt, ty: t) -> t { - mk_ptr(cx, mt {ty: ty, mutbl: ast::m_mutbl}) + mk_ptr(cx, mt {ty: ty, mutbl: ast::MutMutable}) } pub fn mk_imm_ptr(cx: ctxt, ty: t) -> t { - mk_ptr(cx, mt {ty: ty, mutbl: ast::m_imm}) + mk_ptr(cx, mt {ty: ty, mutbl: ast::MutImmutable}) } pub fn mk_nil_ptr(cx: ctxt) -> t { - mk_ptr(cx, mt {ty: mk_nil(), mutbl: ast::m_imm}) + mk_ptr(cx, mt {ty: mk_nil(), mutbl: ast::MutImmutable}) } pub fn mk_evec(cx: ctxt, tm: mt, t: vstore) -> t { @@ -1228,7 +1228,7 @@ pub fn mk_unboxed_vec(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_unboxed_vec(tm)) } pub fn mk_mut_unboxed_vec(cx: ctxt, ty: t) -> t { - mk_t(cx, ty_unboxed_vec(mt {ty: ty, mutbl: ast::m_imm})) + mk_t(cx, ty_unboxed_vec(mt {ty: ty, mutbl: ast::MutImmutable})) } pub fn mk_tup(cx: ctxt, ts: ~[t]) -> t { mk_t(cx, ty_tup(ts)) } @@ -1257,17 +1257,17 @@ pub fn mk_ctor_fn(cx: ctxt, input_tys: &[ty::t], output: ty::t) -> t { pub fn mk_trait(cx: ctxt, - did: ast::def_id, + did: ast::DefId, substs: substs, store: TraitStore, - mutability: ast::mutability, + mutability: ast::Mutability, bounds: BuiltinBounds) -> t { // take a copy of substs so that we own the vectors inside mk_t(cx, ty_trait(did, substs, store, mutability, bounds)) } -pub fn mk_struct(cx: ctxt, struct_id: ast::def_id, substs: substs) -> t { +pub fn mk_struct(cx: ctxt, struct_id: ast::DefId, substs: substs) -> t { // take a copy of substs so that we own the vectors inside mk_t(cx, ty_struct(struct_id, substs)) } @@ -1280,9 +1280,9 @@ pub fn mk_float_var(cx: ctxt, v: FloatVid) -> t { mk_infer(cx, FloatVar(v)) } pub fn mk_infer(cx: ctxt, it: InferTy) -> t { mk_t(cx, ty_infer(it)) } -pub fn mk_self(cx: ctxt, did: ast::def_id) -> t { mk_t(cx, ty_self(did)) } +pub fn mk_self(cx: ctxt, did: ast::DefId) -> t { mk_t(cx, ty_self(did)) } -pub fn mk_param(cx: ctxt, n: uint, k: def_id) -> t { +pub fn mk_param(cx: ctxt, n: uint, k: DefId) -> t { mk_t(cx, ty_param(param_ty { idx: n, def_id: k })) } @@ -2140,7 +2140,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } ty_estr(vstore_slice(r)) => { - borrowed_contents(r, m_imm) + borrowed_contents(r, MutImmutable) } ty_estr(vstore_fixed(_)) => { @@ -2234,11 +2234,11 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { mt: mt, cache: &mut HashMap) -> TypeContents { - let mc = if mt.mutbl == m_mutbl {TC_MUTABLE} else {TC_NONE}; + let mc = if mt.mutbl == MutMutable {TC_MUTABLE} else {TC_NONE}; mc + tc_ty(cx, mt.ty, cache) } - fn apply_tc_attr(cx: ctxt, did: def_id, mut tc: TypeContents) -> TypeContents { + fn apply_tc_attr(cx: ctxt, did: DefId, mut tc: TypeContents) -> TypeContents { if has_attr(cx, did, "no_freeze") { tc = tc + TC_MUTABLE; } @@ -2249,9 +2249,9 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } fn borrowed_contents(region: ty::Region, - mutbl: ast::mutability) -> TypeContents + mutbl: ast::Mutability) -> TypeContents { - let mc = if mutbl == m_mutbl { + let mc = if mutbl == MutMutable { TC_MUTABLE + TC_BORROWED_MUT } else { TC_NONE @@ -2290,17 +2290,17 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { // even more stuff. let st = match cty.sigil { ast::BorrowedSigil => - trait_contents(RegionTraitStore(cty.region), m_imm, cty.bounds) + trait_contents(RegionTraitStore(cty.region), MutImmutable, cty.bounds) + TC_BORROWED_POINTER, // might be an env packet even if static ast::ManagedSigil => - trait_contents(BoxTraitStore, m_imm, cty.bounds), + trait_contents(BoxTraitStore, MutImmutable, cty.bounds), ast::OwnedSigil => - trait_contents(UniqTraitStore, m_imm, cty.bounds), + trait_contents(UniqTraitStore, MutImmutable, cty.bounds), }; // FIXME(#3569): This borrowed_contents call should be taken care of in // trait_contents, after ~Traits and @Traits can have region bounds too. // This one here is redundant for &fns but important for ~fns and @fns. - let rt = borrowed_contents(cty.region, m_imm); + let rt = borrowed_contents(cty.region, MutImmutable); // This also prohibits "@once fn" from being copied, which allows it to // be called. Neither way really makes much sense. let ot = match cty.onceness { @@ -2316,14 +2316,14 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { st + rt + ot + ct } - fn trait_contents(store: TraitStore, mutbl: ast::mutability, + fn trait_contents(store: TraitStore, mutbl: ast::Mutability, bounds: BuiltinBounds) -> TypeContents { let st = match store { UniqTraitStore => TC_OWNED_POINTER, BoxTraitStore => TC_MANAGED, RegionTraitStore(r) => borrowed_contents(r, mutbl), }; - let mt = match mutbl { ast::m_mutbl => TC_MUTABLE, _ => TC_NONE }; + let mt = match mutbl { ast::MutMutable => TC_MUTABLE, _ => TC_NONE }; // We get additional "special type contents" for each bound that *isn't* // on the trait. So iterate over the inverse of the bounds that are set. // This is like with typarams below, but less "pessimistic" and also @@ -2386,7 +2386,7 @@ pub fn type_moves_by_default(cx: ctxt, ty: t) -> bool { // True if instantiating an instance of `r_ty` requires an instance of `r_ty`. pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { - fn type_requires(cx: ctxt, seen: &mut ~[def_id], + fn type_requires(cx: ctxt, seen: &mut ~[DefId], r_ty: t, ty: t) -> bool { debug!("type_requires(%s, %s)?", ::util::ppaux::ty_to_str(cx, r_ty), @@ -2404,7 +2404,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { return r; } - fn subtypes_require(cx: ctxt, seen: &mut ~[def_id], + fn subtypes_require(cx: ctxt, seen: &mut ~[DefId], r_ty: t, ty: t) -> bool { debug!("subtypes_require(%s, %s)?", ::util::ppaux::ty_to_str(cx, r_ty), @@ -2706,7 +2706,7 @@ pub fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option { let variants = enum_variants(cx, did); if (*variants).len() == 1u && variants[0].args.len() == 1u { let v_t = subst(cx, substs, variants[0].args[0]); - Some(mt {ty: v_t, mutbl: ast::m_imm}) + Some(mt {ty: v_t, mutbl: ast::MutImmutable}) } else { None } @@ -2716,7 +2716,7 @@ pub fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option { let fields = struct_fields(cx, did, substs); if fields.len() == 1 && fields[0].ident == syntax::parse::token::special_idents::unnamed_field { - Some(mt {ty: fields[0].mt.ty, mutbl: ast::m_imm}) + Some(mt {ty: fields[0].mt.ty, mutbl: ast::MutImmutable}) } else { None } @@ -2744,7 +2744,7 @@ pub fn index(t: t) -> Option { pub fn index_sty(sty: &sty) -> Option { match *sty { ty_evec(mt, _) => Some(mt), - ty_estr(_) => Some(mt {ty: mk_u8(), mutbl: ast::m_imm}), + ty_estr(_) => Some(mt {ty: mk_u8(), mutbl: ast::MutImmutable}), _ => None } } @@ -2957,7 +2957,7 @@ pub fn block_ty(cx: ctxt, b: &ast::Block) -> t { // Returns the type of a pattern as a monotype. Like @expr_ty, this function // doesn't provide type parameter substitutions. -pub fn pat_ty(cx: ctxt, pat: &ast::pat) -> t { +pub fn pat_ty(cx: ctxt, pat: &ast::Pat) -> t { return node_id_to_type(cx, pat.id); } @@ -2973,11 +2973,11 @@ pub fn pat_ty(cx: ctxt, pat: &ast::pat) -> t { // ask for the type of "id" in "id(3)", it will return "fn(&int) -> int" // instead of "fn(t) -> T with T = int". If this isn't what you want, see // expr_ty_params_and_ty() below. -pub fn expr_ty(cx: ctxt, expr: &ast::expr) -> t { +pub fn expr_ty(cx: ctxt, expr: &ast::Expr) -> t { return node_id_to_type(cx, expr.id); } -pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::expr) -> t { +pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::Expr) -> t { /*! * * Returns the type of `expr`, considering any `AutoAdjustment` @@ -3056,7 +3056,7 @@ pub fn adjust_ty(cx: ctxt, AutoBorrowVecRef(r, m) => { adjusted_ty = borrow_vec(cx, span, r, m, adjusted_ty); - mk_rptr(cx, r, mt {ty: adjusted_ty, mutbl: ast::m_imm}) + mk_rptr(cx, r, mt {ty: adjusted_ty, mutbl: ast::MutImmutable}) } AutoBorrowFn(r) => { @@ -3077,7 +3077,7 @@ pub fn adjust_ty(cx: ctxt, }; fn borrow_vec(cx: ctxt, span: Span, - r: Region, m: ast::mutability, + r: Region, m: ast::Mutability, ty: ty::t) -> ty::t { match get(ty).sty { ty_evec(mt, _) => { @@ -3117,7 +3117,7 @@ pub fn adjust_ty(cx: ctxt, } fn borrow_obj(cx: ctxt, span: Span, r: Region, - m: ast::mutability, ty: ty::t) -> ty::t { + m: ast::Mutability, ty: ty::t) -> ty::t { match get(ty).sty { ty_trait(trt_did, ref trt_substs, _, _, b) => { ty::mk_trait(cx, trt_did, trt_substs.clone(), @@ -3152,7 +3152,7 @@ pub struct ParamsTy { } pub fn expr_ty_params_and_ty(cx: ctxt, - expr: &ast::expr) + expr: &ast::Expr) -> ParamsTy { ParamsTy { params: node_id_to_type_params(cx, expr.id), @@ -3160,7 +3160,7 @@ pub fn expr_ty_params_and_ty(cx: ctxt, } } -pub fn expr_has_ty_params(cx: ctxt, expr: &ast::expr) -> bool { +pub fn expr_has_ty_params(cx: ctxt, expr: &ast::Expr) -> bool { return node_id_has_type_params(cx, expr.id); } @@ -3197,7 +3197,7 @@ pub fn method_call_type_param_defs(tcx: ctxt, } } -pub fn resolve_expr(tcx: ctxt, expr: &ast::expr) -> ast::def { +pub fn resolve_expr(tcx: ctxt, expr: &ast::Expr) -> ast::Def { match tcx.def_map.find(&expr.id) { Some(&def) => def, None => { @@ -3209,7 +3209,7 @@ pub fn resolve_expr(tcx: ctxt, expr: &ast::expr) -> ast::def { pub fn expr_is_lval(tcx: ctxt, method_map: typeck::method_map, - e: &ast::expr) -> bool { + e: &ast::Expr) -> bool { match expr_kind(tcx, method_map, e) { LvalueExpr => true, RvalueDpsExpr | RvalueDatumExpr | RvalueStmtExpr => false @@ -3230,34 +3230,34 @@ pub enum ExprKind { pub fn expr_kind(tcx: ctxt, method_map: typeck::method_map, - expr: &ast::expr) -> ExprKind { + expr: &ast::Expr) -> ExprKind { if method_map.contains_key(&expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS. However, assign_op (e.g., `x += y`) is an // exception, as its result is always unit. return match expr.node { - ast::expr_assign_op(*) => RvalueStmtExpr, + ast::ExprAssignOp(*) => RvalueStmtExpr, _ => RvalueDpsExpr }; } match expr.node { - ast::expr_path(*) | ast::expr_self => { + ast::ExprPath(*) | ast::ExprSelf => { match resolve_expr(tcx, expr) { - ast::def_variant(*) | ast::def_struct(*) => RvalueDpsExpr, + ast::DefVariant(*) | ast::DefStruct(*) => RvalueDpsExpr, // Fn pointers are just scalar values. - ast::def_fn(*) | ast::def_static_method(*) => RvalueDatumExpr, + ast::DefFn(*) | ast::DefStaticMethod(*) => RvalueDatumExpr, // Note: there is actually a good case to be made that // def_args, particularly those of immediate type, ought to // considered rvalues. - ast::def_static(*) | - ast::def_binding(*) | - ast::def_upvar(*) | - ast::def_arg(*) | - ast::def_local(*) | - ast::def_self(*) => LvalueExpr, + ast::DefStatic(*) | + ast::DefBinding(*) | + ast::DefUpvar(*) | + ast::DefArg(*) | + ast::DefLocal(*) | + ast::DefSelf(*) => LvalueExpr, def => { tcx.sess.span_bug(expr.span, fmt!( @@ -3267,30 +3267,30 @@ pub fn expr_kind(tcx: ctxt, } } - ast::expr_unary(_, ast::deref, _) | - ast::expr_field(*) | - ast::expr_index(*) => { + ast::ExprUnary(_, ast::UnDeref, _) | + ast::ExprField(*) | + ast::ExprIndex(*) => { LvalueExpr } - ast::expr_call(*) | - ast::expr_method_call(*) | - ast::expr_struct(*) | - ast::expr_tup(*) | - ast::expr_if(*) | - ast::expr_match(*) | - ast::expr_fn_block(*) | - ast::expr_do_body(*) | - ast::expr_block(*) | - ast::expr_repeat(*) | - ast::expr_lit(@codemap::Spanned {node: lit_str(_), _}) | - ast::expr_vstore(_, ast::expr_vstore_slice) | - ast::expr_vstore(_, ast::expr_vstore_mut_slice) | - ast::expr_vec(*) => { + ast::ExprCall(*) | + ast::ExprMethodCall(*) | + ast::ExprStruct(*) | + ast::ExprTup(*) | + ast::ExprIf(*) | + ast::ExprMatch(*) | + ast::ExprFnBlock(*) | + ast::ExprDoBody(*) | + ast::ExprBlock(*) | + ast::ExprRepeat(*) | + ast::ExprLit(@codemap::Spanned {node: lit_str(_), _}) | + ast::ExprVstore(_, ast::ExprVstoreSlice) | + ast::ExprVstore(_, ast::ExprVstoreMutSlice) | + ast::ExprVec(*) => { RvalueDpsExpr } - ast::expr_cast(*) => { + ast::ExprCast(*) => { match tcx.node_types.find(&(expr.id as uint)) { Some(&t) => { if ty::type_is_immediate(tcx, t) { @@ -3316,33 +3316,33 @@ pub fn expr_kind(tcx: ctxt, } } - ast::expr_break(*) | - ast::expr_again(*) | - ast::expr_ret(*) | - ast::expr_log(*) | - ast::expr_while(*) | - ast::expr_loop(*) | - ast::expr_assign(*) | - ast::expr_inline_asm(*) | - ast::expr_assign_op(*) => { + ast::ExprBreak(*) | + ast::ExprAgain(*) | + ast::ExprRet(*) | + ast::ExprLog(*) | + ast::ExprWhile(*) | + ast::ExprLoop(*) | + ast::ExprAssign(*) | + ast::ExprInlineAsm(*) | + ast::ExprAssignOp(*) => { RvalueStmtExpr } - ast::expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - ast::expr_lit(_) | // Note: lit_str is carved out above - ast::expr_unary(*) | - ast::expr_addr_of(*) | - ast::expr_binary(*) | - ast::expr_vstore(_, ast::expr_vstore_box) | - ast::expr_vstore(_, ast::expr_vstore_mut_box) | - ast::expr_vstore(_, ast::expr_vstore_uniq) => { + ast::ExprLit(_) | // Note: lit_str is carved out above + ast::ExprUnary(*) | + ast::ExprAddrOf(*) | + ast::ExprBinary(*) | + ast::ExprVstore(_, ast::ExprVstoreBox) | + ast::ExprVstore(_, ast::ExprVstoreMutBox) | + ast::ExprVstore(_, ast::ExprVstoreUniq) => { RvalueDatumExpr } - ast::expr_paren(e) => expr_kind(tcx, method_map, e), + ast::ExprParen(e) => expr_kind(tcx, method_map, e), - ast::expr_mac(*) => { + ast::ExprMac(*) => { tcx.sess.span_bug( expr.span, "macro expression remains after expansion"); @@ -3350,12 +3350,12 @@ pub fn expr_kind(tcx: ctxt, } } -pub fn stmt_node_id(s: &ast::stmt) -> ast::NodeId { +pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId { match s.node { - ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { + ast::StmtDecl(_, id) | StmtExpr(_, id) | StmtSemi(_, id) => { return id; } - ast::stmt_mac(*) => fail!("unexpanded macro in trans") + ast::StmtMac(*) => fail!("unexpanded macro in trans") } } @@ -3627,19 +3627,19 @@ pub fn note_and_explain_type_err(cx: ctxt, err: &type_err) { } } -pub fn def_has_ty_params(def: ast::def) -> bool { +pub fn def_has_ty_params(def: ast::Def) -> bool { match def { - ast::def_fn(_, _) | ast::def_variant(_, _) | ast::def_struct(_) + ast::DefFn(_, _) | ast::DefVariant(_, _) | ast::DefStruct(_) => true, _ => false } } -pub fn provided_source(cx: ctxt, id: ast::def_id) -> Option { +pub fn provided_source(cx: ctxt, id: ast::DefId) -> Option { cx.provided_method_sources.find(&id).map_move(|x| *x) } -pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[@Method] { +pub fn provided_trait_methods(cx: ctxt, id: ast::DefId) -> ~[@Method] { if is_local(id) { match cx.items.find(&id.node) { Some(&ast_map::node_item(@ast::item { @@ -3658,7 +3658,7 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[@Method] { } pub fn trait_supertraits(cx: ctxt, - id: ast::def_id) -> @~[@TraitRef] + id: ast::DefId) -> @~[@TraitRef] { // Check the cache. match cx.supertraits.find(&id) { @@ -3685,8 +3685,8 @@ pub fn trait_ref_supertraits(cx: ctxt, trait_ref: &ty::TraitRef) -> ~[@TraitRef] fn lookup_locally_or_in_crate_store( descr: &str, - def_id: ast::def_id, - map: &mut HashMap, + def_id: ast::DefId, + map: &mut HashMap, load_external: &fn() -> V) -> V { /*! @@ -3713,13 +3713,13 @@ fn lookup_locally_or_in_crate_store( v } -pub fn trait_method(cx: ctxt, trait_did: ast::def_id, idx: uint) -> @Method { +pub fn trait_method(cx: ctxt, trait_did: ast::DefId, idx: uint) -> @Method { let method_def_id = ty::trait_method_def_ids(cx, trait_did)[idx]; ty::method(cx, method_def_id) } -pub fn trait_methods(cx: ctxt, trait_did: ast::def_id) -> @~[@Method] { +pub fn trait_methods(cx: ctxt, trait_did: ast::DefId) -> @~[@Method] { match cx.trait_methods_cache.find(&trait_did) { Some(&methods) => methods, None => { @@ -3731,19 +3731,19 @@ pub fn trait_methods(cx: ctxt, trait_did: ast::def_id) -> @~[@Method] { } } -pub fn method(cx: ctxt, id: ast::def_id) -> @Method { +pub fn method(cx: ctxt, id: ast::DefId) -> @Method { lookup_locally_or_in_crate_store( "methods", id, cx.methods, || @csearch::get_method(cx, id)) } -pub fn trait_method_def_ids(cx: ctxt, id: ast::def_id) -> @~[def_id] { +pub fn trait_method_def_ids(cx: ctxt, id: ast::DefId) -> @~[DefId] { lookup_locally_or_in_crate_store( "methods", id, cx.trait_method_def_ids, || @csearch::get_trait_method_def_ids(cx.cstore, id)) } -pub fn impl_trait_ref(cx: ctxt, id: ast::def_id) -> Option<@TraitRef> { +pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> { match cx.impl_trait_cache.find(&id) { Some(&ret) => { return ret; } None => {} @@ -3769,13 +3769,13 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::def_id) -> Option<@TraitRef> { return ret; } -pub fn trait_ref_to_def_id(tcx: ctxt, tr: &ast::trait_ref) -> ast::def_id { +pub fn trait_ref_to_def_id(tcx: ctxt, tr: &ast::trait_ref) -> ast::DefId { let def = tcx.def_map.find(&tr.ref_id).expect("no def-map entry for trait"); ast_util::def_id_of_def(*def) } pub fn try_add_builtin_trait(tcx: ctxt, - trait_def_id: ast::def_id, + trait_def_id: ast::DefId, builtin_bounds: &mut BuiltinBounds) -> bool { //! Checks whether `trait_ref` refers to one of the builtin //! traits, like `Send`, and adds the corresponding @@ -3788,7 +3788,7 @@ pub fn try_add_builtin_trait(tcx: ctxt, } } -pub fn ty_to_def_id(ty: t) -> Option { +pub fn ty_to_def_id(ty: t) -> Option { match get(ty).sty { ty_trait(id, _, _, _, _) | ty_struct(id, _) | ty_enum(id, _) => Some(id), _ => None @@ -3798,7 +3798,7 @@ pub fn ty_to_def_id(ty: t) -> Option { /// Returns the def ID of the constructor for the given tuple-like struct, or /// None if the struct is not tuple-like. Fails if the given def ID does not /// refer to a struct at all. -fn struct_ctor_id(cx: ctxt, struct_did: ast::def_id) -> Option { +fn struct_ctor_id(cx: ctxt, struct_did: ast::DefId) -> Option { if struct_did.crate != ast::LOCAL_CRATE { // XXX: Cross-crate functionality. cx.sess.unimpl("constructor ID of cross-crate tuple structs"); @@ -3826,7 +3826,7 @@ pub struct VariantInfo { arg_names: Option<~[ast::Ident]>, ctor_ty: t, name: ast::Ident, - id: ast::def_id, + id: ast::DefId, disr_val: Disr, vis: visibility } @@ -3886,7 +3886,7 @@ impl VariantInfo { } pub fn substd_enum_variants(cx: ctxt, - id: ast::def_id, + id: ast::DefId, substs: &substs) -> ~[@VariantInfo] { do enum_variants(cx, id).iter().map |variant_info| { @@ -3903,13 +3903,13 @@ pub fn substd_enum_variants(cx: ctxt, }.collect() } -pub fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str { +pub fn item_path_str(cx: ctxt, id: ast::DefId) -> ~str { ast_map::path_to_str(item_path(cx, id), token::get_ident_interner()) } pub enum DtorKind { NoDtor, - TraitDtor(def_id, bool) + TraitDtor(DefId, bool) } impl DtorKind { @@ -3934,7 +3934,7 @@ impl DtorKind { /* If struct_id names a struct with a dtor, return Some(the dtor's id). Otherwise return none. */ -pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind { +pub fn ty_dtor(cx: ctxt, struct_id: DefId) -> DtorKind { match cx.destructor_for_type.find(&struct_id) { Some(&method_def_id) => { let flag = !has_attr(cx, struct_id, "unsafe_no_drop_flag"); @@ -3945,11 +3945,11 @@ pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind { } } -pub fn has_dtor(cx: ctxt, struct_id: def_id) -> bool { +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::def_id) -> ast_map::path { +pub fn item_path(cx: ctxt, id: ast::DefId) -> ast_map::path { if id.crate != ast::LOCAL_CRATE { csearch::get_item_path(cx, id) } else { @@ -4002,7 +4002,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { } } -pub fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool { +pub fn enum_is_univariant(cx: ctxt, id: ast::DefId) -> bool { enum_variants(cx, id).len() == 1 } @@ -4013,7 +4013,7 @@ pub fn type_is_empty(cx: ctxt, t: t) -> bool { } } -pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[@VariantInfo] { +pub fn enum_variants(cx: ctxt, id: ast::DefId) -> @~[@VariantInfo] { match cx.enum_var_cache.find(&id) { Some(&variants) => return variants, _ => { /* fallthrough */ } @@ -4070,8 +4070,8 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[@VariantInfo] { // Returns information about the enum variant with the given ID: pub fn enum_variant_with_id(cx: ctxt, - enum_id: ast::def_id, - variant_id: ast::def_id) + enum_id: ast::DefId, + variant_id: ast::DefId) -> @VariantInfo { let variants = enum_variants(cx, enum_id); let mut i = 0; @@ -4087,7 +4087,7 @@ pub fn enum_variant_with_id(cx: ctxt, // If the given item is in an external crate, looks up its type and adds it to // the type cache. Returns the type parameters and type. pub fn lookup_item_type(cx: ctxt, - did: ast::def_id) + did: ast::DefId) -> ty_param_bounds_and_ty { lookup_locally_or_in_crate_store( "tcache", did, cx.tcache, @@ -4095,7 +4095,7 @@ pub fn lookup_item_type(cx: ctxt, } pub fn lookup_impl_vtables(cx: ctxt, - did: ast::def_id) + did: ast::DefId) -> typeck::impl_res { lookup_locally_or_in_crate_store( "impl_vtables", did, cx.impl_vtables, @@ -4103,7 +4103,7 @@ pub fn lookup_impl_vtables(cx: ctxt, } /// Given the did of a trait, returns its canonical trait ref. -pub fn lookup_trait_def(cx: ctxt, did: ast::def_id) -> @ty::TraitDef { +pub fn lookup_trait_def(cx: ctxt, did: ast::DefId) -> @ty::TraitDef { match cx.trait_defs.find(&did) { Some(&trait_def) => { // The item is in this crate. The caller should have added it to the @@ -4120,7 +4120,7 @@ pub fn lookup_trait_def(cx: ctxt, did: ast::def_id) -> @ty::TraitDef { } /// Determine whether an item is annotated with an attribute -pub fn has_attr(tcx: ctxt, did: def_id, attr: &str) -> bool { +pub fn has_attr(tcx: ctxt, did: DefId, attr: &str) -> bool { if is_local(did) { match tcx.items.find(&did.node) { Some( @@ -4141,20 +4141,20 @@ pub fn has_attr(tcx: ctxt, did: def_id, attr: &str) -> bool { } /// Determine whether an item is annotated with `#[packed]` -pub fn lookup_packed(tcx: ctxt, did: def_id) -> bool { +pub fn lookup_packed(tcx: ctxt, did: DefId) -> bool { has_attr(tcx, did, "packed") } /// Determine whether an item is annotated with `#[simd]` -pub fn lookup_simd(tcx: ctxt, did: def_id) -> bool { +pub fn lookup_simd(tcx: ctxt, did: DefId) -> bool { has_attr(tcx, did, "simd") } // Look up a field ID, whether or not it's local // Takes a list of type substs in case the struct is generic pub fn lookup_field_type(tcx: ctxt, - struct_id: def_id, - id: def_id, + struct_id: DefId, + id: DefId, substs: &substs) -> ty::t { let t = if id.crate == ast::LOCAL_CRATE { @@ -4175,7 +4175,7 @@ pub fn lookup_field_type(tcx: ctxt, // Look up the list of field names and IDs for a given struct // Fails if the id is not bound to a struct. -pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { +pub fn lookup_struct_fields(cx: ctxt, did: ast::DefId) -> ~[field_ty] { if did.crate == ast::LOCAL_CRATE { match cx.items.find(&did.node) { Some(&ast_map::node_item(i,_)) => { @@ -4211,8 +4211,8 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } pub fn lookup_struct_field(cx: ctxt, - parent: ast::def_id, - field_id: ast::def_id) + parent: ast::DefId, + field_id: ast::DefId) -> field_ty { let r = lookup_struct_fields(cx, parent); match r.iter().find( @@ -4246,20 +4246,20 @@ fn struct_field_tys(fields: &[@struct_field]) -> ~[field_ty] { // Returns a list of fields corresponding to the struct's items. trans uses // this. Takes a list of substs with which to instantiate field types. -pub fn struct_fields(cx: ctxt, did: ast::def_id, substs: &substs) +pub fn struct_fields(cx: ctxt, did: ast::DefId, substs: &substs) -> ~[field] { do lookup_struct_fields(cx, did).map |f| { field { ident: f.ident, mt: mt { ty: lookup_field_type(cx, did, f.id, substs), - mutbl: m_imm + mutbl: MutImmutable } } } } -pub fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool { +pub fn is_binopable(cx: ctxt, ty: t, op: ast::BinOp) -> bool { static tycat_other: int = 0; static tycat_bool: int = 1; static tycat_int: int = 2; @@ -4276,26 +4276,26 @@ pub fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool { static opcat_bit: int = 6; static opcat_logic: int = 7; - fn opcat(op: ast::binop) -> int { + fn opcat(op: ast::BinOp) -> int { match op { - ast::add => opcat_add, - ast::subtract => opcat_sub, - ast::mul => opcat_mult, - ast::div => opcat_mult, - ast::rem => opcat_mult, - ast::and => opcat_logic, - ast::or => opcat_logic, - ast::bitxor => opcat_bit, - ast::bitand => opcat_bit, - ast::bitor => opcat_bit, - ast::shl => opcat_shift, - ast::shr => opcat_shift, - ast::eq => opcat_eq, - ast::ne => opcat_eq, - ast::lt => opcat_rel, - ast::le => opcat_rel, - ast::ge => opcat_rel, - ast::gt => opcat_rel + ast::BiAdd => opcat_add, + ast::BiSub => opcat_sub, + ast::BiMul => opcat_mult, + ast::BiDiv => opcat_mult, + ast::BiRem => opcat_mult, + ast::BiAnd => opcat_logic, + ast::BiOr => opcat_logic, + ast::BiBitXor => opcat_bit, + ast::BiBitAnd => opcat_bit, + ast::BiBitOr => opcat_bit, + ast::BiShl => opcat_shift, + ast::BiShr => opcat_shift, + ast::BiEq => opcat_eq, + ast::BiNe => opcat_eq, + ast::BiLt => opcat_rel, + ast::BiLe => opcat_rel, + ast::BiGe => opcat_rel, + ast::BiGt => opcat_rel } } @@ -4413,12 +4413,12 @@ pub fn normalize_ty(cx: ctxt, t: t) -> t { } pub trait ExprTyProvider { - fn expr_ty(&self, ex: &ast::expr) -> t; + fn expr_ty(&self, ex: &ast::Expr) -> t; fn ty_ctxt(&self) -> ctxt; } impl ExprTyProvider for ctxt { - fn expr_ty(&self, ex: &ast::expr) -> t { + fn expr_ty(&self, ex: &ast::Expr) -> t { expr_ty(*self, ex) } @@ -4428,7 +4428,7 @@ impl ExprTyProvider for ctxt { } // Returns the repeat count for a repeating vector expression. -pub fn eval_repeat_count(tcx: &T, count_expr: &ast::expr) -> uint { +pub fn eval_repeat_count(tcx: &T, count_expr: &ast::Expr) -> uint { match const_eval::eval_const_expr_partial(tcx, count_expr) { Ok(ref const_val) => match *const_val { const_eval::const_int(count) => if count < 0 { @@ -4572,13 +4572,13 @@ pub fn visitor_object_ty(tcx: ctxt, trait_ref.def_id, trait_ref.substs.clone(), RegionTraitStore(region), - ast::m_mutbl, + ast::MutMutable, EmptyBuiltinBounds()))) } /// Records a trait-to-implementation mapping. fn record_trait_implementation(tcx: ctxt, - trait_def_id: def_id, + trait_def_id: DefId, implementation: @Impl) { let implementation_list; match tcx.trait_impls.find(&trait_def_id) { @@ -4597,7 +4597,7 @@ fn record_trait_implementation(tcx: ctxt, /// Populates the type context with all the implementations for the given type /// if necessary. pub fn populate_implementations_for_type_if_necessary(tcx: ctxt, - type_id: ast::def_id) { + type_id: ast::DefId) { if type_id.crate == LOCAL_CRATE { return } @@ -4652,7 +4652,7 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt, /// trait if necessary. pub fn populate_implementations_for_trait_if_necessary( tcx: ctxt, - trait_id: ast::def_id) { + trait_id: ast::DefId) { if trait_id.crate == LOCAL_CRATE { return } @@ -4684,8 +4684,8 @@ pub fn populate_implementations_for_trait_if_necessary( /// If the given def ID describes a trait method, returns the ID of the trait /// that the method belongs to. Otherwise, returns `None`. -pub fn trait_of_method(tcx: ctxt, def_id: ast::def_id) - -> Option { +pub fn trait_of_method(tcx: ctxt, def_id: ast::DefId) + -> Option { match tcx.methods.find(&def_id) { Some(method_descriptor) => { match method_descriptor.container { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 8ba6234e6095a..c0825a9c0b6b8 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -74,8 +74,8 @@ use util::common::indenter; pub trait AstConv { fn tcx(&self) -> ty::ctxt; - fn get_item_ty(&self, id: ast::def_id) -> ty::ty_param_bounds_and_ty; - fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef; + fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty; + fn get_trait_def(&self, id: ast::DefId) -> @ty::TraitDef; // what type should we use when a type is omitted? fn ty_infer(&self, span: Span) -> ty::t; @@ -132,7 +132,7 @@ pub fn ast_region_to_region( fn ast_path_substs( this: &AC, rscope: &RS, - def_id: ast::def_id, + def_id: ast::DefId, decl_generics: &ty::Generics, self_ty: Option, path: &ast::Path) -> ty::substs @@ -203,7 +203,7 @@ pub fn ast_path_to_substs_and_ty( this: &AC, rscope: &RS, - did: ast::def_id, + did: ast::DefId, path: &ast::Path) -> ty_param_substs_and_ty { let tcx = this.tcx(); @@ -220,7 +220,7 @@ pub fn ast_path_to_substs_and_ty( this: &AC, rscope: &RS, - trait_def_id: ast::def_id, + trait_def_id: ast::DefId, self_ty: Option, path: &ast::Path) -> @ty::TraitRef { @@ -243,7 +243,7 @@ pub fn ast_path_to_trait_ref( pub fn ast_path_to_ty( this: &AC, rscope: &RS, - did: ast::def_id, + did: ast::DefId, path: &ast::Path) -> ty_param_substs_and_ty { @@ -286,7 +286,7 @@ pub fn ast_ty_to_ty( match a_seq_ty.ty.node { ast::ty_vec(ref mt) => { let mut mt = ast_mt_to_mt(this, rscope, mt); - if a_seq_ty.mutbl == ast::m_mutbl { + if a_seq_ty.mutbl == ast::MutMutable { mt = ty::mt { ty: mt.ty, mutbl: a_seq_ty.mutbl }; } return ty::mk_evec(tcx, mt, vst); @@ -296,11 +296,11 @@ pub fn ast_ty_to_ty( // restriction is enforced in the below case for ty_path, which // will run after this as long as the path isn't a trait. match tcx.def_map.find(&id) { - Some(&ast::def_prim_ty(ast::ty_str)) if a_seq_ty.mutbl == ast::m_imm => { + Some(&ast::DefPrimTy(ast::ty_str)) if a_seq_ty.mutbl == ast::MutImmutable => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); return ty::mk_estr(tcx, vst); } - Some(&ast::def_trait(trait_def_id)) => { + Some(&ast::DefTrait(trait_def_id)) => { let result = ast_path_to_trait_ref( this, rscope, trait_def_id, None, path); let trait_store = match vst { @@ -430,14 +430,14 @@ pub fn ast_ty_to_ty( // Kind bounds on path types are only supported for traits. match a_def { // But don't emit the error if the user meant to do a trait anyway. - ast::def_trait(*) => { }, + ast::DefTrait(*) => { }, _ if bounds.is_some() => tcx.sess.span_err(ast_ty.span, "kind bounds can only be used on trait types"), _ => { }, } match a_def { - ast::def_trait(_) => { + ast::DefTrait(_) => { let path_str = path_to_str(path, tcx.sess.intr()); tcx.sess.span_err( ast_ty.span, @@ -446,10 +446,10 @@ pub fn ast_ty_to_ty( path_str, path_str, path_str, path_str)); ty::mk_err() } - ast::def_ty(did) | ast::def_struct(did) => { + ast::DefTy(did) | ast::DefStruct(did) => { ast_path_to_ty(this, rscope, did, path).ty } - ast::def_prim_ty(nty) => { + ast::DefPrimTy(nty) => { match nty { ast::ty_bool => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); @@ -475,11 +475,11 @@ pub fn ast_ty_to_ty( } } } - ast::def_ty_param(id, n) => { + ast::DefTyParam(id, n) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_param(tcx, n, id) } - ast::def_self_ty(id) => { + ast::DefSelfTy(id) => { // n.b.: resolve guarantees that the this type only appears in a // trait, which we rely upon in various places when creating // substs @@ -684,7 +684,7 @@ fn ty_of_method_or_bare_fn( ast::sty_uniq => { Some(ty::mk_uniq(this.tcx(), ty::mt {ty: self_info.untransformed_self_ty, - mutbl: ast::m_imm})) + mutbl: ast::MutImmutable})) } } } @@ -788,7 +788,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option { match lookup_def_tcx(tcx, b.path.span, b.ref_id) { - ast::def_trait(trait_did) => { + ast::DefTrait(trait_did) => { if ty::try_add_builtin_trait(tcx, trait_did, &mut builtin_bounds) { loop; // success diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index b2cec19963df9..bb3ed2e15d03f 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -25,9 +25,9 @@ use syntax::codemap::Span; use syntax::print::pprust; pub fn check_match(fcx: @mut FnCtxt, - expr: @ast::expr, - discrim: @ast::expr, - arms: &[ast::arm]) { + expr: @ast::Expr, + discrim: @ast::Expr, + arms: &[ast::Arm]) { let tcx = fcx.ccx.tcx; let discrim_ty = fcx.infcx().next_ty_var(); @@ -105,8 +105,8 @@ pub struct pat_ctxt { map: PatIdMap, } -pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path, - subpats: &Option<~[@ast::pat]>, expected: ty::t) { +pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path, + subpats: &Option<~[@ast::Pat]>, expected: ty::t) { // Typecheck the path. let fcx = pcx.fcx; @@ -286,9 +286,9 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path, pub fn check_struct_pat_fields(pcx: &pat_ctxt, span: Span, path: &ast::Path, - fields: &[ast::field_pat], + fields: &[ast::FieldPat], class_fields: ~[ty::field_ty], - class_id: ast::def_id, + class_id: ast::DefId, substitutions: &ty::substs, etc: bool) { let tcx = pcx.fcx.ccx.tcx; @@ -340,8 +340,8 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt, pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: Span, expected: ty::t, path: &ast::Path, - fields: &[ast::field_pat], etc: bool, - struct_id: ast::def_id, + fields: &[ast::FieldPat], etc: bool, + struct_id: ast::DefId, substitutions: &ty::substs) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; @@ -350,11 +350,11 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: Span, // Check to ensure that the struct is the one specified. match tcx.def_map.find(&pat_id) { - Some(&ast::def_struct(supplied_def_id)) + Some(&ast::DefStruct(supplied_def_id)) if supplied_def_id == struct_id => { // OK. } - Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => { + Some(&ast::DefStruct(*)) | Some(&ast::DefVariant(*)) => { let name = pprust::path_to_str(path, tcx.sess.intr()); tcx.sess.span_err(span, fmt!("mismatched types: expected `%s` but found `%s`", @@ -375,16 +375,16 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, span: Span, expected: ty::t, path: &ast::Path, - fields: &[ast::field_pat], + fields: &[ast::FieldPat], etc: bool, - enum_id: ast::def_id, + enum_id: ast::DefId, substitutions: &ty::substs) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; // Find the variant that was specified. match tcx.def_map.find(&pat_id) { - Some(&ast::def_variant(found_enum_id, variant_id)) + Some(&ast::DefVariant(found_enum_id, variant_id)) if found_enum_id == enum_id => { // Get the struct fields from this struct-like enum variant. let class_fields = ty::lookup_struct_fields(tcx, variant_id); @@ -392,7 +392,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, check_struct_pat_fields(pcx, span, path, fields, class_fields, variant_id, substitutions, etc); } - Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => { + Some(&ast::DefStruct(*)) | Some(&ast::DefVariant(*)) => { let name = pprust::path_to_str(path, tcx.sess.intr()); tcx.sess.span_err(span, fmt!("mismatched types: expected `%s` but \ @@ -408,19 +408,19 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, // Pattern checking is top-down rather than bottom-up so that bindings get // their types immediately. -pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { +pub fn check_pat(pcx: &pat_ctxt, pat: @ast::Pat, expected: ty::t) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; match pat.node { - ast::pat_wild => { + ast::PatWild => { fcx.write_ty(pat.id, expected); } - ast::pat_lit(lt) => { + ast::PatLit(lt) => { check_expr_has_type(fcx, lt, expected); fcx.write_ty(pat.id, fcx.expr_ty(lt)); } - ast::pat_range(begin, end) => { + ast::PatRange(begin, end) => { check_expr_has_type(fcx, begin, expected); check_expr_has_type(fcx, end, expected); let b_ty = @@ -451,18 +451,18 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { } fcx.write_ty(pat.id, b_ty); } - ast::pat_enum(*) | - ast::pat_ident(*) if pat_is_const(tcx.def_map, pat) => { + ast::PatEnum(*) | + ast::PatIdent(*) if pat_is_const(tcx.def_map, pat) => { let const_did = ast_util::def_id_of_def(tcx.def_map.get_copy(&pat.id)); let const_tpt = ty::lookup_item_type(tcx, const_did); demand::suptype(fcx, pat.span, expected, const_tpt.ty); fcx.write_ty(pat.id, const_tpt.ty); } - ast::pat_ident(bm, ref name, sub) if pat_is_binding(tcx.def_map, pat) => { + ast::PatIdent(bm, ref name, sub) if pat_is_binding(tcx.def_map, pat) => { let typ = fcx.local_ty(pat.span, pat.id); match bm { - ast::bind_by_ref(mutbl) => { + ast::BindByRef(mutbl) => { // if the binding is like // ref x | ref const x | ref mut x // then the type of x is &M T where M is the mutability @@ -475,7 +475,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { demand::eqtype(fcx, pat.span, region_ty, typ); } // otherwise the type of x is the expected type T - ast::bind_infer => { + ast::BindInfer => { demand::eqtype(fcx, pat.span, expected, typ); } } @@ -494,13 +494,13 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { _ => () } } - ast::pat_ident(_, ref path, _) => { + ast::PatIdent(_, ref path, _) => { check_pat_variant(pcx, pat, path, &Some(~[]), expected); } - ast::pat_enum(ref path, ref subpats) => { + ast::PatEnum(ref path, ref subpats) => { check_pat_variant(pcx, pat, path, subpats, expected); } - ast::pat_struct(ref path, ref fields, etc) => { + ast::PatStruct(ref path, ref fields, etc) => { // Grab the class data that we care about. let structure = structure_of(fcx, pat.span, expected); let mut error_happened = false; @@ -524,7 +524,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { Some(expected), ~"a structure pattern", None); match tcx.def_map.find(&pat.id) { - Some(&ast::def_struct(supplied_def_id)) => { + Some(&ast::DefStruct(supplied_def_id)) => { check_struct_pat(pcx, pat.id, pat.span, ty::mk_err(), path, *fields, etc, supplied_def_id, &ty::substs { self_ty: None, tps: ~[], regions: ty::ErasedRegions} ); @@ -542,7 +542,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.write_ty(pat.id, expected); } } - ast::pat_tup(ref elts) => { + ast::PatTup(ref elts) => { let s = structure_of(fcx, pat.span, expected); let e_count = elts.len(); match *s { @@ -572,16 +572,16 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { } } } - ast::pat_box(inner) => { + ast::PatBox(inner) => { check_pointer_pat(pcx, Managed, inner, pat.id, pat.span, expected); } - ast::pat_uniq(inner) => { + ast::PatUniq(inner) => { check_pointer_pat(pcx, Send, inner, pat.id, pat.span, expected); } - ast::pat_region(inner) => { + ast::PatRegion(inner) => { check_pointer_pat(pcx, Borrowed, inner, pat.id, pat.span, expected); } - ast::pat_vec(ref before, slice, ref after) => { + ast::PatVec(ref before, slice, ref after) => { let default_region_var = fcx.infcx().next_region_var( infer::PatternRegion(pat.span)); @@ -649,7 +649,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { // Helper function to check @, ~ and & patterns pub fn check_pointer_pat(pcx: &pat_ctxt, pointer_kind: PointerKind, - inner: @ast::pat, + inner: @ast::Pat, pat_id: ast::NodeId, span: Span, expected: ty::t) { diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 6b755510e8d15..dc718bbef752f 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -57,7 +57,7 @@ pub fn eqtype(fcx: @mut FnCtxt, sp: Span, expected: ty::t, actual: ty::t) { pub fn coerce(fcx: @mut FnCtxt, sp: Span, expected: ty::t, - expr: @ast::expr) { + expr: @ast::Expr) { let expr_ty = fcx.expr_ty(expr); match fcx.mk_assignty(expr, expr_ty, expected) { result::Ok(()) => { /* ok */ } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index c45f1c6ac4a10..75ccfdbf9ddbd 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -100,9 +100,9 @@ use std::hashmap::HashSet; use std::result; use std::vec; use extra::list::Nil; -use syntax::ast::{def_id, sty_value, sty_region, sty_box}; +use syntax::ast::{DefId, sty_value, sty_region, sty_box}; use syntax::ast::{sty_uniq, sty_static, NodeId}; -use syntax::ast::{m_mutbl, m_imm}; +use syntax::ast::{MutMutable, MutImmutable}; use syntax::ast; use syntax::ast_map; @@ -122,8 +122,8 @@ pub fn lookup( fcx: @mut FnCtxt, // In a call `a.b::(...)`: - expr: @ast::expr, // The expression `a.b(...)`. - self_expr: @ast::expr, // The expression `a`. + expr: @ast::Expr, // The expression `a.b(...)`. + self_expr: @ast::Expr, // The expression `a`. callee_id: NodeId, /* Where to store `a.b`'s type, * also the scope of the call */ m_name: ast::Ident, // The ident `b`. @@ -170,12 +170,12 @@ pub fn lookup( pub struct LookupContext<'self> { fcx: @mut FnCtxt, - expr: @ast::expr, - self_expr: @ast::expr, + expr: @ast::Expr, + self_expr: @ast::Expr, callee_id: NodeId, m_name: ast::Ident, supplied_tps: &'self [ty::t], - impl_dups: @mut HashSet, + impl_dups: @mut HashSet, inherent_candidates: @mut ~[Candidate], extension_candidates: @mut ~[Candidate], deref_args: check::DerefArgs, @@ -205,7 +205,7 @@ pub struct Candidate { /// because traits are not types, this is a pain to do. #[deriving(Clone)] enum RcvrMatchCondition { - RcvrMatchesIfObject(ast::def_id), + RcvrMatchesIfObject(ast::DefId), RcvrMatchesIfSubtype(ty::t) } @@ -371,7 +371,7 @@ impl<'self> LookupContext<'self> { // to a trait and its supertraits. fn get_method_index(&self, trait_ref: @TraitRef, - subtrait_id: ast::def_id, + subtrait_id: ast::DefId, n_method: uint) -> uint { let tcx = self.tcx(); @@ -395,7 +395,7 @@ impl<'self> LookupContext<'self> { fn push_inherent_candidates_from_object(&self, - did: def_id, + did: DefId, substs: &ty::substs) { debug!("push_inherent_candidates_from_object(did=%s, substs=%s)", self.did_to_str(did), @@ -468,7 +468,7 @@ impl<'self> LookupContext<'self> { fn push_inherent_candidates_from_self(&self, self_ty: ty::t, - did: def_id) { + did: DefId) { let tcx = self.tcx(); let trait_ref = ty::lookup_trait_def(tcx, did).trait_ref; @@ -537,7 +537,7 @@ impl<'self> LookupContext<'self> { } - fn push_inherent_impl_candidates_for_type(&self, did: def_id) { + fn push_inherent_impl_candidates_for_type(&self, did: DefId) { // Read the inherent implementation candidates for this type from the // metadata if necessary. ty::populate_implementations_for_type_if_necessary(self.tcx(), did); @@ -686,7 +686,7 @@ impl<'self> LookupContext<'self> { // the default method code fails when you try to reborrow // because it is not handling types correctly. In lieu of // fixing that, I am introducing this horrible hack. - ndm - self_mt.mutbl == m_imm && ty::type_is_self(self_mt.ty) + self_mt.mutbl == MutImmutable && ty::type_is_self(self_mt.ty) } } @@ -708,7 +708,7 @@ impl<'self> LookupContext<'self> { ty_evec(mt, vstore_fixed(_)) => { // First try to borrow to a slice let entry = self.search_for_some_kind_of_autorefd_method( - AutoBorrowVec, autoderefs, [m_imm, m_mutbl], + AutoBorrowVec, autoderefs, [MutImmutable, MutMutable], |m,r| ty::mk_evec(tcx, ty::mt {ty:mt.ty, mutbl:m}, vstore_slice(r))); @@ -717,7 +717,7 @@ impl<'self> LookupContext<'self> { // Then try to borrow to a slice *and* borrow a pointer. self.search_for_some_kind_of_autorefd_method( - AutoBorrowVecRef, autoderefs, [m_imm, m_mutbl], + AutoBorrowVecRef, autoderefs, [MutImmutable, MutMutable], |m,r| { let slice_ty = ty::mk_evec(tcx, ty::mt {ty:mt.ty, mutbl:m}, @@ -727,7 +727,7 @@ impl<'self> LookupContext<'self> { // to a temporary pointer (the borrowed // slice), so any update the callee makes to // it can't be observed. - ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m_imm}) + ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:MutImmutable}) }) } @@ -735,13 +735,13 @@ impl<'self> LookupContext<'self> { ty_estr(vstore_uniq) | ty_estr(vstore_fixed(_)) => { let entry = self.search_for_some_kind_of_autorefd_method( - AutoBorrowVec, autoderefs, [m_imm], + AutoBorrowVec, autoderefs, [MutImmutable], |_m,r| ty::mk_estr(tcx, vstore_slice(r))); if entry.is_some() { return entry; } self.search_for_some_kind_of_autorefd_method( - AutoBorrowVecRef, autoderefs, [m_imm], + AutoBorrowVecRef, autoderefs, [MutImmutable], |m,r| { let slice_ty = ty::mk_estr(tcx, vstore_slice(r)); ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m}) @@ -752,7 +752,7 @@ impl<'self> LookupContext<'self> { // Coerce ~/@/&Trait instances to &Trait. self.search_for_some_kind_of_autorefd_method( - AutoBorrowObj, autoderefs, [m_imm, m_mutbl], + AutoBorrowObj, autoderefs, [MutImmutable, MutMutable], |trt_mut, reg| { ty::mk_trait(tcx, trt_did, trt_substs.clone(), RegionTraitStore(reg), trt_mut, b) @@ -787,7 +787,7 @@ impl<'self> LookupContext<'self> { ty_float(*) | ty_enum(*) | ty_ptr(*) | ty_struct(*) | ty_tup(*) | ty_estr(*) | ty_evec(*) | ty_trait(*) | ty_closure(*) => { self.search_for_some_kind_of_autorefd_method( - AutoPtr, autoderefs, [m_imm, m_mutbl], + AutoPtr, autoderefs, [MutImmutable, MutMutable], |m,r| ty::mk_rptr(tcx, r, ty::mt {ty:self_ty, mutbl:m})) } @@ -803,10 +803,10 @@ impl<'self> LookupContext<'self> { fn search_for_some_kind_of_autorefd_method( &self, - kind: &fn(Region, ast::mutability) -> ty::AutoRef, + kind: &fn(Region, ast::Mutability) -> ty::AutoRef, autoderefs: uint, - mutbls: &[ast::mutability], - mk_autoref_ty: &fn(ast::mutability, ty::Region) -> ty::t) + mutbls: &[ast::Mutability], + mk_autoref_ty: &fn(ast::Mutability, ty::Region) -> ty::t) -> Option { // This is hokey. We should have mutability inference as a // variable. But for now, try &const, then &, then &mut: @@ -1050,7 +1050,7 @@ impl<'self> LookupContext<'self> { fn construct_transformed_self_ty_for_object( &self, - trait_def_id: ast::def_id, + trait_def_id: ast::DefId, rcvr_substs: &ty::substs, method_ty: &ty::Method) -> ty::t { @@ -1252,7 +1252,7 @@ impl<'self> LookupContext<'self> { } }; - fn rcvr_matches_object(self_did: ast::def_id, + fn rcvr_matches_object(self_did: ast::DefId, candidate: &Candidate) -> bool { match candidate.rcvr_match_condition { RcvrMatchesIfObject(desired_did) => { @@ -1277,8 +1277,8 @@ impl<'self> LookupContext<'self> { } } - fn mutability_matches(self_mutbl: ast::mutability, - candidate_mutbl: ast::mutability) + fn mutability_matches(self_mutbl: ast::Mutability, + candidate_mutbl: ast::Mutability) -> bool { //! True if `self_mutbl <: candidate_mutbl` self_mutbl == candidate_mutbl @@ -1299,7 +1299,7 @@ impl<'self> LookupContext<'self> { } } - fn report_static_candidate(&self, idx: uint, did: def_id) { + fn report_static_candidate(&self, idx: uint, did: DefId) { let span = if did.crate == ast::LOCAL_CRATE { match self.tcx().items.find(&did.node) { Some(&ast_map::node_method(m, _, _)) => m.span, @@ -1315,7 +1315,7 @@ impl<'self> LookupContext<'self> { ty::item_path_str(self.tcx(), did))); } - fn report_param_candidate(&self, idx: uint, did: def_id) { + fn report_param_candidate(&self, idx: uint, did: DefId) { self.tcx().sess.span_note( self.expr.span, fmt!("candidate #%u derives from the bound `%s`", @@ -1323,7 +1323,7 @@ impl<'self> LookupContext<'self> { ty::item_path_str(self.tcx(), did))); } - fn report_trait_candidate(&self, idx: uint, did: def_id) { + fn report_trait_candidate(&self, idx: uint, did: DefId) { self.tcx().sess.span_note( self.expr.span, fmt!("candidate #%u derives from the type of the receiver, \ @@ -1351,7 +1351,7 @@ impl<'self> LookupContext<'self> { cand.origin) } - fn did_to_str(&self, did: def_id) -> ~str { + fn did_to_str(&self, did: DefId) -> ~str { ty::item_path_str(self.tcx(), did) } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 8d5f257ebd6bf..ddf5a91202b5e 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -288,7 +288,7 @@ pub fn blank_fn_ctxt(ccx: @mut CrateCtxt, } impl ExprTyProvider for FnCtxt { - fn expr_ty(&self, ex: &ast::expr) -> ty::t { + fn expr_ty(&self, ex: &ast::Expr) -> ty::t { self.expr_ty(ex) } @@ -371,9 +371,9 @@ impl Visitor<()> for GatherLocalsVisitor { } // Add pattern bindings. - fn visit_pat(&mut self, p:@ast::pat, _:()) { + fn visit_pat(&mut self, p:@ast::Pat, _:()) { match p.node { - ast::pat_ident(_, ref path, _) + ast::PatIdent(_, ref path, _) if pat_util::pat_is_binding(self.fcx.ccx.tcx.def_map, p) => { self.assign(p.id, None); debug!("Pattern binding %s is assigned to %s", @@ -657,11 +657,11 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { impl AstConv for FnCtxt { fn tcx(&self) -> ty::ctxt { self.ccx.tcx } - fn get_item_ty(&self, id: ast::def_id) -> ty::ty_param_bounds_and_ty { + fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty { ty::lookup_item_type(self.tcx(), id) } - fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef { + fn get_trait_def(&self, id: ast::DefId) -> @ty::TraitDef { ty::lookup_trait_def(self.tcx(), id) } @@ -800,11 +800,11 @@ impl FnCtxt { ast_ty_to_ty(self, self, ast_t) } - pub fn pat_to_str(&self, pat: @ast::pat) -> ~str { + pub fn pat_to_str(&self, pat: @ast::Pat) -> ~str { pat.repr(self.tcx()) } - pub fn expr_ty(&self, ex: &ast::expr) -> ty::t { + pub fn expr_ty(&self, ex: &ast::Expr) -> ty::t { match self.inh.node_types.find(&ex.id) { Some(&t) => t, None => { @@ -867,7 +867,7 @@ impl FnCtxt { } pub fn mk_assignty(&self, - expr: @ast::expr, + expr: @ast::Expr, sub: ty::t, sup: ty::t) -> Result<(), ty::type_err> { @@ -1040,8 +1040,8 @@ pub fn check_lit(fcx: @mut FnCtxt, lit: @ast::lit) -> ty::t { } pub fn valid_range_bounds(ccx: @mut CrateCtxt, - from: @ast::expr, - to: @ast::expr) + from: @ast::Expr, + to: @ast::Expr) -> Option { match const_eval::compare_lit_exprs(ccx.tcx, from, to) { Some(val) => Some(val <= 0), @@ -1050,7 +1050,7 @@ pub fn valid_range_bounds(ccx: @mut CrateCtxt, } pub fn check_expr_has_type( - fcx: @mut FnCtxt, expr: @ast::expr, + fcx: @mut FnCtxt, expr: @ast::Expr, expected: ty::t) { do check_expr_with_unifier(fcx, expr, Some(expected)) { demand::suptype(fcx, expr.span, expected, fcx.expr_ty(expr)); @@ -1058,7 +1058,7 @@ pub fn check_expr_has_type( } pub fn check_expr_coercable_to_type( - fcx: @mut FnCtxt, expr: @ast::expr, + fcx: @mut FnCtxt, expr: @ast::Expr, expected: ty::t) { do check_expr_with_unifier(fcx, expr, Some(expected)) { demand::coerce(fcx, expr.span, expected, expr) @@ -1066,18 +1066,18 @@ pub fn check_expr_coercable_to_type( } pub fn check_expr_with_hint( - fcx: @mut FnCtxt, expr: @ast::expr, + fcx: @mut FnCtxt, expr: @ast::Expr, expected: ty::t) { check_expr_with_unifier(fcx, expr, Some(expected), || ()) } pub fn check_expr_with_opt_hint( - fcx: @mut FnCtxt, expr: @ast::expr, + fcx: @mut FnCtxt, expr: @ast::Expr, expected: Option) { check_expr_with_unifier(fcx, expr, expected, || ()) } -pub fn check_expr(fcx: @mut FnCtxt, expr: @ast::expr) { +pub fn check_expr(fcx: @mut FnCtxt, expr: @ast::Expr) { check_expr_with_unifier(fcx, expr, None, || ()) } @@ -1088,7 +1088,7 @@ pub fn check_expr(fcx: @mut FnCtxt, expr: @ast::expr) { pub fn impl_self_ty(vcx: &VtableContext, location_info: &LocationInfo, // (potential) receiver for // this impl - did: ast::def_id) + did: ast::DefId) -> ty_param_substs_and_ty { let tcx = vcx.tcx(); @@ -1114,7 +1114,7 @@ pub fn impl_self_ty(vcx: &VtableContext, // Only for fields! Returns for methods> // Indifferent to privacy flags pub fn lookup_field_ty(tcx: ty::ctxt, - class_id: ast::def_id, + class_id: ast::DefId, items: &[ty::field_ty], fieldname: ast::Ident, substs: &ty::substs) -> Option { @@ -1151,7 +1151,7 @@ fn generics_of_static_method_container(type_context: ty::ctxt, // locations. fn check_type_parameter_positions_in_path(function_context: @mut FnCtxt, path: &ast::Path, - def: ast::def) { + def: ast::Def) { // We only care about checking the case in which the path has two or // more segments. if path.segments.len() < 2 { @@ -1193,7 +1193,7 @@ fn check_type_parameter_positions_in_path(function_context: @mut FnCtxt, // ensure that the segment of the path which names the trait or // implementation (the penultimate segment) is annotated with the // right number of type parameters. - ast::def_static_method(_, provenance, _) => { + ast::DefStaticMethod(_, provenance, _) => { let generics = generics_of_static_method_container(function_context.ccx.tcx, provenance); @@ -1299,7 +1299,7 @@ fn check_type_parameter_positions_in_path(function_context: @mut FnCtxt, /// that there are actually multiple representations for both `ty_err` and /// `ty_bot`, so avoid that when err and bot need to be handled differently. pub fn check_expr_with_unifier(fcx: @mut FnCtxt, - expr: @ast::expr, + expr: @ast::Expr, expected: Option, unifier: &fn()) { debug!(">> typechecking"); @@ -1308,8 +1308,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx: @mut FnCtxt, sp: Span, method_fn_ty: ty::t, - callee_expr: @ast::expr, - args: &[@ast::expr], + callee_expr: @ast::Expr, + args: &[@ast::Expr], sugar: ast::CallSugar, deref_args: DerefArgs) -> ty::t { @@ -1338,8 +1338,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx: @mut FnCtxt, sp: Span, fn_inputs: &[ty::t], - callee_expr: @ast::expr, - args: &[@ast::expr], + callee_expr: @ast::Expr, + args: &[@ast::Expr], sugar: ast::CallSugar, deref_args: DerefArgs) { @@ -1403,8 +1403,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, for (i, arg) in args.iter().enumerate() { let is_block = match arg.node { - ast::expr_fn_block(*) | - ast::expr_do_body(*) => true, + ast::ExprFnBlock(*) | + ast::ExprDoBody(*) => true, _ => false }; @@ -1439,8 +1439,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // A generic function for checking assignment expressions fn check_assignment(fcx: @mut FnCtxt, - lhs: @ast::expr, - rhs: @ast::expr, + lhs: @ast::Expr, + rhs: @ast::Expr, id: ast::NodeId) { check_expr(fcx, lhs); let lhs_type = fcx.expr_ty(lhs); @@ -1450,7 +1450,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fn write_call(fcx: @mut FnCtxt, - call_expr: @ast::expr, + call_expr: @ast::Expr, output: ty::t, sugar: ast::CallSugar) { let ret_ty = match sugar { @@ -1472,9 +1472,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // A generic function for doing all of the checking for call expressions fn check_call(fcx: @mut FnCtxt, callee_id: ast::NodeId, - call_expr: @ast::expr, - f: @ast::expr, - args: &[@ast::expr], + call_expr: @ast::Expr, + f: @ast::Expr, + args: &[@ast::Expr], sugar: ast::CallSugar) { // Index expressions need to be handled separately, to inform them // that they appear in call position. @@ -1534,10 +1534,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // Checks a method call. fn check_method_call(fcx: @mut FnCtxt, callee_id: ast::NodeId, - expr: @ast::expr, - rcvr: @ast::expr, + expr: @ast::Expr, + rcvr: @ast::Expr, method_name: ast::Ident, - args: &[@ast::expr], + args: &[@ast::Expr], tps: &[ast::Ty], sugar: ast::CallSugar) { check_expr(fcx, rcvr); @@ -1593,9 +1593,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // A generic function for checking the then and else in an if // or if-check fn check_then_else(fcx: @mut FnCtxt, - cond_expr: @ast::expr, + cond_expr: @ast::Expr, then_blk: &ast::Block, - opt_else_expr: Option<@ast::expr>, + opt_else_expr: Option<@ast::Expr>, id: ast::NodeId, sp: Span, expected: Option) { @@ -1633,11 +1633,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn lookup_op_method(fcx: @mut FnCtxt, callee_id: ast::NodeId, - op_ex: @ast::expr, - self_ex: @ast::expr, + op_ex: @ast::Expr, + self_ex: @ast::Expr, self_t: ty::t, opname: ast::Ident, - args: ~[@ast::expr], + args: ~[@ast::Expr], deref_args: DerefArgs, autoderef_receiver: AutoderefReceiverFlag, unbound_method: &fn(), @@ -1671,10 +1671,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // could be either a expr_binop or an expr_assign_binop fn check_binop(fcx: @mut FnCtxt, callee_id: ast::NodeId, - expr: @ast::expr, - op: ast::binop, - lhs: @ast::expr, - rhs: @ast::expr, + expr: @ast::Expr, + op: ast::BinOp, + lhs: @ast::Expr, + rhs: @ast::Expr, // Used only in the error case expected_result: Option, allow_overloaded_operators: AllowOverloadedOperatorsFlag @@ -1701,8 +1701,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, check_expr_has_type(fcx, rhs, tvar); let result_t = match op { - ast::eq | ast::ne | ast::lt | ast::le | ast::ge | - ast::gt => { + ast::BiEq | ast::BiNe | ast::BiLt | ast::BiLe | ast::BiGe | + ast::BiGt => { ty::mk_bool() } _ => { @@ -1714,7 +1714,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, return; } - if op == ast::or || op == ast::and { + if op == ast::BiOr || op == ast::BiAnd { // This is an error; one of the operands must have the wrong // type fcx.write_error(expr.id); @@ -1759,11 +1759,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn check_user_binop(fcx: @mut FnCtxt, callee_id: ast::NodeId, - ex: @ast::expr, - lhs_expr: @ast::expr, + ex: @ast::Expr, + lhs_expr: @ast::Expr, lhs_resolved_t: ty::t, - op: ast::binop, - rhs: @ast::expr, + op: ast::BinOp, + rhs: @ast::Expr, expected_result: Option) -> ty::t { let tcx = fcx.ccx.tcx; match ast_util::binop_to_method_name(op) { @@ -1786,7 +1786,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // If the or operator is used it might be that the user forgot to // supply the do keyword. Let's be more helpful in that situation. - if op == ast::or { + if op == ast::BiOr { match ty::get(lhs_resolved_t).sty { ty::ty_bare_fn(_) | ty::ty_closure(_) => { tcx.sess.span_note( @@ -1803,8 +1803,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, callee_id: ast::NodeId, op_str: &str, mname: &str, - ex: @ast::expr, - rhs_expr: @ast::expr, + ex: @ast::Expr, + rhs_expr: @ast::Expr, rhs_t: ty::t, expected_t: Option) -> ty::t { @@ -1840,7 +1840,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fn check_expr_fn(fcx: @mut FnCtxt, - expr: @ast::expr, + expr: @ast::Expr, ast_sigil_opt: Option, decl: &ast::fn_decl, body: &ast::Block, @@ -1934,8 +1934,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, // Check field access expressions fn check_field(fcx: @mut FnCtxt, - expr: @ast::expr, - base: @ast::expr, + expr: @ast::Expr, + base: @ast::Expr, field: ast::Ident, tys: &[ast::Ty]) { let tcx = fcx.ccx.tcx; @@ -2006,7 +2006,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn check_struct_or_variant_fields(fcx: @mut FnCtxt, span: Span, - class_id: ast::def_id, + class_id: ast::DefId, node_id: ast::NodeId, substitutions: ty::substs, field_types: &[ty::field_ty], @@ -2097,9 +2097,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn check_struct_constructor(fcx: @mut FnCtxt, id: ast::NodeId, span: codemap::Span, - class_id: ast::def_id, + class_id: ast::DefId, fields: &[ast::Field], - base_expr: Option<@ast::expr>) { + base_expr: Option<@ast::Expr>) { let tcx = fcx.ccx.tcx; // Look up the number of type parameters and the raw type, and @@ -2186,8 +2186,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn check_struct_enum_variant(fcx: @mut FnCtxt, id: ast::NodeId, span: codemap::Span, - enum_id: ast::def_id, - variant_id: ast::def_id, + enum_id: ast::DefId, + variant_id: ast::DefId, fields: &[ast::Field]) { let tcx = fcx.ccx.tcx; @@ -2257,20 +2257,20 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let tcx = fcx.ccx.tcx; let id = expr.id; match expr.node { - ast::expr_vstore(ev, vst) => { + ast::ExprVstore(ev, vst) => { let typ = match ev.node { - ast::expr_lit(@codemap::Spanned { node: ast::lit_str(_), _ }) => { + ast::ExprLit(@codemap::Spanned { node: ast::lit_str(_), _ }) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); ty::mk_estr(tcx, tt) } - ast::expr_vec(ref args, mutbl) => { + ast::ExprVec(ref args, mutbl) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); let mutability; let mut any_error = false; let mut any_bot = false; match vst { - ast::expr_vstore_mut_box | ast::expr_vstore_mut_slice => { - mutability = ast::m_mutbl + ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => { + mutability = ast::MutMutable } _ => mutability = mutbl } @@ -2295,13 +2295,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt) } } - ast::expr_repeat(element, count_expr, mutbl) => { + ast::ExprRepeat(element, count_expr, mutbl) => { check_expr_with_hint(fcx, count_expr, ty::mk_uint()); let _ = ty::eval_repeat_count(fcx, count_expr); let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); let mutability = match vst { - ast::expr_vstore_mut_box | ast::expr_vstore_mut_slice => { - ast::m_mutbl + ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => { + ast::MutMutable } _ => mutbl }; @@ -2323,11 +2323,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(id, typ); } - ast::expr_lit(lit) => { + ast::ExprLit(lit) => { let typ = check_lit(fcx, lit); fcx.write_ty(id, typ); } - ast::expr_binary(callee_id, op, lhs, rhs) => { + ast::ExprBinary(callee_id, op, lhs, rhs) => { check_binop(fcx, callee_id, expr, @@ -2348,7 +2348,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_bot(id); } } - ast::expr_assign_op(callee_id, op, lhs, rhs) => { + ast::ExprAssignOp(callee_id, op, lhs, rhs) => { check_binop(fcx, callee_id, expr, @@ -2370,15 +2370,15 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_nil(expr.id); } } - ast::expr_unary(callee_id, unop, oprnd) => { + ast::ExprUnary(callee_id, unop, oprnd) => { let exp_inner = do unpack_expected(fcx, expected) |sty| { match unop { - ast::box(_) | ast::uniq => match *sty { + ast::UnBox(_) | ast::UnUniq => match *sty { ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty), _ => None }, - ast::not | ast::neg => expected, - ast::deref => None + ast::UnNot | ast::UnNeg => expected, + ast::UnDeref => None } }; check_expr_with_opt_hint(fcx, oprnd, exp_inner); @@ -2386,16 +2386,16 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, if !ty::type_is_error(oprnd_t) && !ty::type_is_bot(oprnd_t) { match unop { - ast::box(mutbl) => { + ast::UnBox(mutbl) => { oprnd_t = ty::mk_box(tcx, ty::mt {ty: oprnd_t, mutbl: mutbl}); } - ast::uniq => { + ast::UnUniq => { oprnd_t = ty::mk_uniq(tcx, ty::mt {ty: oprnd_t, - mutbl: ast::m_imm}); + mutbl: ast::MutImmutable}); } - ast::deref => { + ast::UnDeref => { let sty = structure_of(fcx, expr.span, oprnd_t); let operand_ty = ty::deref_sty(tcx, sty, true); match operand_ty { @@ -2425,7 +2425,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } } } - ast::not => { + ast::UnNot => { oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || @@ -2435,7 +2435,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, expected); } } - ast::neg => { + ast::UnNeg => { oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || @@ -2448,7 +2448,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fcx.write_ty(id, oprnd_t); } - ast::expr_addr_of(mutbl, oprnd) => { + ast::ExprAddrOf(mutbl, oprnd) => { let hint = unpack_expected( fcx, expected, |sty| match *sty { ty::ty_rptr(_, ref mt) => Some(mt.ty), @@ -2482,20 +2482,20 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, }; fcx.write_ty(id, oprnd_t); } - ast::expr_path(ref pth) => { + ast::ExprPath(ref pth) => { let defn = lookup_def(fcx, pth.span, id); check_type_parameter_positions_in_path(fcx, pth, defn); let tpt = ty_param_bounds_and_ty_for_def(fcx, expr.span, defn); instantiate_path(fcx, pth, tpt, defn, expr.span, expr.id); } - ast::expr_self => { + ast::ExprSelf => { let definition = lookup_def(fcx, expr.span, id); let ty_param_bounds_and_ty = ty_param_bounds_and_ty_for_def(fcx, expr.span, definition); fcx.write_ty(id, ty_param_bounds_and_ty.ty); } - ast::expr_inline_asm(ref ia) => { + ast::ExprInlineAsm(ref ia) => { for &(_, input) in ia.inputs.iter() { check_expr(fcx, input); } @@ -2504,10 +2504,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fcx.write_nil(id); } - ast::expr_mac(_) => tcx.sess.bug("unexpanded macro"), - ast::expr_break(_) => { fcx.write_bot(id); } - ast::expr_again(_) => { fcx.write_bot(id); } - ast::expr_ret(expr_opt) => { + ast::ExprMac(_) => tcx.sess.bug("unexpanded macro"), + ast::ExprBreak(_) => { fcx.write_bot(id); } + ast::ExprAgain(_) => { fcx.write_bot(id); } + ast::ExprRet(expr_opt) => { let ret_ty = fcx.ret_ty; match expr_opt { None => match fcx.mk_eqty(false, infer::Misc(expr.span), @@ -2525,7 +2525,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fcx.write_bot(id); } - ast::expr_log(lv, e) => { + ast::ExprLog(lv, e) => { check_expr_has_type(fcx, lv, ty::mk_mach_uint(ast::ty_u32)); @@ -2538,11 +2538,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_nil(id); } } - ast::expr_paren(a) => { + ast::ExprParen(a) => { check_expr_with_opt_hint(fcx, a, expected); fcx.write_ty(id, fcx.expr_ty(a)); } - ast::expr_assign(lhs, rhs) => { + ast::ExprAssign(lhs, rhs) => { check_assignment(fcx, lhs, rhs, id); let lhs_ty = fcx.expr_ty(lhs); let rhs_ty = fcx.expr_ty(rhs); @@ -2556,11 +2556,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_nil(id); } } - ast::expr_if(cond, ref then_blk, opt_else_expr) => { + ast::ExprIf(cond, ref then_blk, opt_else_expr) => { check_then_else(fcx, cond, then_blk, opt_else_expr, id, expr.span, expected); } - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { check_expr_has_type(fcx, cond, ty::mk_bool()); check_block_no_value(fcx, body); let cond_ty = fcx.expr_ty(cond); @@ -2575,9 +2575,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_nil(id); } } - ast::expr_for_loop(*) => + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop"), - ast::expr_loop(ref body, _) => { + ast::ExprLoop(ref body, _) => { check_block_no_value(fcx, (body)); if !may_break(tcx, expr.id, body) { fcx.write_bot(id); @@ -2586,14 +2586,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_nil(id); } } - ast::expr_match(discrim, ref arms) => { + ast::ExprMatch(discrim, ref arms) => { _match::check_match(fcx, expr, discrim, *arms); } - ast::expr_fn_block(ref decl, ref body) => { + ast::ExprFnBlock(ref decl, ref body) => { check_expr_fn(fcx, expr, None, decl, body, Vanilla, expected); } - ast::expr_do_body(b) => { + ast::ExprDoBody(b) => { let expected_sty = unpack_expected(fcx, expected, |x| Some((*x).clone())); @@ -2618,7 +2618,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } }; match b.node { - ast::expr_fn_block(ref decl, ref body) => { + ast::ExprFnBlock(ref decl, ref body) => { check_expr_fn(fcx, b, None, decl, body, DoBlock, Some(inner_ty)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); @@ -2628,11 +2628,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fcx.write_ty(expr.id, fcx.node_ty(b.id)); } - ast::expr_block(ref b) => { + ast::ExprBlock(ref b) => { check_block_with_expected(fcx, b, expected); fcx.write_ty(id, fcx.node_ty(b.id)); } - ast::expr_call(f, ref args, sugar) => { + ast::ExprCall(f, ref args, sugar) => { check_call(fcx, expr.id, expr, f, *args, sugar); let f_ty = fcx.expr_ty(f); let (args_bot, args_err) = args.iter().fold((false, false), @@ -2648,7 +2648,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_bot(id); } } - ast::expr_method_call(callee_id, rcvr, ident, ref tps, ref args, sugar) => { + ast::ExprMethodCall(callee_id, rcvr, ident, ref tps, ref args, sugar) => { check_method_call(fcx, callee_id, expr, rcvr, ident, *args, *tps, sugar); let f_ty = fcx.expr_ty(rcvr); let arg_tys = args.map(|a| fcx.expr_ty(*a)); @@ -2663,7 +2663,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_bot(id); } } - ast::expr_cast(e, ref t) => { + ast::ExprCast(e, ref t) => { check_expr(fcx, e); let t_1 = fcx.to_ty(t); let t_e = fcx.expr_ty(e); @@ -2757,7 +2757,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(id, t_1); } } - ast::expr_vec(ref args, mutbl) => { + ast::ExprVec(ref args, mutbl) => { let t: ty::t = fcx.infcx().next_ty_var(); for e in args.iter() { check_expr_has_type(fcx, *e, t); @@ -2766,7 +2766,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::vstore_fixed(args.len())); fcx.write_ty(id, typ); } - ast::expr_repeat(element, count_expr, mutbl) => { + ast::ExprRepeat(element, count_expr, mutbl) => { check_expr_with_hint(fcx, count_expr, ty::mk_uint()); let count = ty::eval_repeat_count(fcx, count_expr); let t: ty::t = fcx.infcx().next_ty_var(); @@ -2784,7 +2784,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(id, t); } } - ast::expr_tup(ref elts) => { + ast::ExprTup(ref elts) => { let flds = unpack_expected(fcx, expected, |sty| { match *sty { ty::ty_tup(ref flds) => Some((*flds).clone()), @@ -2814,14 +2814,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(id, typ); } } - ast::expr_struct(ref path, ref fields, base_expr) => { + ast::ExprStruct(ref path, ref fields, base_expr) => { // Resolve the path. match tcx.def_map.find(&id) { - Some(&ast::def_struct(type_def_id)) => { + Some(&ast::DefStruct(type_def_id)) => { check_struct_constructor(fcx, id, expr.span, type_def_id, *fields, base_expr); } - Some(&ast::def_variant(enum_id, variant_id)) => { + Some(&ast::DefVariant(enum_id, variant_id)) => { check_struct_enum_variant(fcx, id, expr.span, enum_id, variant_id, *fields); } @@ -2831,10 +2831,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } } } - ast::expr_field(base, field, ref tys) => { + ast::ExprField(base, field, ref tys) => { check_field(fcx, expr, base, field, *tys); } - ast::expr_index(callee_id, base, idx) => { + ast::ExprIndex(callee_id, base, idx) => { check_expr(fcx, base); check_expr(fcx, idx); let raw_base_t = fcx.expr_ty(base); @@ -2908,7 +2908,7 @@ pub fn require_integral(fcx: @mut FnCtxt, sp: Span, t: ty::t) { pub fn check_decl_initializer(fcx: @mut FnCtxt, nid: ast::NodeId, - init: @ast::expr) + init: @ast::Expr) { let local_ty = fcx.local_ty(init.span, nid); check_expr_coercable_to_type(fcx, init, local_ty) @@ -2942,24 +2942,24 @@ pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::Local) { } } -pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) { +pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::Stmt) { let node_id; let mut saw_bot = false; let mut saw_err = false; match stmt.node { - ast::stmt_decl(decl, id) => { + ast::StmtDecl(decl, id) => { node_id = id; match decl.node { - ast::decl_local(ref l) => { + ast::DeclLocal(ref l) => { check_decl_local(fcx, *l); let l_t = fcx.node_ty(l.id); saw_bot = saw_bot || ty::type_is_bot(l_t); saw_err = saw_err || ty::type_is_error(l_t); } - ast::decl_item(_) => {/* ignore for now */ } + ast::DeclItem(_) => {/* ignore for now */ } } } - ast::stmt_expr(expr, id) => { + ast::StmtExpr(expr, id) => { node_id = id; // Check with expected type of () check_expr_has_type(fcx, expr, ty::mk_nil()); @@ -2967,14 +2967,14 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) { saw_bot = saw_bot || ty::type_is_bot(expr_ty); saw_err = saw_err || ty::type_is_error(expr_ty); } - ast::stmt_semi(expr, id) => { + ast::StmtSemi(expr, id) => { node_id = id; check_expr(fcx, expr); let expr_ty = fcx.expr_ty(expr); saw_bot |= ty::type_is_bot(expr_ty); saw_err |= ty::type_is_error(expr_ty); } - ast::stmt_mac(*) => fcx.ccx.tcx.sess.bug("unexpanded macro") + ast::StmtMac(*) => fcx.ccx.tcx.sess.bug("unexpanded macro") } if saw_bot { fcx.write_bot(node_id); @@ -3022,9 +3022,9 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt, let s_id = ast_util::stmt_id(*s); let s_ty = fcx.node_ty(s_id); if last_was_bot && !warned && match s.node { - ast::stmt_decl(@codemap::Spanned { node: ast::decl_local(_), + ast::StmtDecl(@codemap::Spanned { node: ast::DeclLocal(_), _}, _) | - ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => { + ast::StmtExpr(_, _) | ast::StmtSemi(_, _) => { true } _ => false @@ -3071,7 +3071,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt, pub fn check_const(ccx: @mut CrateCtxt, sp: Span, - e: @ast::expr, + e: @ast::Expr, id: ast::NodeId) { let rty = ty::node_id_to_type(ccx.tcx, id); let fcx = blank_fn_ctxt(ccx, rty, e.id); @@ -3081,7 +3081,7 @@ pub fn check_const(ccx: @mut CrateCtxt, pub fn check_const_with_ty(fcx: @mut FnCtxt, _: Span, - e: @ast::expr, + e: @ast::Expr, declty: ty::t) { check_expr(fcx, e); let cty = fcx.expr_ty(e); @@ -3236,54 +3236,54 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, check_instantiable(ccx.tcx, sp, id); } -pub fn lookup_def(fcx: @mut FnCtxt, sp: Span, id: ast::NodeId) -> ast::def { +pub fn lookup_def(fcx: @mut FnCtxt, sp: Span, id: ast::NodeId) -> ast::Def { lookup_def_ccx(fcx.ccx, sp, id) } // Returns the type parameter count and the type for the given definition. pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, sp: Span, - defn: ast::def) + defn: ast::Def) -> ty_param_bounds_and_ty { match defn { - ast::def_arg(nid, _) | ast::def_local(nid, _) | ast::def_self(nid) | - ast::def_binding(nid, _) => { + ast::DefArg(nid, _) | ast::DefLocal(nid, _) | ast::DefSelf(nid) | + ast::DefBinding(nid, _) => { let typ = fcx.local_ty(sp, nid); return no_params(typ); } - ast::def_fn(id, _) | ast::def_static_method(id, _, _) | - ast::def_static(id, _) | ast::def_variant(_, id) | - ast::def_struct(id) => { + ast::DefFn(id, _) | ast::DefStaticMethod(id, _, _) | + ast::DefStatic(id, _) | ast::DefVariant(_, id) | + ast::DefStruct(id) => { return ty::lookup_item_type(fcx.ccx.tcx, id); } - ast::def_upvar(_, inner, _, _) => { + ast::DefUpvar(_, inner, _, _) => { return ty_param_bounds_and_ty_for_def(fcx, sp, *inner); } - ast::def_trait(_) | - ast::def_ty(_) | - ast::def_prim_ty(_) | - ast::def_ty_param(*)=> { + ast::DefTrait(_) | + ast::DefTy(_) | + ast::DefPrimTy(_) | + ast::DefTyParam(*)=> { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type"); } - ast::def_mod(*) | ast::def_foreign_mod(*) => { + ast::DefMod(*) | ast::DefForeignMod(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found module"); } - ast::def_use(*) => { + ast::DefUse(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found use"); } - ast::def_region(*) => { + ast::DefRegion(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found region"); } - ast::def_typaram_binder(*) => { + ast::DefTyParamBinder(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type parameter"); } - ast::def_label(*) => { + ast::DefLabel(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found label"); } - ast::def_self_ty(*) => { + ast::DefSelfTy(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found self ty"); } - ast::def_method(*) => { + ast::DefMethod(*) => { fcx.ccx.tcx.sess.span_bug(sp, "expected value but found method"); } } @@ -3294,7 +3294,7 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, pub fn instantiate_path(fcx: @mut FnCtxt, pth: &ast::Path, tpt: ty_param_bounds_and_ty, - def: ast::def, + def: ast::Def, span: Span, node_id: ast::NodeId) { debug!(">>> instantiate_path"); @@ -3341,7 +3341,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt, // of type parameters actually manifest in the AST. This will differ from // the internal type parameter count when there are self types involved. let (user_type_parameter_count, self_parameter_index) = match def { - ast::def_static_method(_, provenance @ ast::FromTrait(_), _) => { + ast::DefStaticMethod(_, provenance @ ast::FromTrait(_), _) => { let generics = generics_of_static_method_container(fcx.ccx.tcx, provenance); (ty_param_count - 1, Some(generics.type_param_defs.len())) @@ -3455,13 +3455,13 @@ pub fn type_is_c_like_enum(fcx: @mut FnCtxt, sp: Span, typ: ty::t) -> bool { } pub fn ast_expr_vstore_to_vstore(fcx: @mut FnCtxt, - e: @ast::expr, - v: ast::expr_vstore) + e: @ast::Expr, + v: ast::ExprVstore) -> ty::vstore { match v { - ast::expr_vstore_uniq => ty::vstore_uniq, - ast::expr_vstore_box | ast::expr_vstore_mut_box => ty::vstore_box, - ast::expr_vstore_slice | ast::expr_vstore_mut_slice => { + ast::ExprVstoreUniq => ty::vstore_uniq, + ast::ExprVstoreBox | ast::ExprVstoreMutBox => ty::vstore_box, + ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => { let r = fcx.infcx().next_region_var(infer::AddrOfSlice(e.span)); ty::vstore_slice(r) } @@ -3474,7 +3474,7 @@ pub fn may_break(cx: ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool { // inside the loop? (loop_query(b, |e| { match *e { - ast::expr_break(_) => true, + ast::ExprBreak(_) => true, _ => false } })) || @@ -3482,9 +3482,9 @@ pub fn may_break(cx: ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool { // nested anywhere inside the loop? (block_query(b, |e| { match e.node { - ast::expr_break(Some(_)) => + ast::ExprBreak(Some(_)) => match cx.def_map.find(&e.id) { - Some(&ast::def_label(loop_id)) if id == loop_id => true, + Some(&ast::DefLabel(loop_id)) if id == loop_id => true, _ => false, }, _ => false @@ -3610,7 +3610,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { }; let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt { ty: tydesc_ty, - mutbl: ast::m_imm + mutbl: ast::MutImmutable }); (1u, ~[], td_ptr) } @@ -3627,7 +3627,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt { ty: tydesc_ty, - mutbl: ast::m_imm + mutbl: ast::MutImmutable }); (0, ~[ td_ptr, visitor_object_ty ], ty::mk_nil()) } @@ -3654,13 +3654,13 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable }), ty::mk_int() ], ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable })) } "memcpy32" => { @@ -3668,11 +3668,11 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable }), ty::mk_u32() ], @@ -3683,11 +3683,11 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable }), ty::mk_u64() ], @@ -3698,11 +3698,11 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable }), ty::mk_u32() ], @@ -3713,11 +3713,11 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_imm + mutbl: ast::MutImmutable }), ty::mk_u64() ], @@ -3728,7 +3728,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_u8(), ty::mk_u32() @@ -3740,7 +3740,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~[ ty::mk_ptr(tcx, ty::mt { ty: param(ccx, 0), - mutbl: ast::m_mutbl + mutbl: ast::MutMutable }), ty::mk_u8(), ty::mk_u64() diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index dc5a60876a45e..d121496af2b2d 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -40,7 +40,7 @@ use util::ppaux::{ty_to_str, region_to_str}; use middle::pat_util; use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil}; -use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar}; +use syntax::ast::{DefArg, DefBinding, DefLocal, DefSelf, DefUpvar}; use syntax::ast; use syntax::codemap::Span; use syntax::visit; @@ -54,14 +54,14 @@ pub struct Rcx { repeating_scope: ast::NodeId, } -fn encl_region_of_def(fcx: @mut FnCtxt, def: ast::def) -> ty::Region { +fn encl_region_of_def(fcx: @mut FnCtxt, def: ast::Def) -> ty::Region { let tcx = fcx.tcx(); match def { - def_local(node_id, _) | def_arg(node_id, _) | - def_self(node_id) | def_binding(node_id, _) => { + DefLocal(node_id, _) | DefArg(node_id, _) | + DefSelf(node_id) | DefBinding(node_id, _) => { tcx.region_maps.encl_region(node_id) } - def_upvar(_, subdef, closure_id, body_id) => { + DefUpvar(_, subdef, closure_id, body_id) => { match ty::ty_closure_sigil(fcx.node_ty(closure_id)) { BorrowedSigil => encl_region_of_def(fcx, *subdef), ManagedSigil | OwnedSigil => re_scope(body_id) @@ -127,7 +127,7 @@ impl Rcx { } /// Try to resolve the type for the given node. - pub fn resolve_expr_type_adjusted(@mut self, expr: @ast::expr) -> ty::t { + pub fn resolve_expr_type_adjusted(@mut self, expr: @ast::Expr) -> ty::t { let ty_unadjusted = self.resolve_node_type(expr.id); if ty::type_is_error(ty_unadjusted) || ty::type_is_bot(ty_unadjusted) { ty_unadjusted @@ -140,7 +140,7 @@ impl Rcx { } } -pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) { +pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::Expr) { let rcx = @mut Rcx { fcx: fcx, errors_reported: 0, repeating_scope: e.id }; if fcx.err_count_since_creation() == 0 { @@ -175,11 +175,11 @@ impl Visitor<@mut Rcx> for RegionckVisitor { fn visit_item(&mut self, i:@ast::item, e:@mut Rcx) { visit_item(self, i, e); } - fn visit_expr(&mut self, ex:@ast::expr, e:@mut Rcx) { visit_expr(self, ex, e); } + fn visit_expr(&mut self, ex:@ast::Expr, e:@mut Rcx) { visit_expr(self, ex, e); } //visit_pat: visit_pat, // (*) see above - fn visit_arm(&mut self, a:&ast::arm, e:@mut Rcx) { visit_arm(self, a, e); } + fn visit_arm(&mut self, a:&ast::Arm, e:@mut Rcx) { visit_arm(self, a, e); } fn visit_local(&mut self, l:@ast::Local, e:@mut Rcx) { visit_local(self, l, e); } @@ -199,7 +199,7 @@ fn visit_block(v: &mut RegionckVisitor, b: &ast::Block, rcx: @mut Rcx) { visit::walk_block(v, b, rcx); } -fn visit_arm(v: &mut RegionckVisitor, arm: &ast::arm, rcx: @mut Rcx) { +fn visit_arm(v: &mut RegionckVisitor, arm: &ast::Arm, rcx: @mut Rcx) { // see above for &p in arm.pats.iter() { constrain_bindings_in_pat(p, rcx); @@ -214,7 +214,7 @@ fn visit_local(v: &mut RegionckVisitor, l: @ast::Local, rcx: @mut Rcx) { visit::walk_local(v, l, rcx); } -fn constrain_bindings_in_pat(pat: @ast::pat, rcx: @mut Rcx) { +fn constrain_bindings_in_pat(pat: @ast::Pat, rcx: @mut Rcx) { let tcx = rcx.fcx.tcx(); debug!("regionck::visit_pat(pat=%s)", pat.repr(tcx)); do pat_util::pat_bindings(tcx.def_map, pat) |_, id, span, _| { @@ -248,7 +248,7 @@ fn constrain_bindings_in_pat(pat: @ast::pat, rcx: @mut Rcx) { } } -fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { +fn visit_expr(v: &mut RegionckVisitor, expr: @ast::Expr, rcx: @mut Rcx) { debug!("regionck::visit_expr(e=%s, repeating_scope=%?)", expr.repr(rcx.fcx.tcx()), rcx.repeating_scope); @@ -271,21 +271,21 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { // // ast::expr_assign_op(*) | - ast::expr_index(*) | - ast::expr_binary(*) | - ast::expr_unary(*) if has_method_map => { + ast::ExprIndex(*) | + ast::ExprBinary(*) | + ast::ExprUnary(*) if has_method_map => { tcx.region_maps.record_cleanup_scope(expr.id); } - ast::expr_binary(_, ast::and, lhs, rhs) | - ast::expr_binary(_, ast::or, lhs, rhs) => { + ast::ExprBinary(_, ast::BiAnd, lhs, rhs) | + ast::ExprBinary(_, ast::BiOr, lhs, rhs) => { tcx.region_maps.record_cleanup_scope(lhs.id); tcx.region_maps.record_cleanup_scope(rhs.id); } - ast::expr_call(*) | - ast::expr_method_call(*) => { + ast::ExprCall(*) | + ast::ExprMethodCall(*) => { tcx.region_maps.record_cleanup_scope(expr.id); } - ast::expr_match(_, ref arms) => { + ast::ExprMatch(_, ref arms) => { tcx.region_maps.record_cleanup_scope(expr.id); for arm in arms.iter() { for guard in arm.guard.iter() { @@ -293,10 +293,10 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { } } } - ast::expr_loop(ref body, _) => { + ast::ExprLoop(ref body, _) => { tcx.region_maps.record_cleanup_scope(body.id); } - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { tcx.region_maps.record_cleanup_scope(cond.id); tcx.region_maps.record_cleanup_scope(body.id); } @@ -332,22 +332,22 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { } match expr.node { - ast::expr_call(callee, ref args, _) => { + ast::ExprCall(callee, ref args, _) => { constrain_callee(rcx, callee.id, expr, callee); constrain_call(rcx, callee.id, expr, None, *args, false); visit::walk_expr(v, expr, rcx); } - ast::expr_method_call(callee_id, arg0, _, _, ref args, _) => { + ast::ExprMethodCall(callee_id, arg0, _, _, ref args, _) => { constrain_call(rcx, callee_id, expr, Some(arg0), *args, false); visit::walk_expr(v,expr, rcx); } - ast::expr_index(callee_id, lhs, rhs) | - ast::expr_assign_op(callee_id, _, lhs, rhs) | - ast::expr_binary(callee_id, _, lhs, rhs) if has_method_map => { + ast::ExprIndex(callee_id, lhs, rhs) | + ast::ExprAssignOp(callee_id, _, lhs, rhs) | + ast::ExprBinary(callee_id, _, lhs, rhs) if has_method_map => { // As `expr_method_call`, but the call is via an // overloaded op. Note that we (sadly) currently use an // implicit "by ref" sort of passing style here. This @@ -357,14 +357,14 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { visit::walk_expr(v, expr, rcx); } - ast::expr_unary(callee_id, _, lhs) if has_method_map => { + ast::ExprUnary(callee_id, _, lhs) if has_method_map => { // As above. constrain_call(rcx, callee_id, expr, Some(lhs), [], true); visit::walk_expr(v, expr, rcx); } - ast::expr_unary(_, ast::deref, base) => { + ast::ExprUnary(_, ast::UnDeref, base) => { // For *a, the lifetime of a must enclose the deref let base_ty = rcx.resolve_node_type(base.id); constrain_derefs(rcx, expr, 1, base_ty); @@ -372,7 +372,7 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { visit::walk_expr(v, expr, rcx); } - ast::expr_index(_, vec_expr, _) => { + ast::ExprIndex(_, vec_expr, _) => { // For a[b], the lifetime of a must enclose the deref let vec_type = rcx.resolve_expr_type_adjusted(vec_expr); constrain_index(rcx, expr, vec_type); @@ -380,7 +380,7 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { visit::walk_expr(v, expr, rcx); } - ast::expr_cast(source, _) => { + ast::ExprCast(source, _) => { // Determine if we are casting `source` to an trait // instance. If so, we have to be sure that the type of // the source obeys the trait's region bound. @@ -410,7 +410,7 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { visit::walk_expr(v, expr, rcx); } - ast::expr_addr_of(_, base) => { + ast::ExprAddrOf(_, base) => { guarantor::for_addr_of(rcx, expr, base); // Require that when you write a `&expr` expression, the @@ -426,23 +426,23 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { visit::walk_expr(v, expr, rcx); } - ast::expr_match(discr, ref arms) => { + ast::ExprMatch(discr, ref arms) => { guarantor::for_match(rcx, discr, *arms); visit::walk_expr(v, expr, rcx); } - ast::expr_fn_block(*) => { + ast::ExprFnBlock(*) => { check_expr_fn_block(rcx, expr, v); } - ast::expr_loop(ref body, _) => { + ast::ExprLoop(ref body, _) => { let repeating_scope = rcx.set_repeating_scope(body.id); visit::walk_expr(v, expr, rcx); rcx.set_repeating_scope(repeating_scope); } - ast::expr_while(cond, ref body) => { + ast::ExprWhile(cond, ref body) => { let repeating_scope = rcx.set_repeating_scope(cond.id); v.visit_expr(cond, rcx); @@ -459,11 +459,11 @@ fn visit_expr(v: &mut RegionckVisitor, expr: @ast::expr, rcx: @mut Rcx) { } fn check_expr_fn_block(rcx: @mut Rcx, - expr: @ast::expr, + expr: @ast::Expr, v: &mut RegionckVisitor) { let tcx = rcx.fcx.tcx(); match expr.node { - ast::expr_fn_block(_, ref body) => { + ast::ExprFnBlock(_, ref body) => { let function_type = rcx.resolve_node_type(expr.id); match ty::get(function_type).sty { ty::ty_closure( @@ -503,8 +503,8 @@ fn check_expr_fn_block(rcx: @mut Rcx, fn constrain_callee(rcx: @mut Rcx, callee_id: ast::NodeId, - call_expr: @ast::expr, - callee_expr: @ast::expr) + call_expr: @ast::Expr, + callee_expr: @ast::Expr) { let call_region = ty::re_scope(call_expr.id); @@ -530,9 +530,9 @@ fn constrain_call(rcx: @mut Rcx, // might be expr_call, expr_method_call, or an overloaded // operator callee_id: ast::NodeId, - call_expr: @ast::expr, - receiver: Option<@ast::expr>, - arg_exprs: &[@ast::expr], + call_expr: @ast::Expr, + receiver: Option<@ast::Expr>, + arg_exprs: &[@ast::Expr], implicitly_ref_args: bool) { //! Invoked on every call site (i.e., normal calls, method calls, @@ -590,7 +590,7 @@ fn constrain_call(rcx: @mut Rcx, } fn constrain_derefs(rcx: @mut Rcx, - deref_expr: @ast::expr, + deref_expr: @ast::Expr, derefs: uint, mut derefd_ty: ty::t) { @@ -635,7 +635,7 @@ pub fn mk_subregion_due_to_derefence(rcx: @mut Rcx, fn constrain_index(rcx: @mut Rcx, - index_expr: @ast::expr, + index_expr: @ast::Expr, indexed_ty: ty::t) { /*! @@ -661,7 +661,7 @@ fn constrain_index(rcx: @mut Rcx, fn constrain_free_variables(rcx: @mut Rcx, region: ty::Region, - expr: @ast::expr) { + expr: @ast::Expr) { /*! * Make sure that all free variables referenced inside the closure * outlive the closure itself. @@ -812,7 +812,7 @@ pub mod guarantor { use syntax::codemap::Span; use util::ppaux::{ty_to_str}; - pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::expr, base: @ast::expr) { + pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::Expr, base: @ast::Expr) { /*! * Computes the guarantor for an expression `&base` and then * ensures that the lifetime of the resulting pointer is linked @@ -825,7 +825,7 @@ pub mod guarantor { link(rcx, expr.span, expr.id, guarantor); } - pub fn for_match(rcx: @mut Rcx, discr: @ast::expr, arms: &[ast::arm]) { + pub fn for_match(rcx: @mut Rcx, discr: @ast::Expr, arms: &[ast::Arm]) { /*! * Computes the guarantors for any ref bindings in a match and * then ensures that the lifetime of the resulting pointer is @@ -843,7 +843,7 @@ pub mod guarantor { } pub fn for_autoref(rcx: @mut Rcx, - expr: @ast::expr, + expr: @ast::Expr, autoderefs: uint, autoref: &ty::AutoRef) { /*! @@ -883,7 +883,7 @@ pub mod guarantor { fn maybe_make_subregion( rcx: @mut Rcx, - expr: @ast::expr, + expr: @ast::Expr, sub_region: ty::Region, sup_region: Option) { @@ -895,7 +895,7 @@ pub mod guarantor { } pub fn for_by_ref(rcx: @mut Rcx, - expr: @ast::expr, + expr: @ast::Expr, callee_scope: ast::NodeId) { /*! * Computes the guarantor for cases where the `expr` is @@ -974,7 +974,7 @@ pub mod guarantor { ty: ty::t } - fn guarantor(rcx: @mut Rcx, expr: @ast::expr) -> Option { + fn guarantor(rcx: @mut Rcx, expr: @ast::Expr) -> Option { /*! * * Computes the guarantor of `expr`, or None if `expr` is @@ -985,23 +985,23 @@ pub mod guarantor { debug!("guarantor()"); match expr.node { - ast::expr_unary(_, ast::deref, b) => { + ast::ExprUnary(_, ast::UnDeref, b) => { let cat = categorize(rcx, b); guarantor_of_deref(&cat) } - ast::expr_field(b, _, _) => { + ast::ExprField(b, _, _) => { categorize(rcx, b).guarantor } - ast::expr_index(_, b, _) => { + ast::ExprIndex(_, b, _) => { let cat = categorize(rcx, b); guarantor_of_deref(&cat) } - ast::expr_paren(e) => { + ast::ExprParen(e) => { guarantor(rcx, e) } - ast::expr_path(*) | ast::expr_self => { + ast::ExprPath(*) | ast::ExprSelf => { // Either a variable or constant and hence resides // in constant memory or on the stack frame. Either way, // not guaranteed by a region pointer. @@ -1010,42 +1010,42 @@ pub mod guarantor { // All of these expressions are rvalues and hence their // value is not guaranteed by a region pointer. - ast::expr_inline_asm(*) | - ast::expr_mac(*) | - ast::expr_lit(_) | - ast::expr_unary(*) | - ast::expr_addr_of(*) | - ast::expr_binary(*) | - ast::expr_vstore(*) | - ast::expr_break(*) | - ast::expr_again(*) | - ast::expr_ret(*) | - ast::expr_log(*) | - ast::expr_while(*) | - ast::expr_loop(*) | - ast::expr_assign(*) | - ast::expr_assign_op(*) | - ast::expr_cast(*) | - ast::expr_call(*) | - ast::expr_method_call(*) | - ast::expr_struct(*) | - ast::expr_tup(*) | - ast::expr_if(*) | - ast::expr_match(*) | - ast::expr_fn_block(*) | - ast::expr_do_body(*) | - ast::expr_block(*) | - ast::expr_repeat(*) | - ast::expr_vec(*) => { + ast::ExprInlineAsm(*) | + ast::ExprMac(*) | + ast::ExprLit(_) | + ast::ExprUnary(*) | + ast::ExprAddrOf(*) | + ast::ExprBinary(*) | + ast::ExprVstore(*) | + ast::ExprBreak(*) | + ast::ExprAgain(*) | + ast::ExprRet(*) | + ast::ExprLog(*) | + ast::ExprWhile(*) | + ast::ExprLoop(*) | + ast::ExprAssign(*) | + ast::ExprAssignOp(*) | + ast::ExprCast(*) | + ast::ExprCall(*) | + ast::ExprMethodCall(*) | + ast::ExprStruct(*) | + ast::ExprTup(*) | + ast::ExprIf(*) | + ast::ExprMatch(*) | + ast::ExprFnBlock(*) | + ast::ExprDoBody(*) | + ast::ExprBlock(*) | + ast::ExprRepeat(*) | + ast::ExprVec(*) => { assert!(!ty::expr_is_lval( rcx.fcx.tcx(), rcx.fcx.inh.method_map, expr)); None } - ast::expr_for_loop(*) => fail!("non-desugared expr_for_loop"), + ast::ExprForLoop(*) => fail!("non-desugared expr_for_loop"), } } - fn categorize(rcx: @mut Rcx, expr: @ast::expr) -> ExprCategorization { + fn categorize(rcx: @mut Rcx, expr: @ast::Expr) -> ExprCategorization { debug!("categorize()"); let mut expr_ct = categorize_unadjusted(rcx, expr); @@ -1097,7 +1097,7 @@ pub mod guarantor { } fn categorize_unadjusted(rcx: @mut Rcx, - expr: @ast::expr) + expr: @ast::Expr) -> ExprCategorizationType { debug!("categorize_unadjusted()"); @@ -1121,7 +1121,7 @@ pub mod guarantor { fn apply_autoderefs( rcx: @mut Rcx, - expr: @ast::expr, + expr: @ast::Expr, autoderefs: uint, ct: ExprCategorizationType) -> ExprCategorizationType { @@ -1199,7 +1199,7 @@ pub mod guarantor { fn link_ref_bindings_in_pat( rcx: @mut Rcx, - pat: @ast::pat, + pat: @ast::Pat, guarantor: Option) { /*! * @@ -1215,45 +1215,45 @@ pub mod guarantor { rcx.fcx.pat_to_str(pat), guarantor); match pat.node { - ast::pat_wild => {} - ast::pat_ident(ast::bind_by_ref(_), _, opt_p) => { + ast::PatWild => {} + ast::PatIdent(ast::BindByRef(_), _, opt_p) => { link(rcx, pat.span, pat.id, guarantor); for p in opt_p.iter() { link_ref_bindings_in_pat(rcx, *p, guarantor); } } - ast::pat_ident(_, _, opt_p) => { + ast::PatIdent(_, _, opt_p) => { for p in opt_p.iter() { link_ref_bindings_in_pat(rcx, *p, guarantor); } } - ast::pat_enum(_, None) => {} - ast::pat_enum(_, Some(ref pats)) => { + ast::PatEnum(_, None) => {} + ast::PatEnum(_, Some(ref pats)) => { link_ref_bindings_in_pats(rcx, pats, guarantor); } - ast::pat_struct(_, ref fpats, _) => { + ast::PatStruct(_, ref fpats, _) => { for fpat in fpats.iter() { link_ref_bindings_in_pat(rcx, fpat.pat, guarantor); } } - ast::pat_tup(ref ps) => { + ast::PatTup(ref ps) => { link_ref_bindings_in_pats(rcx, ps, guarantor) } - ast::pat_box(p) => { + ast::PatBox(p) => { link_ref_bindings_in_pat(rcx, p, None) } - ast::pat_uniq(p) => { + ast::PatUniq(p) => { link_ref_bindings_in_pat(rcx, p, guarantor) } - ast::pat_region(p) => { + ast::PatRegion(p) => { let rptr_ty = rcx.resolve_node_type(pat.id); let r = ty::ty_region(rcx.fcx.tcx(), pat.span, rptr_ty); link_ref_bindings_in_pat(rcx, p, Some(r)); } - ast::pat_lit(*) => {} - ast::pat_range(*) => {} - ast::pat_vec(ref before, ref slice, ref after) => { + ast::PatLit(*) => {} + ast::PatRange(*) => {} + ast::PatVec(ref before, ref slice, ref after) => { let vec_ty = rcx.resolve_node_type(pat.id); let vstore = ty::ty_vstore(vec_ty); let guarantor1 = match vstore { @@ -1272,7 +1272,7 @@ pub mod guarantor { } fn link_ref_bindings_in_pats(rcx: @mut Rcx, - pats: &~[@ast::pat], + pats: &~[@ast::Pat], guarantor: Option) { for pat in pats.iter() { link_ref_bindings_in_pat(rcx, *pat, guarantor); diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index abea685eaf897..b96f85b676b27 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -473,7 +473,7 @@ fn search_for_vtable(vcx: &VtableContext, fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo, - id: ast::def_id, + id: ast::DefId, substs: ty::substs, is_early: bool) -> Option { @@ -482,7 +482,7 @@ fn fixup_substs(vcx: &VtableContext, let t = ty::mk_trait(tcx, id, substs, ty::RegionTraitStore(ty::re_static), - ast::m_imm, + ast::MutImmutable, ty::EmptyBuiltinBounds()); do fixup_ty(vcx, location_info, t, is_early).map |t_f| { match ty::get(*t_f).sty { @@ -516,7 +516,7 @@ fn connect_trait_tps(vcx: &VtableContext, location_info: &LocationInfo, impl_substs: &ty::substs, trait_ref: @ty::TraitRef, - impl_did: ast::def_id) + impl_did: ast::DefId) { let tcx = vcx.tcx(); @@ -538,7 +538,7 @@ fn insert_vtables(fcx: @mut FnCtxt, fcx.inh.vtable_map.insert(callee_id, vtables); } -pub fn location_info_for_expr(expr: @ast::expr) -> LocationInfo { +pub fn location_info_for_expr(expr: @ast::Expr) -> LocationInfo { LocationInfo { span: expr.span, id: expr.id @@ -551,7 +551,7 @@ pub fn location_info_for_item(item: @ast::item) -> LocationInfo { } } -pub fn early_resolve_expr(ex: @ast::expr, +pub fn early_resolve_expr(ex: @ast::Expr, fcx: @mut FnCtxt, is_early: bool) { debug!("vtable: early_resolve_expr() ex with id %? (early: %b): %s", @@ -560,7 +560,7 @@ pub fn early_resolve_expr(ex: @ast::expr, let cx = fcx.ccx; match ex.node { - ast::expr_path(*) => { + ast::ExprPath(*) => { do fcx.opt_node_ty_substs(ex.id) |substs| { debug!("vtable resolution on parameter bounds for expr %s", ex.repr(fcx.tcx())); @@ -584,16 +584,16 @@ pub fn early_resolve_expr(ex: @ast::expr, }; } - ast::expr_paren(e) => { + ast::ExprParen(e) => { early_resolve_expr(e, fcx, is_early); } // Must resolve bounds on methods with bounded params - ast::expr_binary(callee_id, _, _, _) | - ast::expr_unary(callee_id, _, _) | - ast::expr_assign_op(callee_id, _, _, _) | - ast::expr_index(callee_id, _, _) | - ast::expr_method_call(callee_id, _, _, _, _, _) => { + ast::ExprBinary(callee_id, _, _, _) | + ast::ExprUnary(callee_id, _, _) | + ast::ExprAssignOp(callee_id, _, _, _) | + ast::ExprIndex(callee_id, _, _) | + ast::ExprMethodCall(callee_id, _, _, _, _, _) => { match ty::method_call_type_param_defs(cx.tcx, fcx.inh.method_map, ex.id) { Some(type_param_defs) => { debug!("vtable resolution on parameter bounds for method call %s", @@ -611,17 +611,17 @@ pub fn early_resolve_expr(ex: @ast::expr, None => () } } - ast::expr_cast(src, _) => { + ast::ExprCast(src, _) => { debug!("vtable resolution on expr %s", ex.repr(fcx.tcx())); let target_ty = fcx.expr_ty(ex); match ty::get(target_ty).sty { // Bounds of type's contents are not checked here, but in kind.rs. ty::ty_trait(target_def_id, ref target_substs, store, target_mutbl, _bounds) => { - fn mutability_allowed(a_mutbl: ast::mutability, - b_mutbl: ast::mutability) -> bool { + fn mutability_allowed(a_mutbl: ast::Mutability, + b_mutbl: ast::Mutability) -> bool { a_mutbl == b_mutbl || - (a_mutbl == ast::m_mutbl && b_mutbl == ast::m_imm) + (a_mutbl == ast::MutMutable && b_mutbl == ast::MutImmutable) } // Look up vtables for the type we're casting to, // passing in the source and target type. The source @@ -721,7 +721,7 @@ pub fn early_resolve_expr(ex: @ast::expr, } fn resolve_expr(v: &mut VtableResolveVisitor, - ex: @ast::expr, + ex: @ast::Expr, fcx: @mut FnCtxt) { early_resolve_expr(ex, fcx, false); visit::walk_expr(v, ex, fcx); @@ -774,7 +774,7 @@ pub fn resolve_impl(ccx: @mut CrateCtxt, impl_item: @ast::item) { struct VtableResolveVisitor; impl visit::Visitor<@mut FnCtxt> for VtableResolveVisitor { - fn visit_expr(&mut self, ex:@ast::expr, e:@mut FnCtxt) { + fn visit_expr(&mut self, ex:@ast::Expr, e:@mut FnCtxt) { resolve_expr(self, ex, e); } fn visit_item(&mut self, _:@ast::item, _:@mut FnCtxt) { diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 6878cbcbb7b21..1d5cc7490c2e1 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -216,13 +216,13 @@ struct WbCtxt { type wb_vt = oldvisit::vt<@mut WbCtxt>; -fn visit_stmt(s: @ast::stmt, (wbcx, v): (@mut WbCtxt, wb_vt)) { +fn visit_stmt(s: @ast::Stmt, (wbcx, v): (@mut WbCtxt, wb_vt)) { if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, s.span, ty::stmt_node_id(s)); oldvisit::visit_stmt(s, (wbcx, v)); } -fn visit_expr(e: @ast::expr, (wbcx, v): (@mut WbCtxt, wb_vt)) { +fn visit_expr(e: @ast::Expr, (wbcx, v): (@mut WbCtxt, wb_vt)) { if !wbcx.success { return; } @@ -246,20 +246,20 @@ fn visit_expr(e: @ast::expr, (wbcx, v): (@mut WbCtxt, wb_vt)) { } match e.node { - ast::expr_fn_block(ref decl, _) => { + ast::ExprFnBlock(ref decl, _) => { for input in decl.inputs.iter() { let _ = resolve_type_vars_for_node(wbcx, e.span, input.id); } } - ast::expr_binary(callee_id, _, _, _) | - ast::expr_unary(callee_id, _, _) | - ast::expr_assign_op(callee_id, _, _, _) | - ast::expr_index(callee_id, _, _) => { + ast::ExprBinary(callee_id, _, _, _) | + ast::ExprUnary(callee_id, _, _) | + ast::ExprAssignOp(callee_id, _, _, _) | + ast::ExprIndex(callee_id, _, _) => { maybe_resolve_type_vars_for_node(wbcx, e.span, callee_id); } - ast::expr_method_call(callee_id, _, _, _, _, _) => { + ast::ExprMethodCall(callee_id, _, _, _, _, _) => { // We must always have written in a callee ID type for these. resolve_type_vars_for_node(wbcx, e.span, callee_id); } @@ -279,7 +279,7 @@ fn visit_block(b: &ast::Block, (wbcx, v): (@mut WbCtxt, wb_vt)) { oldvisit::visit_block(b, (wbcx, v)); } -fn visit_pat(p: @ast::pat, (wbcx, v): (@mut WbCtxt, wb_vt)) { +fn visit_pat(p: @ast::Pat, (wbcx, v): (@mut WbCtxt, wb_vt)) { if !wbcx.success { return; } @@ -329,7 +329,7 @@ fn mk_visitor() -> oldvisit::vt<@mut WbCtxt> { .. *oldvisit::default_visitor()}) } -pub fn resolve_type_vars_in_expr(fcx: @mut FnCtxt, e: @ast::expr) -> bool { +pub fn resolve_type_vars_in_expr(fcx: @mut FnCtxt, e: @ast::Expr) -> bool { let wbcx = @mut WbCtxt { fcx: fcx, success: true }; let visit = mk_visitor(); (visit.visit_expr)(e, (wbcx, visit)); diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 91ebbbd17ba00..3f18b21dcd390 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -35,7 +35,7 @@ use middle::typeck::infer::combine::Combine; use middle::typeck::infer::InferCtxt; use middle::typeck::infer::{new_infer_ctxt, resolve_ivar, resolve_type}; use middle::typeck::infer; -use syntax::ast::{Crate, def_id, def_struct, def_ty}; +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; @@ -123,7 +123,7 @@ pub fn type_is_defined_in_local_crate(original_type: t) -> bool { pub fn get_base_type_def_id(inference_context: @mut InferCtxt, span: Span, original_type: t) - -> Option { + -> Option { match get_base_type(inference_context, span, original_type) { None => { return None; @@ -322,7 +322,7 @@ impl CoherenceChecker { // and trait pair. Then, for each provided method in the trait, inserts a // `ProvidedMethodInfo` instance into the `provided_method_sources` map. pub fn instantiate_default_methods(&self, - impl_id: ast::def_id, + impl_id: ast::DefId, trait_ref: &ty::TraitRef, all_methods: &mut ~[@Method]) { let tcx = self.crate_context.tcx; @@ -378,7 +378,7 @@ impl CoherenceChecker { } pub fn add_inherent_impl(&self, - base_def_id: def_id, + base_def_id: DefId, implementation: @Impl) { let tcx = self.crate_context.tcx; let implementation_list; @@ -396,7 +396,7 @@ impl CoherenceChecker { } pub fn add_trait_impl(&self, - base_def_id: def_id, + base_def_id: DefId, implementation: @Impl) { let tcx = self.crate_context.tcx; let implementation_list; @@ -420,7 +420,7 @@ impl CoherenceChecker { }; } - pub fn check_implementation_coherence_of(&self, trait_def_id: def_id) { + pub fn check_implementation_coherence_of(&self, trait_def_id: DefId) { // Unify pairs of polytypes. do self.iter_impls_of_trait(trait_def_id) |a| { let implementation_a = a; @@ -452,7 +452,7 @@ impl CoherenceChecker { } } - pub fn iter_impls_of_trait(&self, trait_def_id: def_id, f: &fn(@Impl)) { + pub fn iter_impls_of_trait(&self, trait_def_id: DefId, f: &fn(@Impl)) { match self.crate_context.tcx.trait_impls.find(&trait_def_id) { Some(impls) => { for &im in impls.iter() { @@ -533,7 +533,7 @@ impl CoherenceChecker { visit::walk_crate(&mut visitor, crate, ()); } - pub fn trait_ref_to_trait_def_id(&self, trait_ref: &trait_ref) -> def_id { + pub fn trait_ref_to_trait_def_id(&self, trait_ref: &trait_ref) -> DefId { let def_map = self.crate_context.tcx.def_map; let trait_def = def_map.get_copy(&trait_ref.ref_id); let trait_id = def_id_of_def(trait_def); @@ -545,7 +545,7 @@ impl CoherenceChecker { pub fn check_trait_methods_are_implemented( &self, all_methods: &mut ~[@Method], - trait_did: def_id, + trait_did: DefId, trait_ref_span: Span) { let tcx = self.crate_context.tcx; @@ -575,7 +575,7 @@ impl CoherenceChecker { match original_type.node { ty_path(_, _, path_id) => { match self.crate_context.tcx.def_map.get_copy(&path_id) { - def_ty(def_id) | def_struct(def_id) => { + DefTy(def_id) | DefStruct(def_id) => { if def_id.crate != LOCAL_CRATE { return false; } @@ -663,8 +663,8 @@ impl CoherenceChecker { // External crate handling pub fn add_external_impl(&self, - impls_seen: &mut HashSet, - impl_def_id: def_id) { + impls_seen: &mut HashSet, + impl_def_id: DefId) { let tcx = self.crate_context.tcx; let implementation = @csearch::get_impl(tcx, impl_def_id); @@ -766,7 +766,7 @@ impl CoherenceChecker { } pub fn make_substs_for_receiver_types(tcx: ty::ctxt, - impl_id: ast::def_id, + impl_id: ast::DefId, trait_ref: &ty::TraitRef, method: &ty::Method) -> ty::substs { @@ -814,11 +814,11 @@ pub fn make_substs_for_receiver_types(tcx: ty::ctxt, } fn subst_receiver_types_in_method_ty(tcx: ty::ctxt, - impl_id: ast::def_id, + impl_id: ast::DefId, trait_ref: &ty::TraitRef, - new_def_id: ast::def_id, + new_def_id: ast::DefId, method: &ty::Method, - provided_source: Option) + provided_source: Option) -> ty::Method { let combined_substs = make_substs_for_receiver_types( diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index f882a25ba8086..8056831537f59 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -79,7 +79,7 @@ impl visit::Visitor<()> for CollectItemTypesVisitor { pub fn collect_item_types(ccx: @mut CrateCtxt, crate: &ast::Crate) { fn collect_intrinsic_type(ccx: &CrateCtxt, - lang_item: ast::def_id) { + lang_item: ast::DefId) { let ty::ty_param_bounds_and_ty { ty: ty, _ } = ccx.get_item_ty(lang_item); ccx.tcx.intrinsic_defs.insert(lang_item, ty); @@ -117,7 +117,7 @@ impl ToTy for CrateCtxt { impl AstConv for CrateCtxt { fn tcx(&self) -> ty::ctxt { self.tcx } - fn get_item_ty(&self, id: ast::def_id) -> ty::ty_param_bounds_and_ty { + fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty { if id.crate != ast::LOCAL_CRATE { csearch::get_type(self.tcx, id) } else { @@ -136,7 +136,7 @@ impl AstConv for CrateCtxt { } } - fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef { + fn get_trait_def(&self, id: ast::DefId) -> @ty::TraitDef { get_trait_def(self, id) } @@ -288,7 +288,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, let tcx = ccx.tcx; - let dummy_defid = ast::def_id {crate: 0, node: 0}; + let dummy_defid = ast::DefId {crate: 0, node: 0}; // Represents [A',B',C'] let num_trait_bounds = trait_ty_generics.type_param_defs.len(); @@ -1027,7 +1027,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, let rscope = TypeRscope(rp); match lookup_def_tcx(ccx.tcx, ast_trait_ref.path.span, ast_trait_ref.ref_id) { - ast::def_trait(trait_did) => { + ast::DefTrait(trait_did) => { let trait_ref = astconv::ast_path_to_trait_ref( ccx, &rscope, trait_did, Some(self_ty), &ast_trait_ref.path); @@ -1045,7 +1045,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, } } -fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::def_id) -> @ty::TraitDef { +fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> @ty::TraitDef { if trait_id.crate != ast::LOCAL_CRATE { ty::lookup_trait_def(ccx.tcx, trait_id) } else { @@ -1276,7 +1276,7 @@ pub fn ty_generics(ccx: &CrateCtxt, pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, decl: &ast::fn_decl, - def_id: ast::def_id, + def_id: ast::DefId, ast_generics: &ast::Generics, abis: AbiSet) -> ty::ty_param_bounds_and_ty { diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 7736dbbb99d98..99c7725c7a2da 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -77,7 +77,7 @@ use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::resolve::try_resolve_tvar_shallow; use util::common::indenter; -use syntax::ast::m_imm; +use syntax::ast::MutImmutable; use syntax::ast; // Note: Coerce is not actually a combiner, in that it does not @@ -238,7 +238,7 @@ impl Coerce { if_ok!(self.subtype(a_borrowed, b)); Ok(Some(@AutoDerefRef(AutoDerefRef { autoderefs: 0, - autoref: Some(AutoBorrowVec(r_a, m_imm)) + autoref: Some(AutoBorrowVec(r_a, MutImmutable)) }))) } @@ -275,7 +275,7 @@ impl Coerce { a: ty::t, sty_a: &ty::sty, b: ty::t, - b_mutbl: ast::mutability) -> CoerceResult + b_mutbl: ast::Mutability) -> CoerceResult { debug!("coerce_borrowed_object(a=%s, sty_a=%?, b=%s)", a.inf_str(self.infcx), sty_a, diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 86c0736090c93..1939987d7f078 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -21,7 +21,7 @@ use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::infer::{TypeTrace, Subtype}; use middle::typeck::infer::fold_regions_in_sig; use middle::typeck::isr_alist; -use syntax::ast::{Many, Once, extern_fn, impure_fn, m_imm, m_mutbl}; +use syntax::ast::{Many, Once, extern_fn, impure_fn, MutImmutable, MutMutable}; use syntax::ast::{unsafe_fn}; use syntax::ast::{Onceness, purity}; use util::common::{indenter}; @@ -52,23 +52,23 @@ impl Combine for Glb { match (a.mutbl, b.mutbl) { // If one side or both is mut, then the GLB must use // the precise type from the mut side. - (m_mutbl, m_mutbl) => { + (MutMutable, MutMutable) => { eq_tys(self, a.ty, b.ty).then(|| { - Ok(ty::mt {ty: a.ty, mutbl: m_mutbl}) + Ok(ty::mt {ty: a.ty, mutbl: MutMutable}) }) } // If one side or both is immutable, we can use the GLB of - // both sides but mutbl must be `m_imm`. - (m_imm, m_imm) => { + // both sides but mutbl must be `MutImmutable`. + (MutImmutable, MutImmutable) => { self.tys(a.ty, b.ty).chain(|t| { - Ok(ty::mt {ty: t, mutbl: m_imm}) + Ok(ty::mt {ty: t, mutbl: MutImmutable}) }) } // There is no mutual subtype of these combinations. - (m_mutbl, m_imm) | - (m_imm, m_mutbl) => { + (MutMutable, MutImmutable) | + (MutImmutable, MutMutable) => { Err(ty::terr_mutability) } } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 50bddaacc3fc9..db5873f09fe2c 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -61,11 +61,11 @@ impl Combine for Lub { let m = a.mutbl; match m { - m_imm => { + MutImmutable => { self.tys(a.ty, b.ty).chain(|t| Ok(ty::mt {ty: t, mutbl: m}) ) } - m_mutbl => { + MutMutable => { self.infcx.try(|| { eq_tys(self, a.ty, b.ty).then(|| { Ok(ty::mt {ty: a.ty, mutbl: m}) diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index da3471168ddc4..a2d2cd92e135a 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -41,7 +41,7 @@ use std::result; use std::vec; use extra::list::Nil; use extra::smallintmap::SmallIntMap; -use syntax::ast::{m_imm, m_mutbl}; +use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap; use syntax::codemap::Span; @@ -106,7 +106,7 @@ pub enum TypeOrigin { MethodCompatCheck(Span), // Checking that this expression can be assigned where it needs to be - ExprAssignable(@ast::expr), + ExprAssignable(@ast::Expr), // Relating trait refs when resolving vtables RelateTraitRefs(Span), @@ -678,7 +678,7 @@ impl InferCtxt { trait_ref.def_id, trait_ref.substs.clone(), ty::UniqTraitStore, - ast::m_imm, + ast::MutImmutable, ty::EmptyBuiltinBounds()); let dummy1 = self.resolve_type_vars_if_possible(dummy0); match ty::get(dummy1).sty { diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index a00f018ceab0f..36c5f8a50d28a 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -72,12 +72,12 @@ impl Combine for Sub { } match b.mutbl { - m_mutbl => { + MutMutable => { // If supertype is mut, subtype must match exactly // (i.e., invariant if mut): eq_tys(self, a.ty, b.ty).then(|| Ok(*a)) } - m_imm => { + MutImmutable => { // Otherwise we can be covariant: self.tys(a.ty, b.ty).chain(|_t| Ok(*a) ) } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 4d88df06480bc..8d7dbdf263ed8 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -82,7 +82,7 @@ pub enum param_index { #[deriving(Clone, Encodable, Decodable)] pub enum method_origin { // fully statically resolved method - method_static(ast::def_id), + method_static(ast::DefId), // method invoked on a type parameter with a bounded trait method_param(method_param), @@ -97,7 +97,7 @@ pub enum method_origin { #[deriving(Clone, Encodable, Decodable)] pub struct method_param { // the trait containing the method to be invoked - trait_id: ast::def_id, + trait_id: ast::DefId, // index of the method to be invoked amongst the trait's methods method_num: uint, @@ -114,10 +114,10 @@ pub struct method_param { #[deriving(Clone, Encodable, Decodable)] pub struct method_object { // the (super)trait containing the method to be invoked - trait_id: ast::def_id, + trait_id: ast::DefId, // the actual base trait id of the object - object_trait_id: ast::def_id, + object_trait_id: ast::DefId, // index of the method to be invoked amongst the trait's methods method_num: uint, @@ -161,7 +161,7 @@ pub enum vtable_origin { from whence comes the vtable, and tys are the type substs. vtable_res is the vtable itself */ - vtable_static(ast::def_id, ~[ty::t], vtable_res), + vtable_static(ast::DefId, ~[ty::t], vtable_res), /* Dynamic vtable, comes from a parameter that has a bound on it: @@ -214,7 +214,7 @@ impl Repr for impl_res { } } -pub type impl_vtable_map = @mut HashMap; +pub type impl_vtable_map = @mut HashMap; pub struct CrateCtxt { // A mapping from method call sites to traits that have that method. @@ -249,7 +249,7 @@ pub fn write_tpt_to_tcx(tcx: ty::ctxt, } } -pub fn lookup_def_tcx(tcx: ty::ctxt, sp: Span, id: ast::NodeId) -> ast::def { +pub fn lookup_def_tcx(tcx: ty::ctxt, sp: Span, id: ast::NodeId) -> ast::Def { match tcx.def_map.find(&id) { Some(&x) => x, _ => { @@ -259,7 +259,7 @@ pub fn lookup_def_tcx(tcx: ty::ctxt, sp: Span, id: ast::NodeId) -> ast::def { } pub fn lookup_def_ccx(ccx: &CrateCtxt, sp: Span, id: ast::NodeId) - -> ast::def { + -> ast::Def { lookup_def_tcx(ccx.tcx, sp, id) } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index e2475efa40b8b..eb9206a52b125 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -54,23 +54,23 @@ pub fn indenter() -> _indenter { _indenter(()) } -pub fn field_expr(f: ast::Field) -> @ast::expr { return f.expr; } +pub fn field_expr(f: ast::Field) -> @ast::Expr { return f.expr; } -pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::expr] { +pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] { fields.map(|f| f.expr) } struct LoopQueryVisitor { - p: @fn(&ast::expr_) -> bool + p: @fn(&ast::Expr_) -> bool } impl Visitor<@mut bool> for LoopQueryVisitor { - fn visit_expr(&mut self, e:@ast::expr, flag:@mut bool) { + fn visit_expr(&mut self, e:@ast::Expr, flag:@mut bool) { *flag |= (self.p)(&e.node); match e.node { // Skip inner loops, since a break in the inner loop isn't a // break inside the outer loop - ast::expr_loop(*) | ast::expr_while(*) => {} + ast::ExprLoop(*) | ast::ExprWhile(*) => {} _ => visit::walk_expr(self, e, flag) } } @@ -78,7 +78,7 @@ impl Visitor<@mut bool> for LoopQueryVisitor { // Takes a predicate p, returns true iff p is true for any subexpressions // of b -- skipping any inner loops (loop, while, loop_body) -pub fn loop_query(b: &ast::Block, p: @fn(&ast::expr_) -> bool) -> bool { +pub fn loop_query(b: &ast::Block, p: @fn(&ast::Expr_) -> bool) -> bool { let rs = @mut false; let mut v = LoopQueryVisitor { p: p }; visit::walk_block(&mut v, b, rs); @@ -86,11 +86,11 @@ pub fn loop_query(b: &ast::Block, p: @fn(&ast::expr_) -> bool) -> bool { } struct BlockQueryVisitor { - p: @fn(@ast::expr) -> bool + p: @fn(@ast::Expr) -> bool } impl Visitor<@mut bool> for BlockQueryVisitor { - fn visit_expr(&mut self, e:@ast::expr, flag:@mut bool) { + fn visit_expr(&mut self, e:@ast::Expr, flag:@mut bool) { *flag |= (self.p)(e); visit::walk_expr(self, e, flag) } @@ -98,7 +98,7 @@ impl Visitor<@mut bool> for BlockQueryVisitor { // Takes a predicate p, returns true iff p is true for any subexpressions // of b -- skipping any inner loops (loop, while, loop_body) -pub fn block_query(b: &ast::Block, p: @fn(@ast::expr) -> bool) -> bool { +pub fn block_query(b: &ast::Block, p: @fn(@ast::Expr) -> bool) -> bool { let rs = @mut false; let mut v = BlockQueryVisitor { p: p }; visit::walk_block(&mut v, b, rs); diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index fe33205171430..104c3753452bf 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -81,11 +81,11 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) } Some(&ast_map::node_expr(expr)) => { match expr.node { - ast::expr_call(*) => explain_span(cx, "call", expr.span), - ast::expr_method_call(*) => { + ast::ExprCall(*) => explain_span(cx, "call", expr.span), + ast::ExprMethodCall(*) => { explain_span(cx, "method call", expr.span) }, - ast::expr_match(*) => explain_span(cx, "match", expr.span), + ast::ExprMatch(*) => explain_span(cx, "match", expr.span), _ => explain_span(cx, "expression", expr.span) } } @@ -173,18 +173,18 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str { } Some(&ast_map::node_expr(expr)) => { match expr.node { - ast::expr_call(*) => { + ast::ExprCall(*) => { fmt!("", cx.sess.codemap.span_to_str(expr.span)) } - ast::expr_match(*) => { + ast::ExprMatch(*) => { fmt!("", cx.sess.codemap.span_to_str(expr.span)) } - ast::expr_assign_op(*) | - ast::expr_unary(*) | - ast::expr_binary(*) | - ast::expr_index(*) => { + ast::ExprAssignOp(*) | + ast::ExprUnary(*) | + ast::ExprBinary(*) | + ast::ExprIndex(*) => { fmt!("", cx.sess.codemap.span_to_str(expr.span)) } @@ -235,10 +235,10 @@ pub fn region_to_str(cx: ctxt, prefix: &str, space: bool, region: Region) -> ~st } } -fn mutability_to_str(m: ast::mutability) -> ~str { +fn mutability_to_str(m: ast::Mutability) -> ~str { match m { - ast::m_mutbl => ~"mut ", - ast::m_imm => ~"", + ast::MutMutable => ~"mut ", + ast::MutImmutable => ~"", } } @@ -613,7 +613,7 @@ impl Repr for ty::TraitRef { } } -impl Repr for ast::expr { +impl Repr for ast::Expr { fn repr(&self, tcx: ctxt) -> ~str { fmt!("expr(%d: %s)", self.id, @@ -621,7 +621,7 @@ impl Repr for ast::expr { } } -impl Repr for ast::pat { +impl Repr for ast::Pat { fn repr(&self, tcx: ctxt) -> ~str { fmt!("pat(%d: %s)", self.id, @@ -641,7 +641,7 @@ impl Repr for ty::Region { } } -impl Repr for ast::def_id { +impl Repr for ast::DefId { fn repr(&self, tcx: ctxt) -> ~str { // Unfortunately, there seems to be no way to attempt to print // a path for a def-id, so I'll just make a best effort for now diff --git a/src/librusti/program.rs b/src/librusti/program.rs index 07af301260148..9208191e364cd 100644 --- a/src/librusti/program.rs +++ b/src/librusti/program.rs @@ -295,7 +295,7 @@ impl Program { // &T encoded will decode to T, so we need to be sure to // re-take a loan after decoding ty::ty_rptr(_, mt) => { - if mt.mutbl == ast::m_mutbl { + if mt.mutbl == ast::MutMutable { tystr.push_str("&mut "); } else { tystr.push_str("&"); @@ -354,9 +354,9 @@ impl Program { do find_user_block(blk) |blk| { for stmt in blk.stmts.iter() { match stmt.node { - ast::stmt_decl(d, _) => { + ast::StmtDecl(d, _) => { match d.node { - ast::decl_local(l) => { f(l); } + ast::DeclLocal(l) => { f(l); } _ => {} } } @@ -369,9 +369,9 @@ impl Program { fn find_user_block(blk: &ast::Block, f: &fn(&ast::Block)) { for stmt in blk.stmts.iter() { match stmt.node { - ast::stmt_semi(e, _) => { + ast::StmtSemi(e, _) => { match e.node { - ast::expr_block(ref blk) => { return f(blk); } + ast::ExprBlock(ref blk) => { return f(blk); } _ => {} } } diff --git a/src/librusti/rusti.rs b/src/librusti/rusti.rs index 4e4f6e3682b4a..5bd941759f4d7 100644 --- a/src/librusti/rusti.rs +++ b/src/librusti/rusti.rs @@ -166,9 +166,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], for stmt in blk.stmts.iter() { let s = do with_pp(intr) |pp, _| { pprust::print_stmt(pp, *stmt); }; match stmt.node { - ast::stmt_decl(d, _) => { + ast::StmtDecl(d, _) => { match d.node { - ast::decl_item(it) => { + ast::DeclItem(it) => { let name = sess.str_of(it.ident); match it.node { // Structs are treated specially because to make @@ -184,7 +184,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], // Local declarations must be specially dealt with, // record all local declarations for use later on - ast::decl_local(l) => { + ast::DeclLocal(l) => { let mutbl = l.is_mutbl; do each_binding(l) |path, _| { let s = do with_pp(intr) |pp, _| { @@ -198,7 +198,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], } // run statements with expressions (they have effects) - ast::stmt_mac(*) | ast::stmt_semi(*) | ast::stmt_expr(*) => { + ast::StmtMac(*) | ast::StmtSemi(*) | ast::StmtExpr(*) => { to_run.push(s); } } diff --git a/src/librusti/utils.rs b/src/librusti/utils.rs index 467a3fdc27837..400399253a5d0 100644 --- a/src/librusti/utils.rs +++ b/src/librusti/utils.rs @@ -20,9 +20,9 @@ struct EachBindingVisitor { } impl visit::Visitor<()> for EachBindingVisitor { - fn visit_pat(&mut self, pat:@ast::pat, _:()) { + fn visit_pat(&mut self, pat:@ast::Pat, _:()) { match pat.node { - ast::pat_ident(_, ref path, _) => { + ast::PatIdent(_, ref path, _) => { (self.f)(path, pat.id); } _ => {} diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d7a05667a9883..b411316d6266b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -29,7 +29,7 @@ pub struct Ident { name: Name, ctxt: SyntaxContext } impl Ident { /// Construct an identifier with the given name and an empty context: - pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: empty_ctxt}} + pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}} } /// A SyntaxContext represents a chain of macro-expandings @@ -52,9 +52,10 @@ pub struct SCTable { mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>, rename_memo : HashMap<(SyntaxContext,Ident,Name),SyntaxContext> } + // NB: these must be placed in any SCTable... -pub static empty_ctxt : uint = 0; -pub static illegal_ctxt : uint = 1; +pub static EMPTY_CTXT : uint = 0; +pub static ILLEGAL_CTXT : uint = 1; #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum SyntaxContext_ { @@ -69,7 +70,7 @@ pub enum SyntaxContext_ { // in the "from" slot. In essence, they're all // pointers to a single "rename" event node. Rename (Ident,Name,SyntaxContext), - IllegalCtxt() + IllegalCtxt } /// A name is a part of an identifier, representing a string or gensym. It's @@ -92,7 +93,7 @@ impl Decodable for Ident { } /// Function name (not all functions have names) -pub type fn_ident = Option; +pub type FnIdent = Option; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Lifetime { @@ -133,7 +134,7 @@ pub type CrateNum = int; pub type NodeId = int; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes, ToStr)] -pub struct def_id { +pub struct DefId { crate: CrateNum, node: NodeId, } @@ -178,40 +179,39 @@ impl Generics { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum MethodProvenance { - FromTrait(def_id), - FromImpl(def_id), + FromTrait(DefId), + FromImpl(DefId), } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum def { - def_fn(def_id, purity), - def_static_method(/* method */ def_id, MethodProvenance, purity), - def_self(NodeId), - def_self_ty(/* trait id */ NodeId), - def_mod(def_id), - def_foreign_mod(def_id), - def_static(def_id, bool /* is_mutbl */), - def_arg(NodeId, bool /* is_mutbl */), - def_local(NodeId, bool /* is_mutbl */), - def_variant(def_id /* enum */, def_id /* variant */), - def_ty(def_id), - def_trait(def_id), - def_prim_ty(prim_ty), - def_ty_param(def_id, uint), - def_binding(NodeId, binding_mode), - def_use(def_id), - def_upvar(NodeId, // id of closed over var - @def, // closed over def +pub enum Def { + DefFn(DefId, purity), + DefStaticMethod(/* method */ DefId, MethodProvenance, purity), + DefSelf(NodeId), + DefSelfTy(/* trait id */ NodeId), + DefMod(DefId), + DefForeignMod(DefId), + DefStatic(DefId, bool /* is_mutbl */), + DefArg(NodeId, bool /* is_mutbl */), + DefLocal(NodeId, bool /* is_mutbl */), + DefVariant(DefId /* enum */, DefId /* variant */), + DefTy(DefId), + DefTrait(DefId), + DefPrimTy(prim_ty), + DefTyParam(DefId, uint), + DefBinding(NodeId, BindingMode), + DefUse(DefId), + DefUpvar(NodeId, // id of closed over var + @Def, // closed over def NodeId, // expr node that creates the closure NodeId), // id for the block/body of the closure expr - def_struct(def_id), - def_typaram_binder(NodeId), /* struct, impl or trait with ty params */ - def_region(NodeId), - def_label(NodeId), - def_method(def_id /* method */, Option /* trait */), + DefStruct(DefId), + DefTyParamBinder(NodeId), /* struct, impl or trait with ty params */ + DefRegion(NodeId), + DefLabel(NodeId), + DefMethod(DefId /* method */, Option /* trait */), } - // The set of MetaItems that define the compilation environment of the crate, // used to drive conditional compilation pub type CrateConfig = ~[@MetaItem]; @@ -261,35 +261,35 @@ impl Eq for MetaItem_ { #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] pub struct Block { view_items: ~[view_item], - stmts: ~[@stmt], - expr: Option<@expr>, + stmts: ~[@Stmt], + expr: Option<@Expr>, id: NodeId, rules: BlockCheckMode, span: Span, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct pat { +pub struct Pat { id: NodeId, - node: pat_, + node: Pat_, span: Span, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct field_pat { +pub struct FieldPat { ident: Ident, - pat: @pat, + pat: @Pat, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum binding_mode { - bind_by_ref(mutability), - bind_infer +pub enum BindingMode { + BindByRef(Mutability), + BindInfer } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum pat_ { - pat_wild, +pub enum Pat_ { + PatWild, // A pat_ident may either be a new bound variable, // or a nullary enum (in which case the second field // is None). @@ -297,25 +297,25 @@ pub enum pat_ { // which it is. The resolver determines this, and // records this pattern's NodeId in an auxiliary // set (of "pat_idents that refer to nullary enums") - pat_ident(binding_mode, Path, Option<@pat>), - pat_enum(Path, Option<~[@pat]>), /* "none" means a * pattern where + PatIdent(BindingMode, Path, Option<@Pat>), + PatEnum(Path, Option<~[@Pat]>), /* "none" means a * pattern where * we don't bind the fields to names */ - pat_struct(Path, ~[field_pat], bool), - pat_tup(~[@pat]), - pat_box(@pat), - pat_uniq(@pat), - pat_region(@pat), // borrowed pointer pattern - pat_lit(@expr), - pat_range(@expr, @expr), + PatStruct(Path, ~[FieldPat], bool), + PatTup(~[@Pat]), + PatBox(@Pat), + PatUniq(@Pat), + PatRegion(@Pat), // borrowed pointer pattern + PatLit(@Expr), + PatRange(@Expr, @Expr), // [a, b, ..i, y, z] is represented as // pat_vec(~[a, b], Some(i), ~[y, z]) - pat_vec(~[@pat], Option<@pat>, ~[@pat]) + PatVec(~[@Pat], Option<@Pat>, ~[@Pat]) } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum mutability { - m_mutbl, - m_imm, +pub enum Mutability { + MutMutable, + MutImmutable, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] @@ -336,69 +336,69 @@ impl ToStr for Sigil { } #[deriving(Eq, Encodable, Decodable, IterBytes)] -pub enum vstore { +pub enum Vstore { // FIXME (#3469): Change uint to @expr (actually only constant exprs) - vstore_fixed(Option), // [1,2,3,4] - vstore_uniq, // ~[1,2,3,4] - vstore_box, // @[1,2,3,4] - vstore_slice(Option) // &'foo? [1,2,3,4] + VstoreFixed(Option), // [1,2,3,4] + VstoreUniq, // ~[1,2,3,4] + VstoreBox, // @[1,2,3,4] + VstoreSlice(Option) // &'foo? [1,2,3,4] } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum expr_vstore { - expr_vstore_uniq, // ~[1,2,3,4] - expr_vstore_box, // @[1,2,3,4] - expr_vstore_mut_box, // @mut [1,2,3,4] - expr_vstore_slice, // &[1,2,3,4] - expr_vstore_mut_slice, // &mut [1,2,3,4] +pub enum ExprVstore { + ExprVstoreUniq, // ~[1,2,3,4] + ExprVstoreBox, // @[1,2,3,4] + ExprVstoreMutBox, // @mut [1,2,3,4] + ExprVstoreSlice, // &[1,2,3,4] + ExprVstoreMutSlice, // &mut [1,2,3,4] } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum binop { - add, - subtract, - mul, - div, - rem, - and, - or, - bitxor, - bitand, - bitor, - shl, - shr, - eq, - lt, - le, - ne, - ge, - gt, +pub enum BinOp { + BiAdd, + BiSub, + BiMul, + BiDiv, + BiRem, + BiAnd, + BiOr, + BiBitXor, + BiBitAnd, + BiBitOr, + BiShl, + BiShr, + BiEq, + BiLt, + BiLe, + BiNe, + BiGe, + BiGt, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum unop { - box(mutability), - uniq, - deref, - not, - neg +pub enum UnOp { + UnBox(Mutability), + UnUniq, + UnDeref, + UnNot, + UnNeg } -pub type stmt = Spanned; +pub type Stmt = Spanned; #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum stmt_ { +pub enum Stmt_ { // could be an item or a local (let) binding: - stmt_decl(@decl, NodeId), + StmtDecl(@Decl, NodeId), // expr without trailing semi-colon (must have unit type): - stmt_expr(@expr, NodeId), + StmtExpr(@Expr, NodeId), // expr with trailing semi-colon (may have any type): - stmt_semi(@expr, NodeId), + StmtSemi(@Expr, NodeId), // bool: is there a trailing sem-colon? - stmt_mac(mac, bool), + StmtMac(mac, bool), } // FIXME (pending discussion of #1697, #2178...): local should really be @@ -407,33 +407,33 @@ pub enum stmt_ { pub struct Local { is_mutbl: bool, ty: Ty, - pat: @pat, - init: Option<@expr>, + pat: @Pat, + init: Option<@Expr>, id: NodeId, span: Span, } -pub type decl = Spanned; +pub type Decl = Spanned; #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub enum decl_ { +pub enum Decl_ { // a local (let) binding: - decl_local(@Local), + DeclLocal(@Local), // an item binding: - decl_item(@item), + DeclItem(@item), } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub struct arm { - pats: ~[@pat], - guard: Option<@expr>, +pub struct Arm { + pats: ~[@Pat], + guard: Option<@Expr>, body: Block, } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct Field { ident: Ident, - expr: @expr, + expr: @Expr, span: Span, } @@ -444,20 +444,20 @@ pub enum BlockCheckMode { } #[deriving(Eq, Encodable, Decodable,IterBytes)] -pub struct expr { +pub struct Expr { id: NodeId, - node: expr_, + node: Expr_, span: Span, } -impl expr { +impl Expr { pub fn get_callee_id(&self) -> Option { match self.node { - expr_method_call(callee_id, _, _, _, _, _) | - expr_index(callee_id, _, _) | - expr_binary(callee_id, _, _, _) | - expr_assign_op(callee_id, _, _, _) | - expr_unary(callee_id, _, _) => Some(callee_id), + ExprMethodCall(callee_id, _, _, _, _, _) | + ExprIndex(callee_id, _, _) | + ExprBinary(callee_id, _, _, _) | + ExprAssignOp(callee_id, _, _, _) | + ExprUnary(callee_id, _, _) => Some(callee_id), _ => None, } } @@ -471,54 +471,54 @@ pub enum CallSugar { } #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] -pub enum expr_ { - expr_vstore(@expr, expr_vstore), - expr_vec(~[@expr], mutability), - expr_call(@expr, ~[@expr], CallSugar), - expr_method_call(NodeId, @expr, Ident, ~[Ty], ~[@expr], CallSugar), - expr_tup(~[@expr]), - expr_binary(NodeId, binop, @expr, @expr), - expr_unary(NodeId, unop, @expr), - expr_lit(@lit), - expr_cast(@expr, Ty), - expr_if(@expr, Block, Option<@expr>), - expr_while(@expr, Block), - expr_for_loop(@pat, @expr, Block), +pub enum Expr_ { + ExprVstore(@Expr, ExprVstore), + ExprVec(~[@Expr], Mutability), + ExprCall(@Expr, ~[@Expr], CallSugar), + ExprMethodCall(NodeId, @Expr, Ident, ~[Ty], ~[@Expr], CallSugar), + ExprTup(~[@Expr]), + ExprBinary(NodeId, BinOp, @Expr, @Expr), + ExprUnary(NodeId, UnOp, @Expr), + ExprLit(@lit), + ExprCast(@Expr, Ty), + ExprIf(@Expr, Block, Option<@Expr>), + ExprWhile(@Expr, Block), + ExprForLoop(@Pat, @Expr, Block), /* Conditionless loop (can be exited with break, cont, or ret) Same semantics as while(true) { body }, but typestate knows that the (implicit) condition is always true. */ - expr_loop(Block, Option), - expr_match(@expr, ~[arm]), - expr_fn_block(fn_decl, Block), - expr_do_body(@expr), - expr_block(Block), - - expr_assign(@expr, @expr), - expr_assign_op(NodeId, binop, @expr, @expr), - expr_field(@expr, Ident, ~[Ty]), - expr_index(NodeId, @expr, @expr), - expr_path(Path), + ExprLoop(Block, Option), + ExprMatch(@Expr, ~[Arm]), + ExprFnBlock(fn_decl, Block), + ExprDoBody(@Expr), + ExprBlock(Block), + + ExprAssign(@Expr, @Expr), + ExprAssignOp(NodeId, BinOp, @Expr, @Expr), + ExprField(@Expr, Ident, ~[Ty]), + ExprIndex(NodeId, @Expr, @Expr), + ExprPath(Path), /// The special identifier `self`. - expr_self, - expr_addr_of(mutability, @expr), - expr_break(Option), - expr_again(Option), - expr_ret(Option<@expr>), - expr_log(@expr, @expr), + ExprSelf, + ExprAddrOf(Mutability, @Expr), + ExprBreak(Option), + ExprAgain(Option), + ExprRet(Option<@Expr>), + ExprLog(@Expr, @Expr), - expr_inline_asm(inline_asm), + ExprInlineAsm(inline_asm), - expr_mac(mac), + ExprMac(mac), // A struct literal expression. - expr_struct(Path, ~[Field], Option<@expr> /* base */), + ExprStruct(Path, ~[Field], Option<@Expr> /* base */), // A vector literal constructed from one repeated element. - expr_repeat(@expr /* element */, @expr /* count */, mutability), + ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability), // No-op: used solely so we can pretty-print faithfully - expr_paren(@expr) + ExprParen(@Expr) } // When the main rust parser encounters a syntax-extension invocation, it @@ -646,7 +646,7 @@ pub enum lit_ { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct mt { ty: ~Ty, - mutbl: mutability, + mutbl: Mutability, } #[deriving(Eq, Encodable, Decodable,IterBytes)] @@ -785,7 +785,7 @@ pub enum ty_ { ty_box(mt), ty_uniq(mt), ty_vec(mt), - ty_fixed_length_vec(mt, @expr), + ty_fixed_length_vec(mt, @Expr), ty_ptr(mt), ty_rptr(Option, mt), ty_closure(@TyClosure), @@ -793,7 +793,7 @@ pub enum ty_ { ty_tup(~[Ty]), ty_path(Path, Option>, NodeId), // for #7264; see above ty_mac(mac), - ty_typeof(@expr), + ty_typeof(@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. @@ -810,8 +810,8 @@ pub enum asm_dialect { pub struct inline_asm { asm: @str, clobbers: @str, - inputs: ~[(@str, @expr)], - outputs: ~[(@str, @expr)], + inputs: ~[(@str, @Expr)], + outputs: ~[(@str, @Expr)], volatile: bool, alignstack: bool, dialect: asm_dialect @@ -821,7 +821,7 @@ pub struct inline_asm { pub struct arg { is_mutbl: bool, ty: Ty, - pat: @pat, + pat: @Pat, id: NodeId, } @@ -861,8 +861,8 @@ pub enum ret_style { pub enum explicit_self_ { sty_static, // no self sty_value, // `self` - sty_region(Option, mutability), // `&'lt self` - sty_box(mutability), // `@self` + sty_region(Option, Mutability), // `&'lt self` + sty_box(Mutability), // `@self` sty_uniq // `~self` } @@ -927,7 +927,7 @@ pub struct variant_ { attrs: ~[Attribute], kind: variant_kind, id: NodeId, - disr_expr: Option<@expr>, + disr_expr: Option<@Expr>, vis: visibility, } @@ -1067,7 +1067,7 @@ pub struct item { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum item_ { - item_static(Ty, mutability, @expr), + item_static(Ty, Mutability, @Expr), item_fn(fn_decl, purity, AbiSet, Generics, Block), item_mod(_mod), item_foreign_mod(foreign_mod), @@ -1105,7 +1105,7 @@ pub enum foreign_item_ { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum inlined_item { ii_item(@item), - ii_method(def_id /* impl id */, bool /* is provided */, @method), + ii_method(DefId /* impl id */, bool /* is provided */, @method), ii_foreign(@foreign_item), } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 6e022e9804b41..ccaadcbad4df4 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -67,17 +67,17 @@ pub fn path_elt_to_str(pe: path_elt, itr: @ident_interner) -> ~str { pub enum ast_node { node_item(@item, @path), node_foreign_item(@foreign_item, AbiSet, visibility, @path), - node_trait_method(@trait_method, def_id /* trait did */, + node_trait_method(@trait_method, DefId /* trait did */, @path /* path to the trait */), - node_method(@method, def_id /* impl did */, @path /* path to the impl */), + node_method(@method, DefId /* impl did */, @path /* path to the impl */), node_variant(variant, @item, @path), - node_expr(@expr), - node_stmt(@stmt), + node_expr(@Expr), + node_stmt(@Stmt), node_arg, node_local(Ident), node_block(Block), node_struct_ctor(@struct_def, @item, @path), - node_callee_scope(@expr) + node_callee_scope(@Expr) } pub type map = @mut HashMap; @@ -94,7 +94,7 @@ impl Ctx { } fn map_method(&mut self, - impl_did: def_id, + impl_did: DefId, impl_path: @path, m: @method, is_provided: bool) { @@ -130,7 +130,7 @@ impl Ctx { } } - fn map_expr(&mut self, ex: @expr) { + fn map_expr(&mut self, ex: @Expr) { self.map.insert(ex.id, node_expr(ex)); // Expressions which are or might be calls: @@ -156,7 +156,7 @@ impl Ctx { visit::walk_fn(self, fk, decl, body, sp, id, ()); } - fn map_stmt(&mut self, stmt: @stmt) { + fn map_stmt(&mut self, stmt: @Stmt) { self.map.insert(stmt_id(stmt), node_stmt(stmt)); visit::walk_stmt(self, stmt, ()); } @@ -167,9 +167,9 @@ impl Ctx { visit::walk_block(self, b, ()); } - fn map_pat(&mut self, pat: @pat) { + fn map_pat(&mut self, pat: @Pat) { match pat.node { - pat_ident(_, ref path, _) => { + PatIdent(_, ref path, _) => { // Note: this is at least *potentially* a pattern... self.map.insert(pat.id, node_local(ast_util::path_to_ident(path))); @@ -265,16 +265,16 @@ impl Visitor<()> for Ctx { self.path.pop(); } - fn visit_pat(&mut self, pat: @pat, _: ()) { + fn visit_pat(&mut self, pat: @Pat, _: ()) { self.map_pat(pat); visit::walk_pat(self, pat, ()) } - fn visit_expr(&mut self, expr: @expr, _: ()) { + fn visit_expr(&mut self, expr: @Expr, _: ()) { self.map_expr(expr) } - fn visit_stmt(&mut self, stmt: @stmt, _: ()) { + fn visit_stmt(&mut self, stmt: @Stmt, _: ()) { self.map_stmt(stmt) } @@ -310,15 +310,15 @@ impl Visitor<()> for Ctx { visit::walk_local(self, local, ()) } - fn visit_arm(&mut self, arm: &arm, _: ()) { + fn visit_arm(&mut self, arm: &Arm, _: ()) { visit::walk_arm(self, arm, ()) } - fn visit_decl(&mut self, decl: @decl, _: ()) { + fn visit_decl(&mut self, decl: @Decl, _: ()) { visit::walk_decl(self, decl, ()) } - fn visit_expr_post(&mut self, _: @expr, _: ()) { + fn visit_expr_post(&mut self, _: @Expr, _: ()) { // Empty! } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 810ce9940f2e1..62b8fc687a6b5 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -32,121 +32,121 @@ pub fn path_to_ident(path: &Path) -> Ident { path.segments.last().identifier } -pub fn local_def(id: NodeId) -> def_id { - ast::def_id { crate: LOCAL_CRATE, node: id } +pub fn local_def(id: NodeId) -> DefId { + ast::DefId { crate: LOCAL_CRATE, node: id } } -pub fn is_local(did: ast::def_id) -> bool { did.crate == LOCAL_CRATE } +pub fn is_local(did: ast::DefId) -> bool { did.crate == LOCAL_CRATE } -pub fn stmt_id(s: &stmt) -> NodeId { +pub fn stmt_id(s: &Stmt) -> NodeId { match s.node { - stmt_decl(_, id) => id, - stmt_expr(_, id) => id, - stmt_semi(_, id) => id, - stmt_mac(*) => fail!("attempted to analyze unexpanded stmt") + StmtDecl(_, id) => id, + StmtExpr(_, id) => id, + StmtSemi(_, id) => id, + StmtMac(*) => fail!("attempted to analyze unexpanded stmt") } } -pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> { +pub fn variant_def_ids(d: Def) -> Option<(DefId, DefId)> { match d { - def_variant(enum_id, var_id) => { + DefVariant(enum_id, var_id) => { Some((enum_id, var_id)) } _ => None } } -pub fn def_id_of_def(d: def) -> def_id { +pub fn def_id_of_def(d: Def) -> DefId { match d { - def_fn(id, _) | def_static_method(id, _, _) | def_mod(id) | - def_foreign_mod(id) | def_static(id, _) | - def_variant(_, id) | def_ty(id) | def_ty_param(id, _) | - def_use(id) | def_struct(id) | def_trait(id) | def_method(id, _) => { + DefFn(id, _) | DefStaticMethod(id, _, _) | DefMod(id) | + DefForeignMod(id) | DefStatic(id, _) | + DefVariant(_, id) | DefTy(id) | DefTyParam(id, _) | + DefUse(id) | DefStruct(id) | DefTrait(id) | DefMethod(id, _) => { id } - def_arg(id, _) | def_local(id, _) | def_self(id) | def_self_ty(id) - | def_upvar(id, _, _, _) | def_binding(id, _) | def_region(id) - | def_typaram_binder(id) | def_label(id) => { + DefArg(id, _) | DefLocal(id, _) | DefSelf(id) | DefSelfTy(id) + | DefUpvar(id, _, _, _) | DefBinding(id, _) | DefRegion(id) + | DefTyParamBinder(id) | DefLabel(id) => { local_def(id) } - def_prim_ty(_) => fail!() + DefPrimTy(_) => fail!() } } -pub fn binop_to_str(op: binop) -> ~str { +pub fn binop_to_str(op: BinOp) -> ~str { match op { - add => return ~"+", - subtract => return ~"-", - mul => return ~"*", - div => return ~"/", - rem => return ~"%", - and => return ~"&&", - or => return ~"||", - bitxor => return ~"^", - bitand => return ~"&", - bitor => return ~"|", - shl => return ~"<<", - shr => return ~">>", - eq => return ~"==", - lt => return ~"<", - le => return ~"<=", - ne => return ~"!=", - ge => return ~">=", - gt => return ~">" - } -} - -pub fn binop_to_method_name(op: binop) -> Option<~str> { + BiAdd => return ~"+", + BiSub => return ~"-", + BiMul => return ~"*", + BiDiv => return ~"/", + BiRem => return ~"%", + BiAnd => return ~"&&", + BiOr => return ~"||", + BiBitXor => return ~"^", + BiBitAnd => return ~"&", + BiBitOr => return ~"|", + BiShl => return ~"<<", + BiShr => return ~">>", + BiEq => return ~"==", + BiLt => return ~"<", + BiLe => return ~"<=", + BiNe => return ~"!=", + BiGe => return ~">=", + BiGt => return ~">" + } +} + +pub fn binop_to_method_name(op: BinOp) -> Option<~str> { match op { - add => return Some(~"add"), - subtract => return Some(~"sub"), - mul => return Some(~"mul"), - div => return Some(~"div"), - rem => return Some(~"rem"), - bitxor => return Some(~"bitxor"), - bitand => return Some(~"bitand"), - bitor => return Some(~"bitor"), - shl => return Some(~"shl"), - shr => return Some(~"shr"), - lt => return Some(~"lt"), - le => return Some(~"le"), - ge => return Some(~"ge"), - gt => return Some(~"gt"), - eq => return Some(~"eq"), - ne => return Some(~"ne"), - and | or => return None - } -} - -pub fn lazy_binop(b: binop) -> bool { + BiAdd => return Some(~"add"), + BiSub => return Some(~"sub"), + BiMul => return Some(~"mul"), + BiDiv => return Some(~"div"), + BiRem => return Some(~"rem"), + BiBitXor => return Some(~"bitxor"), + BiBitAnd => return Some(~"bitand"), + BiBitOr => return Some(~"bitor"), + BiShl => return Some(~"shl"), + BiShr => return Some(~"shr"), + BiLt => return Some(~"lt"), + BiLe => return Some(~"le"), + BiGe => return Some(~"ge"), + BiGt => return Some(~"gt"), + BiEq => return Some(~"eq"), + BiNe => return Some(~"ne"), + BiAnd | BiOr => return None + } +} + +pub fn lazy_binop(b: BinOp) -> bool { match b { - and => true, - or => true, + BiAnd => true, + BiOr => true, _ => false } } -pub fn is_shift_binop(b: binop) -> bool { +pub fn is_shift_binop(b: BinOp) -> bool { match b { - shl => true, - shr => true, + BiShl => true, + BiShr => true, _ => false } } -pub fn unop_to_str(op: unop) -> ~str { +pub fn unop_to_str(op: UnOp) -> ~str { match op { - box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" }, - uniq => ~"~", - deref => ~"*", - not => ~"!", - neg => ~"-" + UnBox(mt) => if mt == MutMutable { ~"@mut " } else { ~"@" }, + UnUniq => ~"~", + UnDeref => ~"*", + UnNot => ~"!", + UnNeg => ~"-" } } -pub fn is_path(e: @expr) -> bool { - return match e.node { expr_path(_) => true, _ => false }; +pub fn is_path(e: @Expr) -> bool { + return match e.node { ExprPath(_) => true, _ => false }; } pub fn int_ty_to_str(t: int_ty) -> ~str { @@ -192,19 +192,19 @@ pub fn float_ty_to_str(t: float_ty) -> ~str { match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" } } -pub fn is_call_expr(e: @expr) -> bool { - match e.node { expr_call(*) => true, _ => false } +pub fn is_call_expr(e: @Expr) -> bool { + match e.node { ExprCall(*) => true, _ => false } } -pub fn block_from_expr(e: @expr) -> Block { - let mut blk = default_block(~[], option::Some::<@expr>(e), e.id); +pub fn block_from_expr(e: @Expr) -> Block { + let mut blk = default_block(~[], option::Some::<@Expr>(e), e.id); blk.span = e.span; return blk; } pub fn default_block( - stmts1: ~[@stmt], - expr1: Option<@expr>, + stmts1: ~[@Stmt], + expr1: Option<@Expr>, id1: NodeId ) -> Block { ast::Block { @@ -231,20 +231,20 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path { } } -pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> @pat { - @ast::pat { id: id, - node: pat_ident(bind_infer, ident_to_path(s, i), None), +pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> @Pat { + @ast::Pat { id: id, + node: PatIdent(BindInfer, ident_to_path(s, i), None), span: s } } -pub fn is_unguarded(a: &arm) -> bool { +pub fn is_unguarded(a: &Arm) -> bool { match a.guard { None => true, _ => false } } -pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> { +pub fn unguarded_pat(a: &Arm) -> Option<~[@Pat]> { if is_unguarded(a) { Some(/* FIXME (#2543) */ a.pats.clone()) } else { @@ -335,28 +335,28 @@ impl inlined_item_utils for inlined_item { /* True if d is either a def_self, or a chain of def_upvars referring to a def_self */ -pub fn is_self(d: ast::def) -> bool { +pub fn is_self(d: ast::Def) -> bool { match d { - def_self(*) => true, - def_upvar(_, d, _, _) => is_self(*d), + DefSelf(*) => true, + DefUpvar(_, d, _, _) => is_self(*d), _ => false } } /// Maps a binary operator to its precedence -pub fn operator_prec(op: ast::binop) -> uint { +pub fn operator_prec(op: ast::BinOp) -> uint { match op { // 'as' sits here with 12 - mul | div | rem => 11u, - add | subtract => 10u, - shl | shr => 9u, - bitand => 8u, - bitxor => 7u, - bitor => 6u, - lt | le | ge | gt => 4u, - eq | ne => 3u, - and => 2u, - or => 1u + BiMul | BiDiv | BiRem => 11u, + BiAdd | BiSub => 10u, + BiShl | BiShr => 9u, + BiBitAnd => 8u, + BiBitXor => 7u, + BiBitOr => 6u, + BiLt | BiLe | BiGe | BiGt => 4u, + BiEq | BiNe => 3u, + BiAnd => 2u, + BiOr => 1u } } @@ -497,27 +497,27 @@ impl Visitor<()> for IdVisitor { visit::walk_block(self, block, env) } - fn visit_stmt(&mut self, statement: @stmt, env: ()) { + fn visit_stmt(&mut self, statement: @Stmt, env: ()) { (self.visit_callback)(ast_util::stmt_id(statement)); visit::walk_stmt(self, statement, env) } // XXX: Default - fn visit_arm(&mut self, arm: &arm, env: ()) { + fn visit_arm(&mut self, arm: &Arm, env: ()) { visit::walk_arm(self, arm, env) } - fn visit_pat(&mut self, pattern: @pat, env: ()) { + fn visit_pat(&mut self, pattern: @Pat, env: ()) { (self.visit_callback)(pattern.id); visit::walk_pat(self, pattern, env) } // XXX: Default - fn visit_decl(&mut self, declaration: @decl, env: ()) { + fn visit_decl(&mut self, declaration: @Decl, env: ()) { visit::walk_decl(self, declaration, env) } - fn visit_expr(&mut self, expression: @expr, env: ()) { + fn visit_expr(&mut self, expression: @Expr, env: ()) { { let optional_callee_id = expression.get_callee_id(); for callee_id in optional_callee_id.iter() { @@ -529,7 +529,7 @@ impl Visitor<()> for IdVisitor { } // XXX: Default - fn visit_expr_post(&mut self, _: @expr, _: ()) { + fn visit_expr_post(&mut self, _: @Expr, _: ()) { // Empty! } @@ -654,29 +654,29 @@ pub fn is_item_impl(item: @ast::item) -> bool { } } -pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool { +pub fn walk_pat(pat: @Pat, it: &fn(@Pat) -> bool) -> bool { if !it(pat) { return false; } match pat.node { - pat_ident(_, _, Some(p)) => walk_pat(p, it), - pat_struct(_, ref fields, _) => { + PatIdent(_, _, Some(p)) => walk_pat(p, it), + PatStruct(_, ref fields, _) => { fields.iter().advance(|f| walk_pat(f.pat, |p| it(p))) } - pat_enum(_, Some(ref s)) | pat_tup(ref s) => { + PatEnum(_, Some(ref s)) | PatTup(ref s) => { s.iter().advance(|&p| walk_pat(p, |p| it(p))) } - pat_box(s) | pat_uniq(s) | pat_region(s) => { + PatBox(s) | PatUniq(s) | PatRegion(s) => { walk_pat(s, it) } - pat_vec(ref before, ref slice, ref after) => { + PatVec(ref before, ref slice, ref after) => { before.iter().advance(|&p| walk_pat(p, |p| it(p))) && slice.iter().advance(|&p| walk_pat(p, |p| it(p))) && after.iter().advance(|&p| walk_pat(p, |p| it(p))) } - pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _) | - pat_enum(_, _) => { + PatWild | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) | + PatEnum(_, _) => { true } } @@ -709,22 +709,22 @@ impl SimpleVisitor for EachViewItemData { fn visit_block(&mut self, _: &Block) { // XXX: Default method. } - fn visit_stmt(&mut self, _: @stmt) { + fn visit_stmt(&mut self, _: @Stmt) { // XXX: Default method. } - fn visit_arm(&mut self, _: &arm) { + fn visit_arm(&mut self, _: &Arm) { // XXX: Default method. } - fn visit_pat(&mut self, _: @pat) { + fn visit_pat(&mut self, _: @Pat) { // XXX: Default method. } - fn visit_decl(&mut self, _: @decl) { + fn visit_decl(&mut self, _: @Decl) { // XXX: Default method. } - fn visit_expr(&mut self, _: @expr) { + fn visit_expr(&mut self, _: @Expr) { // XXX: Default method. } - fn visit_expr_post(&mut self, _: @expr) { + fn visit_expr_post(&mut self, _: @Expr) { // XXX: Default method. } fn visit_ty(&mut self, _: &Ty) { @@ -817,9 +817,9 @@ pub enum Privacy { /// Returns true if the given pattern consists solely of an identifier /// and false otherwise. -pub fn pat_is_ident(pat: @ast::pat) -> bool { +pub fn pat_is_ident(pat: @ast::Pat) -> bool { match pat.node { - ast::pat_ident(*) => true, + ast::PatIdent(*) => true, _ => false, } } @@ -1015,7 +1015,7 @@ mod test { // convert a list of uints to an @[ident] // (ignores the interner completely) fn uints_to_idents (uints: &~[uint]) -> @~[Ident] { - @uints.map(|u| Ident {name:*u, ctxt: empty_ctxt}) + @uints.map(|u| Ident {name:*u, ctxt: EMPTY_CTXT}) } fn id (u : uint, s: SyntaxContext) -> Ident { @@ -1065,7 +1065,7 @@ mod test { let mut t = new_sctable_internal(); let test_sc = ~[M(3),R(id(101,0),14),M(9)]; - assert_eq!(unfold_test_sc(test_sc.clone(),empty_ctxt,&mut t),4); + assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); assert_eq!(t.table[2],Mark(9,0)); assert_eq!(t.table[3],Rename(id(101,0),14,2)); assert_eq!(t.table[4],Mark(3,3)); @@ -1082,7 +1082,7 @@ mod test { #[test] fn unfold_marks_test() { let mut t = new_sctable_internal(); - assert_eq!(unfold_marks(~[3,7],empty_ctxt,&mut t),3); + assert_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3); assert_eq!(t.table[2],Mark(7,0)); assert_eq!(t.table[3],Mark(3,2)); } @@ -1091,31 +1091,31 @@ mod test { let stopname = 242; let name1 = 243; let mut t = new_sctable_internal(); - assert_eq!(marksof (empty_ctxt,stopname,&t),~[]); + assert_eq!(marksof (EMPTY_CTXT,stopname,&t),~[]); // FIXME #5074: ANF'd to dodge nested calls - { let ans = unfold_marks(~[4,98],empty_ctxt,&mut t); + { let ans = unfold_marks(~[4,98],EMPTY_CTXT,&mut t); assert_eq! (marksof (ans,stopname,&t),~[4,98]);} // does xoring work? - { let ans = unfold_marks(~[5,5,16],empty_ctxt,&mut t); + { let ans = unfold_marks(~[5,5,16],EMPTY_CTXT,&mut t); assert_eq! (marksof (ans,stopname,&t), ~[16]);} // does nested xoring work? - { let ans = unfold_marks(~[5,10,10,5,16],empty_ctxt,&mut t); + { let ans = unfold_marks(~[5,10,10,5,16],EMPTY_CTXT,&mut t); assert_eq! (marksof (ans, stopname,&t), ~[16]);} // rename where stop doesn't match: { let chain = ~[M(9), R(id(name1, - new_mark_internal (4, empty_ctxt,&mut t)), + new_mark_internal (4, EMPTY_CTXT,&mut t)), 100101102), M(14)]; - let ans = unfold_test_sc(chain,empty_ctxt,&mut t); + let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t); assert_eq! (marksof (ans, stopname, &t), ~[9,14]);} // rename where stop does match - { let name1sc = new_mark_internal(4, empty_ctxt, &mut t); + { let name1sc = new_mark_internal(4, EMPTY_CTXT, &mut t); let chain = ~[M(9), R(id(name1, name1sc), stopname), M(14)]; - let ans = unfold_test_sc(chain,empty_ctxt,&mut t); + let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t); assert_eq! (marksof (ans, stopname, &t), ~[9]); } } @@ -1124,38 +1124,38 @@ mod test { let a = 40; let mut t = new_sctable_internal(); // - ctxt is MT - assert_eq!(resolve_internal(id(a,empty_ctxt),&mut t),a); + assert_eq!(resolve_internal(id(a,EMPTY_CTXT),&mut t),a); // - simple ignored marks - { let sc = unfold_marks(~[1,2,3],empty_ctxt,&mut t); + { let sc = unfold_marks(~[1,2,3],EMPTY_CTXT,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t),a);} // - orthogonal rename where names don't match - { let sc = unfold_test_sc(~[R(id(50,empty_ctxt),51),M(12)],empty_ctxt,&mut t); + { let sc = unfold_test_sc(~[R(id(50,EMPTY_CTXT),51),M(12)],EMPTY_CTXT,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t),a);} // - rename where names do match, but marks don't - { let sc1 = new_mark_internal(1,empty_ctxt,&mut t); + { let sc1 = new_mark_internal(1,EMPTY_CTXT,&mut t); let sc = unfold_test_sc(~[R(id(a,sc1),50), M(1), M(2)], - empty_ctxt,&mut t); + EMPTY_CTXT,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t), a);} // - rename where names and marks match - { let sc1 = unfold_test_sc(~[M(1),M(2)],empty_ctxt,&mut t); - let sc = unfold_test_sc(~[R(id(a,sc1),50),M(1),M(2)],empty_ctxt,&mut t); + { let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t); + let sc = unfold_test_sc(~[R(id(a,sc1),50),M(1),M(2)],EMPTY_CTXT,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t), 50); } // - rename where names and marks match by literal sharing - { let sc1 = unfold_test_sc(~[M(1),M(2)],empty_ctxt,&mut t); + { let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t); let sc = unfold_test_sc(~[R(id(a,sc1),50)],sc1,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t), 50); } // - two renames of the same var.. can only happen if you use // local-expand to prevent the inner binding from being renamed // during the rename-pass caused by the first: io::println("about to run bad test"); - { let sc = unfold_test_sc(~[R(id(a,empty_ctxt),50), - R(id(a,empty_ctxt),51)], - empty_ctxt,&mut t); + { let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50), + R(id(a,EMPTY_CTXT),51)], + EMPTY_CTXT,&mut t); assert_eq!(resolve_internal(id(a,sc),&mut t), 51); } // the simplest double-rename: - { let a_to_a50 = new_rename_internal(id(a,empty_ctxt),50,empty_ctxt,&mut t); + { let a_to_a50 = new_rename_internal(id(a,EMPTY_CTXT),50,EMPTY_CTXT,&mut t); let a50_to_a51 = new_rename_internal(id(a,a_to_a50),51,a_to_a50,&mut t); assert_eq!(resolve_internal(id(a,a50_to_a51),&mut t),51); // mark on the outside doesn't stop rename: @@ -1171,10 +1171,10 @@ mod test { #[test] fn hashing_tests () { let mut t = new_sctable_internal(); - assert_eq!(new_mark_internal(12,empty_ctxt,&mut t),2); - assert_eq!(new_mark_internal(13,empty_ctxt,&mut t),3); + assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); + assert_eq!(new_mark_internal(13,EMPTY_CTXT,&mut t),3); // using the same one again should result in the same index: - assert_eq!(new_mark_internal(12,empty_ctxt,&mut t),2); + assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); // I'm assuming that the rename table will behave the same.... } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index e023c0c67edfa..3937cd8e416d1 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -75,10 +75,10 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) let out = p.parse_expr(); p.expect(&token::RPAREN); - let out = @ast::expr { + let out = @ast::Expr { id: cx.next_id(), span: out.span, - node: ast::expr_addr_of(ast::m_mutbl, out) + node: ast::ExprAddrOf(ast::MutMutable, out) }; outputs.push((constraint, out)); @@ -171,9 +171,9 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) } } - MRExpr(@ast::expr { + MRExpr(@ast::Expr { id: cx.next_id(), - node: ast::expr_inline_asm(ast::inline_asm { + node: ast::ExprInlineAsm(ast::inline_asm { asm: asm, clobbers: cons.to_managed(), inputs: inputs, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 913b68da0cb47..50683358f876a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -62,11 +62,11 @@ pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt, -> MacResult; pub enum MacResult { - MRExpr(@ast::expr), + MRExpr(@ast::Expr), MRItem(@ast::item), - MRAny(@fn() -> @ast::expr, + MRAny(@fn() -> @ast::Expr, @fn() -> Option<@ast::item>, - @fn() -> @ast::stmt), + @fn() -> @ast::Stmt), MRDef(MacroDef) } @@ -319,9 +319,9 @@ impl ExtCtxt { } } -pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: &str) -> @str { +pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> @str { match expr.node { - ast::expr_lit(l) => match l.node { + ast::ExprLit(l) => match l.node { ast::lit_str(s) => s, _ => cx.span_fatal(l.span, err_msg) }, @@ -353,7 +353,7 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt, pub fn get_exprs_from_tts(cx: @ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> ~[@ast::expr] { + tts: &[ast::token_tree]) -> ~[@ast::Expr] { let 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 55f7a35e1df52..339583ed426cc 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -21,7 +21,7 @@ use opt_vec::OptVec; pub struct Field { ident: ast::Ident, - ex: @ast::expr + ex: @ast::Expr } // Transitional reexports so qquote can find the paths it is looking for @@ -43,7 +43,7 @@ pub trait AstBuilder { -> ast::Path; // types - fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt; + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::Mutability) -> ast::mt; fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty; fn ty_path(&self, ast::Path, Option>) -> ast::Ty; @@ -52,9 +52,9 @@ pub trait AstBuilder { fn ty_rptr(&self, span: Span, ty: ast::Ty, lifetime: Option, - mutbl: ast::mutability) -> ast::Ty; + mutbl: ast::Mutability) -> ast::Ty; fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty; - fn ty_box(&self, span: Span, ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty; + fn ty_box(&self, span: Span, ty: ast::Ty, mutbl: ast::Mutability) -> ast::Ty; fn ty_option(&self, ty: ast::Ty) -> ast::Ty; fn ty_infer(&self, sp: Span) -> ast::Ty; @@ -72,101 +72,101 @@ pub trait AstBuilder { fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime; // statements - fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt; - fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt; + fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt; + fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt; fn stmt_let_typed(&self, sp: Span, mutbl: bool, ident: ast::Ident, typ: ast::Ty, - ex: @ast::expr) - -> @ast::stmt; + ex: @ast::Expr) + -> @ast::Stmt; // blocks - fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block; - fn block_expr(&self, expr: @ast::expr) -> ast::Block; + fn block(&self, span: Span, stmts: ~[@ast::Stmt], expr: Option<@ast::Expr>) -> ast::Block; + fn block_expr(&self, expr: @ast::Expr) -> ast::Block; fn block_all(&self, span: Span, view_items: ~[ast::view_item], - stmts: ~[@ast::stmt], - expr: Option<@ast::expr>) -> ast::Block; + stmts: ~[@ast::Stmt], + expr: Option<@ast::Expr>) -> ast::Block; // expressions - fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr; - fn expr_path(&self, path: ast::Path) -> @ast::expr; - fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr; - - fn expr_self(&self, span: Span) -> @ast::expr; - fn expr_binary(&self, sp: Span, op: ast::binop, - lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr; - fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr; - fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr) -> @ast::expr; - - fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr; - fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr; - fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr; - fn expr_field_access(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr; - fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr; - fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr; + fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr; + fn expr_path(&self, path: ast::Path) -> @ast::Expr; + fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr; + + fn expr_self(&self, span: Span) -> @ast::Expr; + fn expr_binary(&self, sp: Span, op: ast::BinOp, + lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr; + fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; + fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) -> @ast::Expr; + + fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; + fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; + fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; + fn expr_field_access(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr; + fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr; + fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr; fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident], - args: ~[@ast::expr]) -> @ast::expr; + args: ~[@ast::Expr]) -> @ast::Expr; fn expr_method_call(&self, span: Span, - expr: @ast::expr, ident: ast::Ident, - args: ~[@ast::expr]) -> @ast::expr; - fn expr_block(&self, b: ast::Block) -> @ast::expr; + expr: @ast::Expr, ident: ast::Ident, + args: ~[@ast::Expr]) -> @ast::Expr; + fn expr_block(&self, b: ast::Block) -> @ast::Expr; - fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field; - 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 field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field; + 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; - fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr; - fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr; + fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr; + fn expr_int(&self, sp: Span, i: int) -> @ast::Expr; + fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr; + fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr; - fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr; - fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr; - fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr; - fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr; - fn expr_str(&self, sp: Span, s: @str) -> @ast::expr; - fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr; + fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr; + fn expr_vec(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr; + fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr; + fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr; + fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr; + fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr; - fn expr_unreachable(&self, span: Span) -> @ast::expr; + fn expr_unreachable(&self, span: Span) -> @ast::Expr; - fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat; - fn pat_wild(&self, span: Span) -> @ast::pat; - fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat; - fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat; + fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat; + fn pat_wild(&self, span: Span) -> @ast::Pat; + fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat; + fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat; fn pat_ident_binding_mode(&self, span: Span, ident: ast::Ident, - bm: ast::binding_mode) -> @ast::pat; - fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat; + bm: ast::BindingMode) -> @ast::Pat; + fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::Pat]) -> @ast::Pat; fn pat_struct(&self, span: Span, - path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat; + path: ast::Path, field_pats: ~[ast::FieldPat]) -> @ast::Pat; - fn arm(&self, span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm; - fn arm_unreachable(&self, span: Span) -> ast::arm; + fn arm(&self, span: Span, pats: ~[@ast::Pat], expr: @ast::Expr) -> ast::Arm; + fn arm_unreachable(&self, span: Span) -> ast::Arm; - fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @ast::expr; + fn expr_match(&self, span: Span, arg: @ast::Expr, arms: ~[ast::Arm]) -> @ast::Expr; fn expr_if(&self, span: Span, - cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr; + cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr; - fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr; + fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::Expr; - fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr; - fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::expr; - fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr; + fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::Expr; + fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::Expr; + fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr; - fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], blk: @ast::expr) -> @ast::expr; - fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr; - fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr; + fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], blk: @ast::Expr) -> @ast::Expr; + fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr; + fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr; - fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], blk: ~[@ast::stmt]) -> @ast::expr; - fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr; - fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr; + fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], blk: ~[@ast::Stmt]) -> @ast::Expr; + fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::Stmt]) -> @ast::Expr; + fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::Stmt], ident: ast::Ident) -> @ast::Expr; // items fn item(&self, span: Span, @@ -268,7 +268,7 @@ impl AstBuilder for @ExtCtxt { } } - fn ty_mt(&self, ty: ast::Ty, mutbl: ast::mutability) -> ast::mt { + fn ty_mt(&self, ty: ast::Ty, mutbl: ast::Mutability) -> ast::mt { ast::mt { ty: ~ty, mutbl: mutbl @@ -300,16 +300,16 @@ impl AstBuilder for @ExtCtxt { span: Span, ty: ast::Ty, lifetime: Option, - mutbl: ast::mutability) + mutbl: ast::Mutability) -> ast::Ty { self.ty(span, ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl))) } fn ty_uniq(&self, span: Span, ty: ast::Ty) -> ast::Ty { - self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::m_imm))) + self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::MutImmutable))) } fn ty_box(&self, span: Span, - ty: ast::Ty, mutbl: ast::mutability) -> ast::Ty { + ty: ast::Ty, mutbl: ast::Mutability) -> ast::Ty { self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl))) } @@ -329,7 +329,7 @@ impl AstBuilder for @ExtCtxt { fn ty_field_imm(&self, span: Span, name: Ident, ty: ast::Ty) -> ast::TypeField { ast::TypeField { ident: name, - mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, + mt: ast::mt { ty: ~ty, mutbl: ast::MutImmutable }, span: span, } } @@ -389,11 +389,11 @@ impl AstBuilder for @ExtCtxt { ast::Lifetime { id: self.next_id(), span: span, ident: ident } } - fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt { - @respan(expr.span, ast::stmt_semi(expr, self.next_id())) + fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt { + @respan(expr.span, ast::StmtSemi(expr, self.next_id())) } - fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt { + fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt { let pat = self.pat_ident(sp, ident); let local = @ast::Local { is_mutbl: mutbl, @@ -403,8 +403,8 @@ impl AstBuilder for @ExtCtxt { id: self.next_id(), span: sp, }; - let decl = respan(sp, ast::decl_local(local)); - @respan(sp, ast::stmt_decl(@decl, self.next_id())) + let decl = respan(sp, ast::DeclLocal(local)); + @respan(sp, ast::StmtDecl(@decl, self.next_id())) } fn stmt_let_typed(&self, @@ -412,8 +412,8 @@ impl AstBuilder for @ExtCtxt { mutbl: bool, ident: ast::Ident, typ: ast::Ty, - ex: @ast::expr) - -> @ast::stmt { + ex: @ast::Expr) + -> @ast::Stmt { let pat = self.pat_ident(sp, ident); let local = @ast::Local { is_mutbl: mutbl, @@ -423,22 +423,22 @@ impl AstBuilder for @ExtCtxt { id: self.next_id(), span: sp, }; - let decl = respan(sp, ast::decl_local(local)); - @respan(sp, ast::stmt_decl(@decl, self.next_id())) + let decl = respan(sp, ast::DeclLocal(local)); + @respan(sp, ast::StmtDecl(@decl, self.next_id())) } - fn block(&self, span: Span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block { + fn block(&self, span: Span, stmts: ~[@ast::Stmt], expr: Option<@Expr>) -> ast::Block { self.block_all(span, ~[], stmts, expr) } - fn block_expr(&self, expr: @ast::expr) -> ast::Block { + fn block_expr(&self, expr: @ast::Expr) -> ast::Block { self.block_all(expr.span, ~[], ~[], Some(expr)) } fn block_all(&self, span: Span, view_items: ~[ast::view_item], - stmts: ~[@ast::stmt], - expr: Option<@ast::expr>) -> ast::Block { + stmts: ~[@ast::Stmt], + expr: Option<@ast::Expr>) -> ast::Block { ast::Block { view_items: view_items, stmts: stmts, @@ -449,122 +449,122 @@ impl AstBuilder for @ExtCtxt { } } - fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr { - @ast::expr { + fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr { + @ast::Expr { id: self.next_id(), node: node, span: span, } } - fn expr_path(&self, path: ast::Path) -> @ast::expr { - self.expr(path.span, ast::expr_path(path)) + fn expr_path(&self, path: ast::Path) -> @ast::Expr { + self.expr(path.span, ast::ExprPath(path)) } - fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr { + fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr { self.expr_path(self.path_ident(span, id)) } - fn expr_self(&self, span: Span) -> @ast::expr { - self.expr(span, ast::expr_self) + fn expr_self(&self, span: Span) -> @ast::Expr { + self.expr(span, ast::ExprSelf) } - fn expr_binary(&self, sp: Span, op: ast::binop, - lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr { - self.expr(sp, ast::expr_binary(self.next_id(), op, lhs, rhs)) + fn expr_binary(&self, sp: Span, op: ast::BinOp, + lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr { + self.expr(sp, ast::ExprBinary(self.next_id(), op, lhs, rhs)) } - fn expr_deref(&self, sp: Span, e: @ast::expr) -> @ast::expr { - self.expr_unary(sp, ast::deref, e) + fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + self.expr_unary(sp, ast::UnDeref, e) } - fn expr_unary(&self, sp: Span, op: ast::unop, e: @ast::expr) - -> @ast::expr { - self.expr(sp, ast::expr_unary(self.next_id(), op, e)) + fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) + -> @ast::Expr { + self.expr(sp, ast::ExprUnary(self.next_id(), op, e)) } - fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr { - self.expr_unary(sp, ast::box(ast::m_imm), e) + fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + self.expr_unary(sp, ast::UnBox(ast::MutImmutable), e) } - fn expr_field_access(&self, sp: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr { - self.expr(sp, ast::expr_field(expr, ident, ~[])) + fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr { + self.expr(sp, ast::ExprField(expr, ident, ~[])) } - fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr { - self.expr(sp, ast::expr_addr_of(ast::m_imm, e)) + fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e)) } - fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr { - self.expr(sp, ast::expr_addr_of(ast::m_mutbl, e)) + fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e)) } - fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr { - self.expr(span, ast::expr_call(expr, args, ast::NoSugar)) + fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr { + self.expr(span, ast::ExprCall(expr, args, ast::NoSugar)) } - fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr { + fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr { self.expr(span, - ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar)) + ast::ExprCall(self.expr_ident(span, id), args, ast::NoSugar)) } fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident], - args: ~[@ast::expr]) -> @ast::expr { + args: ~[@ast::Expr]) -> @ast::Expr { let pathexpr = self.expr_path(self.path_global(sp, fn_path)); self.expr_call(sp, pathexpr, args) } fn expr_method_call(&self, span: Span, - expr: @ast::expr, + expr: @ast::Expr, ident: ast::Ident, - args: ~[@ast::expr]) -> @ast::expr { + args: ~[@ast::Expr]) -> @ast::Expr { self.expr(span, - ast::expr_method_call(self.next_id(), expr, ident, ~[], args, ast::NoSugar)) + ast::ExprMethodCall(self.next_id(), expr, ident, ~[], args, ast::NoSugar)) } - fn expr_block(&self, b: ast::Block) -> @ast::expr { - self.expr(b.span, ast::expr_block(b)) + fn expr_block(&self, b: ast::Block) -> @ast::Expr { + self.expr(b.span, ast::ExprBlock(b)) } - fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field { + fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field { ast::Field { ident: name, expr: e, span: span } } - fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr { - self.expr(span, ast::expr_struct(path, fields, None)) + fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::Expr { + self.expr(span, ast::ExprStruct(path, fields, None)) } fn expr_struct_ident(&self, span: Span, - id: ast::Ident, fields: ~[ast::Field]) -> @ast::expr { + id: ast::Ident, fields: ~[ast::Field]) -> @ast::Expr { self.expr_struct(span, self.path_ident(span, id), fields) } - fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr { - self.expr(sp, ast::expr_lit(@respan(sp, lit))) + 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 { + fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr { self.expr_lit(span, ast::lit_uint(i as u64, ast::ty_u)) } - fn expr_int(&self, sp: Span, i: int) -> @ast::expr { + fn expr_int(&self, sp: Span, i: int) -> @ast::Expr { self.expr_lit(sp, ast::lit_int(i as i64, ast::ty_i)) } - fn expr_u8(&self, sp: Span, u: u8) -> @ast::expr { + fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr { self.expr_lit(sp, ast::lit_uint(u as u64, ast::ty_u8)) } - fn expr_bool(&self, sp: Span, value: bool) -> @ast::expr { + fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr { self.expr_lit(sp, ast::lit_bool(value)) } - fn expr_vstore(&self, sp: Span, expr: @ast::expr, vst: ast::expr_vstore) -> @ast::expr { - self.expr(sp, ast::expr_vstore(expr, vst)) + fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr { + self.expr(sp, ast::ExprVstore(expr, vst)) } - fn expr_vec(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr { - self.expr(sp, ast::expr_vec(exprs, ast::m_imm)) + fn expr_vec(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr { + self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable)) } - fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr { - self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_uniq) + fn expr_vec_uniq(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr { + self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreUniq) } - fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::expr]) -> @ast::expr { - self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::expr_vstore_slice) + fn expr_vec_slice(&self, sp: Span, exprs: ~[@ast::Expr]) -> @ast::Expr { + self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreSlice) } - fn expr_str(&self, sp: Span, s: @str) -> @ast::expr { + fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr { self.expr_lit(sp, ast::lit_str(s)) } - fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::expr { - self.expr_vstore(sp, self.expr_str(sp, s), ast::expr_vstore_uniq) + fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr { + self.expr_vstore(sp, self.expr_str(sp, s), ast::ExprVstoreUniq) } - fn expr_unreachable(&self, span: Span) -> @ast::expr { + fn expr_unreachable(&self, span: Span) -> @ast::Expr { let loc = self.codemap().lookup_char_pos(span.lo); self.expr_call_global( span, @@ -582,110 +582,110 @@ impl AstBuilder for @ExtCtxt { } - fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat { - @ast::pat { id: self.next_id(), node: pat, span: span } + fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat { + @ast::Pat { id: self.next_id(), node: pat, span: span } } - fn pat_wild(&self, span: Span) -> @ast::pat { - self.pat(span, ast::pat_wild) + fn pat_wild(&self, span: Span) -> @ast::Pat { + self.pat(span, ast::PatWild) } - fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat { - self.pat(span, ast::pat_lit(expr)) + fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat { + self.pat(span, ast::PatLit(expr)) } - fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat { - self.pat_ident_binding_mode(span, ident, ast::bind_infer) + fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat { + self.pat_ident_binding_mode(span, ident, ast::BindInfer) } fn pat_ident_binding_mode(&self, span: Span, ident: ast::Ident, - bm: ast::binding_mode) -> @ast::pat { + bm: ast::BindingMode) -> @ast::Pat { let path = self.path_ident(span, ident); - let pat = ast::pat_ident(bm, path, None); + let pat = ast::PatIdent(bm, path, None); self.pat(span, pat) } - fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat { - let pat = ast::pat_enum(path, Some(subpats)); + fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::Pat]) -> @ast::Pat { + let pat = ast::PatEnum(path, Some(subpats)); self.pat(span, pat) } fn pat_struct(&self, span: Span, - path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat { - let pat = ast::pat_struct(path, field_pats, false); + path: ast::Path, field_pats: ~[ast::FieldPat]) -> @ast::Pat { + let pat = ast::PatStruct(path, field_pats, false); self.pat(span, pat) } - fn arm(&self, _span: Span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm { - ast::arm { + fn arm(&self, _span: Span, pats: ~[@ast::Pat], expr: @ast::Expr) -> ast::Arm { + ast::Arm { pats: pats, guard: None, body: self.block_expr(expr) } } - fn arm_unreachable(&self, span: Span) -> ast::arm { + fn arm_unreachable(&self, span: Span) -> ast::Arm { self.arm(span, ~[self.pat_wild(span)], self.expr_unreachable(span)) } - fn expr_match(&self, span: Span, arg: @ast::expr, arms: ~[ast::arm]) -> @expr { - self.expr(span, ast::expr_match(arg, arms)) + fn expr_match(&self, span: Span, arg: @ast::Expr, arms: ~[ast::Arm]) -> @Expr { + self.expr(span, ast::ExprMatch(arg, arms)) } fn expr_if(&self, span: Span, - cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr { + cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr { let els = els.map_move(|x| self.expr_block(self.block_expr(x))); - self.expr(span, ast::expr_if(cond, self.block_expr(then), els)) + self.expr(span, ast::ExprIf(cond, self.block_expr(then), els)) } - fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr { - self.expr(span, ast::expr_fn_block(fn_decl, blk)) + fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::Expr { + self.expr(span, ast::ExprFnBlock(fn_decl, blk)) } - fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr { + fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::Expr { let fn_decl = self.fn_decl( ids.map(|id| self.arg(span, *id, self.ty_infer(span))), self.ty_infer(span)); - self.expr(span, ast::expr_fn_block(fn_decl, blk)) + self.expr(span, ast::ExprFnBlock(fn_decl, blk)) } #[cfg(stage0)] - fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr { + fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::Expr { let ext_cx = *self; - let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); + let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone())); quote_expr!(|| $blk_e ) } #[cfg(not(stage0))] - fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::expr { - let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); + fn lambda0(&self, _span: Span, blk: ast::Block) -> @ast::Expr { + let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone())); quote_expr!(*self, || $blk_e ) } #[cfg(stage0)] - fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr { + fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr { let ext_cx = *self; - let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); + let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone())); quote_expr!(|$ident| $blk_e ) } #[cfg(not(stage0))] - fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr { - let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); + fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::Expr { + let blk_e = self.expr(blk.span, ast::ExprBlock(blk.clone())); quote_expr!(*self, |$ident| $blk_e ) } - fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::expr) -> @ast::expr { + fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::Expr) -> @ast::Expr { self.lambda(span, ids, self.block_expr(expr)) } - fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr { + fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr { self.lambda0(span, self.block_expr(expr)) } - fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr { + fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr { self.lambda1(span, self.block_expr(expr), ident) } - fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], stmts: ~[@ast::stmt]) -> @ast::expr { + fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], stmts: ~[@ast::Stmt]) -> @ast::Expr { self.lambda(span, ids, self.block(span, stmts, None)) } - fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr { + fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::Stmt]) -> @ast::Expr { self.lambda0(span, self.block(span, stmts, None)) } - fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr { + fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::Stmt], ident: ast::Ident) -> @ast::Expr { self.lambda1(span, self.block(span, stmts, None), ident) } @@ -889,8 +889,8 @@ pub trait Duplicate { fn duplicate(&self, cx: @ExtCtxt) -> Self; } -impl Duplicate for @ast::expr { - fn duplicate(&self, cx: @ExtCtxt) -> @ast::expr { +impl Duplicate for @ast::Expr { + fn duplicate(&self, cx: @ExtCtxt) -> @ast::Expr { let folder = fold::default_ast_fold(); let folder = @fold::AstFoldFns { new_id: |_| cx.next_id(), diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 1c8f582e7eed9..faf3e2653b91f 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -24,7 +24,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> bas for expr in exprs.iter() { match expr.node { // expression is a literal - ast::expr_lit(lit) => match lit.node { + ast::ExprLit(lit) => match lit.node { // string literal, push each byte to vector expression ast::lit_str(s) => { for byte in s.byte_iter() { diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 5354a4e2469f1..16e54093a147a 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -34,9 +34,9 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) } let res = str_to_ident(res_str); - let e = @ast::expr { + let e = @ast::Expr { id: cx.next_id(), - node: ast::expr_path( + node: ast::ExprPath( ast::Path { span: sp, global: false, diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 01cf61f45a478..9ef995b0d5700 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; @@ -69,7 +69,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt, fn cs_clone( name: &str, cx: @ExtCtxt, span: Span, - substr: &Substructure) -> @expr { + substr: &Substructure) -> @Expr { let clone_ident = substr.method_ident; let ctor_ident; let all_fields; diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index ce2b9ba7894e5..d147875d5e12f 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; @@ -20,11 +20,11 @@ pub fn expand_deriving_eq(cx: @ExtCtxt, 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 { + fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } - fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { + fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_or(|cx, span, _, _| cx.expr_bool(span, true), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 3f7492bb6b641..33f45d45bdb85 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; @@ -48,8 +48,8 @@ pub fn expand_deriving_ord(cx: @ExtCtxt, } /// Strict inequality. -fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { - let op = if less {ast::lt} else {ast::gt}; +fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + let op = if less {ast::BiLt} else {ast::BiGt}; cs_fold( false, // need foldr, |cx, span, subexpr, self_f, other_fs| { @@ -79,13 +79,13 @@ fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructur cx.expr_deref(span, self_f), cx.expr_deref(span, other_f)); - let not_cmp = cx.expr_unary(span, ast::not, + let not_cmp = cx.expr_unary(span, ast::UnNot, cx.expr_binary(span, op, cx.expr_deref(span, other_f), cx.expr_deref(span, self_f))); - let and = cx.expr_binary(span, ast::and, not_cmp, subexpr); - cx.expr_binary(span, ast::or, cmp, and) + let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr); + cx.expr_binary(span, ast::BiOr, cmp, and) }, cx.expr_bool(span, equal), |cx, span, args, _| { diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 97b7464b3b5c3..c6123451071b4 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; @@ -18,7 +18,7 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { - fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { + 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 8f520ff6c334b..34c6d1104dac2 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; @@ -54,7 +54,7 @@ pub fn ordering_const(cx: @ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { } pub fn cs_cmp(cx: @ExtCtxt, span: Span, - substr: &Substructure) -> @expr { + substr: &Substructure) -> @Expr { let test_id = cx.ident_of("__test"); let equals_path = ordering_const(cx, span, Equal); @@ -89,7 +89,7 @@ pub fn cs_cmp(cx: @ExtCtxt, span: Span, let assign = cx.stmt_let(span, false, test_id, new); - let cond = cx.expr_binary(span, ast::eq, + let cond = cx.expr_binary(span, ast::BiEq, cx.expr_ident(span, test_id), cx.expr_path(equals_path.clone())); let if_ = cx.expr_if(span, diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 6a2cddb3583d3..66cd2d511a89d 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -15,7 +15,7 @@ encodable.rs for more. use std::vec; -use ast::{MetaItem, item, expr, m_mutbl}; +use ast::{MetaItem, item, Expr, MutMutable}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -39,7 +39,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt, generics: LifetimeBounds::empty(), explicit_self: None, args: ~[Ptr(~Literal(Path::new_local("__D")), - Borrowed(None, m_mutbl))], + Borrowed(None, MutMutable))], ret_ty: Self, const_nonmatching: true, combine_substructure: decodable_substructure, @@ -51,7 +51,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt, } fn decodable_substructure(cx: @ExtCtxt, span: Span, - substr: &Substructure) -> @expr { + substr: &Substructure) -> @Expr { let decoder = substr.nonself_args[0]; let recurse = ~[cx.ident_of("extra"), cx.ident_of("serialize"), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index ee7863bc270db..99b2359232c2a 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, m_imm, m_mutbl}; +use ast::{MetaItem, item, Expr, MutImmutable, MutMutable}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -97,9 +97,9 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt, MethodDef { name: "encode", generics: LifetimeBounds::empty(), - explicit_self: Some(Some(Borrowed(None, m_imm))), + explicit_self: Some(Some(Borrowed(None, MutImmutable))), args: ~[Ptr(~Literal(Path::new_local("__E")), - Borrowed(None, m_mutbl))], + Borrowed(None, MutMutable))], ret_ty: nil_ty(), const_nonmatching: true, combine_substructure: encodable_substructure, @@ -111,7 +111,7 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt, } fn encodable_substructure(cx: @ExtCtxt, span: Span, - substr: &Substructure) -> @expr { + substr: &Substructure) -> @Expr { let encoder = substr.nonself_args[0]; // throw an underscore in front to suppress unused variable warnings let blkarg = cx.ident_of("_e"); diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index eb05f87a8ceac..7050cfbedb73e 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -163,7 +163,7 @@ StaticEnum(, ~[(, Left(1)), */ use ast; -use ast::{enum_def, expr, Ident, Generics, struct_def}; +use ast::{enum_def, Expr, Ident, Generics, struct_def}; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -220,9 +220,9 @@ pub struct Substructure<'self> { /// ident of the method method_ident: Ident, /// dereferenced access to any Self or Ptr(Self, _) arguments - self_args: &'self [@expr], + self_args: &'self [@Expr], /// verbatim access to any other arguments - nonself_args: &'self [@expr], + nonself_args: &'self [@Expr], fields: &'self SubstructureFields<'self> } @@ -234,21 +234,21 @@ pub enum SubstructureFields<'self> { ident is the ident of the current field (`None` for all fields in tuple structs). */ - Struct(~[(Option, @expr, ~[@expr])]), + Struct(~[(Option, @Expr, ~[@Expr])]), /** Matching variants of the enum: variant index, ast::variant, fields: `(field ident, self, [others])`, where the field ident is only non-`None` in the case of a struct variant. */ - EnumMatching(uint, &'self ast::variant, ~[(Option, @expr, ~[@expr])]), + EnumMatching(uint, &'self ast::variant, ~[(Option, @Expr, ~[@Expr])]), /** non-matching variants of the enum, [(variant index, ast::variant, [field ident, fields])] (i.e. all fields for self are in the first tuple, for other1 are in the second tuple, etc.) */ - EnumNonMatching(&'self [(uint, ast::variant, ~[(Option, @expr)])]), + EnumNonMatching(&'self [(uint, ast::variant, ~[(Option, @Expr)])]), /// A static method where Self is a struct StaticStruct(&'self ast::struct_def, Either), @@ -263,7 +263,7 @@ Combine the values of all the fields together. The last argument is all the fields of all the structures, see above for details. */ pub type CombineSubstructureFunc<'self> = - &'self fn(@ExtCtxt, Span, &Substructure) -> @expr; + &'self fn(@ExtCtxt, Span, &Substructure) -> @Expr; /** Deal with non-matching enum variants, the arguments are a list @@ -273,8 +273,8 @@ representing each variant: (variant index, ast::variant instance, pub type EnumNonMatchFunc<'self> = &'self fn(@ExtCtxt, Span, &[(uint, ast::variant, - ~[(Option, @expr)])], - &[@expr]) -> @expr; + ~[(Option, @Expr)])], + &[@Expr]) -> @Expr; impl<'self> TraitDef<'self> { @@ -440,10 +440,10 @@ impl<'self> MethodDef<'self> { cx: @ExtCtxt, span: Span, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr], + self_args: &[@Expr], + nonself_args: &[@Expr], fields: &SubstructureFields) - -> @expr { + -> @Expr { let substructure = Substructure { type_ident: type_ident, method_ident: cx.ident_of(self.name), @@ -466,7 +466,7 @@ impl<'self> MethodDef<'self> { fn split_self_nonself_args(&self, cx: @ExtCtxt, span: Span, type_ident: Ident, generics: &Generics) - -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(Ident, ast::Ty)]) { + -> (ast::explicit_self, ~[@Expr], ~[@Expr], ~[(Ident, ast::Ty)]) { let mut self_args = ~[]; let mut nonself_args = ~[]; @@ -515,7 +515,7 @@ impl<'self> MethodDef<'self> { generics: &Generics, explicit_self: ast::explicit_self, arg_types: ~[(Ident, 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(cx, span, type_ident, generics); @@ -572,9 +572,9 @@ impl<'self> MethodDef<'self> { span: Span, struct_def: &struct_def, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr]) - -> @expr { + self_args: &[@Expr], + nonself_args: &[@Expr]) + -> @Expr { let mut raw_fields = ~[]; // ~[[fields of self], // [fields of next Self arg], [etc]] @@ -582,7 +582,7 @@ impl<'self> MethodDef<'self> { for i in range(0u, self_args.len()) { let (pat, ident_expr) = create_struct_pattern(cx, span, type_ident, struct_def, - fmt!("__self_%u", i), ast::m_imm); + fmt!("__self_%u", i), ast::MutImmutable); patterns.push(pat); raw_fields.push(ident_expr); } @@ -626,9 +626,9 @@ impl<'self> MethodDef<'self> { span: Span, struct_def: &struct_def, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr]) - -> @expr { + self_args: &[@Expr], + nonself_args: &[@Expr]) + -> @Expr { let summary = summarise_struct(cx, span, struct_def); self.call_substructure_method(cx, span, @@ -668,9 +668,9 @@ impl<'self> MethodDef<'self> { span: Span, enum_def: &enum_def, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr]) - -> @expr { + self_args: &[@Expr], + nonself_args: &[@Expr]) + -> @Expr { let mut matches = ~[]; self.build_enum_match(cx, span, enum_def, type_ident, self_args, nonself_args, @@ -703,12 +703,12 @@ impl<'self> MethodDef<'self> { cx: @ExtCtxt, span: Span, enum_def: &enum_def, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr], + self_args: &[@Expr], + nonself_args: &[@Expr], matching: Option, matches_so_far: &mut ~[(uint, ast::variant, - ~[(Option, @expr)])], - match_count: uint) -> @expr { + ~[(Option, @Expr)])], + match_count: uint) -> @Expr { if match_count == self_args.len() { // we've matched against all arguments, so make the final // expression at the bottom of the match tree @@ -787,7 +787,7 @@ impl<'self> MethodDef<'self> { let (pattern, idents) = create_enum_variant_pattern(cx, span, variant, current_match_str, - ast::m_imm); + ast::MutImmutable); matches_so_far.push((index, /*bad*/ (*variant).clone(), @@ -818,7 +818,7 @@ impl<'self> MethodDef<'self> { let (pattern, idents) = create_enum_variant_pattern(cx, span, variant, current_match_str, - ast::m_imm); + ast::MutImmutable); matches_so_far.push((index, /*bad*/ (*variant).clone(), @@ -853,9 +853,9 @@ impl<'self> MethodDef<'self> { span: Span, enum_def: &enum_def, type_ident: Ident, - self_args: &[@expr], - nonself_args: &[@expr]) - -> @expr { + self_args: &[@Expr], + nonself_args: &[@Expr]) + -> @Expr { let summary = do enum_def.variants.map |v| { let ident = v.node.name; let summary = match v.node.kind { @@ -898,11 +898,11 @@ fn summarise_struct(cx: @ExtCtxt, span: Span, pub fn create_subpatterns(cx: @ExtCtxt, span: Span, field_paths: ~[ast::Path], - mutbl: ast::mutability) - -> ~[@ast::pat] { + mutbl: ast::Mutability) + -> ~[@ast::Pat] { do field_paths.map |path| { cx.pat(span, - ast::pat_ident(ast::bind_by_ref(mutbl), (*path).clone(), None)) + ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None)) } } @@ -916,12 +916,12 @@ fn create_struct_pattern(cx: @ExtCtxt, struct_ident: Ident, struct_def: &struct_def, prefix: &str, - mutbl: ast::mutability) - -> (@ast::pat, ~[(Option, @expr)]) { + mutbl: ast::Mutability) + -> (@ast::Pat, ~[(Option, @Expr)]) { if struct_def.fields.is_empty() { return ( cx.pat_ident_binding_mode( - span, struct_ident, ast::bind_infer), + span, struct_ident, ast::BindInfer), ~[]); } @@ -961,7 +961,7 @@ fn create_struct_pattern(cx: @ExtCtxt, let field_pats = do vec::build |push| { for (&pat, &(id, _)) in subpats.iter().zip(ident_expr.iter()) { // id is guaranteed to be Some - push(ast::field_pat { ident: id.unwrap(), pat: pat }) + push(ast::FieldPat { ident: id.unwrap(), pat: pat }) } }; cx.pat_struct(span, matching_path, field_pats) @@ -976,15 +976,15 @@ fn create_enum_variant_pattern(cx: @ExtCtxt, span: Span, variant: &ast::variant, prefix: &str, - mutbl: ast::mutability) - -> (@ast::pat, ~[(Option, @expr)]) { + mutbl: ast::Mutability) + -> (@ast::Pat, ~[(Option, @Expr)]) { let variant_ident = variant.node.name; match variant.node.kind { ast::tuple_variant_kind(ref variant_args) => { if variant_args.is_empty() { return (cx.pat_ident_binding_mode( - span, variant_ident, ast::bind_infer), ~[]); + span, variant_ident, ast::BindInfer), ~[]); } let matching_path = cx.path_ident(span, variant_ident); @@ -1023,13 +1023,13 @@ left-to-right (`true`) or right-to-left (`false`). */ pub fn cs_fold(use_foldl: bool, f: &fn(@ExtCtxt, Span, - old: @expr, - self_f: @expr, - other_fs: &[@expr]) -> @expr, - base: @expr, + old: @Expr, + self_f: @Expr, + other_fs: &[@Expr]) -> @Expr, + base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { + substructure: &Substructure) -> @Expr { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { if use_foldl { @@ -1064,10 +1064,10 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), ~~~ */ #[inline] -pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@expr]) -> @expr, +pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@Expr]) -> @Expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { + substructure: &Substructure) -> @Expr { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) @@ -1097,11 +1097,11 @@ fields. `use_foldl` controls whether this is done left-to-right */ #[inline] pub fn cs_same_method_fold(use_foldl: bool, - f: &fn(@ExtCtxt, Span, @expr, @expr) -> @expr, - base: @expr, + f: &fn(@ExtCtxt, Span, @Expr, @Expr) -> @Expr, + base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { + substructure: &Substructure) -> @Expr { cs_same_method( |cx, span, vals| { if use_foldl { @@ -1124,10 +1124,10 @@ Use a given binop to combine the result of calling the derived method on all the fields. */ #[inline] -pub fn cs_binop(binop: ast::binop, base: @expr, +pub fn cs_binop(binop: ast::BinOp, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { + substructure: &Substructure) -> @Expr { cs_same_method_fold( true, // foldl is good enough |cx, span, old, new| { @@ -1145,8 +1145,8 @@ pub fn cs_binop(binop: ast::binop, base: @expr, #[inline] pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { - cs_binop(ast::or, cx.expr_bool(span, false), + substructure: &Substructure) -> @Expr { + cs_binop(ast::BiOr, cx.expr_bool(span, false), enum_nonmatch_f, cx, span, substructure) } @@ -1154,8 +1154,8 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, #[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: Span, - substructure: &Substructure) -> @expr { - cs_binop(ast::and, cx.expr_bool(span, true), + substructure: &Substructure) -> @Expr { + cs_binop(ast::BiAnd, cx.expr_bool(span, true), enum_nonmatch_f, cx, span, substructure) } diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 4dd628ca7b0b8..0f4e57b0889ab 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, and}; +use ast::{MetaItem, item, Expr, BiAnd}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -42,7 +42,7 @@ pub fn expand_deriving_iter_bytes(cx: @ExtCtxt, trait_def.expand(cx, span, mitem, in_items) } -fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { +fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let (lsb0, f)= match substr.nonself_args { [l, f] => (l, f), _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`") @@ -90,6 +90,6 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @ } do exprs.slice(1, exprs.len()).iter().fold(exprs[0]) |prev, me| { - cx.expr_binary(span, and, prev, *me) + cx.expr_binary(span, BiAnd, prev, *me) } } diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index b24c8eb84abdd..8afd99e80af0f 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, Duplicate}; @@ -37,7 +37,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt, explicit_self: None, args: ~[ Ptr(~Literal(Path::new_local("R")), - Borrowed(None, ast::m_mutbl)) + Borrowed(None, ast::MutMutable)) ], ret_ty: Self, const_nonmatching: false, @@ -48,7 +48,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt, trait_def.expand(cx, span, mitem, in_items) } -fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { +fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let rng = match substr.nonself_args { [rng] => ~[ rng ], _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") @@ -100,7 +100,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { // rand() % variants.len() let value_ref = cx.expr_ident(span, value_ident); let rand_variant = cx.expr_binary(span, - ast::rem, + ast::BiRem, value_ref, variant_count); @@ -115,7 +115,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { rand_thing(cx, span, ident, summary, || rand_call())) } } - }.collect::<~[ast::arm]>(); + }.collect::<~[ast::Arm]>(); // _ => {} at the end. Should never occur arms.push(cx.arm_unreachable(span)); @@ -131,7 +131,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { fn rand_thing(cx: @ExtCtxt, span: Span, ctor_ident: Ident, summary: &Either, - rand_call: &fn() -> @expr) -> @expr { + rand_call: &fn() -> @Expr) -> @Expr { match *summary { Left(count) => { if count == 0 { diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index eecce06f69f0b..fa13f78d0f9b6 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; @@ -44,11 +44,11 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt, // to_str() method on each field. Hence we mirror the logic of the log_str() // method, but with tweaks to call to_str() on sub-fields. fn to_str_substructure(cx: @ExtCtxt, span: Span, - substr: &Substructure) -> @expr { + substr: &Substructure) -> @Expr { let to_str = cx.ident_of("to_str"); let doit = |start: &str, end: @str, name: ast::Ident, - fields: &[(Option, @expr, ~[@expr])]| { + fields: &[(Option, @Expr, ~[@Expr])]| { if fields.len() == 0 { cx.expr_str_uniq(span, cx.str_of(name)) } else { @@ -58,7 +58,7 @@ fn to_str_substructure(cx: @ExtCtxt, span: Span, let mut stmts = ~[cx.stmt_let(span, true, buf, init)]; let push_str = cx.ident_of("push_str"); - let push = |s: @expr| { + let push = |s: @Expr| { let ebuf = cx.expr_ident(span, buf); let call = cx.expr_method_call(span, ebuf, push_str, ~[s]); stmts.push(cx.stmt_expr(call)); diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 6c1b8100f4204..d6f5e2df5a49a 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -14,7 +14,7 @@ explicit `Self` type to use when specifying impls to be derived. */ use ast; -use ast::{expr,Generics,Ident}; +use ast::{Expr,Generics,Ident}; use ext::base::ExtCtxt; use ext::build::AstBuilder; use codemap::{Span,respan}; @@ -23,8 +23,8 @@ use opt_vec; /// The types of pointers pub enum PtrTy<'self> { Send, // ~ - Managed(ast::mutability), // @[mut] - Borrowed(Option<&'self str>, ast::mutability), // &['lifetime] [mut] + Managed(ast::Mutability), // @[mut] + Borrowed(Option<&'self str>, ast::Mutability), // &['lifetime] [mut] } /// A path, e.g. `::std::option::Option::` (global). Has support @@ -91,7 +91,7 @@ pub enum Ty<'self> { } pub fn borrowed_ptrty<'r>() -> PtrTy<'r> { - Borrowed(None, ast::m_imm) + Borrowed(None, ast::MutImmutable) } pub fn borrowed<'r>(ty: ~Ty<'r>) -> Ty<'r> { Ptr(ty, borrowed_ptrty()) @@ -236,7 +236,7 @@ impl<'self> LifetimeBounds<'self> { pub fn get_explicit_self(cx: @ExtCtxt, span: Span, self_ptr: &Option) - -> (@expr, ast::explicit_self) { + -> (@Expr, ast::explicit_self) { let self_path = cx.expr_self(span); match *self_ptr { None => { diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index f9cd1b4b35bdc..fc527d44b5332 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; @@ -55,7 +55,7 @@ pub fn expand_deriving_zero(cx: @ExtCtxt, trait_def.expand(cx, span, mitem, in_items) } -fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr { +fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let zero_ident = ~[ cx.ident_of("std"), cx.ident_of("num"), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 0827a9fabee5c..adccf513ea93e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{Block, Crate, NodeId, expr_, expr_mac, Ident, mac_invoc_tt}; -use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi}; -use ast::{illegal_ctxt}; +use ast::{Block, Crate, NodeId, Expr_, ExprMac, Ident, mac_invoc_tt}; +use ast::{item_mac, Stmt_, StmtMac, StmtExpr, StmtSemi}; +use ast::{ILLEGAL_CTXT}; use ast; use ast_util::{new_rename, new_mark, resolve}; use attr; @@ -31,15 +31,15 @@ use std::vec; pub fn expand_expr(extsbox: @mut SyntaxEnv, cx: @ExtCtxt, - e: &expr_, + e: &Expr_, s: Span, fld: @ast_fold, - orig: @fn(&expr_, Span, @ast_fold) -> (expr_, Span)) - -> (expr_, Span) { + orig: @fn(&Expr_, Span, @ast_fold) -> (Expr_, Span)) + -> (Expr_, Span) { match *e { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. - expr_mac(ref mac) => { + ExprMac(ref mac) => { match (*mac).node { // Token-tree macros: mac_invoc_tt(ref pth, ref tts) => { @@ -104,7 +104,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // Desugar expr_for_loop // From: `for in ` - ast::expr_for_loop(src_pat, src_expr, ref src_loop_block) => { + ast::ExprForLoop(src_pat, src_expr, ref src_loop_block) => { let src_pat = src_pat.clone(); let src_expr = src_expr.clone(); @@ -118,8 +118,8 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, let hi = s.hi; pub fn mk_expr(cx: @ExtCtxt, span: Span, - node: expr_) -> @ast::expr { - @ast::expr { + node: Expr_) -> @ast::Expr { + @ast::Expr { id: cx.next_id(), node: node, span: span, @@ -127,8 +127,8 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, } fn mk_block(cx: @ExtCtxt, - stmts: &[@ast::stmt], - expr: Option<@ast::expr>, + stmts: &[@ast::Stmt], + expr: Option<@ast::Expr>, span: Span) -> ast::Block { ast::Block { view_items: ~[], @@ -186,33 +186,33 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, let local = @ast::Local { is_mutbl: false, ty: ty, - pat: @ast::pat { + pat: @ast::Pat { id: cx.next_id(), - node: ast::pat_ident(ast::bind_infer, local_path_1, None), + node: ast::PatIdent(ast::BindInfer, local_path_1, None), span: src_expr.span }, init: Some(mk_expr(cx, src_expr.span, - ast::expr_addr_of(ast::m_mutbl, src_expr))), + ast::ExprAddrOf(ast::MutMutable, src_expr))), id: cx.next_id(), span: src_expr.span, }; let e = @spanned(src_expr.span.lo, src_expr.span.hi, - ast::decl_local(local)); - @spanned(lo, hi, ast::stmt_decl(e, cx.next_id())) + ast::DeclLocal(local)); + @spanned(lo, hi, ast::StmtDecl(e, cx.next_id())) }; // `None => break;` let none_arm = { - let break_expr = mk_expr(cx, span, ast::expr_break(None)); - let break_stmt = @spanned(lo, hi, ast::stmt_expr(break_expr, cx.next_id())); + let break_expr = mk_expr(cx, span, ast::ExprBreak(None)); + let break_stmt = @spanned(lo, hi, ast::StmtExpr(break_expr, cx.next_id())); let none_block = mk_block(cx, [break_stmt], None, span); - let none_pat = @ast::pat { + let none_pat = @ast::Pat { id: cx.next_id(), - node: ast::pat_ident(ast::bind_infer, none_path, None), + node: ast::PatIdent(ast::BindInfer, none_path, None), span: span }; - ast::arm { + ast::Arm { pats: ~[none_pat], guard: None, body: none_block @@ -221,12 +221,12 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // `Some() => ` let some_arm = { - let pat = @ast::pat { + let pat = @ast::Pat { id: cx.next_id(), - node: ast::pat_enum(some_path, Some(~[src_pat])), + node: ast::PatEnum(some_path, Some(~[src_pat])), span: src_pat.span }; - ast::arm { + ast::Arm { pats: ~[pat], guard: None, body: src_loop_block @@ -235,27 +235,27 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // `match i.next() { ... }` let match_stmt = { - let local_expr = mk_expr(cx, span, ast::expr_path(local_path_2)); + let local_expr = mk_expr(cx, span, ast::ExprPath(local_path_2)); let next_call_expr = mk_expr(cx, span, - ast::expr_method_call(cx.next_id(), + ast::ExprMethodCall(cx.next_id(), local_expr, next_ident, ~[], ~[], ast::NoSugar)); - let match_expr = mk_expr(cx, span, ast::expr_match(next_call_expr, + let match_expr = mk_expr(cx, span, ast::ExprMatch(next_call_expr, ~[none_arm, some_arm])); - @spanned(lo, hi, ast::stmt_expr(match_expr, cx.next_id())) + @spanned(lo, hi, ast::StmtExpr(match_expr, cx.next_id())) }; // `loop { ... }` let loop_block = { let loop_body_block = mk_block(cx, [match_stmt], None, span); - let loop_body_expr = mk_expr(cx, span, ast::expr_loop(loop_body_block, None)); - let loop_body_stmt = @spanned(lo, hi, ast::stmt_expr(loop_body_expr, cx.next_id())); + let loop_body_expr = mk_expr(cx, span, ast::ExprLoop(loop_body_block, None)); + let loop_body_stmt = @spanned(lo, hi, ast::StmtExpr(loop_body_expr, cx.next_id())); mk_block(cx, [iter_decl_stmt, loop_body_stmt], None, span) }; - (ast::expr_block(loop_block), span) + (ast::ExprBlock(loop_block), span) } _ => orig(e, s, fld) @@ -448,14 +448,14 @@ fn insert_macro(exts: SyntaxEnv, name: ast::Name, transformer: @Transformer) { // expand a stmt pub fn expand_stmt(extsbox: @mut SyntaxEnv, cx: @ExtCtxt, - s: &stmt_, + s: &Stmt_, sp: Span, fld: @ast_fold, - orig: @fn(&stmt_, Span, @ast_fold) - -> (Option, Span)) - -> (Option, Span) { + orig: @fn(&Stmt_, Span, @ast_fold) + -> (Option, Span)) + -> (Option, Span) { let (mac, pth, tts, semi) = match *s { - stmt_mac(ref mac, semi) => { + StmtMac(ref mac, semi) => { match mac.node { mac_invoc_tt(ref pth, ref tts) => { ((*mac).clone(), pth, (*tts).clone(), semi) @@ -484,7 +484,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, }); let expanded = match exp(cx, mac.span, tts) { MRExpr(e) => - @codemap::Spanned { node: stmt_expr(e, cx.next_id()), + @codemap::Spanned { node: StmtExpr(e, cx.next_id()), span: e.span}, MRAny(_,_,stmt_mkr) => stmt_mkr(), _ => cx.span_fatal( @@ -515,7 +515,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, }; (match fully_expanded { - stmt_expr(e, stmt_id) if semi => Some(stmt_semi(e, stmt_id)), + StmtExpr(e, stmt_id) if semi => Some(StmtSemi(e, stmt_id)), _ => { Some(fully_expanded) } /* might already have a semi */ }, sp) @@ -527,12 +527,12 @@ struct NewNameFinderContext { } impl Visitor<()> for NewNameFinderContext { - fn visit_pat(&mut self, pattern: @ast::pat, _: ()) { + fn visit_pat(&mut self, pattern: @ast::Pat, _: ()) { match *pattern { // we found a pat_ident! - ast::pat { + ast::Pat { id: _, - node: ast::pat_ident(_, ref path, ref inner), + node: ast::PatIdent(_, ref path, ref inner), span: _ } => { match path { @@ -589,23 +589,23 @@ impl Visitor<()> for NewNameFinderContext { visit::walk_block(self, block, ()) } - fn visit_stmt(&mut self, stmt: @ast::stmt, _: ()) { + fn visit_stmt(&mut self, stmt: @ast::Stmt, _: ()) { visit::walk_stmt(self, stmt, ()) } - fn visit_arm(&mut self, arm: &ast::arm, _: ()) { + fn visit_arm(&mut self, arm: &ast::Arm, _: ()) { visit::walk_arm(self, arm, ()) } - fn visit_decl(&mut self, decl: @ast::decl, _: ()) { + fn visit_decl(&mut self, decl: @ast::Decl, _: ()) { visit::walk_decl(self, decl, ()) } - fn visit_expr(&mut self, expr: @ast::expr, _: ()) { + fn visit_expr(&mut self, expr: @ast::Expr, _: ()) { visit::walk_expr(self, expr, ()) } - fn visit_expr_post(&mut self, _: @ast::expr, _: ()) { + fn visit_expr_post(&mut self, _: @ast::Expr, _: ()) { // Empty! } @@ -714,7 +714,7 @@ fn renames_to_fold(renames : @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold { } // perform a bunch of renames -fn apply_pending_renames(folder : @ast_fold, stmt : ast::stmt) -> @ast::stmt { +fn apply_pending_renames(folder : @ast_fold, stmt : ast::Stmt) -> @ast::Stmt { match folder.fold_stmt(&stmt) { Some(s) => s, None => fail!(fmt!("renaming of stmt produced None")) @@ -1182,7 +1182,7 @@ pub fn new_ident_resolver() -> |id : ast::Ident| ast::Ident { name : resolve(id), - ctxt : illegal_ctxt + ctxt : ILLEGAL_CTXT } } @@ -1191,7 +1191,7 @@ pub fn new_ident_resolver() -> mod test { use super::*; use ast; - use ast::{Attribute_, AttrOuter, MetaWord, empty_ctxt}; + use ast::{Attribute_, AttrOuter, MetaWord, EMPTY_CTXT}; use codemap; use codemap::Spanned; use parse; @@ -1304,7 +1304,7 @@ mod test { }; let a_name = intern("a"); let a2_name = intern("a2"); - let renamer = new_ident_renamer(ast::Ident{name:a_name,ctxt:empty_ctxt}, + let renamer = new_ident_renamer(ast::Ident{name:a_name,ctxt:EMPTY_CTXT}, a2_name); let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).unwrap(); let resolver = new_ident_resolver(); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 4e7275b75c8ef..9adb02ecc987f 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -48,8 +48,8 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) // expressions. Also: Cleanup the naming of these functions. // Note: Moved many of the common ones to build.rs --kevina fn pieces_to_expr(cx: @ExtCtxt, sp: Span, - pieces: ~[Piece], args: ~[@ast::expr]) - -> @ast::expr { + pieces: ~[Piece], args: ~[@ast::Expr]) + -> @ast::Expr { fn make_path_vec(ident: &str) -> ~[ast::Ident] { return ~[str_to_ident("std"), str_to_ident("unstable"), @@ -57,15 +57,15 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, str_to_ident("rt"), str_to_ident(ident)]; } - fn make_rt_path_expr(cx: @ExtCtxt, sp: Span, nm: &str) -> @ast::expr { + fn make_rt_path_expr(cx: @ExtCtxt, sp: Span, nm: &str) -> @ast::Expr { let path = make_path_vec(nm); cx.expr_path(cx.path_global(sp, path)) } // Produces an AST expression that represents a RT::conv record, // which tells the RT::conv* functions how to perform the conversion - fn make_rt_conv_expr(cx: @ExtCtxt, sp: Span, cnv: &Conv) -> @ast::expr { - fn make_flags(cx: @ExtCtxt, sp: Span, flags: &[Flag]) -> @ast::expr { + fn make_rt_conv_expr(cx: @ExtCtxt, sp: Span, cnv: &Conv) -> @ast::Expr { + fn make_flags(cx: @ExtCtxt, sp: Span, flags: &[Flag]) -> @ast::Expr { let mut tmp_expr = make_rt_path_expr(cx, sp, "flag_none"); for f in flags.iter() { let fstr = match *f { @@ -75,12 +75,12 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, FlagSignAlways => "flag_sign_always", FlagAlternate => "flag_alternate" }; - tmp_expr = cx.expr_binary(sp, ast::bitor, tmp_expr, + tmp_expr = cx.expr_binary(sp, ast::BiBitOr, tmp_expr, make_rt_path_expr(cx, sp, fstr)); } return tmp_expr; } - fn make_count(cx: @ExtCtxt, sp: Span, cnt: Count) -> @ast::expr { + fn make_count(cx: @ExtCtxt, sp: Span, cnt: Count) -> @ast::Expr { match cnt { CountImplied => { return make_rt_path_expr(cx, sp, "CountImplied"); @@ -94,7 +94,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, _ => cx.span_unimpl(sp, "unimplemented fmt! conversion") } } - fn make_ty(cx: @ExtCtxt, sp: Span, t: Ty) -> @ast::expr { + fn make_ty(cx: @ExtCtxt, sp: Span, t: Ty) -> @ast::Expr { let rt_type = match t { TyHex(c) => match c { CaseUpper => "TyHexUpper", @@ -106,9 +106,9 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, }; return make_rt_path_expr(cx, sp, rt_type); } - fn make_conv_struct(cx: @ExtCtxt, sp: Span, flags_expr: @ast::expr, - width_expr: @ast::expr, precision_expr: @ast::expr, - ty_expr: @ast::expr) -> @ast::expr { + fn make_conv_struct(cx: @ExtCtxt, sp: Span, flags_expr: @ast::Expr, + width_expr: @ast::Expr, precision_expr: @ast::Expr, + ty_expr: @ast::Expr) -> @ast::Expr { cx.expr_struct( sp, cx.path_global(sp, make_path_vec("Conv")), @@ -128,7 +128,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, rt_conv_precision, rt_conv_ty) } fn make_conv_call(cx: @ExtCtxt, sp: Span, conv_type: &str, cnv: &Conv, - arg: @ast::expr, buf: @ast::expr) -> @ast::expr { + arg: @ast::Expr, buf: @ast::Expr) -> @ast::Expr { let fname = ~"conv_" + conv_type; let path = make_path_vec(fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); @@ -137,7 +137,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, } fn make_new_conv(cx: @ExtCtxt, sp: Span, cnv: &Conv, - arg: @ast::expr, buf: @ast::expr) -> @ast::expr { + arg: @ast::Expr, buf: @ast::Expr) -> @ast::Expr { fn is_signed_type(cnv: &Conv) -> bool { match cnv.ty { TyInt(s) => match s { diff --git a/src/libsyntax/ext/ifmt.rs b/src/libsyntax/ext/ifmt.rs index 474c0ce60a782..ddddd44c7f1e0 100644 --- a/src/libsyntax/ext/ifmt.rs +++ b/src/libsyntax/ext/ifmt.rs @@ -34,14 +34,14 @@ struct Context { // Parsed argument expressions and the types that we've found so far for // them. - args: ~[@ast::expr], + args: ~[@ast::Expr], arg_types: ~[Option], // Parsed named expressions and the types that we've found for them so far - names: HashMap<@str, @ast::expr>, + names: HashMap<@str, @ast::Expr>, name_types: HashMap<@str, ArgumentType>, // Collection of the compiled `rt::Piece` structures - pieces: ~[@ast::expr], + pieces: ~[@ast::Expr], name_positions: HashMap<@str, uint>, method_statics: ~[@ast::item], @@ -55,8 +55,8 @@ impl Context { /// there's a parse error so we can continue parsing other fmt! expressions. fn parse_args(&mut self, sp: Span, leading_expr: bool, - tts: &[ast::token_tree]) -> (Option<@ast::expr>, - Option<@ast::expr>) { + tts: &[ast::token_tree]) -> (Option<@ast::Expr>, + Option<@ast::Expr>) { let p = rsparse::new_parser_from_tts(self.ecx.parse_sess(), self.ecx.cfg(), tts.to_owned()); @@ -327,7 +327,7 @@ impl Context { } /// Translate a `parse::Piece` to a static `rt::Piece` - fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::expr { + fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr { let sp = self.fmtsp; let parsepath = |s: &str| { ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), @@ -345,7 +345,7 @@ impl Context { let p = self.ecx.path(sp, ~[self.ecx.ident_of("None")]); self.ecx.expr_path(p) }; - let some = |e: @ast::expr| { + let some = |e: @ast::Expr| { self.ecx.expr_call_ident(sp, self.ecx.ident_of("Some"), ~[e]) }; let trans_count = |c: parse::Count| { @@ -444,7 +444,7 @@ impl Context { Some(life), ~[] ), None); - let st = ast::item_static(ty, ast::m_imm, method); + let st = ast::item_static(ty, ast::MutImmutable, method); let static_name = self.ecx.ident_of(fmt!("__static_method_%u", self.method_statics.len())); // Flag these statics as `address_insignificant` so LLVM can @@ -542,16 +542,16 @@ impl Context { /// Actually builds the expression which the ifmt! block will be expanded /// to - fn to_expr(&self, extra: Option<@ast::expr>, f: &str) -> @ast::expr { + fn to_expr(&self, extra: Option<@ast::Expr>, f: &str) -> @ast::Expr { let mut lets = ~[]; let mut locals = ~[]; let mut names = vec::from_fn(self.name_positions.len(), |_| None); // First, declare all of our methods that are statics for &method in self.method_statics.iter() { - let decl = respan(self.fmtsp, ast::decl_item(method)); + let decl = respan(self.fmtsp, ast::DeclItem(method)); lets.push(@respan(self.fmtsp, - ast::stmt_decl(@decl, self.ecx.next_id()))); + ast::StmtDecl(@decl, self.ecx.next_id()))); } // Next, build up the static array which will become our precompiled @@ -570,19 +570,19 @@ impl Context { Some(self.ecx.lifetime(self.fmtsp, self.ecx.ident_of("static"))), ~[] ), None), - ast::m_imm + ast::MutImmutable ), self.ecx.expr_uint(self.fmtsp, self.pieces.len()) ); let ty = self.ecx.ty(self.fmtsp, ty); - let st = ast::item_static(ty, ast::m_imm, fmt); + let st = ast::item_static(ty, ast::MutImmutable, fmt); let static_name = self.ecx.ident_of("__static_fmtstr"); // see above comment for `address_insignificant` and why we do it let unnamed = self.ecx.meta_word(self.fmtsp, @"address_insignificant"); let unnamed = self.ecx.attribute(self.fmtsp, unnamed); let item = self.ecx.item(self.fmtsp, static_name, ~[unnamed], st); - let decl = respan(self.fmtsp, ast::decl_item(item)); - lets.push(@respan(self.fmtsp, ast::stmt_decl(@decl, self.ecx.next_id()))); + let decl = respan(self.fmtsp, ast::DeclItem(item)); + lets.push(@respan(self.fmtsp, ast::StmtDecl(@decl, self.ecx.next_id()))); // Right now there is a bug such that for the expression: // foo(bar(&1)) @@ -637,7 +637,7 @@ impl Context { } fn format_arg(&self, sp: Span, arg: Either, - ident: ast::Ident) -> @ast::expr { + ident: ast::Ident) -> @ast::Expr { let ty = match arg { Left(i) => self.arg_types[i].unwrap(), Right(s) => *self.name_types.get(&s) diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 206cc7be1fdee..adc246ab89aaf 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -29,9 +29,9 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, get_ident_interner())); //trivial expression - MRExpr(@ast::expr { + MRExpr(@ast::Expr { id: cx.next_id(), - node: ast::expr_lit(@codemap::Spanned { + node: ast::ExprLit(@codemap::Spanned { node: ast::lit_nil, span: sp }), diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index bea18d868a0d1..8d43872e9c13b 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -104,7 +104,7 @@ pub mod rt { } } - impl ToSource for @ast::expr { + impl ToSource for @ast::Expr { fn to_source(&self) -> @str { pprust::expr_to_str(*self, get_ident_interner()).to_managed() } @@ -222,7 +222,7 @@ pub mod rt { impl_to_tokens!(ast::Ty) impl_to_tokens_self!(&'self [ast::Ty]) impl_to_tokens!(Generics) - impl_to_tokens!(@ast::expr) + impl_to_tokens!(@ast::Expr) impl_to_tokens!(ast::Block) impl_to_tokens_self!(&'self str) impl_to_tokens!(int) @@ -238,8 +238,8 @@ pub mod rt { pub trait ExtParseUtils { 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_expr(&self, s: @str) -> @ast::Expr; + fn parse_stmt(&self, s: @str) -> @ast::Stmt; fn parse_tts(&self, s: @str) -> ~[ast::token_tree]; } @@ -261,7 +261,7 @@ pub mod rt { } } - fn parse_stmt(&self, s: @str) -> @ast::stmt { + fn parse_stmt(&self, s: @str) -> @ast::Stmt { parse::parse_stmt_from_source_str( @"", s, @@ -270,7 +270,7 @@ pub mod rt { self.parse_sess()) } - fn parse_expr(&self, s: @str) -> @ast::expr { + fn parse_expr(&self, s: @str) -> @ast::Expr { parse::parse_expr_from_source_str( @"", s, @@ -343,7 +343,7 @@ fn id_ext(str: &str) -> ast::Ident { } // Lift an ident to the expr that evaluates to that ident. -fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::expr { +fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { let e_str = cx.expr_str(sp, cx.str_of(ident)); cx.expr_method_call(sp, cx.expr_ident(sp, id_ext("ext_cx")), @@ -351,13 +351,13 @@ fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::expr { ~[e_str]) } -fn mk_bytepos(cx: @ExtCtxt, sp: Span, bpos: BytePos) -> @ast::expr { +fn mk_bytepos(cx: @ExtCtxt, sp: Span, bpos: BytePos) -> @ast::Expr { let path = id_ext("BytePos"); let arg = cx.expr_uint(sp, bpos.to_uint()); cx.expr_call_ident(sp, path, ~[arg]) } -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", @@ -373,7 +373,7 @@ fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::expr { cx.expr_ident(sp, id_ext(name)) } -fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::expr { +fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { match *tok { BINOP(binop) => { @@ -515,7 +515,7 @@ 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] { + -> ~[@ast::Stmt] { match *tt { @@ -557,7 +557,7 @@ fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree) } fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) - -> ~[@ast::stmt] { + -> ~[@ast::Stmt] { let mut ss = ~[]; for tt in tts.iter() { ss.push_all_move(mk_tt(cx, sp, tt)); @@ -567,7 +567,7 @@ fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) fn expand_tts(cx: @ExtCtxt, sp: Span, - tts: &[ast::token_tree]) -> (@ast::expr, @ast::expr) { + tts: &[ast::token_tree]) -> (@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 @@ -640,8 +640,8 @@ fn expand_tts(cx: @ExtCtxt, fn expand_wrapper(cx: @ExtCtxt, sp: Span, - cx_expr: @ast::expr, - expr: @ast::expr) -> @ast::expr { + cx_expr: @ast::Expr, + expr: @ast::Expr) -> @ast::Expr { let uses = ~[ cx.view_use_glob(sp, ast::public, ids_ext(~[~"syntax", ~"ext", @@ -656,8 +656,8 @@ fn expand_wrapper(cx: @ExtCtxt, fn expand_parse_call(cx: @ExtCtxt, sp: Span, parse_method: &str, - arg_exprs: ~[@ast::expr], - tts: &[ast::token_tree]) -> @ast::expr { + arg_exprs: ~[@ast::Expr], + tts: &[ast::token_tree]) -> @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 96c8482c41814..e76ade0dc3dae 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -105,7 +105,7 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { result::Ok(src) => { - let u8_exprs: ~[@ast::expr] = src.iter().map(|char| cx.expr_u8(sp, *char)).collect(); + let u8_exprs: ~[@ast::Expr] = src.iter().map(|char| cx.expr_u8(sp, *char)).collect(); base::MRExpr(cx.expr_vec(sp, u8_exprs)) } result::Err(ref e) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 7e3695614ae38..7aa0f3abe87cd 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -23,11 +23,11 @@ pub trait ast_fold { fn fold_item_underscore(@self, &item_) -> item_; fn fold_method(@self, @method) -> @method; fn fold_block(@self, &Block) -> Block; - fn fold_stmt(@self, &stmt) -> Option<@stmt>; - fn fold_arm(@self, &arm) -> arm; - fn fold_pat(@self, @pat) -> @pat; - fn fold_decl(@self, @decl) -> Option<@decl>; - fn fold_expr(@self, @expr) -> @expr; + fn fold_stmt(@self, &Stmt) -> Option<@Stmt>; + fn fold_arm(@self, &Arm) -> Arm; + fn fold_pat(@self, @Pat) -> @Pat; + fn fold_decl(@self, @Decl) -> Option<@Decl>; + fn fold_expr(@self, @Expr) -> @Expr; fn fold_ty(@self, &Ty) -> Ty; fn fold_mod(@self, &_mod) -> _mod; fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod; @@ -35,7 +35,7 @@ pub trait ast_fold { fn fold_ident(@self, Ident) -> Ident; fn fold_path(@self, &Path) -> Path; fn fold_local(@self, @Local) -> @Local; - fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; + fn map_exprs(@self, @fn(@Expr) -> @Expr, &[@Expr]) -> ~[@Expr]; fn new_id(@self, NodeId) -> NodeId; fn new_span(@self, Span) -> Span; } @@ -52,11 +52,11 @@ pub struct AstFoldFns { fold_item_underscore: @fn(&item_, @ast_fold) -> item_, fold_method: @fn(@method, @ast_fold) -> @method, fold_block: @fn(&Block, @ast_fold) -> Block, - fold_stmt: @fn(&stmt_, Span, @ast_fold) -> (Option, Span), - fold_arm: @fn(&arm, @ast_fold) -> arm, - fold_pat: @fn(&pat_, Span, @ast_fold) -> (pat_, Span), - fold_decl: @fn(&decl_, Span, @ast_fold) -> (Option, Span), - fold_expr: @fn(&expr_, Span, @ast_fold) -> (expr_, Span), + fold_stmt: @fn(&Stmt_, Span, @ast_fold) -> (Option, Span), + fold_arm: @fn(&Arm, @ast_fold) -> Arm, + fold_pat: @fn(&Pat_, Span, @ast_fold) -> (Pat_, Span), + fold_decl: @fn(&Decl_, Span, @ast_fold) -> (Option, Span), + fold_expr: @fn(&Expr_, Span, @ast_fold) -> (Expr_, Span), fold_ty: @fn(&ty_, Span, @ast_fold) -> (ty_, Span), fold_mod: @fn(&_mod, @ast_fold) -> _mod, fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod, @@ -64,7 +64,7 @@ pub struct AstFoldFns { fold_ident: @fn(Ident, @ast_fold) -> Ident, fold_path: @fn(&Path, @ast_fold) -> Path, fold_local: @fn(@Local, @ast_fold) -> @Local, - map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], + map_exprs: @fn(@fn(@Expr) -> @Expr, &[@Expr]) -> ~[@Expr], new_id: @fn(NodeId) -> NodeId, new_span: @fn(Span) -> Span } @@ -395,69 +395,69 @@ pub fn noop_fold_block(b: &Block, fld: @ast_fold) -> Block { } } -fn noop_fold_stmt(s: &stmt_, fld: @ast_fold) -> Option { +fn noop_fold_stmt(s: &Stmt_, fld: @ast_fold) -> Option { let fold_mac = |x| fold_mac_(x, fld); match *s { - stmt_decl(d, nid) => { + StmtDecl(d, nid) => { match fld.fold_decl(d) { - Some(d) => Some(stmt_decl(d, fld.new_id(nid))), + Some(d) => Some(StmtDecl(d, fld.new_id(nid))), None => None, } } - stmt_expr(e, nid) => { - Some(stmt_expr(fld.fold_expr(e), fld.new_id(nid))) + StmtExpr(e, nid) => { + Some(StmtExpr(fld.fold_expr(e), fld.new_id(nid))) } - stmt_semi(e, nid) => { - Some(stmt_semi(fld.fold_expr(e), fld.new_id(nid))) + StmtSemi(e, nid) => { + Some(StmtSemi(fld.fold_expr(e), fld.new_id(nid))) } - stmt_mac(ref mac, semi) => Some(stmt_mac(fold_mac(mac), semi)) + StmtMac(ref mac, semi) => Some(StmtMac(fold_mac(mac), semi)) } } -fn noop_fold_arm(a: &arm, fld: @ast_fold) -> arm { - arm { +fn noop_fold_arm(a: &Arm, fld: @ast_fold) -> Arm { + Arm { pats: a.pats.map(|x| fld.fold_pat(*x)), guard: a.guard.map_move(|x| fld.fold_expr(x)), body: fld.fold_block(&a.body), } } -pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ { +pub fn noop_fold_pat(p: &Pat_, fld: @ast_fold) -> Pat_ { match *p { - pat_wild => pat_wild, - pat_ident(binding_mode, ref pth, ref sub) => { - pat_ident( + PatWild => PatWild, + PatIdent(binding_mode, ref pth, ref sub) => { + PatIdent( binding_mode, fld.fold_path(pth), sub.map_move(|x| fld.fold_pat(x)) ) } - pat_lit(e) => pat_lit(fld.fold_expr(e)), - pat_enum(ref pth, ref pats) => { - pat_enum( + PatLit(e) => PatLit(fld.fold_expr(e)), + PatEnum(ref pth, ref pats) => { + PatEnum( fld.fold_path(pth), pats.map(|pats| pats.map(|x| fld.fold_pat(*x))) ) } - pat_struct(ref pth, ref fields, etc) => { + PatStruct(ref pth, ref fields, etc) => { let pth_ = fld.fold_path(pth); let fs = do fields.map |f| { - ast::field_pat { + ast::FieldPat { ident: f.ident, pat: fld.fold_pat(f.pat) } }; - pat_struct(pth_, fs, etc) - } - pat_tup(ref elts) => pat_tup(elts.map(|x| fld.fold_pat(*x))), - pat_box(inner) => pat_box(fld.fold_pat(inner)), - pat_uniq(inner) => pat_uniq(fld.fold_pat(inner)), - pat_region(inner) => pat_region(fld.fold_pat(inner)), - pat_range(e1, e2) => { - pat_range(fld.fold_expr(e1), fld.fold_expr(e2)) + PatStruct(pth_, fs, etc) + } + PatTup(ref elts) => PatTup(elts.map(|x| fld.fold_pat(*x))), + PatBox(inner) => PatBox(fld.fold_pat(inner)), + PatUniq(inner) => PatUniq(fld.fold_pat(inner)), + PatRegion(inner) => PatRegion(fld.fold_pat(inner)), + PatRange(e1, e2) => { + PatRange(fld.fold_expr(e1), fld.fold_expr(e2)) }, - pat_vec(ref before, ref slice, ref after) => { - pat_vec( + PatVec(ref before, ref slice, ref after) => { + PatVec( before.map(|x| fld.fold_pat(*x)), slice.map_move(|x| fld.fold_pat(x)), after.map(|x| fld.fold_pat(*x)) @@ -466,12 +466,12 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ { } } -fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> Option { +fn noop_fold_decl(d: &Decl_, fld: @ast_fold) -> Option { match *d { - decl_local(ref l) => Some(decl_local(fld.fold_local(*l))), - decl_item(it) => { + DeclLocal(ref l) => Some(DeclLocal(fld.fold_local(*l))), + DeclItem(it) => { match fld.fold_item(it) { - Some(it_folded) => Some(decl_item(it_folded)), + Some(it_folded) => Some(DeclItem(it_folded)), None => None, } } @@ -486,7 +486,7 @@ pub fn wrap(f: @fn(&T, @ast_fold) -> T) result } -pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { +pub fn noop_fold_expr(e: &Expr_, fld: @ast_fold) -> Expr_ { fn fold_field_(field: Field, fld: @ast_fold) -> Field { ast::Field { ident: fld.fold_ident(field.ident), @@ -499,25 +499,25 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { let fold_mac = |x| fold_mac_(x, fld); match *e { - expr_vstore(e, v) => { - expr_vstore(fld.fold_expr(e), v) + ExprVstore(e, v) => { + ExprVstore(fld.fold_expr(e), v) } - expr_vec(ref exprs, mutt) => { - expr_vec(fld.map_exprs(|x| fld.fold_expr(x), *exprs), mutt) + ExprVec(ref exprs, mutt) => { + ExprVec(fld.map_exprs(|x| fld.fold_expr(x), *exprs), mutt) } - expr_repeat(expr, count, mutt) => { - expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt) + ExprRepeat(expr, count, mutt) => { + ExprRepeat(fld.fold_expr(expr), fld.fold_expr(count), mutt) } - expr_tup(ref elts) => expr_tup(elts.map(|x| fld.fold_expr(*x))), - expr_call(f, ref args, blk) => { - expr_call( + ExprTup(ref elts) => ExprTup(elts.map(|x| fld.fold_expr(*x))), + ExprCall(f, ref args, blk) => { + ExprCall( fld.fold_expr(f), fld.map_exprs(|x| fld.fold_expr(x), *args), blk ) } - expr_method_call(callee_id, f, i, ref tps, ref args, blk) => { - expr_method_call( + ExprMethodCall(callee_id, f, i, ref tps, ref args, blk) => { + ExprMethodCall( fld.new_id(callee_id), fld.fold_expr(f), fld.fold_ident(i), @@ -526,118 +526,118 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { blk ) } - expr_binary(callee_id, binop, lhs, rhs) => { - expr_binary( + ExprBinary(callee_id, binop, lhs, rhs) => { + ExprBinary( fld.new_id(callee_id), binop, fld.fold_expr(lhs), fld.fold_expr(rhs) ) } - expr_unary(callee_id, binop, ohs) => { - expr_unary( + ExprUnary(callee_id, binop, ohs) => { + ExprUnary( fld.new_id(callee_id), binop, fld.fold_expr(ohs) ) } - expr_do_body(f) => expr_do_body(fld.fold_expr(f)), - expr_lit(_) => (*e).clone(), - expr_cast(expr, ref ty) => { - expr_cast(fld.fold_expr(expr), (*ty).clone()) + ExprDoBody(f) => ExprDoBody(fld.fold_expr(f)), + ExprLit(_) => (*e).clone(), + ExprCast(expr, ref ty) => { + ExprCast(fld.fold_expr(expr), (*ty).clone()) } - expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)), - expr_if(cond, ref tr, fl) => { - expr_if( + ExprAddrOf(m, ohs) => ExprAddrOf(m, fld.fold_expr(ohs)), + ExprIf(cond, ref tr, fl) => { + ExprIf( fld.fold_expr(cond), fld.fold_block(tr), fl.map_move(|x| fld.fold_expr(x)) ) } - expr_while(cond, ref body) => { - expr_while(fld.fold_expr(cond), fld.fold_block(body)) + ExprWhile(cond, ref body) => { + ExprWhile(fld.fold_expr(cond), fld.fold_block(body)) } - expr_for_loop(pat, iter, ref body) => { - expr_for_loop(fld.fold_pat(pat), + ExprForLoop(pat, iter, ref body) => { + ExprForLoop(fld.fold_pat(pat), fld.fold_expr(iter), fld.fold_block(body)) } - expr_loop(ref body, opt_ident) => { - expr_loop( + ExprLoop(ref body, opt_ident) => { + ExprLoop( fld.fold_block(body), opt_ident.map_move(|x| fld.fold_ident(x)) ) } - expr_match(expr, ref arms) => { - expr_match( + ExprMatch(expr, ref arms) => { + ExprMatch( fld.fold_expr(expr), arms.map(|x| fld.fold_arm(x)) ) } - expr_fn_block(ref decl, ref body) => { - expr_fn_block( + ExprFnBlock(ref decl, ref body) => { + ExprFnBlock( fold_fn_decl(decl, fld), fld.fold_block(body) ) } - expr_block(ref blk) => expr_block(fld.fold_block(blk)), - expr_assign(el, er) => { - expr_assign(fld.fold_expr(el), fld.fold_expr(er)) + ExprBlock(ref blk) => ExprBlock(fld.fold_block(blk)), + ExprAssign(el, er) => { + ExprAssign(fld.fold_expr(el), fld.fold_expr(er)) } - expr_assign_op(callee_id, op, el, er) => { - expr_assign_op( + ExprAssignOp(callee_id, op, el, er) => { + ExprAssignOp( fld.new_id(callee_id), op, fld.fold_expr(el), fld.fold_expr(er) ) } - expr_field(el, id, ref tys) => { - expr_field( + ExprField(el, id, ref tys) => { + ExprField( fld.fold_expr(el), fld.fold_ident(id), tys.map(|x| fld.fold_ty(x)) ) } - expr_index(callee_id, el, er) => { - expr_index( + ExprIndex(callee_id, el, er) => { + ExprIndex( fld.new_id(callee_id), fld.fold_expr(el), fld.fold_expr(er) ) } - expr_path(ref pth) => expr_path(fld.fold_path(pth)), - expr_self => expr_self, - expr_break(ref opt_ident) => { - expr_break(opt_ident.map_move(|x| fld.fold_ident(x))) + ExprPath(ref pth) => ExprPath(fld.fold_path(pth)), + ExprSelf => ExprSelf, + ExprBreak(ref opt_ident) => { + ExprBreak(opt_ident.map_move(|x| fld.fold_ident(x))) } - expr_again(ref opt_ident) => { - expr_again(opt_ident.map_move(|x| fld.fold_ident(x))) + ExprAgain(ref opt_ident) => { + ExprAgain(opt_ident.map_move(|x| fld.fold_ident(x))) } - expr_ret(ref e) => { - expr_ret(e.map_move(|x| fld.fold_expr(x))) + ExprRet(ref e) => { + ExprRet(e.map_move(|x| fld.fold_expr(x))) } - expr_log(lv, e) => { - expr_log( + ExprLog(lv, e) => { + ExprLog( fld.fold_expr(lv), fld.fold_expr(e) ) } - expr_inline_asm(ref a) => { - expr_inline_asm(inline_asm { + ExprInlineAsm(ref a) => { + ExprInlineAsm(inline_asm { inputs: a.inputs.map(|&(c, input)| (c, fld.fold_expr(input))), outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))), .. (*a).clone() }) } - expr_mac(ref mac) => expr_mac(fold_mac(mac)), - expr_struct(ref path, ref fields, maybe_expr) => { - expr_struct( + ExprMac(ref mac) => ExprMac(fold_mac(mac)), + ExprStruct(ref path, ref fields, maybe_expr) => { + ExprStruct( fld.fold_path(path), fields.map(|x| fold_field(*x)), maybe_expr.map_move(|x| fld.fold_expr(x)) ) }, - expr_paren(ex) => expr_paren(fld.fold_expr(ex)) + ExprParen(ex) => ExprParen(fld.fold_expr(ex)) } } @@ -787,7 +787,7 @@ fn noop_fold_local(l: @Local, fld: @ast_fold) -> @Local { /* temporarily eta-expand because of a compiler bug with using `fn` as a value */ -fn noop_map_exprs(f: @fn(@expr) -> @expr, es: &[@expr]) -> ~[@expr] { +fn noop_map_exprs(f: @fn(@Expr) -> @Expr, es: &[@Expr]) -> ~[@Expr] { es.map(|x| f(*x)) } @@ -862,34 +862,34 @@ impl ast_fold for AstFoldFns { fn fold_block(@self, x: &Block) -> Block { (self.fold_block)(x, self as @ast_fold) } - fn fold_stmt(@self, x: &stmt) -> Option<@stmt> { + fn fold_stmt(@self, x: &Stmt) -> Option<@Stmt> { let (n_opt, s) = (self.fold_stmt)(&x.node, x.span, self as @ast_fold); match n_opt { Some(n) => Some(@Spanned { node: n, span: (self.new_span)(s) }), None => None, } } - fn fold_arm(@self, x: &arm) -> arm { + fn fold_arm(@self, x: &Arm) -> Arm { (self.fold_arm)(x, self as @ast_fold) } - fn fold_pat(@self, x: @pat) -> @pat { + fn fold_pat(@self, x: @Pat) -> @Pat { let (n, s) = (self.fold_pat)(&x.node, x.span, self as @ast_fold); - @pat { + @Pat { id: (self.new_id)(x.id), node: n, span: (self.new_span)(s), } } - fn fold_decl(@self, x: @decl) -> Option<@decl> { + fn fold_decl(@self, x: @Decl) -> Option<@Decl> { let (n_opt, s) = (self.fold_decl)(&x.node, x.span, self as @ast_fold); match n_opt { Some(n) => Some(@Spanned { node: n, span: (self.new_span)(s) }), None => None, } } - fn fold_expr(@self, x: @expr) -> @expr { + fn fold_expr(@self, x: @Expr) -> @Expr { let (n, s) = (self.fold_expr)(&x.node, x.span, self as @ast_fold); - @expr { + @Expr { id: (self.new_id)(x.id), node: n, span: (self.new_span)(s), @@ -923,9 +923,9 @@ impl ast_fold for AstFoldFns { (self.fold_local)(x, self as @ast_fold) } fn map_exprs(@self, - f: @fn(@expr) -> @expr, - e: &[@expr]) - -> ~[@expr] { + f: @fn(@Expr) -> @Expr, + e: &[@Expr]) + -> ~[@Expr] { (self.map_exprs)(f, e) } fn new_id(@self, node_id: ast::NodeId) -> NodeId { diff --git a/src/libsyntax/oldvisit.rs b/src/libsyntax/oldvisit.rs index ac3a2d1316fbf..e9d7b5c4a0dd1 100644 --- a/src/libsyntax/oldvisit.rs +++ b/src/libsyntax/oldvisit.rs @@ -77,12 +77,12 @@ pub struct Visitor { visit_item: @fn(@item, (E, vt)), visit_local: @fn(@Local, (E, vt)), visit_block: @fn(&Block, (E, vt)), - visit_stmt: @fn(@stmt, (E, vt)), - visit_arm: @fn(&arm, (E, vt)), - visit_pat: @fn(@pat, (E, vt)), - visit_decl: @fn(@decl, (E, vt)), - visit_expr: @fn(@expr, (E, vt)), - visit_expr_post: @fn(@expr, (E, vt)), + visit_stmt: @fn(@Stmt, (E, vt)), + visit_arm: @fn(&Arm, (E, vt)), + visit_pat: @fn(@Pat, (E, vt)), + visit_decl: @fn(@Decl, (E, vt)), + visit_expr: @fn(@Expr, (E, vt)), + visit_expr_post: @fn(@Expr, (E, vt)), visit_ty: @fn(&Ty, (E, vt)), visit_generics: @fn(&Generics, (E, vt)), visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId, (E, vt)), @@ -294,9 +294,9 @@ pub fn visit_path(p: &Path, (e, v): (E, vt)) { } } -pub fn visit_pat(p: &pat, (e, v): (E, vt)) { +pub fn visit_pat(p: &Pat, (e, v): (E, vt)) { match p.node { - pat_enum(ref path, ref children) => { + PatEnum(ref path, ref children) => { visit_path(path, (e.clone(), v)); for children in children.iter() { for child in children.iter() { @@ -304,33 +304,33 @@ pub fn visit_pat(p: &pat, (e, v): (E, vt)) { } } } - pat_struct(ref path, ref fields, _) => { + PatStruct(ref path, ref fields, _) => { visit_path(path, (e.clone(), v)); for f in fields.iter() { (v.visit_pat)(f.pat, (e.clone(), v)); } } - pat_tup(ref elts) => { + PatTup(ref elts) => { for elt in elts.iter() { (v.visit_pat)(*elt, (e.clone(), v)) } }, - pat_box(inner) | pat_uniq(inner) | pat_region(inner) => { + PatBox(inner) | PatUniq(inner) | PatRegion(inner) => { (v.visit_pat)(inner, (e, v)) }, - pat_ident(_, ref path, ref inner) => { + PatIdent(_, ref path, ref inner) => { visit_path(path, (e.clone(), v)); for subpat in inner.iter() { (v.visit_pat)(*subpat, (e.clone(), v)) } } - pat_lit(ex) => (v.visit_expr)(ex, (e, v)), - pat_range(e1, e2) => { + PatLit(ex) => (v.visit_expr)(ex, (e, v)), + PatRange(e1, e2) => { (v.visit_expr)(e1, (e.clone(), v)); (v.visit_expr)(e2, (e, v)); } - pat_wild => (), - pat_vec(ref before, ref slice, ref after) => { + PatWild => (), + PatVec(ref before, ref slice, ref after) => { for elt in before.iter() { (v.visit_pat)(*elt, (e.clone(), v)); } @@ -446,27 +446,27 @@ pub fn visit_block(b: &Block, (e, v): (E, vt)) { visit_expr_opt(b.expr, (e, v)); } -pub fn visit_stmt(s: &stmt, (e, v): (E, vt)) { +pub fn visit_stmt(s: &Stmt, (e, v): (E, vt)) { match s.node { - stmt_decl(d, _) => (v.visit_decl)(d, (e, v)), - stmt_expr(ex, _) => (v.visit_expr)(ex, (e, v)), - stmt_semi(ex, _) => (v.visit_expr)(ex, (e, v)), - stmt_mac(ref mac, _) => visit_mac(mac, (e, v)) + StmtDecl(d, _) => (v.visit_decl)(d, (e, v)), + StmtExpr(ex, _) => (v.visit_expr)(ex, (e, v)), + StmtSemi(ex, _) => (v.visit_expr)(ex, (e, v)), + StmtMac(ref mac, _) => visit_mac(mac, (e, v)) } } -pub fn visit_decl(d: &decl, (e, v): (E, vt)) { +pub fn visit_decl(d: &Decl, (e, v): (E, vt)) { match d.node { - decl_local(ref loc) => (v.visit_local)(*loc, (e, v)), - decl_item(it) => (v.visit_item)(it, (e, v)) + DeclLocal(ref loc) => (v.visit_local)(*loc, (e, v)), + DeclItem(it) => (v.visit_item)(it, (e, v)) } } -pub fn visit_expr_opt(eo: Option<@expr>, (e, v): (E, vt)) { +pub fn visit_expr_opt(eo: Option<@Expr>, (e, v): (E, vt)) { match eo { None => (), Some(ex) => (v.visit_expr)(ex, (e, v)) } } -pub fn visit_exprs(exprs: &[@expr], (e, v): (E, vt)) { +pub fn visit_exprs(exprs: &[@Expr], (e, v): (E, vt)) { for ex in exprs.iter() { (v.visit_expr)(*ex, (e.clone(), v)); } } @@ -474,66 +474,66 @@ pub fn visit_mac(_m: &mac, (_e, _v): (E, vt)) { /* no user-serviceable parts inside */ } -pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { +pub fn visit_expr(ex: @Expr, (e, v): (E, vt)) { match ex.node { - expr_vstore(x, _) => (v.visit_expr)(x, (e.clone(), v)), - expr_vec(ref es, _) => visit_exprs(*es, (e.clone(), v)), - expr_repeat(element, count, _) => { + ExprVstore(x, _) => (v.visit_expr)(x, (e.clone(), v)), + ExprVec(ref es, _) => visit_exprs(*es, (e.clone(), v)), + ExprRepeat(element, count, _) => { (v.visit_expr)(element, (e.clone(), v)); (v.visit_expr)(count, (e.clone(), v)); } - expr_struct(ref p, ref flds, base) => { + ExprStruct(ref p, ref flds, base) => { visit_path(p, (e.clone(), v)); for f in flds.iter() { (v.visit_expr)(f.expr, (e.clone(), v)); } visit_expr_opt(base, (e.clone(), v)); } - expr_tup(ref elts) => { + ExprTup(ref elts) => { for el in elts.iter() { (v.visit_expr)(*el, (e.clone(), v)) } } - expr_call(callee, ref args, _) => { + ExprCall(callee, ref args, _) => { visit_exprs(*args, (e.clone(), v)); (v.visit_expr)(callee, (e.clone(), v)); } - expr_method_call(_, callee, _, ref tys, ref args, _) => { + ExprMethodCall(_, callee, _, ref tys, ref args, _) => { visit_exprs(*args, (e.clone(), v)); for tp in tys.iter() { (v.visit_ty)(tp, (e.clone(), v)); } (v.visit_expr)(callee, (e.clone(), v)); } - expr_binary(_, _, a, b) => { + ExprBinary(_, _, a, b) => { (v.visit_expr)(a, (e.clone(), v)); (v.visit_expr)(b, (e.clone(), v)); } - expr_addr_of(_, x) | expr_unary(_, _, x) | - expr_do_body(x) => (v.visit_expr)(x, (e.clone(), v)), - expr_lit(_) => (), - expr_cast(x, ref t) => { + ExprAddrOf(_, x) | ExprUnary(_, _, x) | + ExprDoBody(x) => (v.visit_expr)(x, (e.clone(), v)), + ExprLit(_) => (), + ExprCast(x, ref t) => { (v.visit_expr)(x, (e.clone(), v)); (v.visit_ty)(t, (e.clone(), v)); } - expr_if(x, ref b, eo) => { + ExprIf(x, ref b, eo) => { (v.visit_expr)(x, (e.clone(), v)); (v.visit_block)(b, (e.clone(), v)); visit_expr_opt(eo, (e.clone(), v)); } - expr_while(x, ref b) => { + ExprWhile(x, ref b) => { (v.visit_expr)(x, (e.clone(), v)); (v.visit_block)(b, (e.clone(), v)); } - expr_for_loop(pattern, subexpression, ref block) => { + ExprForLoop(pattern, subexpression, ref block) => { (v.visit_pat)(pattern, (e.clone(), v)); (v.visit_expr)(subexpression, (e.clone(), v)); (v.visit_block)(block, (e.clone(), v)) } - expr_loop(ref b, _) => (v.visit_block)(b, (e.clone(), v)), - expr_match(x, ref arms) => { + ExprLoop(ref b, _) => (v.visit_block)(b, (e.clone(), v)), + ExprMatch(x, ref arms) => { (v.visit_expr)(x, (e.clone(), v)); for a in arms.iter() { (v.visit_arm)(a, (e.clone(), v)); } } - expr_fn_block(ref decl, ref body) => { + ExprFnBlock(ref decl, ref body) => { (v.visit_fn)( &fk_fn_block, decl, @@ -543,37 +543,37 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { (e.clone(), v) ); } - expr_block(ref b) => (v.visit_block)(b, (e.clone(), v)), - expr_assign(a, b) => { + ExprBlock(ref b) => (v.visit_block)(b, (e.clone(), v)), + ExprAssign(a, b) => { (v.visit_expr)(b, (e.clone(), v)); (v.visit_expr)(a, (e.clone(), v)); } - expr_assign_op(_, _, a, b) => { + ExprAssignOp(_, _, a, b) => { (v.visit_expr)(b, (e.clone(), v)); (v.visit_expr)(a, (e.clone(), v)); } - expr_field(x, _, ref tys) => { + ExprField(x, _, ref tys) => { (v.visit_expr)(x, (e.clone(), v)); for tp in tys.iter() { (v.visit_ty)(tp, (e.clone(), v)); } } - expr_index(_, a, b) => { + ExprIndex(_, a, b) => { (v.visit_expr)(a, (e.clone(), v)); (v.visit_expr)(b, (e.clone(), v)); } - expr_path(ref p) => visit_path(p, (e.clone(), v)), - expr_self => (), - expr_break(_) => (), - expr_again(_) => (), - expr_ret(eo) => visit_expr_opt(eo, (e.clone(), v)), - expr_log(lv, x) => { + ExprPath(ref p) => visit_path(p, (e.clone(), v)), + ExprSelf => (), + ExprBreak(_) => (), + ExprAgain(_) => (), + ExprRet(eo) => visit_expr_opt(eo, (e.clone(), v)), + ExprLog(lv, x) => { (v.visit_expr)(lv, (e.clone(), v)); (v.visit_expr)(x, (e.clone(), v)); } - expr_mac(ref mac) => visit_mac(mac, (e.clone(), v)), - expr_paren(x) => (v.visit_expr)(x, (e.clone(), v)), - expr_inline_asm(ref a) => { + ExprMac(ref mac) => visit_mac(mac, (e.clone(), v)), + ExprParen(x) => (v.visit_expr)(x, (e.clone(), v)), + ExprInlineAsm(ref a) => { for &(_, input) in a.inputs.iter() { (v.visit_expr)(input, (e.clone(), v)); } @@ -585,7 +585,7 @@ pub fn visit_expr(ex: @expr, (e, v): (E, vt)) { (v.visit_expr_post)(ex, (e, v)); } -pub fn visit_arm(a: &arm, (e, v): (E, vt)) { +pub fn visit_arm(a: &Arm, (e, v): (E, vt)) { for p in a.pats.iter() { (v.visit_pat)(*p, (e.clone(), v)); } visit_expr_opt(a.guard, (e.clone(), v)); (v.visit_block)(&a.body, (e.clone(), v)); @@ -601,12 +601,12 @@ pub struct SimpleVisitor { visit_item: @fn(@item), visit_local: @fn(@Local), visit_block: @fn(&Block), - visit_stmt: @fn(@stmt), - visit_arm: @fn(&arm), - visit_pat: @fn(@pat), - visit_decl: @fn(@decl), - visit_expr: @fn(@expr), - visit_expr_post: @fn(@expr), + visit_stmt: @fn(@Stmt), + visit_arm: @fn(&Arm), + visit_pat: @fn(@Pat), + visit_decl: @fn(@Decl), + visit_expr: @fn(@Expr), + visit_expr_post: @fn(@Expr), visit_ty: @fn(&Ty), visit_generics: @fn(&Generics), visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId), @@ -677,27 +677,27 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(bl); visit_block(bl, (e, v)); } - fn v_stmt(f: @fn(@stmt), st: @stmt, (e, v): ((), vt<()>)) { + fn v_stmt(f: @fn(@Stmt), st: @Stmt, (e, v): ((), vt<()>)) { f(st); visit_stmt(st, (e, v)); } - fn v_arm(f: @fn(&arm), a: &arm, (e, v): ((), vt<()>)) { + fn v_arm(f: @fn(&Arm), a: &Arm, (e, v): ((), vt<()>)) { f(a); visit_arm(a, (e, v)); } - fn v_pat(f: @fn(@pat), p: @pat, (e, v): ((), vt<()>)) { + fn v_pat(f: @fn(@Pat), p: @Pat, (e, v): ((), vt<()>)) { f(p); visit_pat(p, (e, v)); } - fn v_decl(f: @fn(@decl), d: @decl, (e, v): ((), vt<()>)) { + fn v_decl(f: @fn(@Decl), d: @Decl, (e, v): ((), vt<()>)) { f(d); visit_decl(d, (e, v)); } - fn v_expr(f: @fn(@expr), ex: @expr, (e, v): ((), vt<()>)) { + fn v_expr(f: @fn(@Expr), ex: @Expr, (e, v): ((), vt<()>)) { f(ex); visit_expr(ex, (e, v)); } - fn v_expr_post(f: @fn(@expr), ex: @expr, (_e, _v): ((), vt<()>)) { + fn v_expr_post(f: @fn(@Expr), ex: @Expr, (_e, _v): ((), vt<()>)) { f(ex); } fn v_ty(f: @fn(&Ty), ty: &Ty, (e, v): ((), vt<()>)) { diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 0bf87f10597ba..a4df5f4a5fc4d 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -21,25 +21,25 @@ use ast; // 'if true {...} else {...} // |x| 5 ' // isn't parsed as (if true {...} else {...} | x) | 5 -pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { +pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool { match e.node { - ast::expr_if(*) - | ast::expr_match(*) - | ast::expr_block(_) - | ast::expr_while(*) - | ast::expr_loop(*) - | ast::expr_for_loop(*) - | ast::expr_call(_, _, ast::DoSugar) - | ast::expr_call(_, _, ast::ForSugar) - | ast::expr_method_call(_, _, _, _, _, ast::DoSugar) - | ast::expr_method_call(_, _, _, _, _, ast::ForSugar) => false, + ast::ExprIf(*) + | ast::ExprMatch(*) + | ast::ExprBlock(_) + | ast::ExprWhile(*) + | ast::ExprLoop(*) + | ast::ExprForLoop(*) + | ast::ExprCall(_, _, ast::DoSugar) + | ast::ExprCall(_, _, ast::ForSugar) + | ast::ExprMethodCall(_, _, _, _, _, ast::DoSugar) + | ast::ExprMethodCall(_, _, _, _, _, ast::ForSugar) => false, _ => true } } -pub fn expr_is_simple_block(e: @ast::expr) -> bool { +pub fn expr_is_simple_block(e: @ast::Expr) -> bool { match e.node { - ast::expr_block( + ast::ExprBlock( ast::Block { rules: ast::DefaultBlock, _ } ) => true, _ => false @@ -49,16 +49,16 @@ pub fn expr_is_simple_block(e: @ast::expr) -> bool { // this statement requires a semicolon after it. // note that in one case (stmt_semi), we've already // seen the semicolon, and thus don't need another. -pub fn stmt_ends_with_semi(stmt: &ast::stmt) -> bool { +pub fn stmt_ends_with_semi(stmt: &ast::Stmt) -> bool { return match stmt.node { - ast::stmt_decl(d, _) => { + ast::StmtDecl(d, _) => { match d.node { - ast::decl_local(_) => true, - ast::decl_item(_) => false + ast::DeclLocal(_) => true, + ast::DeclItem(_) => false } } - ast::stmt_expr(e, _) => { expr_requires_semi_to_be_stmt(e) } - ast::stmt_semi(*) => { false } - ast::stmt_mac(*) => { false } + ast::StmtExpr(e, _) => { expr_requires_semi_to_be_stmt(e) } + ast::StmtSemi(*) => { false } + ast::StmtMac(*) => { false } } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index ea1c9ce9b1e1a..5fa28ff21ae6f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -101,7 +101,7 @@ pub fn parse_expr_from_source_str( source: @str, cfg: ast::CrateConfig, sess: @mut ParseSess -) -> @ast::expr { +) -> @ast::Expr { let p = new_parser_from_source_str( sess, cfg, @@ -148,7 +148,7 @@ pub fn parse_stmt_from_source_str( cfg: ast::CrateConfig, attrs: ~[ast::Attribute], sess: @mut ParseSess -) -> @ast::stmt { +) -> @ast::Stmt { let p = new_parser_from_source_str( sess, cfg, @@ -363,9 +363,9 @@ mod test { #[test] fn path_exprs_1() { assert_eq!(string_to_expr(@"a"), - @ast::expr{ + @ast::Expr{ id: 1, - node: ast::expr_path(ast::Path { + node: ast::ExprPath(ast::Path { span: sp(0, 1), global: false, segments: ~[ @@ -382,9 +382,9 @@ mod test { #[test] fn path_exprs_2 () { assert_eq!(string_to_expr(@"::a::b"), - @ast::expr { + @ast::Expr { id:1, - node: ast::expr_path(ast::Path { + node: ast::ExprPath(ast::Path { span: sp(0, 6), global: true, segments: ~[ @@ -440,11 +440,11 @@ mod test { #[test] fn ret_expr() { assert_eq!(string_to_expr(@"return d"), - @ast::expr{ + @ast::Expr{ id:2, - node:ast::expr_ret(Some(@ast::expr{ + node:ast::ExprRet(Some(@ast::Expr{ id:1, - node:ast::expr_path(ast::Path{ + node:ast::ExprPath(ast::Path{ span: sp(7, 8), global: false, segments: ~[ @@ -464,9 +464,9 @@ mod test { #[test] fn parse_stmt_1 () { assert_eq!(string_to_stmt(@"b;"), @Spanned{ - node: ast::stmt_expr(@ast::expr { + node: ast::StmtExpr(@ast::Expr { id: 1, - node: ast::expr_path(ast::Path { + node: ast::ExprPath(ast::Path { span:sp(0,1), global:false, segments: ~[ @@ -490,9 +490,9 @@ mod test { #[test] fn parse_ident_pat () { let parser = string_to_parser(@"b"); assert_eq!(parser.parse_pat(), - @ast::pat{id:1, // fixme - node: ast::pat_ident( - ast::bind_infer, + @ast::Pat{id:1, // fixme + node: ast::PatIdent( + ast::BindInfer, ast::Path { span:sp(0,1), global:false, @@ -536,10 +536,10 @@ mod test { }, None, 2), span:sp(10,13) }, - pat: @ast::pat { + pat: @ast::Pat { id:1, // fixme - node: ast::pat_ident( - ast::bind_infer, + node: ast::PatIdent( + ast::BindInfer, ast::Path { span:sp(6,7), global:false, @@ -572,9 +572,9 @@ mod test { ast::Block { view_items: ~[], stmts: ~[@Spanned{ - node: ast::stmt_semi(@ast::expr{ + node: ast::StmtSemi(@ast::Expr{ id: 6, - node: ast::expr_path( + node: ast::ExprPath( ast::Path{ span:sp(17,18), global:false, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 62cf856a2c84d..b056b39eb6e89 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, expr_lit, lit_nil, Attribute}; +use ast::{Expr, ExprLit, lit_nil, Attribute}; use ast; use codemap::{Span, respan}; use parse::parser::Parser; @@ -79,7 +79,7 @@ pub trait ParserObsoleteMethods { fn obsolete(&self, sp: Span, kind: ObsoleteSyntax); // Reports an obsolete syntax non-fatal error, and returns // a placeholder expression - fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @expr; + fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @Expr; fn report(&self, sp: Span, kind: ObsoleteSyntax, @@ -263,9 +263,9 @@ impl ParserObsoleteMethods for Parser { // Reports an obsolete syntax non-fatal error, and returns // a placeholder expression - fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @expr { + fn obsolete_expr(&self, sp: Span, kind: ObsoleteSyntax) -> @Expr { self.obsolete(sp, kind); - self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil))) + self.mk_expr(sp.lo, sp.hi, ExprLit(@respan(sp, lit_nil))) } fn report(&self, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 02af6d23b4415..6e7d54e4f7611 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -17,44 +17,44 @@ use ast::{CallSugar, NoSugar, DoSugar}; use ast::{TyBareFn, TyClosure}; use ast::{RegionTyParamBound, TraitTyParamBound}; use ast::{provided, public, purity}; -use ast::{_mod, add, arg, arm, Attribute, bind_by_ref, bind_infer}; -use ast::{bitand, bitor, bitxor, Block}; -use ast::{BlockCheckMode, box}; -use ast::{Crate, CrateConfig, decl, decl_item}; -use ast::{decl_local, DefaultBlock, deref, div, enum_def, explicit_self}; -use ast::{expr, expr_, expr_addr_of, expr_match, expr_again}; -use ast::{expr_assign, expr_assign_op, expr_binary, expr_block}; -use ast::{expr_break, expr_call, expr_cast, expr_do_body}; -use ast::{expr_field, expr_fn_block, expr_if, expr_index}; -use ast::{expr_lit, expr_log, expr_loop, expr_mac}; -use ast::{expr_method_call, expr_paren, expr_path, expr_repeat}; -use ast::{expr_ret, expr_self, expr_struct, expr_tup, expr_unary}; -use ast::{expr_vec, expr_vstore, expr_vstore_mut_box}; -use ast::{expr_vstore_slice, expr_vstore_box}; -use ast::{expr_vstore_mut_slice, expr_while, expr_for_loop, extern_fn, Field, fn_decl}; -use ast::{expr_vstore_uniq, Onceness, Once, Many}; +use ast::{_mod, BiAdd, arg, Arm, Attribute, BindByRef, BindInfer}; +use ast::{BiBitAnd, BiBitOr, BiBitXor, Block}; +use ast::{BlockCheckMode, UnBox}; +use ast::{Crate, CrateConfig, Decl, DeclItem}; +use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, enum_def, explicit_self}; +use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; +use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock}; +use ast::{ExprBreak, ExprCall, ExprCast, ExprDoBody}; +use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex}; +use ast::{ExprLit, ExprLog, ExprLoop, ExprMac}; +use ast::{ExprMethodCall, ExprParen, ExprPath, ExprRepeat}; +use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary}; +use ast::{ExprVec, ExprVstore, ExprVstoreMutBox}; +use ast::{ExprVstoreSlice, ExprVstoreBox}; +use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl}; +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}; use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, Local}; -use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal}; -use ast::{match_seq, match_tok, method, mt, mul, mutability}; -use ast::{named_field, neg, NodeId, noreturn, not, pat, pat_box, pat_enum}; -use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct}; -use ast::{pat_tup, pat_uniq, pat_wild, private}; -use ast::{rem, required}; -use ast::{ret_style, return_val, shl, shr, stmt, stmt_decl}; -use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field}; -use ast::{struct_variant_kind, subtract}; +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, NodeId, noreturn, UnNot, Pat, PatBox, PatEnum}; +use ast::{PatIdent, PatLit, PatRange, PatRegion, PatStruct}; +use ast::{PatTup, PatUniq, PatWild, 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::{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, uniq}; +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}; @@ -160,7 +160,7 @@ macro_rules! maybe_whole_expr ( Some($p.mk_expr( ($p).span.lo, ($p).span.hi, - expr_path(/* bad */ (**pt).clone()))) + ExprPath(/* bad */ (**pt).clone()))) } _ => None }; @@ -442,10 +442,10 @@ impl Parser { // Commit to parsing a complete expression `e` expected to be // followed by some token from the set edible + inedible. Recover // from anticipated input errors, discarding erroneous characters. - pub fn commit_expr(&self, e: @expr, edible: &[token::Token], inedible: &[token::Token]) { + pub fn commit_expr(&self, e: @Expr, edible: &[token::Token], inedible: &[token::Token]) { debug!("commit_expr %?", e); match e.node { - expr_path(*) => { + ExprPath(*) => { // might be unit-struct construction; check for recoverableinput error. let expected = vec::append(edible.to_owned(), inedible); self.check_for_erroneous_unit_struct_expecting(expected); @@ -455,14 +455,14 @@ impl Parser { self.expect_one_of(edible, inedible) } - pub fn commit_expr_expecting(&self, e: @expr, edible: token::Token) { + pub fn commit_expr_expecting(&self, e: @Expr, edible: token::Token) { self.commit_expr(e, &[edible], &[]) } // Commit to parsing a complete statement `s`, which expects to be // followed by some token from the set edible + inedible. Check // for recoverable input errors, discarding erroneous characters. - pub fn commit_stmt(&self, s: @stmt, edible: &[token::Token], inedible: &[token::Token]) { + pub fn commit_stmt(&self, s: @Stmt, edible: &[token::Token], inedible: &[token::Token]) { debug!("commit_stmt %?", s); let _s = s; // unused, but future checks might want to inspect `s`. if self.last_token.map_default(false, |t|is_ident_or_path(*t)) { @@ -472,7 +472,7 @@ impl Parser { self.expect_one_of(edible, inedible) } - pub fn commit_stmt_expecting(&self, s: @stmt, edible: token::Token) { + pub fn commit_stmt_expecting(&self, s: @Stmt, edible: token::Token) { self.commit_stmt(s, &[edible], &[]) } @@ -1112,7 +1112,7 @@ impl Parser { // VECTOR self.expect(&token::LBRACKET); let mt = self.parse_mt(); - if mt.mutbl == m_mutbl { // `m_const` too after snapshot + if mt.mutbl == MutMutable { // `m_const` too after snapshot self.obsolete(*self.last_span, ObsoleteMutVector); } @@ -1191,7 +1191,7 @@ impl Parser { // reflected in the AST type. let mt = self.parse_mt(); - if mt.mutbl != m_imm && sigil == OwnedSigil { + if mt.mutbl != MutImmutable && sigil == OwnedSigil { self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); } @@ -1308,7 +1308,7 @@ impl Parser { }) } - pub fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> { + pub fn maybe_parse_fixed_vstore(&self) -> Option<@ast::Expr> { if self.eat(&token::BINOP(token::STAR)) { self.obsolete(*self.last_span, ObsoleteFixedLengthVectorType); Some(self.parse_expr()) @@ -1353,18 +1353,18 @@ impl Parser { } // matches '-' lit | lit - pub fn parse_literal_maybe_minus(&self) -> @expr { + pub fn parse_literal_maybe_minus(&self) -> @Expr { let minus_lo = self.span.lo; let minus_present = self.eat(&token::BINOP(token::MINUS)); let lo = self.span.lo; let literal = @self.parse_lit(); let hi = self.span.hi; - let expr = self.mk_expr(lo, hi, expr_lit(literal)); + let expr = self.mk_expr(lo, hi, ExprLit(literal)); if minus_present { let minus_hi = self.span.hi; - self.mk_expr(minus_lo, minus_hi, self.mk_unary(neg, expr)) + self.mk_expr(minus_lo, minus_hi, self.mk_unary(UnNeg, expr)) } else { expr } @@ -1618,14 +1618,14 @@ impl Parser { } // parse mutability declaration (mut/const/imm) - pub fn parse_mutability(&self) -> mutability { + pub fn parse_mutability(&self) -> Mutability { if self.eat_keyword(keywords::Mut) { - m_mutbl + MutMutable } else if self.eat_keyword(keywords::Const) { self.obsolete(*self.last_span, ObsoleteConstPointer); - m_imm + MutImmutable } else { - m_imm + MutImmutable } } @@ -1642,65 +1642,65 @@ impl Parser { } } - pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr { - @expr { + pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: Expr_) -> @Expr { + @Expr { id: self.get_id(), node: node, span: mk_sp(lo, hi), } } - pub fn mk_unary(&self, unop: ast::unop, expr: @expr) -> ast::expr_ { - expr_unary(self.get_id(), unop, expr) + pub fn mk_unary(&self, unop: ast::UnOp, expr: @Expr) -> ast::Expr_ { + ExprUnary(self.get_id(), unop, expr) } - pub fn mk_binary(&self, binop: ast::binop, lhs: @expr, rhs: @expr) -> ast::expr_ { - expr_binary(self.get_id(), binop, lhs, rhs) + pub fn mk_binary(&self, binop: ast::BinOp, lhs: @Expr, rhs: @Expr) -> ast::Expr_ { + ExprBinary(self.get_id(), binop, lhs, rhs) } - pub fn mk_call(&self, f: @expr, args: ~[@expr], sugar: CallSugar) -> ast::expr_ { - expr_call(f, args, sugar) + pub fn mk_call(&self, f: @Expr, args: ~[@Expr], sugar: CallSugar) -> ast::Expr_ { + ExprCall(f, args, sugar) } pub fn mk_method_call(&self, - rcvr: @expr, + rcvr: @Expr, ident: Ident, tps: ~[Ty], - args: ~[@expr], - sugar: CallSugar) -> ast::expr_ { - expr_method_call(self.get_id(), rcvr, ident, tps, args, sugar) + args: ~[@Expr], + sugar: CallSugar) -> ast::Expr_ { + ExprMethodCall(self.get_id(), rcvr, ident, tps, args, sugar) } - pub fn mk_index(&self, expr: @expr, idx: @expr) -> ast::expr_ { - expr_index(self.get_id(), expr, idx) + pub fn mk_index(&self, expr: @Expr, idx: @Expr) -> ast::Expr_ { + ExprIndex(self.get_id(), expr, idx) } - pub fn mk_field(&self, expr: @expr, ident: Ident, tys: ~[Ty]) -> ast::expr_ { - expr_field(expr, ident, tys) + pub fn mk_field(&self, expr: @Expr, ident: Ident, tys: ~[Ty]) -> ast::Expr_ { + ExprField(expr, ident, tys) } - pub fn mk_assign_op(&self, binop: ast::binop, lhs: @expr, rhs: @expr) -> ast::expr_ { - expr_assign_op(self.get_id(), binop, lhs, rhs) + pub fn mk_assign_op(&self, binop: ast::BinOp, lhs: @Expr, rhs: @Expr) -> ast::Expr_ { + ExprAssignOp(self.get_id(), binop, lhs, rhs) } - pub fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr { - @expr { + pub fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @Expr { + @Expr { id: self.get_id(), - node: expr_mac(codemap::Spanned {node: m, span: mk_sp(lo, hi)}), + node: ExprMac(codemap::Spanned {node: m, span: mk_sp(lo, hi)}), span: mk_sp(lo, hi), } } - pub fn mk_lit_u32(&self, i: u32) -> @expr { + pub fn mk_lit_u32(&self, i: u32) -> @Expr { let span = self.span; let lv_lit = @codemap::Spanned { node: lit_uint(i as u64, ty_u32), span: *span }; - @expr { + @Expr { id: self.get_id(), - node: expr_lit(lv_lit), + node: ExprLit(lv_lit), span: *span, } } @@ -1708,13 +1708,13 @@ impl Parser { // at the bottom (top?) of the precedence hierarchy, // parse things like parenthesized exprs, // macros, return, etc. - pub fn parse_bottom_expr(&self) -> @expr { + pub fn parse_bottom_expr(&self) -> @Expr { maybe_whole_expr!(self); let lo = self.span.lo; let mut hi = self.span.hi; - let ex: expr_; + let ex: Expr_; if *self.token == token::LPAREN { self.bump(); @@ -1725,7 +1725,7 @@ impl Parser { hi = self.span.hi; self.bump(); let lit = @spanned(lo, hi, lit_nil); - return self.mk_expr(lo, hi, expr_lit(lit)); + return self.mk_expr(lo, hi, ExprLit(lit)); } let mut es = ~[self.parse_expr()]; self.commit_expr(*es.last(), &[], &[token::COMMA, token::RPAREN]); @@ -1743,20 +1743,20 @@ impl Parser { self.commit_expr_expecting(*es.last(), token::RPAREN); return if es.len() == 1 && !trailing_comma { - self.mk_expr(lo, self.span.hi, expr_paren(es[0])) + self.mk_expr(lo, self.span.hi, ExprParen(es[0])) } else { - self.mk_expr(lo, hi, expr_tup(es)) + self.mk_expr(lo, hi, ExprTup(es)) } } else if *self.token == token::LBRACE { self.bump(); let blk = self.parse_block_tail(lo, DefaultBlock); return self.mk_expr(blk.span.lo, blk.span.hi, - expr_block(blk)); + ExprBlock(blk)); } else if token::is_bar(&*self.token) { return self.parse_lambda_expr(); } else if self.eat_keyword(keywords::Self) { - ex = expr_self; + ex = ExprSelf; hi = self.span.hi; } else if self.eat_keyword(keywords::If) { return self.parse_if_expr(); @@ -1764,7 +1764,7 @@ impl Parser { return self.parse_for_expr(); } else if self.eat_keyword(keywords::Do) { return self.parse_sugary_call_expr(lo, ~"do", DoSugar, - expr_do_body); + ExprDoBody); } else if self.eat_keyword(keywords::While) { return self.parse_while_expr(); } else if self.token_is_lifetime(&*self.token) { @@ -1782,14 +1782,14 @@ impl Parser { } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); - if mutbl == m_mutbl { + if mutbl == MutMutable { self.obsolete(*self.last_span, ObsoleteMutVector); } if *self.token == token::RBRACKET { // Empty vector. self.bump(); - ex = expr_vec(~[], mutbl); + ex = ExprVec(~[], mutbl); } else { // Nonempty vector. let first_expr = self.parse_expr(); @@ -1800,7 +1800,7 @@ impl Parser { self.bump(); let count = self.parse_expr(); self.expect(&token::RBRACKET); - ex = expr_repeat(first_expr, count, mutbl); + ex = ExprRepeat(first_expr, count, mutbl); } else if *self.token == token::COMMA { // Vector with two or more elements. self.bump(); @@ -1809,11 +1809,11 @@ impl Parser { seq_sep_trailing_allowed(token::COMMA), |p| p.parse_expr() ); - ex = expr_vec(~[first_expr] + remaining_exprs, mutbl); + ex = ExprVec(~[first_expr] + remaining_exprs, mutbl); } else { // Vector with one element. self.expect(&token::RBRACKET); - ex = expr_vec(~[first_expr], mutbl); + ex = ExprVec(~[first_expr], mutbl); } } hi = self.last_span.hi; @@ -1823,7 +1823,7 @@ impl Parser { let lvl = self.parse_expr(); self.expect(&token::COMMA); let e = self.parse_expr(); - ex = expr_log(lvl, e); + ex = ExprLog(lvl, e); hi = self.span.hi; self.expect(&token::RPAREN); } else if self.eat_keyword(keywords::Return) { @@ -1831,16 +1831,16 @@ impl Parser { if can_begin_expr(&*self.token) { let e = self.parse_expr(); hi = e.span.hi; - ex = expr_ret(Some(e)); - } else { ex = expr_ret(None); } + ex = ExprRet(Some(e)); + } else { ex = ExprRet(None); } } else if self.eat_keyword(keywords::Break) { // BREAK expression if self.token_is_lifetime(&*self.token) { let lifetime = self.get_lifetime(&*self.token); self.bump(); - ex = expr_break(Some(lifetime)); + ex = ExprBreak(Some(lifetime)); } else { - ex = expr_break(None); + ex = ExprBreak(None); } hi = self.span.hi; } else if *self.token == token::MOD_SEP || @@ -1896,18 +1896,18 @@ impl Parser { hi = pth.span.hi; self.commit_expr_expecting(fields.last().expr, token::RBRACE); - ex = expr_struct(pth, fields, base); + ex = ExprStruct(pth, fields, base); return self.mk_expr(lo, hi, ex); } } hi = pth.span.hi; - ex = expr_path(pth); + ex = ExprPath(pth); } else { // other literal expression let lit = self.parse_lit(); hi = lit.span.hi; - ex = expr_lit(@lit); + ex = ExprLit(@lit); } return self.mk_expr(lo, hi, ex); @@ -1915,19 +1915,19 @@ impl Parser { // parse a block or unsafe block pub fn parse_block_expr(&self, lo: BytePos, blk_mode: BlockCheckMode) - -> @expr { + -> @Expr { self.expect(&token::LBRACE); let blk = self.parse_block_tail(lo, blk_mode); - return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); + return self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk)); } // parse a.b or a(13) or a[4] or just a - pub fn parse_dot_or_call_expr(&self) -> @expr { + pub fn parse_dot_or_call_expr(&self) -> @Expr { let b = self.parse_bottom_expr(); self.parse_dot_or_call_expr_with(b) } - pub fn parse_dot_or_call_expr_with(&self, e0: @expr) -> @expr { + pub fn parse_dot_or_call_expr_with(&self, e0: @Expr) -> @Expr { let mut e = e0; let lo = e.span.lo; let mut hi; @@ -2185,7 +2185,7 @@ impl Parser { } // parse a prefix-operator expr - pub fn parse_prefix_expr(&self) -> @expr { + pub fn parse_prefix_expr(&self) -> @Expr { let lo = self.span.lo; let hi; @@ -2195,7 +2195,7 @@ impl Parser { self.bump(); let e = self.parse_prefix_expr(); hi = e.span.hi; - ex = self.mk_unary(not, e); + ex = self.mk_unary(UnNot, e); } token::BINOP(b) => { match b { @@ -2203,13 +2203,13 @@ impl Parser { self.bump(); let e = self.parse_prefix_expr(); hi = e.span.hi; - ex = self.mk_unary(neg, e); + ex = self.mk_unary(UnNeg, e); } token::STAR => { self.bump(); let e = self.parse_prefix_expr(); hi = e.span.hi; - ex = self.mk_unary(deref, e); + ex = self.mk_unary(UnDeref, e); } token::AND => { self.bump(); @@ -2219,16 +2219,16 @@ impl Parser { hi = e.span.hi; // HACK: turn &[...] into a &-evec ex = match e.node { - expr_vec(*) | expr_lit(@codemap::Spanned { + ExprVec(*) | ExprLit(@codemap::Spanned { node: lit_str(_), span: _ }) - if m == m_imm => { - expr_vstore(e, expr_vstore_slice) + if m == MutImmutable => { + ExprVstore(e, ExprVstoreSlice) } - expr_vec(*) if m == m_mutbl => { - expr_vstore(e, expr_vstore_mut_slice) + ExprVec(*) if m == MutMutable => { + ExprVstore(e, ExprVstoreMutSlice) } - _ => expr_addr_of(m, e) + _ => ExprAddrOf(m, e) }; } _ => return self.parse_dot_or_call_expr() @@ -2241,18 +2241,18 @@ impl Parser { hi = e.span.hi; // HACK: turn @[...] into a @-evec ex = match e.node { - expr_vec(*) | expr_repeat(*) if m == m_mutbl => - expr_vstore(e, expr_vstore_mut_box), - expr_vec(*) | - expr_lit(@codemap::Spanned { node: lit_str(_), span: _}) | - expr_repeat(*) if m == m_imm => expr_vstore(e, expr_vstore_box), - _ => self.mk_unary(box(m), e) + ExprVec(*) | ExprRepeat(*) if m == MutMutable => + ExprVstore(e, ExprVstoreMutBox), + ExprVec(*) | + ExprLit(@codemap::Spanned { node: lit_str(_), span: _}) | + ExprRepeat(*) if m == MutImmutable => ExprVstore(e, ExprVstoreBox), + _ => self.mk_unary(UnBox(m), e) }; } token::TILDE => { self.bump(); let m = self.parse_mutability(); - if m != m_imm { + if m != MutImmutable { self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); } @@ -2260,10 +2260,10 @@ impl Parser { hi = e.span.hi; // HACK: turn ~[...] into a ~-evec ex = match e.node { - expr_vec(*) | - expr_lit(@codemap::Spanned { node: lit_str(_), span: _}) | - expr_repeat(*) => expr_vstore(e, expr_vstore_uniq), - _ => self.mk_unary(uniq, e) + ExprVec(*) | + ExprLit(@codemap::Spanned { node: lit_str(_), span: _}) | + ExprRepeat(*) => ExprVstore(e, ExprVstoreUniq), + _ => self.mk_unary(UnUniq, e) }; } _ => return self.parse_dot_or_call_expr() @@ -2272,12 +2272,12 @@ impl Parser { } // parse an expression of binops - pub fn parse_binops(&self) -> @expr { + pub fn parse_binops(&self) -> @Expr { self.parse_more_binops(self.parse_prefix_expr(), 0) } // parse an expression of binops of at least min_prec precedence - pub fn parse_more_binops(&self, lhs: @expr, min_prec: uint) -> @expr { + pub fn parse_more_binops(&self, lhs: @Expr, min_prec: uint) -> @Expr { if self.expr_is_complete(lhs) { return lhs; } // Prevent dynamic borrow errors later on by limiting the @@ -2314,7 +2314,7 @@ impl Parser { let rhs = self.parse_ty(true); let _as = self.mk_expr(lhs.span.lo, rhs.span.hi, - expr_cast(lhs, rhs)); + ExprCast(lhs, rhs)); self.parse_more_binops(_as, min_prec) } else { lhs @@ -2326,29 +2326,29 @@ impl Parser { // parse an assignment expression.... // actually, this seems to be the main entry point for // parsing an arbitrary expression. - pub fn parse_assign_expr(&self) -> @expr { + pub fn parse_assign_expr(&self) -> @Expr { let lo = self.span.lo; let lhs = self.parse_binops(); match *self.token { token::EQ => { self.bump(); let rhs = self.parse_expr(); - self.mk_expr(lo, rhs.span.hi, expr_assign(lhs, rhs)) + self.mk_expr(lo, rhs.span.hi, ExprAssign(lhs, rhs)) } token::BINOPEQ(op) => { self.bump(); let rhs = self.parse_expr(); let aop = match op { - token::PLUS => add, - token::MINUS => subtract, - token::STAR => mul, - token::SLASH => div, - token::PERCENT => rem, - token::CARET => bitxor, - token::AND => bitand, - token::OR => bitor, - token::SHL => shl, - token::SHR => shr + token::PLUS => BiAdd, + token::MINUS => BiSub, + token::STAR => BiMul, + token::SLASH => BiDiv, + token::PERCENT => BiRem, + token::CARET => BiBitXor, + token::AND => BiBitAnd, + token::OR => BiBitOr, + token::SHL => BiShl, + token::SHR => BiShr }; self.mk_expr(lo, rhs.span.hi, self.mk_assign_op(aop, lhs, rhs)) @@ -2360,14 +2360,14 @@ impl Parser { self.bump(); // rhs self.bump(); // ; self.mk_expr(lo, self.span.hi, - expr_break(None)) + ExprBreak(None)) } token::DARROW => { self.obsolete(*self.span, ObsoleteSwap); self.bump(); // Ignore what we get, this is an error anyway self.parse_expr(); - self.mk_expr(lo, self.span.hi, expr_break(None)) + self.mk_expr(lo, self.span.hi, ExprBreak(None)) } _ => { lhs @@ -2376,22 +2376,22 @@ impl Parser { } // parse an 'if' expression ('if' token already eaten) - pub fn parse_if_expr(&self) -> @expr { + pub fn parse_if_expr(&self) -> @Expr { let lo = self.last_span.lo; let cond = self.parse_expr(); let thn = self.parse_block(); - let mut els: Option<@expr> = None; + let mut els: Option<@Expr> = None; let mut hi = thn.span.hi; if self.eat_keyword(keywords::Else) { let elexpr = self.parse_else_expr(); els = Some(elexpr); hi = elexpr.span.hi; } - self.mk_expr(lo, hi, expr_if(cond, thn, els)) + self.mk_expr(lo, hi, ExprIf(cond, thn, els)) } // `|args| { ... }` or `{ ...}` like in `do` expressions - pub fn parse_lambda_block_expr(&self) -> @expr { + pub fn parse_lambda_block_expr(&self) -> @Expr { self.parse_lambda_expr_( || { match *self.token { @@ -2414,12 +2414,12 @@ impl Parser { }, || { let blk = self.parse_block(); - self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)) + self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk)) }) } // `|args| expr` - pub fn parse_lambda_expr(&self) -> @expr { + pub fn parse_lambda_expr(&self) -> @Expr { self.parse_lambda_expr_(|| self.parse_fn_block_decl(), || self.parse_expr()) } @@ -2429,8 +2429,8 @@ impl Parser { // and in parsing a block expr as e.g. in for... pub fn parse_lambda_expr_(&self, parse_decl: &fn() -> fn_decl, - parse_body: &fn() -> @expr) - -> @expr { + parse_body: &fn() -> @Expr) + -> @Expr { let lo = self.last_span.lo; let decl = parse_decl(); let body = parse_body(); @@ -2444,20 +2444,20 @@ impl Parser { }; return self.mk_expr(lo, body.span.hi, - expr_fn_block(decl, fakeblock)); + ExprFnBlock(decl, fakeblock)); } - pub fn parse_else_expr(&self) -> @expr { + pub fn parse_else_expr(&self) -> @Expr { if self.eat_keyword(keywords::If) { return self.parse_if_expr(); } else { let blk = self.parse_block(); - return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); + return self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk)); } } // parse a 'for' .. 'in' expression ('for' token already eaten) - pub fn parse_for_expr(&self) -> @expr { + pub fn parse_for_expr(&self) -> @Expr { // Parse: `for in ` let lo = self.last_span.lo; @@ -2467,7 +2467,7 @@ impl Parser { let loop_block = self.parse_block(); let hi = self.span.hi; - self.mk_expr(lo, hi, expr_for_loop(pat, expr, loop_block)) + self.mk_expr(lo, hi, ExprForLoop(pat, expr, loop_block)) } @@ -2477,8 +2477,8 @@ impl Parser { pub fn parse_sugary_call_expr(&self, lo: BytePos, keyword: ~str, sugar: CallSugar, - ctor: &fn(v: @expr) -> expr_) - -> @expr { + ctor: &fn(v: @Expr) -> Expr_) + -> @Expr { // Parse the callee `foo` in // for foo || { // for foo.bar || { @@ -2490,14 +2490,14 @@ impl Parser { // them as the lambda arguments let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP); match e.node { - expr_call(f, ref args, NoSugar) => { + ExprCall(f, ref args, NoSugar) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, ctor(block)); let args = vec::append((*args).clone(), [last_arg]); - self.mk_expr(lo, block.span.hi, expr_call(f, args, sugar)) + self.mk_expr(lo, block.span.hi, ExprCall(f, args, sugar)) } - expr_method_call(_, f, i, ref tps, ref args, NoSugar) => { + ExprMethodCall(_, f, i, ref tps, ref args, NoSugar) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, ctor(block)); @@ -2509,7 +2509,7 @@ impl Parser { args, sugar)) } - expr_field(f, i, ref tps) => { + ExprField(f, i, ref tps) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, ctor(block)); @@ -2520,8 +2520,8 @@ impl Parser { ~[last_arg], sugar)) } - expr_path(*) | expr_call(*) | expr_method_call(*) | - expr_paren(*) => { + ExprPath(*) | ExprCall(*) | ExprMethodCall(*) | + ExprParen(*) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, ctor(block)); @@ -2542,15 +2542,15 @@ impl Parser { } } - pub fn parse_while_expr(&self) -> @expr { + pub fn parse_while_expr(&self) -> @Expr { let lo = self.last_span.lo; let cond = self.parse_expr(); let body = self.parse_block(); let hi = body.span.hi; - return self.mk_expr(lo, hi, expr_while(cond, body)); + return self.mk_expr(lo, hi, ExprWhile(cond, body)); } - pub fn parse_loop_expr(&self, opt_ident: Option) -> @expr { + pub fn parse_loop_expr(&self, opt_ident: Option) -> @Expr { // loop headers look like 'loop {' or 'loop unsafe {' let is_loop_header = *self.token == token::LBRACE @@ -2562,7 +2562,7 @@ impl Parser { let lo = self.last_span.lo; let body = self.parse_block(); let hi = body.span.hi; - return self.mk_expr(lo, hi, expr_loop(body, opt_ident)); + return self.mk_expr(lo, hi, ExprLoop(body, opt_ident)); } else { // This is a 'continue' expression if opt_ident.is_some() { @@ -2574,9 +2574,9 @@ impl Parser { let ex = if self.token_is_lifetime(&*self.token) { let lifetime = self.get_lifetime(&*self.token); self.bump(); - expr_again(Some(lifetime)) + ExprAgain(Some(lifetime)) } else { - expr_again(None) + ExprAgain(None) }; let hi = self.span.hi; return self.mk_expr(lo, hi, ex); @@ -2591,11 +2591,11 @@ impl Parser { self.look_ahead(2, |t| *t == token::COLON))) } - fn parse_match_expr(&self) -> @expr { + fn parse_match_expr(&self) -> @Expr { let lo = self.last_span.lo; let discriminant = self.parse_expr(); self.commit_expr_expecting(discriminant, token::LBRACE); - let mut arms: ~[arm] = ~[]; + let mut arms: ~[Arm] = ~[]; while *self.token != token::RBRACE { let pats = self.parse_pats(); let mut guard = None; @@ -2624,20 +2624,20 @@ impl Parser { span: expr.span, }; - arms.push(ast::arm { pats: pats, guard: guard, body: blk }); + arms.push(ast::Arm { pats: pats, guard: guard, body: blk }); } let hi = self.span.hi; self.bump(); - return self.mk_expr(lo, hi, expr_match(discriminant, arms)); + return self.mk_expr(lo, hi, ExprMatch(discriminant, arms)); } // parse an expression - pub fn parse_expr(&self) -> @expr { + pub fn parse_expr(&self) -> @Expr { return self.parse_expr_res(UNRESTRICTED); } // parse an expression, subject to the given restriction - fn parse_expr_res(&self, r: restriction) -> @expr { + fn parse_expr_res(&self, r: restriction) -> @Expr { let old = *self.restriction; *self.restriction = r; let e = self.parse_assign_expr(); @@ -2646,7 +2646,7 @@ impl Parser { } // parse the RHS of a local variable declaration (e.g. '= 14;') - fn parse_initializer(&self) -> Option<@expr> { + fn parse_initializer(&self) -> Option<@Expr> { match *self.token { token::EQ => { self.bump(); @@ -2665,7 +2665,7 @@ impl Parser { } // parse patterns, separated by '|' s - fn parse_pats(&self) -> ~[@pat] { + fn parse_pats(&self) -> ~[@Pat] { let mut pats = ~[]; loop { pats.push(self.parse_pat()); @@ -2676,7 +2676,7 @@ impl Parser { fn parse_pat_vec_elements( &self, - ) -> (~[@pat], Option<@pat>, ~[@pat]) { + ) -> (~[@Pat], Option<@Pat>, ~[@Pat]) { let mut before = ~[]; let mut slice = None; let mut after = ~[]; @@ -2699,9 +2699,9 @@ impl Parser { let subpat = self.parse_pat(); if is_slice { match subpat { - @ast::pat { node: pat_wild, _ } => (), - @ast::pat { node: pat_ident(_, _, _), _ } => (), - @ast::pat { span, _ } => self.span_fatal( + @ast::Pat { node: PatWild, _ } => (), + @ast::Pat { node: PatIdent(_, _, _), _ } => (), + @ast::Pat { span, _ } => self.span_fatal( span, "expected an identifier or `_`" ) } @@ -2719,7 +2719,7 @@ impl Parser { } // parse the fields of a struct-like pattern - fn parse_pat_fields(&self) -> (~[ast::field_pat], bool) { + fn parse_pat_fields(&self) -> (~[ast::FieldPat], bool) { let mut fields = ~[]; let mut etc = false; let mut first = true; @@ -2751,19 +2751,19 @@ impl Parser { self.bump(); subpat = self.parse_pat(); } else { - subpat = @ast::pat { + subpat = @ast::Pat { id: self.get_id(), - node: pat_ident(bind_infer, fieldpath, None), + node: PatIdent(BindInfer, fieldpath, None), span: *self.last_span }; } - fields.push(ast::field_pat { ident: fieldname, pat: subpat }); + fields.push(ast::FieldPat { ident: fieldname, pat: subpat }); } return (fields, etc); } // parse a pattern. - pub fn parse_pat(&self) -> @pat { + pub fn parse_pat(&self) -> @Pat { maybe_whole!(self, nt_pat); let lo = self.span.lo; @@ -2773,9 +2773,9 @@ impl Parser { // parse _ token::UNDERSCORE => { self.bump(); - pat = pat_wild; + pat = PatWild; hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2788,22 +2788,22 @@ impl Parser { hi = sub.span.hi; // HACK: parse @"..." as a literal of a vstore @str pat = match sub.node { - pat_lit(e@@expr { - node: expr_lit(@codemap::Spanned { + PatLit(e@@Expr { + node: ExprLit(@codemap::Spanned { node: lit_str(_), span: _}), _ }) => { - let vst = @expr { + let vst = @Expr { id: self.get_id(), - node: expr_vstore(e, expr_vstore_box), + node: ExprVstore(e, ExprVstoreBox), span: mk_sp(lo, hi), }; - pat_lit(vst) + PatLit(vst) } - _ => pat_box(sub) + _ => PatBox(sub) }; hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2816,22 +2816,22 @@ impl Parser { hi = sub.span.hi; // HACK: parse ~"..." as a literal of a vstore ~str pat = match sub.node { - pat_lit(e@@expr { - node: expr_lit(@codemap::Spanned { + PatLit(e@@Expr { + node: ExprLit(@codemap::Spanned { node: lit_str(_), span: _}), _ }) => { - let vst = @expr { + let vst = @Expr { id: self.get_id(), - node: expr_vstore(e, expr_vstore_uniq), + node: ExprVstore(e, ExprVstoreUniq), span: mk_sp(lo, hi), }; - pat_lit(vst) + PatLit(vst) } - _ => pat_uniq(sub) + _ => PatUniq(sub) }; hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2845,21 +2845,21 @@ impl Parser { hi = sub.span.hi; // HACK: parse &"..." as a literal of a borrowed str pat = match sub.node { - pat_lit(e@@expr { - node: expr_lit(@codemap::Spanned { + PatLit(e@@Expr { + node: ExprLit(@codemap::Spanned { node: lit_str(_), span: _}), _ }) => { - let vst = @expr { + let vst = @Expr { id: self.get_id(), - node: expr_vstore(e, expr_vstore_slice), + node: ExprVstore(e, ExprVstoreSlice), span: mk_sp(lo, hi) }; - pat_lit(vst) + PatLit(vst) } - _ => pat_region(sub) + _ => PatRegion(sub) }; hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2870,9 +2870,9 @@ impl Parser { let (_, _) = self.parse_pat_fields(); self.bump(); self.obsolete(*self.span, ObsoleteRecordPattern); - pat = pat_wild; + pat = PatWild; hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2887,8 +2887,8 @@ impl Parser { let lit = @codemap::Spanned { node: lit_nil, span: mk_sp(lo, hi)}; - let expr = self.mk_expr(lo, hi, expr_lit(lit)); - pat = pat_lit(expr); + let expr = self.mk_expr(lo, hi, ExprLit(lit)); + pat = PatLit(expr); } else { let mut fields = ~[self.parse_pat()]; if self.look_ahead(1, |t| *t != token::RPAREN) { @@ -2899,10 +2899,10 @@ impl Parser { } if fields.len() == 1 { self.expect(&token::COMMA); } self.expect(&token::RPAREN); - pat = pat_tup(fields); + pat = PatTup(fields); } hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2915,9 +2915,9 @@ impl Parser { self.parse_pat_vec_elements(); self.expect(&token::RBRACKET); - pat = ast::pat_vec(before, slice, after); + pat = ast::PatVec(before, slice, after); hi = self.last_span.hi; - return @ast::pat { + return @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi) @@ -2940,18 +2940,18 @@ impl Parser { let path = self.parse_path(LifetimeAndTypesWithColons) .path; let hi = self.span.hi; - self.mk_expr(lo, hi, expr_path(path)) + self.mk_expr(lo, hi, ExprPath(path)) } else { self.parse_literal_maybe_minus() }; - pat = pat_range(val, end); + pat = PatRange(val, end); } else { - pat = pat_lit(val); + pat = PatLit(val); } } else if self.eat_keyword(keywords::Ref) { // parse ref pat let mutbl = self.parse_mutability(); - pat = self.parse_pat_ident(bind_by_ref(mutbl)); + pat = self.parse_pat_ident(BindByRef(mutbl)); } else { let can_be_enum_or_struct = do self.look_ahead(1) |t| { match *t { @@ -2965,7 +2965,7 @@ impl Parser { let start = self.parse_expr_res(RESTRICT_NO_BAR_OP); self.eat(&token::DOTDOT); let end = self.parse_expr_res(RESTRICT_NO_BAR_OP); - pat = pat_range(start, end); + pat = PatRange(start, end); } else if is_plain_ident(&*self.token) && !can_be_enum_or_struct { let name = self.parse_path(NoTypesAllowed).path; let sub; @@ -2976,7 +2976,7 @@ impl Parser { // or just foo sub = None; } - pat = pat_ident(bind_infer, name, sub); + pat = PatIdent(BindInfer, name, sub); } else { // parse an enum pat let enum_path = self.parse_path(LifetimeAndTypesWithColons) @@ -2987,10 +2987,10 @@ impl Parser { let (fields, etc) = self.parse_pat_fields(); self.bump(); - pat = pat_struct(enum_path, fields, etc); + pat = PatStruct(enum_path, fields, etc); } _ => { - let mut args: ~[@pat] = ~[]; + let mut args: ~[@Pat] = ~[]; match *self.token { token::LPAREN => { let is_star = do self.look_ahead(1) |t| { @@ -3004,7 +3004,7 @@ impl Parser { self.bump(); self.bump(); self.expect(&token::RPAREN); - pat = pat_enum(enum_path, None); + pat = PatEnum(enum_path, None); } else { args = self.parse_unspanned_seq( &token::LPAREN, @@ -3012,7 +3012,7 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_pat() ); - pat = pat_enum(enum_path, Some(args)); + pat = PatEnum(enum_path, Some(args)); } }, _ => { @@ -3020,11 +3020,11 @@ impl Parser { // it could still be either an enum // or an identifier pattern, resolve // will sort it out: - pat = pat_ident(bind_infer, + pat = PatIdent(BindInfer, enum_path, None); } else { - pat = pat_enum(enum_path, Some(args)); + pat = PatEnum(enum_path, Some(args)); } } } @@ -3033,7 +3033,7 @@ impl Parser { } } hi = self.last_span.hi; - @ast::pat { + @ast::Pat { id: self.get_id(), node: pat, span: mk_sp(lo, hi), @@ -3044,8 +3044,8 @@ impl Parser { // used by the copy foo and ref foo patterns to give a good // error message when parsing mistakes like ref foo(a,b) fn parse_pat_ident(&self, - binding_mode: ast::binding_mode) - -> ast::pat_ { + binding_mode: ast::BindingMode) + -> ast::Pat_ { if !is_plain_ident(&*self.token) { self.span_fatal(*self.last_span, "expected identifier, found path"); @@ -3070,7 +3070,7 @@ impl Parser { "expected identifier, found enum pattern"); } - pat_ident(binding_mode, name, sub) + PatIdent(binding_mode, name, sub) } // parse a local variable declaration @@ -3100,7 +3100,7 @@ impl Parser { } // parse a "let" stmt - fn parse_let(&self) -> @decl { + fn parse_let(&self) -> @Decl { let is_mutbl = self.eat_keyword(keywords::Mut); let lo = self.span.lo; let local = self.parse_local(is_mutbl); @@ -3108,7 +3108,7 @@ impl Parser { let _ = self.parse_local(is_mutbl); self.obsolete(*self.span, ObsoleteMultipleLocalDecl); } - return @spanned(lo, self.last_span.hi, decl_local(local)); + return @spanned(lo, self.last_span.hi, DeclLocal(local)); } // parse a structure field @@ -3132,7 +3132,7 @@ impl Parser { // parse a statement. may include decl. // precondition: any attributes are parsed already - pub fn parse_stmt(&self, item_attrs: ~[Attribute]) -> @stmt { + pub fn parse_stmt(&self, item_attrs: ~[Attribute]) -> @Stmt { maybe_whole!(self, nt_stmt); fn check_expected_item(p: &Parser, found_attrs: bool) { @@ -3147,7 +3147,7 @@ impl Parser { check_expected_item(self, !item_attrs.is_empty()); self.expect_keyword(keywords::Let); let decl = self.parse_let(); - return @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); + return @spanned(lo, decl.span.hi, StmtDecl(decl, self.get_id())); } else if is_ident(&*self.token) && !token::is_any_keyword(self.token) && self.look_ahead(1, |t| *t == token::NOT) { @@ -3186,12 +3186,12 @@ impl Parser { let hi = self.span.hi; if id == token::special_idents::invalid { - return @spanned(lo, hi, stmt_mac( + return @spanned(lo, hi, StmtMac( spanned(lo, hi, mac_invoc_tt(pth, tts)), false)); } else { // if it has a special ident, it's definitely an item - return @spanned(lo, hi, stmt_decl( - @spanned(lo, hi, decl_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))), @@ -3204,8 +3204,8 @@ impl Parser { match self.parse_item_or_view_item(item_attrs, false) { iovi_item(i) => { let hi = i.span.hi; - let decl = @spanned(lo, hi, decl_item(i)); - return @spanned(lo, hi, stmt_decl(decl, self.get_id())); + let decl = @spanned(lo, hi, DeclItem(i)); + return @spanned(lo, hi, StmtDecl(decl, self.get_id())); } iovi_view_item(vi) => { self.span_fatal(vi.span, @@ -3221,12 +3221,12 @@ impl Parser { // Remainder are line-expr stmts. let e = self.parse_expr_res(RESTRICT_STMT_EXPR); - return @spanned(lo, e.span.hi, stmt_expr(e, self.get_id())); + return @spanned(lo, e.span.hi, StmtExpr(e, self.get_id())); } } // is this expression a successfully-parsed statement? - fn expr_is_complete(&self, e: @expr) -> bool { + fn expr_is_complete(&self, e: @Expr) -> bool { return *self.restriction == RESTRICT_STMT_EXPR && !classify::expr_requires_semi_to_be_stmt(e); } @@ -3284,9 +3284,9 @@ impl Parser { false, false); for item in items.iter() { - let decl = @spanned(item.span.lo, item.span.hi, decl_item(*item)); + let decl = @spanned(item.span.lo, item.span.hi, DeclItem(*item)); stmts.push(@spanned(item.span.lo, item.span.hi, - stmt_decl(decl, self.get_id()))); + StmtDecl(decl, self.get_id()))); } let mut attributes_box = attrs_remaining; @@ -3310,7 +3310,7 @@ impl Parser { let stmt = self.parse_stmt(attributes_box); attributes_box = ~[]; match stmt.node { - stmt_expr(e, stmt_id) => { + StmtExpr(e, stmt_id) => { // expression without semicolon if classify::stmt_ends_with_semi(stmt) { // Just check for errors and recover; do not eat semicolon yet. @@ -3321,7 +3321,7 @@ impl Parser { token::SEMI => { self.bump(); stmts.push(@codemap::Spanned { - node: stmt_semi(e, stmt_id), + node: StmtSemi(e, stmt_id), span: stmt.span, }); } @@ -3333,7 +3333,7 @@ impl Parser { } } } - stmt_mac(ref m, _) => { + StmtMac(ref m, _) => { // statement macro; might be an expr let has_semi; match *self.token { @@ -3358,7 +3358,7 @@ impl Parser { if has_semi { self.bump(); stmts.push(@codemap::Spanned { - node: stmt_mac((*m).clone(), true), + node: StmtMac((*m).clone(), true), span: stmt.span, }); } @@ -3531,7 +3531,7 @@ impl Parser { &fn(&Parser) -> arg_or_capture_item ) -> (explicit_self, fn_decl) { fn maybe_parse_explicit_self( - cnstr: &fn(v: mutability) -> ast::explicit_self_, + cnstr: &fn(v: Mutability) -> ast::explicit_self_, p: &Parser ) -> ast::explicit_self_ { // We need to make sure it isn't a mode or a type @@ -3562,7 +3562,7 @@ impl Parser { if this.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { this.bump(); this.expect_self_ident(); - sty_region(None, m_imm) + sty_region(None, MutImmutable) } else if this.look_ahead(1, |t| this.token_is_mutability(t)) && this.look_ahead(2, |t| token::is_keyword(keywords::Self, @@ -3578,7 +3578,7 @@ impl Parser { this.bump(); let lifetime = this.parse_lifetime(); this.expect_self_ident(); - sty_region(Some(lifetime), m_imm) + sty_region(Some(lifetime), MutImmutable) } else if this.look_ahead(1, |t| this.token_is_lifetime(t)) && this.look_ahead(2, |t| this.token_is_mutability(t)) && this.look_ahead(3, |t| token::is_keyword(keywords::Self, @@ -3607,7 +3607,7 @@ impl Parser { } token::TILDE => { maybe_parse_explicit_self(|mutability| { - if mutability != m_imm { + if mutability != MutImmutable { self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); } sty_uniq @@ -4077,7 +4077,7 @@ impl Parser { } fn parse_item_const(&self) -> item_info { - let m = if self.eat_keyword(keywords::Mut) {m_mutbl} else {m_imm}; + let m = if self.eat_keyword(keywords::Mut) {MutMutable} else {MutImmutable}; let id = self.parse_ident(); self.expect(&token::COLON); let ty = self.parse_ty(false); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index c9d61be6b0ebf..1092b2ddf575d 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -100,9 +100,9 @@ pub enum Token { pub enum nonterminal { nt_item(@ast::item), nt_block(~ast::Block), - nt_stmt(@ast::stmt), - nt_pat( @ast::pat), - nt_expr(@ast::expr), + nt_stmt(@ast::Stmt), + nt_pat( @ast::Pat), + nt_expr(@ast::Expr), nt_ty( ~ast::Ty), nt_ident(~ast::Ident, bool), nt_attr(@ast::Attribute), // #[foo] @@ -353,26 +353,26 @@ pub mod special_idents { * Maps a token to a record specifying the corresponding binary * operator */ -pub fn token_to_binop(tok: &Token) -> Option { +pub fn token_to_binop(tok: &Token) -> Option { match *tok { - BINOP(STAR) => Some(ast::mul), - BINOP(SLASH) => Some(ast::div), - BINOP(PERCENT) => Some(ast::rem), - BINOP(PLUS) => Some(ast::add), - BINOP(MINUS) => Some(ast::subtract), - BINOP(SHL) => Some(ast::shl), - BINOP(SHR) => Some(ast::shr), - BINOP(AND) => Some(ast::bitand), - BINOP(CARET) => Some(ast::bitxor), - BINOP(OR) => Some(ast::bitor), - LT => Some(ast::lt), - LE => Some(ast::le), - GE => Some(ast::ge), - GT => Some(ast::gt), - EQEQ => Some(ast::eq), - NE => Some(ast::ne), - ANDAND => Some(ast::and), - OROR => Some(ast::or), + BINOP(STAR) => Some(ast::BiMul), + BINOP(SLASH) => Some(ast::BiDiv), + BINOP(PERCENT) => Some(ast::BiRem), + BINOP(PLUS) => Some(ast::BiAdd), + BINOP(MINUS) => Some(ast::BiSub), + BINOP(SHL) => Some(ast::BiShl), + BINOP(SHR) => Some(ast::BiShr), + BINOP(AND) => Some(ast::BiBitAnd), + BINOP(CARET) => Some(ast::BiBitXor), + BINOP(OR) => Some(ast::BiBitOr), + LT => Some(ast::BiLt), + LE => Some(ast::BiLe), + GE => Some(ast::BiGe), + GT => Some(ast::BiGt), + EQEQ => Some(ast::BiEq), + NE => Some(ast::BiNe), + ANDAND => Some(ast::BiAnd), + OROR => Some(ast::BiOr), _ => None } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c03bcca7bf9e8..e1a0e1bf08da6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -33,8 +33,8 @@ use std::io; pub enum ann_node<'self> { node_block(@ps, &'self ast::Block), node_item(@ps, &'self ast::item), - node_expr(@ps, &'self ast::expr), - node_pat(@ps, &'self ast::pat), + node_expr(@ps, &'self ast::Expr), + node_pat(@ps, &'self ast::Pat), } pub struct pp_ann { pre: @fn(ann_node), @@ -148,11 +148,11 @@ pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~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: @ident_interner) -> ~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: @ident_interner) -> ~str { to_str(e, print_expr, intr) } @@ -168,7 +168,7 @@ pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~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: @ident_interner) -> ~str { to_str(s, print_stmt, intr) } @@ -346,7 +346,7 @@ pub fn commasep_cmnt(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T), end(s); } -pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) { +pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::Expr]) { commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span); } @@ -385,8 +385,8 @@ pub fn print_type(s: @ps, ty: &ast::Ty) { ast::ty_vec(ref mt) => { word(s.s, "["); match mt.mutbl { - ast::m_mutbl => word_space(s, "mut"), - ast::m_imm => () + ast::MutMutable => word_space(s, "mut"), + ast::MutImmutable => () } print_type(s, mt.ty); word(s.s, "]"); @@ -427,8 +427,8 @@ pub fn print_type(s: @ps, ty: &ast::Ty) { ast::ty_fixed_length_vec(ref mt, v) => { word(s.s, "["); match mt.mutbl { - ast::m_mutbl => word_space(s, "mut"), - ast::m_imm => () + ast::MutMutable => word_space(s, "mut"), + ast::MutImmutable => () } print_type(s, mt.ty); word(s.s, ", .."); @@ -487,7 +487,7 @@ pub fn print_item(s: @ps, item: &ast::item) { match item.node { ast::item_static(ref ty, m, expr) => { head(s, visibility_qualified(item.vis, "static")); - if m == ast::m_mutbl { + if m == ast::MutMutable { word_space(s, "mut"); } print_ident(s, item.ident); @@ -886,22 +886,22 @@ pub fn print_attribute(s: @ps, attr: &ast::Attribute) { } -pub fn print_stmt(s: @ps, st: &ast::stmt) { +pub fn print_stmt(s: @ps, st: &ast::Stmt) { maybe_print_comment(s, st.span.lo); match st.node { - ast::stmt_decl(decl, _) => { + ast::StmtDecl(decl, _) => { print_decl(s, decl); } - ast::stmt_expr(expr, _) => { + ast::StmtExpr(expr, _) => { space_if_not_bol(s); print_expr(s, expr); } - ast::stmt_semi(expr, _) => { + ast::StmtSemi(expr, _) => { space_if_not_bol(s); print_expr(s, expr); word(s.s, ";"); } - ast::stmt_mac(ref mac, semi) => { + ast::StmtMac(ref mac, semi) => { space_if_not_bol(s); print_mac(s, mac); if semi { word(s.s, ";"); } @@ -978,19 +978,19 @@ pub fn print_possibly_embedded_block_(s: @ps, (s.ann.post)(ann_node); } -pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::Block, - elseopt: Option<@ast::expr>, chk: bool) { +pub fn print_if(s: @ps, 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(s.s); print_block(s, blk); - fn do_else(s: @ps, els: Option<@ast::expr>) { + fn do_else(s: @ps, els: Option<@ast::Expr>) { match els { Some(_else) => { match _else.node { // "another else-if" - ast::expr_if(i, ref t, e) => { + ast::ExprIf(i, ref t, e) => { cbox(s, indent_unit - 1u); ibox(s, 0u); word(s.s, " else if "); @@ -1000,7 +1000,7 @@ pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::Block, do_else(s, e); } // "final else" - ast::expr_block(ref b) => { + ast::ExprBlock(ref b) => { cbox(s, indent_unit - 1u); ibox(s, 0u); word(s.s, " else "); @@ -1030,29 +1030,29 @@ pub fn print_mac(s: @ps, m: &ast::mac) { } } -pub fn print_vstore(s: @ps, t: ast::vstore) { +pub fn print_vstore(s: @ps, t: ast::Vstore) { match t { - ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)), - ast::vstore_fixed(None) => word(s.s, "_"), - ast::vstore_uniq => word(s.s, "~"), - ast::vstore_box => word(s.s, "@"), - ast::vstore_slice(ref r) => { + ast::VstoreFixed(Some(i)) => word(s.s, fmt!("%u", i)), + ast::VstoreFixed(None) => word(s.s, "_"), + ast::VstoreUniq => word(s.s, "~"), + ast::VstoreBox => word(s.s, "@"), + ast::VstoreSlice(ref r) => { word(s.s, "&"); print_opt_lifetime(s, r); } } } -pub fn print_expr_vstore(s: @ps, t: ast::expr_vstore) { +pub fn print_expr_vstore(s: @ps, t: ast::ExprVstore) { match t { - ast::expr_vstore_uniq => word(s.s, "~"), - ast::expr_vstore_box => word(s.s, "@"), - ast::expr_vstore_mut_box => { + ast::ExprVstoreUniq => word(s.s, "~"), + ast::ExprVstoreBox => word(s.s, "@"), + ast::ExprVstoreMutBox => { word(s.s, "@"); word(s.s, "mut"); } - ast::expr_vstore_slice => word(s.s, "&"), - ast::expr_vstore_mut_slice => { + ast::ExprVstoreSlice => word(s.s, "&"), + ast::ExprVstoreMutSlice => { word(s.s, "&"); word(s.s, "mut"); } @@ -1061,8 +1061,8 @@ pub fn print_expr_vstore(s: @ps, t: ast::expr_vstore) { pub fn print_call_pre(s: @ps, sugar: ast::CallSugar, - base_args: &mut ~[@ast::expr]) - -> Option<@ast::expr> { + base_args: &mut ~[@ast::Expr]) + -> Option<@ast::Expr> { match sugar { ast::DoSugar => { head(s, "do"); @@ -1078,8 +1078,8 @@ pub fn print_call_pre(s: @ps, pub fn print_call_post(s: @ps, sugar: ast::CallSugar, - blk: &Option<@ast::expr>, - base_args: &mut ~[@ast::expr]) { + 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); @@ -1089,7 +1089,7 @@ pub fn print_call_post(s: @ps, nbsp(s); match blk.unwrap().node { // need to handle closures specifically - ast::expr_do_body(e) => { + ast::ExprDoBody(e) => { end(s); // we close our head box; closure // will create it's own. print_expr(s, e); @@ -1103,7 +1103,7 @@ pub fn print_call_post(s: @ps, } } -pub fn print_expr(s: @ps, expr: &ast::expr) { +pub fn print_expr(s: @ps, expr: &ast::Expr) { fn print_field(s: @ps, field: &ast::Field) { ibox(s, indent_unit); print_ident(s, field.ident); @@ -1118,14 +1118,14 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { let ann_node = node_expr(s, expr); (s.ann.pre)(ann_node); match expr.node { - ast::expr_vstore(e, v) => { + ast::ExprVstore(e, v) => { print_expr_vstore(s, v); print_expr(s, e); }, - ast::expr_vec(ref exprs, mutbl) => { + ast::ExprVec(ref exprs, mutbl) => { ibox(s, indent_unit); word(s.s, "["); - if mutbl == ast::m_mutbl { + if mutbl == ast::MutMutable { word(s.s, "mut"); if exprs.len() > 0u { nbsp(s); } } @@ -1134,10 +1134,10 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { end(s); } - ast::expr_repeat(element, count, mutbl) => { + ast::ExprRepeat(element, count, mutbl) => { ibox(s, indent_unit); word(s.s, "["); - if mutbl == ast::m_mutbl { + if mutbl == ast::MutMutable { word(s.s, "mut"); nbsp(s); } @@ -1149,7 +1149,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { end(s); } - ast::expr_struct(ref path, ref fields, wth) => { + ast::ExprStruct(ref path, ref fields, wth) => { print_path(s, path, true); word(s.s, "{"); commasep_cmnt(s, consistent, (*fields), print_field, get_span); @@ -1166,7 +1166,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { } word(s.s, "}"); } - ast::expr_tup(ref exprs) => { + ast::ExprTup(ref exprs) => { popen(s); commasep_exprs(s, inconsistent, *exprs); if exprs.len() == 1 { @@ -1174,13 +1174,13 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { } pclose(s); } - ast::expr_call(func, ref args, sugar) => { + ast::ExprCall(func, ref args, sugar) => { let mut base_args = (*args).clone(); let blk = print_call_pre(s, sugar, &mut base_args); print_expr(s, func); print_call_post(s, sugar, &blk, &mut base_args); } - ast::expr_method_call(_, func, ident, ref tys, ref args, sugar) => { + ast::ExprMethodCall(_, func, ident, ref tys, ref args, sugar) => { let mut base_args = (*args).clone(); let blk = print_call_pre(s, sugar, &mut base_args); print_expr(s, func); @@ -1193,43 +1193,43 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { } print_call_post(s, sugar, &blk, &mut base_args); } - ast::expr_binary(_, op, lhs, rhs) => { + ast::ExprBinary(_, op, lhs, rhs) => { print_expr(s, lhs); space(s.s); word_space(s, ast_util::binop_to_str(op)); print_expr(s, rhs); } - ast::expr_unary(_, op, expr) => { + ast::ExprUnary(_, op, expr) => { word(s.s, ast_util::unop_to_str(op)); print_expr(s, expr); } - ast::expr_addr_of(m, expr) => { + ast::ExprAddrOf(m, expr) => { word(s.s, "&"); print_mutability(s, m); // Avoid `& &e` => `&&e`. match (m, &expr.node) { - (ast::m_imm, &ast::expr_addr_of(*)) => space(s.s), + (ast::MutImmutable, &ast::ExprAddrOf(*)) => space(s.s), _ => { } } print_expr(s, expr); } - ast::expr_lit(lit) => print_literal(s, lit), - ast::expr_cast(expr, ref ty) => { + ast::ExprLit(lit) => print_literal(s, lit), + ast::ExprCast(expr, ref ty) => { print_expr(s, expr); space(s.s); word_space(s, "as"); print_type(s, ty); } - ast::expr_if(test, ref blk, elseopt) => { + ast::ExprIf(test, ref blk, elseopt) => { print_if(s, test, blk, elseopt, false); } - ast::expr_while(test, ref blk) => { + ast::ExprWhile(test, ref blk) => { head(s, "while"); print_expr(s, test); space(s.s); print_block(s, blk); } - ast::expr_for_loop(pat, iter, ref blk) => { + ast::ExprForLoop(pat, iter, ref blk) => { head(s, "for"); print_pat(s, pat); space(s.s); @@ -1238,7 +1238,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { space(s.s); print_block(s, blk); } - ast::expr_loop(ref blk, opt_ident) => { + ast::ExprLoop(ref blk, opt_ident) => { for ident in opt_ident.iter() { word(s.s, "'"); print_ident(s, *ident); @@ -1248,7 +1248,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { space(s.s); print_block(s, blk); } - ast::expr_match(expr, ref arms) => { + ast::ExprMatch(expr, ref arms) => { cbox(s, indent_unit); ibox(s, 4); word_nbsp(s, "match"); @@ -1288,7 +1288,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { match arm.body.expr { Some(expr) => { match expr.node { - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { // the block will close the pattern's ibox print_block_unclosed_indent( s, blk, indent_unit); @@ -1313,7 +1313,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { } bclose_(s, expr.span, indent_unit); } - ast::expr_fn_block(ref decl, ref body) => { + ast::ExprFnBlock(ref decl, ref body) => { // in do/for blocks we don't want to show an empty // argument list, but at this point we don't know which // we are inside. @@ -1326,7 +1326,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { assert!(body.expr.is_some()); // we extract the block, so as not to create another set of boxes match body.expr.unwrap().node { - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { print_block_unclosed(s, blk); } _ => { @@ -1340,30 +1340,30 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { // empty box to satisfy the close. ibox(s, 0); } - ast::expr_do_body(body) => { + ast::ExprDoBody(body) => { print_expr(s, body); } - ast::expr_block(ref blk) => { + ast::ExprBlock(ref blk) => { // containing cbox, will be closed by print-block at } cbox(s, indent_unit); // head-box, will be closed by print-block after { ibox(s, 0u); print_block(s, blk); } - ast::expr_assign(lhs, rhs) => { + ast::ExprAssign(lhs, rhs) => { print_expr(s, lhs); space(s.s); word_space(s, "="); print_expr(s, rhs); } - ast::expr_assign_op(_, op, lhs, rhs) => { + ast::ExprAssignOp(_, op, lhs, rhs) => { print_expr(s, lhs); space(s.s); word(s.s, ast_util::binop_to_str(op)); word_space(s, "="); print_expr(s, rhs); } - ast::expr_field(expr, id, ref tys) => { + ast::ExprField(expr, id, ref tys) => { print_expr(s, expr); word(s.s, "."); print_ident(s, id); @@ -1373,15 +1373,15 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { word(s.s, ">"); } } - ast::expr_index(_, expr, index) => { + ast::ExprIndex(_, expr, index) => { print_expr(s, expr); word(s.s, "["); print_expr(s, index); word(s.s, "]"); } - ast::expr_path(ref path) => print_path(s, path, true), - ast::expr_self => word(s.s, "self"), - ast::expr_break(opt_ident) => { + ast::ExprPath(ref path) => print_path(s, path, true), + ast::ExprSelf => word(s.s, "self"), + ast::ExprBreak(opt_ident) => { word(s.s, "break"); space(s.s); for ident in opt_ident.iter() { @@ -1390,7 +1390,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { space(s.s); } } - ast::expr_again(opt_ident) => { + ast::ExprAgain(opt_ident) => { word(s.s, "loop"); space(s.s); for ident in opt_ident.iter() { @@ -1399,14 +1399,14 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { space(s.s) } } - ast::expr_ret(result) => { + ast::ExprRet(result) => { word(s.s, "return"); match result { Some(expr) => { word(s.s, " "); print_expr(s, expr); } _ => () } } - ast::expr_log(lexp, expr) => { + ast::ExprLog(lexp, expr) => { word(s.s, "__log"); popen(s); print_expr(s, lexp); @@ -1415,7 +1415,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { print_expr(s, expr); pclose(s); } - ast::expr_inline_asm(ref a) => { + ast::ExprInlineAsm(ref a) => { if a.volatile { word(s.s, "__volatile__ asm!"); } else { @@ -1443,8 +1443,8 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { print_string(s, a.clobbers); pclose(s); } - ast::expr_mac(ref m) => print_mac(s, m), - ast::expr_paren(e) => { + ast::ExprMac(ref m) => print_mac(s, m), + ast::ExprParen(e) => { popen(s); print_expr(s, e); pclose(s); @@ -1462,10 +1462,10 @@ pub fn print_local_decl(s: @ps, loc: &ast::Local) { } } -pub fn print_decl(s: @ps, decl: &ast::decl) { +pub fn print_decl(s: @ps, decl: &ast::Decl) { maybe_print_comment(s, decl.span.lo); match decl.node { - ast::decl_local(ref loc) => { + ast::DeclLocal(ref loc) => { space_if_not_bol(s); ibox(s, indent_unit); word_nbsp(s, "let"); @@ -1491,7 +1491,7 @@ pub fn print_decl(s: @ps, decl: &ast::decl) { print_local(s, *loc); end(s); } - ast::decl_item(item) => print_item(s, item) + ast::DeclItem(item) => print_item(s, item) } } @@ -1499,7 +1499,7 @@ pub fn print_ident(s: @ps, ident: ast::Ident) { word(s.s, ident_to_str(&ident)); } -pub fn print_for_decl(s: @ps, loc: &ast::Local, coll: &ast::expr) { +pub fn print_for_decl(s: @ps, loc: &ast::Local, coll: &ast::Expr) { print_local_decl(s, loc); space(s.s); word_space(s, "in"); @@ -1565,21 +1565,21 @@ pub fn print_bounded_path(s: @ps, path: &ast::Path, print_path_(s, path, false, bounds) } -pub fn print_pat(s: @ps, pat: &ast::pat) { +pub fn print_pat(s: @ps, pat: &ast::Pat) { maybe_print_comment(s, pat.span.lo); let ann_node = node_pat(s, pat); (s.ann.pre)(ann_node); /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ match pat.node { - ast::pat_wild => word(s.s, "_"), - ast::pat_ident(binding_mode, ref path, sub) => { + ast::PatWild => word(s.s, "_"), + ast::PatIdent(binding_mode, ref path, sub) => { match binding_mode { - ast::bind_by_ref(mutbl) => { + ast::BindByRef(mutbl) => { word_nbsp(s, "ref"); print_mutability(s, mutbl); } - ast::bind_infer => {} + ast::BindInfer => {} } print_path(s, path, true); match sub { @@ -1590,7 +1590,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat) { None => () } } - ast::pat_enum(ref path, ref args_) => { + ast::PatEnum(ref path, ref args_) => { print_path(s, path, true); match *args_ { None => word(s.s, "(*)"), @@ -1604,17 +1604,17 @@ pub fn print_pat(s: @ps, pat: &ast::pat) { } } } - ast::pat_struct(ref path, ref fields, etc) => { + ast::PatStruct(ref path, ref fields, etc) => { print_path(s, path, true); word(s.s, "{"); - fn print_field(s: @ps, f: &ast::field_pat) { + fn print_field(s: @ps, f: &ast::FieldPat) { cbox(s, indent_unit); print_ident(s, f.ident); word_space(s, ":"); print_pat(s, f.pat); end(s); } - fn get_span(f: &ast::field_pat) -> codemap::Span { return f.pat.span; } + fn get_span(f: &ast::FieldPat) -> codemap::Span { return f.pat.span; } commasep_cmnt(s, consistent, *fields, |s, f| print_field(s,f), get_span); @@ -1624,7 +1624,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat) { } word(s.s, "}"); } - ast::pat_tup(ref elts) => { + ast::PatTup(ref elts) => { popen(s); commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p)); if elts.len() == 1 { @@ -1632,26 +1632,26 @@ pub fn print_pat(s: @ps, pat: &ast::pat) { } pclose(s); } - ast::pat_box(inner) => { + ast::PatBox(inner) => { word(s.s, "@"); print_pat(s, inner); } - ast::pat_uniq(inner) => { + ast::PatUniq(inner) => { word(s.s, "~"); print_pat(s, inner); } - ast::pat_region(inner) => { + ast::PatRegion(inner) => { word(s.s, "&"); print_pat(s, inner); } - ast::pat_lit(e) => print_expr(s, e), - ast::pat_range(begin, end) => { + ast::PatLit(e) => print_expr(s, e), + ast::PatRange(begin, end) => { print_expr(s, begin); space(s.s); word(s.s, ".."); print_expr(s, end); } - ast::pat_vec(ref before, slice, ref after) => { + ast::PatVec(ref before, slice, ref after) => { word(s.s, "["); do commasep(s, inconsistent, *before) |s, &p| { print_pat(s, p); @@ -1900,10 +1900,10 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) { end(s); // end outer head-block } -pub fn print_mutability(s: @ps, mutbl: ast::mutability) { +pub fn print_mutability(s: @ps, mutbl: ast::Mutability) { match mutbl { - ast::m_mutbl => word_nbsp(s, "mut"), - ast::m_imm => {/* nothing */ } + ast::MutMutable => word_nbsp(s, "mut"), + ast::MutImmutable => {/* nothing */ } } } @@ -1921,7 +1921,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) { ast::ty_infer => print_pat(s, input.pat), _ => { match input.pat.node { - ast::pat_ident(_, ref path, _) if + ast::PatIdent(_, ref path, _) if path.segments.len() == 1 && path.segments[0].identifier == parse::token::special_idents::invalid => { diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index a421d44e2e36d..ca1e53f7fcd9e 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -47,7 +47,7 @@ pub fn string_to_crate (source_str : @str) -> @ast::Crate { } // parse a string, return an expr -pub fn string_to_expr (source_str : @str) -> @ast::expr { +pub fn string_to_expr (source_str : @str) -> @ast::Expr { do with_error_checking_parse(source_str) |p| { p.parse_expr() } @@ -69,7 +69,7 @@ pub fn string_to_item_and_sess (source_str : @str) -> (Option<@ast::item>,@mut P } // parse a string, return a stmt -pub fn string_to_stmt(source_str : @str) -> @ast::stmt { +pub fn string_to_stmt(source_str : @str) -> @ast::Stmt { do with_error_checking_parse(source_str) |p| { p.parse_stmt(~[]) } @@ -77,7 +77,7 @@ pub fn string_to_stmt(source_str : @str) -> @ast::stmt { // parse a string, return a pat. Uses "irrefutable"... which doesn't // (currently) affect parsing. -pub fn string_to_pat(source_str : @str) -> @ast::pat { +pub fn string_to_pat(source_str : @str) -> @ast::Pat { string_to_parser(source_str).parse_pat() } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6ccaece27b981..ae2044cb97952 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -73,12 +73,12 @@ pub trait Visitor { 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) } - fn visit_arm(&mut self, a:&arm, e:E) { walk_arm(self, a, e) } - fn visit_pat(&mut self, p:@pat, e:E) { walk_pat(self, p, e) } - fn visit_decl(&mut self, d:@decl, e:E) { walk_decl(self, d, e) } - fn visit_expr(&mut self, ex:@expr, e:E) { walk_expr(self, ex, e) } - fn visit_expr_post(&mut self, _ex:@expr, _e:E) { } + fn visit_stmt(&mut self, s:@Stmt, e:E) { walk_stmt(self, s, e) } + fn visit_arm(&mut self, a:&Arm, e:E) { walk_arm(self, a, e) } + fn visit_pat(&mut self, p:@Pat, e:E) { walk_pat(self, p, e) } + fn visit_decl(&mut self, d:@Decl, e:E) { walk_decl(self, d, e) } + fn visit_expr(&mut self, ex:@Expr, e:E) { walk_expr(self, ex, e) } + fn visit_expr_post(&mut self, _ex:@Expr, _e:E) { } fn visit_ty(&mut self, _t:&Ty, _e: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) { @@ -111,22 +111,22 @@ impl Visitor for @mut Visitor { fn visit_block(&mut self, a:&Block, e:E) { (*self).visit_block(a, e) } - fn visit_stmt(&mut self, a:@stmt, e:E) { + fn visit_stmt(&mut self, a:@Stmt, e:E) { (*self).visit_stmt(a, e) } - fn visit_arm(&mut self, a:&arm, e:E) { + fn visit_arm(&mut self, a:&Arm, e:E) { (*self).visit_arm(a, e) } - fn visit_pat(&mut self, a:@pat, e:E) { + fn visit_pat(&mut self, a:@Pat, e:E) { (*self).visit_pat(a, e) } - fn visit_decl(&mut self, a:@decl, e:E) { + fn visit_decl(&mut self, a:@Decl, e:E) { (*self).visit_decl(a, e) } - fn visit_expr(&mut self, a:@expr, e:E) { + fn visit_expr(&mut self, a:@Expr, e:E) { (*self).visit_expr(a, e) } - fn visit_expr_post(&mut self, a:@expr, e:E) { + fn visit_expr_post(&mut self, a:@Expr, e:E) { (*self).visit_expr_post(a, e) } fn visit_ty(&mut self, a:&Ty, e:E) { @@ -329,9 +329,9 @@ pub fn walk_path>(visitor: &mut V, path: &Path, env: E) { } } -pub fn walk_pat>(visitor: &mut V, pattern: &pat, env: E) { +pub fn walk_pat>(visitor: &mut V, pattern: &Pat, env: E) { match pattern.node { - pat_enum(ref path, ref children) => { + PatEnum(ref path, ref children) => { walk_path(visitor, path, env.clone()); for children in children.iter() { for child in children.iter() { @@ -339,36 +339,36 @@ pub fn walk_pat>(visitor: &mut V, pattern: &pat, env: E) { } } } - pat_struct(ref path, ref fields, _) => { + PatStruct(ref path, ref fields, _) => { walk_path(visitor, path, env.clone()); for field in fields.iter() { visitor.visit_pat(field.pat, env.clone()) } } - pat_tup(ref tuple_elements) => { + PatTup(ref tuple_elements) => { for tuple_element in tuple_elements.iter() { visitor.visit_pat(*tuple_element, env.clone()) } } - pat_box(subpattern) | - pat_uniq(subpattern) | - pat_region(subpattern) => { + PatBox(subpattern) | + PatUniq(subpattern) | + PatRegion(subpattern) => { visitor.visit_pat(subpattern, env) } - pat_ident(_, ref path, ref optional_subpattern) => { + PatIdent(_, ref path, ref optional_subpattern) => { walk_path(visitor, path, env.clone()); match *optional_subpattern { None => {} Some(subpattern) => visitor.visit_pat(subpattern, env), } } - pat_lit(expression) => visitor.visit_expr(expression, env), - pat_range(lower_bound, upper_bound) => { + PatLit(expression) => visitor.visit_expr(expression, env), + PatRange(lower_bound, upper_bound) => { visitor.visit_expr(lower_bound, env.clone()); visitor.visit_expr(upper_bound, env) } - pat_wild => (), - pat_vec(ref prepattern, ref slice_pattern, ref postpatterns) => { + PatWild => (), + PatVec(ref prepattern, ref slice_pattern, ref postpatterns) => { for prepattern in prepattern.iter() { visitor.visit_pat(*prepattern, env.clone()) } @@ -501,25 +501,25 @@ pub fn walk_block>(visitor: &mut V, block: &Block, env: E) walk_expr_opt(visitor, block.expr, env) } -pub fn walk_stmt>(visitor: &mut V, statement: &stmt, env: E) { +pub fn walk_stmt>(visitor: &mut V, statement: &Stmt, env: E) { match statement.node { - stmt_decl(declaration, _) => visitor.visit_decl(declaration, env), - stmt_expr(expression, _) | stmt_semi(expression, _) => { + StmtDecl(declaration, _) => visitor.visit_decl(declaration, env), + StmtExpr(expression, _) | StmtSemi(expression, _) => { visitor.visit_expr(expression, env) } - stmt_mac(ref macro, _) => walk_mac(visitor, macro, env), + StmtMac(ref macro, _) => walk_mac(visitor, macro, env), } } -pub fn walk_decl>(visitor: &mut V, declaration: &decl, env: E) { +pub fn walk_decl>(visitor: &mut V, declaration: &Decl, env: E) { match declaration.node { - decl_local(ref local) => visitor.visit_local(*local, env), - decl_item(item) => visitor.visit_item(item, env), + DeclLocal(ref local) => visitor.visit_local(*local, env), + DeclItem(item) => visitor.visit_item(item, env), } } pub fn walk_expr_opt>(visitor: &mut V, - optional_expression: Option<@expr>, + optional_expression: Option<@Expr>, env: E) { match optional_expression { None => {} @@ -528,7 +528,7 @@ pub fn walk_expr_opt>(visitor: &mut V, } pub fn walk_exprs>(visitor: &mut V, - expressions: &[@expr], + expressions: &[@Expr], env: E) { for expression in expressions.iter() { visitor.visit_expr(*expression, env.clone()) @@ -539,79 +539,79 @@ pub fn walk_mac>(_: &mut V, _: &mac, _: E) { // Empty! } -pub fn walk_expr>(visitor: &mut V, expression: @expr, env: E) { +pub fn walk_expr>(visitor: &mut V, expression: @Expr, env: E) { match expression.node { - expr_vstore(subexpression, _) => { + ExprVstore(subexpression, _) => { visitor.visit_expr(subexpression, env.clone()) } - expr_vec(ref subexpressions, _) => { + ExprVec(ref subexpressions, _) => { walk_exprs(visitor, *subexpressions, env.clone()) } - expr_repeat(element, count, _) => { + ExprRepeat(element, count, _) => { visitor.visit_expr(element, env.clone()); visitor.visit_expr(count, env.clone()) } - expr_struct(ref path, ref fields, optional_base) => { + ExprStruct(ref path, ref fields, optional_base) => { walk_path(visitor, path, env.clone()); for field in fields.iter() { visitor.visit_expr(field.expr, env.clone()) } walk_expr_opt(visitor, optional_base, env.clone()) } - expr_tup(ref subexpressions) => { + ExprTup(ref subexpressions) => { for subexpression in subexpressions.iter() { visitor.visit_expr(*subexpression, env.clone()) } } - expr_call(callee_expression, ref arguments, _) => { + ExprCall(callee_expression, ref arguments, _) => { for argument in arguments.iter() { visitor.visit_expr(*argument, env.clone()) } visitor.visit_expr(callee_expression, env.clone()) } - expr_method_call(_, callee, _, ref types, ref arguments, _) => { + ExprMethodCall(_, callee, _, ref types, ref arguments, _) => { walk_exprs(visitor, *arguments, env.clone()); for typ in types.iter() { visitor.visit_ty(typ, env.clone()) } visitor.visit_expr(callee, env.clone()) } - expr_binary(_, _, left_expression, right_expression) => { + ExprBinary(_, _, left_expression, right_expression) => { visitor.visit_expr(left_expression, env.clone()); visitor.visit_expr(right_expression, env.clone()) } - expr_addr_of(_, subexpression) | - expr_unary(_, _, subexpression) | - expr_do_body(subexpression) => { + ExprAddrOf(_, subexpression) | + ExprUnary(_, _, subexpression) | + ExprDoBody(subexpression) => { visitor.visit_expr(subexpression, env.clone()) } - expr_lit(_) => {} - expr_cast(subexpression, ref typ) => { + ExprLit(_) => {} + ExprCast(subexpression, ref typ) => { visitor.visit_expr(subexpression, env.clone()); visitor.visit_ty(typ, env.clone()) } - expr_if(head_expression, ref if_block, optional_else) => { + ExprIf(head_expression, ref if_block, optional_else) => { visitor.visit_expr(head_expression, env.clone()); visitor.visit_block(if_block, env.clone()); walk_expr_opt(visitor, optional_else, env.clone()) } - expr_while(subexpression, ref block) => { + ExprWhile(subexpression, ref block) => { visitor.visit_expr(subexpression, env.clone()); visitor.visit_block(block, env.clone()) } - expr_for_loop(pattern, subexpression, ref block) => { + ExprForLoop(pattern, subexpression, ref block) => { visitor.visit_pat(pattern, env.clone()); visitor.visit_expr(subexpression, env.clone()); visitor.visit_block(block, env.clone()) } - expr_loop(ref block, _) => visitor.visit_block(block, env.clone()), - expr_match(subexpression, ref arms) => { + ExprLoop(ref block, _) => visitor.visit_block(block, env.clone()), + ExprMatch(subexpression, ref arms) => { visitor.visit_expr(subexpression, env.clone()); for arm in arms.iter() { visitor.visit_arm(arm, env.clone()) } } - expr_fn_block(ref function_declaration, ref body) => { + ExprFnBlock(ref function_declaration, ref body) => { visitor.visit_fn(&fk_fn_block, function_declaration, body, @@ -619,39 +619,39 @@ pub fn walk_expr>(visitor: &mut V, expression: @expr, env: expression.id, env.clone()) } - expr_block(ref block) => visitor.visit_block(block, env.clone()), - expr_assign(left_hand_expression, right_hand_expression) => { + ExprBlock(ref block) => visitor.visit_block(block, env.clone()), + ExprAssign(left_hand_expression, right_hand_expression) => { visitor.visit_expr(right_hand_expression, env.clone()); visitor.visit_expr(left_hand_expression, env.clone()) } - expr_assign_op(_, _, left_expression, right_expression) => { + ExprAssignOp(_, _, left_expression, right_expression) => { visitor.visit_expr(right_expression, env.clone()); visitor.visit_expr(left_expression, env.clone()) } - expr_field(subexpression, _, ref types) => { + ExprField(subexpression, _, ref types) => { visitor.visit_expr(subexpression, env.clone()); for typ in types.iter() { visitor.visit_ty(typ, env.clone()) } } - expr_index(_, main_expression, index_expression) => { + ExprIndex(_, main_expression, index_expression) => { visitor.visit_expr(main_expression, env.clone()); visitor.visit_expr(index_expression, env.clone()) } - expr_path(ref path) => walk_path(visitor, path, env.clone()), - expr_self | expr_break(_) | expr_again(_) => {} - expr_ret(optional_expression) => { + ExprPath(ref path) => walk_path(visitor, path, env.clone()), + ExprSelf | ExprBreak(_) | ExprAgain(_) => {} + ExprRet(optional_expression) => { walk_expr_opt(visitor, optional_expression, env.clone()) } - expr_log(level, subexpression) => { + ExprLog(level, subexpression) => { visitor.visit_expr(level, env.clone()); visitor.visit_expr(subexpression, env.clone()); } - expr_mac(ref macro) => walk_mac(visitor, macro, env.clone()), - expr_paren(subexpression) => { + ExprMac(ref macro) => walk_mac(visitor, macro, env.clone()), + ExprParen(subexpression) => { visitor.visit_expr(subexpression, env.clone()) } - expr_inline_asm(ref assembler) => { + ExprInlineAsm(ref assembler) => { for &(_, input) in assembler.inputs.iter() { visitor.visit_expr(input, env.clone()) } @@ -664,7 +664,7 @@ pub fn walk_expr>(visitor: &mut V, expression: @expr, env: visitor.visit_expr_post(expression, env.clone()) } -pub fn walk_arm>(visitor: &mut V, arm: &arm, env: E) { +pub fn walk_arm>(visitor: &mut V, arm: &Arm, env: E) { for pattern in arm.pats.iter() { visitor.visit_pat(*pattern, env.clone()) } @@ -682,12 +682,12 @@ pub trait SimpleVisitor { fn visit_item(&mut self, @item); fn visit_local(&mut self, @Local); fn visit_block(&mut self, &Block); - fn visit_stmt(&mut self, @stmt); - fn visit_arm(&mut self, &arm); - fn visit_pat(&mut self, @pat); - fn visit_decl(&mut self, @decl); - fn visit_expr(&mut self, @expr); - fn visit_expr_post(&mut self, @expr); + fn visit_stmt(&mut self, @Stmt); + fn visit_arm(&mut self, &Arm); + fn visit_pat(&mut self, @Pat); + fn visit_decl(&mut self, @Decl); + fn visit_expr(&mut self, @Expr); + fn visit_expr_post(&mut self, @Expr); fn visit_ty(&mut self, &Ty); fn visit_generics(&mut self, &Generics); fn visit_fn(&mut self, &fn_kind, &fn_decl, &Block, Span, NodeId); @@ -731,27 +731,27 @@ impl Visitor<()> for SimpleVisitorVisitor { self.simple_visitor.visit_block(block); walk_block(self, block, env) } - fn visit_stmt(&mut self, statement: @stmt, env: ()) { + fn visit_stmt(&mut self, statement: @Stmt, env: ()) { self.simple_visitor.visit_stmt(statement); walk_stmt(self, statement, env) } - fn visit_arm(&mut self, arm: &arm, env: ()) { + fn visit_arm(&mut self, arm: &Arm, env: ()) { self.simple_visitor.visit_arm(arm); walk_arm(self, arm, env) } - fn visit_pat(&mut self, pattern: @pat, env: ()) { + fn visit_pat(&mut self, pattern: @Pat, env: ()) { self.simple_visitor.visit_pat(pattern); walk_pat(self, pattern, env) } - fn visit_decl(&mut self, declaration: @decl, env: ()) { + fn visit_decl(&mut self, declaration: @Decl, env: ()) { self.simple_visitor.visit_decl(declaration); walk_decl(self, declaration, env) } - fn visit_expr(&mut self, expression: @expr, env: ()) { + fn visit_expr(&mut self, expression: @Expr, env: ()) { self.simple_visitor.visit_expr(expression); walk_expr(self, expression, env) } - fn visit_expr_post(&mut self, expression: @expr, _: ()) { + fn visit_expr_post(&mut self, expression: @Expr, _: ()) { self.simple_visitor.visit_expr_post(expression) } fn visit_ty(&mut self, typ: &Ty, env: ()) {