diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 4d25beb1b76..e7c78cd48ee 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -361,7 +361,7 @@ mod test { if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; } if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; } @ast_util::respan(ast_util::dummy_sp(), ast::crate_ { - module: {view_items: ~[], items: ~[]}, + module: ast::_mod { view_items: ~[], items: ~[] }, attrs: attrs, config: ~[] }) diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 8d29ec21125..3f75bba7a37 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -67,15 +67,14 @@ fn filter_view_item(cx: ctxt, &&view_item: @ast::view_item } } -fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> - ast::_mod { +fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { let filtered_items = vec::filter_map(m.items, |a| filter_item(cx, *a)); let filtered_view_items = vec::filter_map(m.view_items, |a| filter_view_item(cx, *a)); - return { - view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)), - items: vec::filter_map(filtered_items, |x| fld.fold_item(*x)) - }; + ast::_mod { + view_items: filtered_view_items.map(|x| fld.fold_view_item(*x)), + items: filtered_items.filter_map(|x| fld.fold_item(*x)), + } } fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) -> @@ -85,18 +84,21 @@ fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) -> } else { option::None } } -fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod, - fld: fold::ast_fold) -> ast::foreign_mod { +fn fold_foreign_mod( + cx: ctxt, + nm: ast::foreign_mod, + fld: fold::ast_fold +) -> ast::foreign_mod { let filtered_items = vec::filter_map(nm.items, |a| filter_foreign_item(cx, *a)); let filtered_view_items = vec::filter_map(nm.view_items, |a| filter_view_item(cx, *a)); - return { + ast::foreign_mod { sort: nm.sort, abi: nm.abi, view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)), items: filtered_items - }; + } } fn fold_item_underscore(cx: ctxt, +item: ast::item_, diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index e57627e412c..6762247aba0 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -62,7 +62,7 @@ fn inject_libcore_ref(sess: Session, }; let vis = vec::append(~[vi1], crate.module.view_items); - let mut new_module = { + let mut new_module = ast::_mod { view_items: vis, ../*bad*/copy crate.module }; @@ -95,7 +95,7 @@ fn inject_libcore_ref(sess: Session, let vis = vec::append(~[vi2], module.view_items); // FIXME #2543: Bad copy. - let new_module = { view_items: vis, ..copy module }; + let new_module = ast::_mod { view_items: vis, ..copy module }; fold::noop_fold_mod(new_module, fld) }, ..*fold::default_ast_fold() diff --git a/src/librustc/front/intrinsic_inject.rs b/src/librustc/front/intrinsic_inject.rs index 169fe59e4b4..6bf05e9dbd9 100644 --- a/src/librustc/front/intrinsic_inject.rs +++ b/src/librustc/front/intrinsic_inject.rs @@ -38,7 +38,7 @@ fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate { @ast::spanned { node: ast::crate_ { - module: { + module: ast::_mod { items: items, .. /*bad*/copy crate.node.module }, diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 2dea8d87176..813dc268d56 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -97,10 +97,12 @@ fn fold_mod(cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { } else { item } } - let mod_nomain = - {view_items: /*bad*/copy m.view_items, - items: vec::map(m.items, |i| nomain(cx, *i))}; - return fold::noop_fold_mod(mod_nomain, fld); + let mod_nomain = ast::_mod { + view_items: /*bad*/copy m.view_items, + items: vec::map(m.items, |i| nomain(cx, *i)), + }; + + fold::noop_fold_mod(mod_nomain, fld) } fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> @@ -182,7 +184,10 @@ fn should_fail(i: @ast::item) -> bool { fn add_test_module(cx: test_ctxt, +m: ast::_mod) -> ast::_mod { let testmod = mk_test_module(cx); - return {items: vec::append_one(/*bad*/copy m.items, testmod),.. m}; + ast::_mod { + items: vec::append_one(/*bad*/copy m.items, testmod), + .. m + } } /* @@ -213,8 +218,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { // The synthesized main function which will call the console test runner // with our list of tests let mainfn = mk_main(cx); - let testmod: ast::_mod = { - view_items: view_items, items: ~[mainfn, testsfn] + let testmod = ast::_mod { + view_items: view_items, + items: ~[mainfn, testsfn], }; let item_ = ast::item_mod(testmod); // This attribute tells resolve to let us call unexported functions @@ -276,10 +282,11 @@ fn mk_std(cx: test_ctxt) -> @ast::view_item { fn mk_tests(cx: test_ctxt) -> @ast::item { let ret_ty = mk_test_desc_vec_ty(cx); - let decl: ast::fn_decl = - {inputs: ~[], - output: ret_ty, - cf: ast::return_val}; + let decl = ast::fn_decl { + inputs: ~[], + output: ret_ty, + cf: ast::return_val, + }; // The vector of test_descs for this crate let test_descs = mk_test_desc_vec(cx); @@ -486,7 +493,7 @@ fn mk_test_wrapper(cx: test_ctxt, let call_stmt: ast::stmt = nospan( ast::stmt_semi(@call_expr, cx.sess.next_node_id())); - let wrapper_decl: ast::fn_decl = { + let wrapper_decl = ast::fn_decl { inputs: ~[], output: @ast::Ty { id: cx.sess.next_node_id(), @@ -521,10 +528,11 @@ fn mk_main(cx: test_ctxt) -> @ast::item { span: dummy_sp(), }; - let decl: ast::fn_decl = - {inputs: ~[], - output: @ret_ty, - cf: ast::return_val}; + let decl = ast::fn_decl { + inputs: ~[], + output: @ret_ty, + cf: ast::return_val, + }; let test_main_call_expr = mk_test_main_call(cx); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d8597a7af25..3755c84072c 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1842,13 +1842,17 @@ fn trans_enum_variant(ccx: @crate_ctxt, llfndecl: ValueRef) { let _icx = ccx.insn_ctxt("trans_enum_variant"); // Translate variant arguments to function arguments. - let fn_args = vec::map(args, |varg| - {mode: ast::expl(ast::by_copy), - ty: varg.ty, - pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(), - ast_util::dummy_sp(), - special_idents::arg), - id: varg.id}); + let fn_args = do args.map |varg| { + ast::arg { + mode: ast::expl(ast::by_copy), + ty: varg.ty, + pat: ast_util::ident_to_pat( + ccx.tcx.sess.next_node_id(), + ast_util::dummy_sp(), + special_idents::arg), + id: varg.id, + } + }; // XXX: Bad copy of `param_substs`. let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None, copy param_substs, None); @@ -1902,7 +1906,7 @@ fn trans_tuple_struct(ccx: @crate_ctxt, // Translate struct fields to function arguments. let fn_args = do fields.map |field| { - { + ast::arg { mode: ast::expl(ast::by_copy), ty: field.node.ty, pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(), diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index a151bddf6f7..3215b52794a 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -96,7 +96,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) match map_node { ast_map::node_item(@ast::item { node: item_fn(_, _, _, ref body), _ }, _) | - ast_map::node_method(@{body: ref body, _}, _, _) => { + ast_map::node_method(@ast::method {body: ref body, _}, _, _) => { handle_body(cx, (*body)); } ast_map::node_trait_method(*) => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 953317fe02f..6bb187b61d1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1107,7 +1107,10 @@ impl prim_ty : cmp::Eq { #[auto_encode] #[auto_decode] -type region = {id: node_id, node: region_}; +struct region { + id: node_id, + node: region_, +} #[auto_encode] #[auto_decode] @@ -1194,14 +1197,20 @@ impl Ty : to_bytes::IterBytes { #[auto_encode] #[auto_decode] -type arg = {mode: mode, ty: @Ty, pat: @pat, id: node_id}; +struct arg { + mode: mode, + ty: @Ty, + pat: @pat, + id: node_id, +} #[auto_encode] #[auto_decode] -type fn_decl = - {inputs: ~[arg], - output: @Ty, - cf: ret_style}; +struct fn_decl { + inputs: ~[arg], + output: @Ty, + cf: ret_style, +} #[auto_encode] #[auto_decode] @@ -1321,15 +1330,26 @@ type self_ty = spanned; #[auto_encode] #[auto_decode] -type method = {ident: ident, attrs: ~[attribute], - tps: ~[ty_param], self_ty: self_ty, - purity: purity, decl: fn_decl, body: blk, - id: node_id, span: span, self_id: node_id, - vis: visibility}; +struct method { + ident: ident, + attrs: ~[attribute], + tps: ~[ty_param], + self_ty: self_ty, + purity: purity, + decl: fn_decl, + body: blk, + id: node_id, + span: span, + self_id: node_id, + vis: visibility, +} #[auto_encode] #[auto_decode] -type _mod = {view_items: ~[@view_item], items: ~[@item]}; +struct _mod { + view_items: ~[@view_item], + items: ~[@item], +} #[auto_encode] #[auto_decode] @@ -1367,15 +1387,19 @@ impl foreign_abi : cmp::Eq { #[auto_encode] #[auto_decode] -type foreign_mod = - {sort: foreign_mod_sort, - abi: ident, - view_items: ~[@view_item], - items: ~[@foreign_item]}; +struct foreign_mod { + sort: foreign_mod_sort, + abi: ident, + view_items: ~[@view_item], + items: ~[@foreign_item], +} #[auto_encode] #[auto_decode] -type variant_arg = {ty: @Ty, id: node_id}; +struct variant_arg { + ty: @Ty, + id: node_id, +} #[auto_encode] #[auto_decode] @@ -1387,7 +1411,10 @@ enum variant_kind { #[auto_encode] #[auto_decode] -type enum_def_ = { variants: ~[variant], common: Option<@struct_def> }; +struct enum_def_ { + variants: ~[variant], + common: Option<@struct_def>, +} #[auto_encode] #[auto_decode] @@ -1395,8 +1422,14 @@ enum enum_def = enum_def_; #[auto_encode] #[auto_decode] -type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind, - id: node_id, disr_expr: Option<@expr>, vis: visibility}; +struct variant_ { + name: ident, + attrs: ~[attribute], + kind: variant_kind, + id: node_id, + disr_expr: Option<@expr>, + vis: visibility, +} type variant = spanned; @@ -1492,7 +1525,10 @@ struct attribute_ { */ #[auto_encode] #[auto_decode] -type trait_ref = {path: @path, ref_id: node_id}; +struct trait_ref { + path: @path, + ref_id: node_id, +} #[auto_encode] #[auto_decode] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index a65d6467eb5..73be0598d69 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -443,8 +443,11 @@ fn operator_prec(op: ast::binop) -> uint { fn dtor_dec() -> fn_decl { let nil_t = @ast::Ty { id: 0, node: ty_nil, span: dummy_sp() }; // dtor has no args - {inputs: ~[], - output: nil_t, cf: return_val} + ast::fn_decl { + inputs: ~[], + output: nil_t, + cf: return_val, + } } // ______________________________________________________________________ diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index aa577591804..9578a2f6317 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -462,7 +462,7 @@ fn mk_impl( } ); - let opt_trait = Some(@{ + let opt_trait = Some(@ast::trait_ref { path: path, ref_id: cx.next_id(), }); @@ -581,7 +581,7 @@ fn mk_ser_method( let ty_s = @ast::Ty { id: cx.next_id(), node: ast::ty_rptr( - @{ + @ast::region { id: cx.next_id(), node: ast::re_anon, }, @@ -593,7 +593,7 @@ fn mk_ser_method( span: span, }; - let ser_inputs = ~[{ + let ser_inputs = ~[ast::arg { mode: ast::infer(cx.next_id()), ty: ty_s, pat: @ast::pat { @@ -613,13 +613,13 @@ fn mk_ser_method( span: span, }; - let ser_decl = { + let ser_decl = ast::fn_decl { inputs: ser_inputs, output: ser_output, cf: ast::return_val, }; - @{ + @ast::method { ident: cx.ident_of(~"encode"), attrs: ~[], tps: ~[], @@ -644,7 +644,7 @@ fn mk_deser_method( let ty_d = @ast::Ty { id: cx.next_id(), node: ast::ty_rptr( - @{ + @ast::region { id: cx.next_id(), node: ast::re_anon, }, @@ -656,7 +656,7 @@ fn mk_deser_method( span: span, }; - let deser_inputs = ~[{ + let deser_inputs = ~[ast::arg { mode: ast::infer(cx.next_id()), ty: ty_d, pat: @ast::pat { @@ -670,13 +670,13 @@ fn mk_deser_method( id: cx.next_id(), }]; - let deser_decl = { + let deser_decl = ast::fn_decl { inputs: deser_inputs, output: ty, cf: ast::return_val, }; - @{ + @ast::method { ident: cx.ident_of(~"decode"), attrs: ~[], tps: ~[], @@ -1187,8 +1187,8 @@ fn mk_enum_deser_body( let expr_lambda = cx.expr( span, ast::expr_fn_block( - { - inputs: ~[{ + ast::fn_decl { + inputs: ~[ast::arg { mode: ast::infer(cx.next_id()), ty: @ast::Ty { id: cx.next_id(), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 20f2f16058f..d17db9ad6aa 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -317,7 +317,7 @@ fn mk_arg(cx: ext_ctxt, ty: @ast::Ty) -> ast::arg { let arg_pat = mk_pat_ident(cx, span, ident); - { + ast::arg { mode: ast::infer(cx.next_id()), ty: ty, pat: arg_pat, @@ -325,7 +325,7 @@ fn mk_arg(cx: ext_ctxt, } } fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { - { inputs: move inputs, output: output, cf: ast::return_val } + ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val } } fn mk_ty_param(cx: ext_ctxt, ident: ast::ident, diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index b272348244d..d7059fc1977 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -135,7 +135,7 @@ fn create_eq_method(cx: ext_ctxt, span, type_ident, ty_params); - let arg_region = @{ id: cx.next_id(), node: re_anon }; + let arg_region = @ast::region { id: cx.next_id(), node: re_anon }; let arg_type = ty_rptr( arg_region, ast::mt { ty: arg_path_type, mutbl: m_imm } @@ -168,7 +168,7 @@ fn create_eq_method(cx: ext_ctxt, // Create the method. let self_ty = spanned { node: sty_region(m_imm), span: span }; - return @{ + @ast::method { ident: method_ident, attrs: ~[], tps: ~[], @@ -180,7 +180,7 @@ fn create_eq_method(cx: ext_ctxt, span: span, self_id: cx.next_id(), vis: public - }; + } } fn create_self_type_with_params(cx: ext_ctxt, @@ -234,7 +234,7 @@ fn create_derived_impl(cx: ext_ctxt, types: ~[] }; let trait_path = @move trait_path; - let trait_ref = { + let trait_ref = ast::trait_ref { path: trait_path, ref_id: cx.next_id() }; @@ -319,7 +319,7 @@ fn create_iter_bytes_method(cx: ext_ctxt, // Create the method. let self_ty = spanned { node: sty_region(m_imm), span: span }; let method_ident = cx.ident_of(~"iter_bytes"); - return @{ + @ast::method { ident: method_ident, attrs: ~[], tps: ~[], diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 11abec941e8..eb571b99b4e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -119,7 +119,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt, } }; - return {items: new_items, ..module_}; + ast::_mod { items: new_items, ..module_ } } diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 0bd72790cad..c8c05d27d80 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -198,7 +198,7 @@ impl ext_ctxt: ext_ctxt_ast_builder { } fn arg(name: ident, ty: @ast::Ty) -> ast::arg { - { + ast::arg { mode: ast::infer(self.next_id()), ty: ty, pat: @ast::pat { @@ -231,9 +231,11 @@ impl ext_ctxt: ext_ctxt_ast_builder { fn fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { - {inputs: inputs, - output: output, - cf: ast::return_val} + ast::fn_decl { + inputs: inputs, + output: output, + cf: ast::return_val, + } } fn item(name: ident, @@ -295,15 +297,20 @@ impl ext_ctxt: ext_ctxt_ast_builder { fn variant(name: ident, span: span, +tys: ~[@ast::Ty]) -> ast::variant { - let args = tys.map(|ty| {ty: *ty, id: self.next_id()}); + let args = do tys.map |ty| { + ast::variant_arg { ty: *ty, id: self.next_id() } + }; - spanned { node: { name: name, - attrs: ~[], - kind: ast::tuple_variant_kind(args), - id: self.next_id(), - disr_expr: None, - vis: ast::public}, - span: span} + spanned { + node: ast::variant_ { + name: name, + attrs: ~[], + kind: ast::tuple_variant_kind(args), + id: self.next_id(), + disr_expr: None, + vis: ast::public}, + span: span, + } } fn item_mod(name: ident, @@ -336,11 +343,14 @@ impl ext_ctxt: ext_ctxt_ast_builder { span: ast_util::dummy_sp() }; - self.item(name, - span, - ast::item_mod({ - view_items: ~[vi], - items: items})) + self.item( + name, + span, + ast::item_mod(ast::_mod { + view_items: ~[vi], + items: items, + }) + ) } fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index e88ddb841be..306df24e79f 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -240,11 +240,16 @@ impl state: to_type_decls { items_msg.push(v); } - ~[cx.item_enum_poly(name, - self.span, - ast::enum_def({ variants: items_msg, - common: None }), - self.ty_params)] + ~[ + cx.item_enum_poly( + name, + self.span, + ast::enum_def(enum_def_ { + variants: items_msg, + common: None }), + self.ty_params + ) + ] } fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index e8d96d2e6e0..3582c082b5c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -125,10 +125,12 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute { } //used in noop_fold_foreign_item and noop_fold_fn_decl fn fold_arg_(a: arg, fld: ast_fold) -> arg { - return {mode: a.mode, - ty: fld.fold_ty(a.ty), - pat: fld.fold_pat(a.pat), - id: fld.new_id(a.id)}; + ast::arg { + mode: a.mode, + ty: fld.fold_ty(a.ty), + pat: fld.fold_pat(a.pat), + id: fld.new_id(a.id), + } } //used in noop_fold_expr, and possibly elsewhere in the future fn fold_mac_(m: mac, fld: ast_fold) -> mac { @@ -139,9 +141,11 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { } fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { - return {inputs: vec::map(decl.inputs, |x| fold_arg_(*x, fld) ), - output: fld.fold_ty(decl.output), - cf: decl.cf} + ast::fn_decl { + inputs: decl.inputs.map(|x| fold_arg_(*x, fld)), + output: fld.fold_ty(decl.output), + cf: decl.cf, + } } fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { @@ -189,7 +193,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) match ni.node { foreign_item_fn(fdec, purity, typms) => { foreign_item_fn( - { + ast::fn_decl { inputs: fdec.inputs.map(|a| fold_arg(*a)), output: fld.fold_ty(fdec.output), cf: fdec.cf, @@ -240,11 +244,11 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { item_ty(t, typms) => item_ty(fld.fold_ty(t), fold_ty_params(typms, fld)), item_enum(ref enum_definition, typms) => { - item_enum(ast::enum_def({ - variants: vec::map((*enum_definition).variants, - |x| fld.fold_variant(*x)), - common: option::map(&(*enum_definition).common, - |x| fold_struct_def(*x, fld)) + item_enum(ast::enum_def(ast::enum_def_ { + variants: enum_definition.variants.map( + |x| fld.fold_variant(*x)), + common: enum_definition.common.map( + |x| fold_struct_def(*x, fld)), }), fold_ty_params(typms, fld)) } item_struct(struct_def, typms) => { @@ -285,15 +289,18 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold) .. dtor.node}, span: dtor.span } }; - return @ast::struct_def { - fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)), + @ast::struct_def { + fields: struct_def.fields.map(|f| fold_struct_field(*f, fld)), dtor: dtor, - ctor_id: option::map(&struct_def.ctor_id, |cid| fld.new_id(*cid)) - }; + ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(*cid)), + } } fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref { - @{path: fld.fold_path(p.path), ref_id: fld.new_id(p.ref_id)} + @ast::trait_ref { + path: fld.fold_path(p.path), + ref_id: fld.new_id(p.ref_id), + } } fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field { @@ -304,17 +311,19 @@ fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field { } fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { - return @{ident: fld.fold_ident(m.ident), - attrs: /* FIXME (#2543) */ copy m.attrs, - tps: fold_ty_params(m.tps, fld), - self_ty: m.self_ty, - purity: m.purity, - decl: fold_fn_decl(m.decl, fld), - body: fld.fold_block(m.body), - id: fld.new_id(m.id), - span: fld.new_span(m.span), - self_id: fld.new_id(m.self_id), - vis: m.vis}; + @ast::method { + ident: fld.fold_ident(m.ident), + attrs: /* FIXME (#2543) */ copy m.attrs, + tps: fold_ty_params(m.tps, fld), + self_ty: m.self_ty, + purity: m.purity, + decl: fold_fn_decl(m.decl, fld), + body: fld.fold_block(m.body), + id: fld.new_id(m.id), + span: fld.new_span(m.span), + self_id: fld.new_id(m.self_id), + vis: m.vis, + } } @@ -577,20 +586,24 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { // ...nor do modules fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod { - return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)), - items: vec::filter_map(m.items, |x| fld.fold_item(*x))}; + ast::_mod { + view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)), + items: vec::filter_map(m.items, |x| fld.fold_item(*x)), + } } fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod { - return {sort: nm.sort, - abi: nm.abi, - view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)), - items: vec::map(nm.items, |x| fld.fold_foreign_item(*x))} + ast::foreign_mod { + sort: nm.sort, + abi: nm.abi, + view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)), + items: vec::map(nm.items, |x| fld.fold_foreign_item(*x)), + } } fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg { - return {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)}; + ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) } } let fold_variant_arg = |x| fold_variant_arg_(x, fld); @@ -621,8 +634,12 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { |x| fld.fold_variant(*x)); let common = option::map(&(*enum_definition).common, |x| fold_struct_def(*x, fld)); - kind = enum_variant_kind(ast::enum_def({ variants: variants, - common: common })); + kind = enum_variant_kind( + ast::enum_def(ast::enum_def_ { + variants: variants, + common: common + }) + ); } } @@ -633,12 +650,14 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { Some(e) => Some(fld.fold_expr(e)), None => None }; - return {name: /* FIXME (#2543) */ copy v.name, - attrs: attrs, - kind: kind, - id: fld.new_id(v.id), - disr_expr: de, - vis: v.vis}; + ast::variant_ { + name: /* FIXME (#2543) */ copy v.name, + attrs: attrs, + kind: kind, + id: fld.new_id(v.id), + disr_expr: de, + vis: v.vis, + } } fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b4fbd9beae3..33ae2f22dfe 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -383,8 +383,7 @@ impl Parser { p.parse_arg_general(false) }; let (ret_style, ret_ty) = self.parse_ret_ty(); - return {inputs: inputs, output: ret_ty, - cf: ret_style}; + ast::fn_decl { inputs: inputs, output: ret_ty, cf: ret_style } } fn parse_trait_methods() -> ~[trait_method] { @@ -437,17 +436,19 @@ impl Parser { let (inner_attrs, body) = p.parse_inner_attrs_and_block(true); let attrs = vec::append(attrs, inner_attrs); - provided(@{ident: ident, - attrs: attrs, - tps: tps, - self_ty: self_ty, - purity: pur, - decl: d, - body: body, - id: p.get_id(), - span: mk_sp(lo, hi), - self_id: p.get_id(), - vis: vis}) + provided(@ast::method { + ident: ident, + attrs: attrs, + tps: tps, + self_ty: self_ty, + purity: pur, + decl: d, + body: body, + id: p.get_id(), + span: mk_sp(lo, hi), + self_id: p.get_id(), + vis: vis, + }) } _ => { p.fatal(~"expected `;` or `}` but found `" + @@ -516,7 +517,7 @@ impl Parser { None => re_anon }; - @{id: self.get_id(), node: r} + @ast::region { id: self.get_id(), node: r } } // Parses something like "&x" @@ -729,7 +730,7 @@ impl Parser { let t = self.parse_ty(false); - {mode: m, ty: t, pat: pat, id: self.get_id()} + ast::arg { mode: m, ty: t, pat: pat, id: self.get_id() } } fn parse_arg() -> arg_or_capture_item { @@ -753,7 +754,12 @@ impl Parser { span: mk_sp(p.span.lo, p.span.hi), } }; - either::Left({mode: m, ty: t, pat: pat, id: p.get_id()}) + either::Left(ast::arg { + mode: m, + ty: t, + pat: pat, + id: p.get_id() + }) } } @@ -1580,8 +1586,8 @@ impl Parser { } _ => { // No argument list - `do foo {` - ({ - { + ( + ast::fn_decl { inputs: ~[], output: @Ty { id: self.get_id(), @@ -1589,9 +1595,9 @@ impl Parser { span: self.span }, cf: return_val - } - }, - @~[]) + }, + @~[] + ) } } }, @@ -2549,9 +2555,14 @@ impl Parser { let capture_clause = @either::rights(args_or_capture_items); let (ret_style, ret_ty) = self.parse_ret_ty(); - return ({inputs: inputs, - output: ret_ty, - cf: ret_style}, capture_clause); + ( + ast::fn_decl { + inputs: inputs, + output: ret_ty, + cf: ret_style, + }, + capture_clause + ) } fn is_self_ident() -> bool { @@ -2651,7 +2662,7 @@ impl Parser { let capture_clause = @either::rights(args_or_capture_items); let (ret_style, ret_ty) = self.parse_ret_ty(); - let fn_decl = { + let fn_decl = ast::fn_decl { inputs: inputs, output: ret_ty, cf: ret_style @@ -2676,10 +2687,15 @@ impl Parser { } else { @Ty { id: self.get_id(), node: ty_infer, span: self.span } }; - return ({inputs: either::lefts(inputs_captures), - output: output, - cf: return_val}, - @either::rights(inputs_captures)); + + ( + ast::fn_decl { + inputs: either::lefts(inputs_captures), + output: output, + cf: return_val, + }, + @either::rights(inputs_captures) + ) } fn parse_fn_header() -> {ident: ident, tps: ~[ty_param]} { @@ -2729,10 +2745,19 @@ impl Parser { let (inner_attrs, body) = self.parse_inner_attrs_and_block(true); let attrs = vec::append(attrs, inner_attrs); - @{ident: ident, attrs: attrs, - tps: tps, self_ty: self_ty, purity: pur, decl: decl, - body: body, id: self.get_id(), span: mk_sp(lo, body.span.hi), - self_id: self.get_id(), vis: visa} + @ast::method { + ident: ident, + attrs: attrs, + tps: tps, + self_ty: self_ty, + purity: pur, + decl: decl, + body: body, + id: self.get_id(), + span: mk_sp(lo, body.span.hi), + self_id: self.get_id(), + vis: visa, + } } fn parse_item_trait() -> item_info { @@ -2832,8 +2857,10 @@ impl Parser { } fn parse_trait_ref() -> @trait_ref { - @{path: self.parse_path_with_tps(false), - ref_id: self.get_id()} + @ast::trait_ref { + path: self.parse_path_with_tps(false), + ref_id: self.get_id(), + } } fn parse_trait_ref_list(ket: token::Token) -> ~[@trait_ref] { @@ -3065,7 +3092,7 @@ impl Parser { self.fatal(~"expected item"); } - return {view_items: view_items, items: items}; + ast::_mod { view_items: view_items, items: items } } fn parse_item_const() -> item_info { @@ -3117,7 +3144,7 @@ impl Parser { (item_mod(m), item_mod(n)) => (m, n), _ => self.bug(~"parsed mod item should be mod") }; - let merged_mod = { + let merged_mod = ast::_mod { view_items: main_mod.view_items + new_mod.view_items, items: main_mod.items + new_mod.items }; @@ -3272,12 +3299,12 @@ impl Parser { initial_attrs = ~[]; items.push(self.parse_foreign_item(attrs)); } - return { + ast::foreign_mod { sort: sort, abi: move abi, view_items: view_items, items: items - }; + } } fn parse_item_foreign_mod(lo: BytePos, @@ -3473,7 +3500,10 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false)); for arg_tys.each |ty| { - args.push({ty: *ty, id: self.get_id()}); + args.push(ast::variant_arg { + ty: *ty, + id: self.get_id(), + }); } kind = tuple_variant_kind(args); } else if self.eat(token::EQ) { @@ -3486,9 +3516,14 @@ impl Parser { needs_comma = true; } - let vr = {name: ident, attrs: variant_attrs, - kind: kind, id: self.get_id(), - disr_expr: disr_expr, vis: vis}; + let vr = ast::variant_ { + name: ident, + attrs: variant_attrs, + kind: kind, + id: self.get_id(), + disr_expr: disr_expr, + vis: vis, + }; variants.push(spanned(vlo, self.last_span.hi, vr)); if needs_comma && !self.eat(token::COMMA) { break; } @@ -3499,7 +3534,7 @@ impl Parser { enum"); } - return enum_def({ variants: variants, common: common_fields }); + enum_def(ast::enum_def_ { variants: variants, common: common_fields }) } fn parse_item_enum() -> item_info { @@ -3511,18 +3546,26 @@ impl Parser { self.bump(); let ty = self.parse_ty(false); self.expect(token::SEMI); - let variant = - spanned(ty.span.lo, ty.span.hi, - {name: id, - attrs: ~[], - kind: tuple_variant_kind - (~[{ty: ty, id: self.get_id()}]), - id: self.get_id(), - disr_expr: None, - vis: public}); - return (id, item_enum(enum_def({ variants: ~[variant], - common: None }), - ty_params), None); + let variant = spanned(ty.span.lo, ty.span.hi, ast::variant_ { + name: id, + attrs: ~[], + kind: tuple_variant_kind( + ~[ast::variant_arg {ty: ty, id: self.get_id()}] + ), + id: self.get_id(), + disr_expr: None, + vis: public, + }); + + return ( + id, + item_enum( + enum_def( + ast::enum_def_ { variants: ~[variant], common: None } + ), + ty_params), + None + ); } self.expect(token::LBRACE);