diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-01-15 16:05:20 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-01-20 14:08:18 -0800 |
| commit | d5d77b9351bdcb7a9fd7c6a27950990d33eea232 (patch) | |
| tree | d5d51cb523cbdd41ce069d1c4478437bf1cfff5b /src/libsyntax | |
| parent | 5ba7e55a4c42f6a53eccb60d4098b9422dd6e345 (diff) | |
| download | rust-d5d77b9351bdcb7a9fd7c6a27950990d33eea232.tar.gz rust-d5d77b9351bdcb7a9fd7c6a27950990d33eea232.zip | |
convert the remaining ast record types into structs
These are: region,arg,fn_decl,method,_mod,foreign_mod, variant_arg,enum_def_,variant_,trait_ref.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 80 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_encode.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 46 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 107 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 155 |
10 files changed, 282 insertions, 166 deletions
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<self_ty_>; #[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<variant_>; @@ -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()}); - - spanned { node: { name: name, - attrs: ~[], - kind: ast::tuple_variant_kind(args), - id: self.next_id(), - disr_expr: None, - vis: ast::public}, - span: span} + let args = do tys.map |ty| { + ast::variant_arg { ty: *ty, id: self.next_id() } + }; + + 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); |
