diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-01-14 21:36:27 -0800 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-01-14 21:36:27 -0800 |
| commit | 293cd3480c10855de68503db36c6cc3ce8988b54 (patch) | |
| tree | 34ded4b28bd49ec489bb7499b1fb02fd8767dcad /src/libsyntax | |
| parent | 4bcd19f6be51d7fb26b0930c8a3354b9222143ff (diff) | |
| download | rust-293cd3480c10855de68503db36c6cc3ce8988b54.tar.gz rust-293cd3480c10855de68503db36c6cc3ce8988b54.zip | |
convert ast::{field_,capture_item_,mt} and middle::ty::mt into structs
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_encode.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 34 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 22 |
7 files changed, 77 insertions, 32 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c3f2eac8a2a..6f2ffe00849 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -670,7 +670,11 @@ struct arm { #[auto_encode] #[auto_decode] -type field_ = {mutbl: mutability, ident: ident, expr: @expr}; +struct field_ { + mutbl: mutability, + ident: ident, + expr: @expr, +} type field = spanned<field_>; @@ -762,12 +766,12 @@ enum expr_ { #[auto_encode] #[auto_decode] -type capture_item_ = { +struct capture_item_ { id: int, is_move: bool, name: ident, // Currently, can only capture a local var. - span: span -}; + span: span, +} type capture_item = @capture_item_; @@ -923,7 +927,10 @@ impl lit_: cmp::Eq { // type structure in middle/ty.rs as well. #[auto_encode] #[auto_decode] -type mt = {ty: @Ty, mutbl: mutability}; +struct mt { + ty: @Ty, + mutbl: mutability, +} #[auto_encode] #[auto_decode] diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index fcb11f42647..e241f6435d3 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -571,7 +571,7 @@ fn mk_ser_method( id: cx.next_id(), node: ast::re_anon, }, - { + ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), mutbl: ast::m_imm } @@ -634,7 +634,7 @@ fn mk_deser_method( id: cx.next_id(), node: ast::re_anon, }, - { + ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), mutbl: ast::m_imm } @@ -908,7 +908,11 @@ fn mk_deser_fields( ); ast::spanned { - node: { mutbl: field.mutbl, ident: field.ident, expr: expr }, + node: ast::field_ { + mutbl: field.mutbl, + ident: field.ident, + expr: expr, + }, span: span, } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 72c13747bf1..cc4c58f3504 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -145,8 +145,10 @@ fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { } fn mk_field(sp: span, f: &{ident: ast::ident, ex: @ast::expr}) -> ast::field { - ast::spanned { node: {mutbl: ast::m_imm, ident: f.ident, expr: f.ex}, - span: sp } + ast::spanned { + node: ast::field_ { mutbl: ast::m_imm, ident: f.ident, expr: f.ex }, + span: sp, + } } fn mk_fields(sp: span, fields: ~[{ident: ast::ident, ex: @ast::expr}]) -> ~[ast::field] { diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 2148ad0cdb6..83d968bb2ac 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -136,7 +136,10 @@ fn create_eq_method(cx: ext_ctxt, type_ident, ty_params); let arg_region = @{ id: cx.next_id(), node: re_anon }; - let arg_type = ty_rptr(arg_region, { ty: arg_path_type, mutbl: m_imm }); + let arg_type = ty_rptr( + arg_region, + ast::mt { ty: arg_path_type, mutbl: m_imm } + ); let arg_type = @{ id: cx.next_id(), node: move arg_type, span: span }; // Create the `other` parameter. diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 29d27e53d68..19cbf833c0f 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -146,8 +146,10 @@ impl ext_ctxt: ext_ctxt_ast_builder { } fn field_imm(name: ident, e: @ast::expr) -> ast::field { - spanned { node: { mutbl: ast::m_imm, ident: name, expr: e }, - span: dummy_sp()} + spanned { + node: ast::field_ { mutbl: ast::m_imm, ident: name, expr: e }, + span: dummy_sp(), + } } fn rec(+fields: ~[ast::field]) -> @ast::expr { @@ -158,8 +160,13 @@ impl ext_ctxt: ext_ctxt_ast_builder { } fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field { - spanned { node: { ident: name, mt: { ty: ty, mutbl: ast::m_imm } }, - span: dummy_sp() } + spanned { + node: { + ident: name, + mt: ast::mt { ty: ty, mutbl: ast::m_imm }, + }, + span: dummy_sp(), + } } fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index c1d5e6094fc..23915ea189b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -412,10 +412,14 @@ fn wrap<T>(f: fn@(T, ast_fold) -> T) fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { fn fold_field_(field: field, fld: ast_fold) -> field { - spanned { node: { mutbl: field.node.mutbl, - ident: fld.fold_ident(field.node.ident), - expr: fld.fold_expr(field.node.expr)}, - span: fld.new_span(field.span) } + spanned { + node: ast::field_ { + mutbl: field.node.mutbl, + ident: fld.fold_ident(field.node.ident), + expr: fld.fold_expr(field.node.expr), + }, + span: fld.new_span(field.span), + } } let fold_field = |x| fold_field_(x, fld); @@ -472,17 +476,25 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { vec::map((*arms), |x| fld.fold_arm(*x))) } expr_fn(proto, decl, ref body, captures) => { + let captures = do captures.map |cap_item| { + @ast::capture_item_ { + id: fld.new_id(cap_item.id), + ..**cap_item + } + }; expr_fn(proto, fold_fn_decl(decl, fld), fld.fold_block((*body)), - @((*captures).map(|cap_item| { - @({id: fld.new_id(cap_item.id), - ..**cap_item})}))) + @captures) } expr_fn_block(decl, ref body, captures) => { + let captures = do captures.map |cap_item| { + @ast::capture_item_ { + id: fld.new_id(cap_item.id), + ..**cap_item + } + }; expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block((*body)), - @((*captures).map(|cap_item| { - @({id: fld.new_id(cap_item.id), - ..**cap_item})}))) + @captures) } expr_block(ref blk) => expr_block(fld.fold_block((*blk))), expr_copy(e) => expr_copy(fld.fold_expr(e)), @@ -526,7 +538,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { let fold_mac = |x| fold_mac_(x, fld); fn fold_mt(mt: mt, fld: ast_fold) -> mt { - {ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl} + mt { ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl } } fn fold_field(f: ty_field, fld: ast_fold) -> ty_field { spanned { node: { ident: fld.fold_ident(f.node.ident), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 770c942059e..6fba59d6a84 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -455,7 +455,7 @@ impl Parser { fn parse_mt() -> mt { let mutbl = self.parse_mutability(); let t = self.parse_ty(false); - return {ty: t, mutbl: mutbl}; + mt { ty: t, mutbl: mutbl } } fn parse_ty_field() -> ty_field { @@ -464,9 +464,14 @@ impl Parser { let id = self.parse_ident(); self.expect(token::COLON); let ty = self.parse_ty(false); - return spanned(lo, ty.span.hi, { - ident: id, mt: {ty: ty, mutbl: mutbl} - }); + spanned( + lo, + ty.span.hi, + { + ident: id, + mt: ast::mt { ty: ty, mutbl: mutbl } + } + ) } fn parse_ret_ty() -> (ret_style, @Ty) { @@ -673,7 +678,12 @@ impl Parser { fn parse_capture_item(p:Parser, is_move: bool) -> capture_item { let sp = mk_sp(p.span.lo, p.span.hi); let ident = p.parse_ident(); - @{id: p.get_id(), is_move: is_move, name: ident, span: sp} + @ast::capture_item_ { + id: p.get_id(), + is_move: is_move, + name: ident, + span: sp, + } } if self.eat_keyword(~"move") { @@ -874,7 +884,7 @@ impl Parser { let i = self.parse_ident(); self.expect(sep); let e = self.parse_expr(); - return spanned(lo, e.span.hi, {mutbl: m, ident: i, expr: e}); + spanned(lo, e.span.hi, ast::field_ { mutbl: m, ident: i, expr: e }) } fn mk_expr(+lo: BytePos, +hi: BytePos, +node: expr_) -> @expr { |
