about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-01-15 14:59:39 -0800
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-01-20 14:08:18 -0800
commit8cdc3fda11b2e341f305c03678a04c6bb01ce635 (patch)
tree203eb55d29526de6c6148fd603d94d597165334c /src/libsyntax
parent8a3a1fc1489fb1f313fdd75af4e73a6a3b271ce2 (diff)
downloadrust-8cdc3fda11b2e341f305c03678a04c6bb01ce635.tar.gz
rust-8cdc3fda11b2e341f305c03678a04c6bb01ce635.zip
convert ast::ty into a struct
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs6
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/ext/auto_encode.rs37
-rw-r--r--src/libsyntax/ext/build.rs6
-rw-r--r--src/libsyntax/ext/deriving.rs16
-rw-r--r--src/libsyntax/ext/pipes/ast_builder.rs32
-rw-r--r--src/libsyntax/fold.rs6
-rw-r--r--src/libsyntax/parse/parser.rs82
8 files changed, 122 insertions, 65 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 4b3962efc7f..4ae99d03c8d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1040,7 +1040,11 @@ impl float_ty : cmp::Eq {
 
 #[auto_encode]
 #[auto_decode]
-type Ty = {id: node_id, node: ty_, span: span};
+struct Ty {
+    id: node_id,
+    node: ty_,
+    span: span,
+}
 
 // Not represented directly in the AST, referred to by name through a ty_path.
 #[auto_encode]
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index d744a3e01cc..0af9d2211be 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -435,7 +435,7 @@ fn operator_prec(op: ast::binop) -> uint {
 }
 
 fn dtor_dec() -> fn_decl {
-    let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()};
+    let nil_t = @ast::Ty { id: 0, node: ty_nil, span: dummy_sp() };
     // dtor has no args
     {inputs: ~[],
      output: nil_t, cf: return_val}
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 625c04a6463..aa577591804 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -130,7 +130,10 @@ fn expand_auto_encode(
     do vec::flat_map(in_items) |item| {
         if item.attrs.any(is_auto_encode) {
             match item.node {
-                ast::item_ty(@{node: ast::ty_rec(ref fields), _}, tps) => {
+                ast::item_ty(
+                    @ast::Ty {node: ast::ty_rec(ref fields), _},
+                    tps
+                ) => {
                     let ser_impl = mk_rec_ser_impl(
                         cx,
                         item.span,
@@ -196,7 +199,10 @@ fn expand_auto_decode(
     do vec::flat_map(in_items) |item| {
         if item.attrs.any(is_auto_decode) {
             match item.node {
-                ast::item_ty(@{node: ast::ty_rec(ref fields), _}, tps) => {
+                ast::item_ty(
+                    @ast::Ty {node: ast::ty_rec(ref fields), _},
+                    tps
+                ) => {
                     let deser_impl = mk_rec_deser_impl(
                         cx,
                         item.span,
@@ -249,7 +255,7 @@ priv impl ext_ctxt {
         path: @ast::path,
         bounds: @~[ast::ty_param_bound]
     ) -> ast::ty_param {
-        let bound = ast::TraitTyParamBound(@{
+        let bound = ast::TraitTyParamBound(@ast::Ty {
             id: self.next_id(),
             node: ast::ty_path(path, self.next_id()),
             span: span,
@@ -315,9 +321,13 @@ priv impl ext_ctxt {
 
     fn ty_path(span: span, strs: ~[ast::ident],
                tps: ~[@ast::Ty]) -> @ast::Ty {
-        @{id: self.next_id(),
-          node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()),
-          span: span}
+        @ast::Ty {
+            id: self.next_id(),
+            node: ast::ty_path(
+                self.path_tps(span, strs, tps),
+                self.next_id()),
+            span: span,
+        }
     }
 
     fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
@@ -438,7 +448,7 @@ fn mk_impl(
     let mut trait_tps = vec::append(
         ~[ty_param],
          do tps.map |tp| {
-            let t_bound = ast::TraitTyParamBound(@{
+            let t_bound = ast::TraitTyParamBound(@ast::Ty {
                 id: cx.next_id(),
                 node: ast::ty_path(path, cx.next_id()),
                 span: span,
@@ -568,7 +578,7 @@ fn mk_ser_method(
     span: span,
     ser_body: ast::blk
 ) -> @ast::method {
-    let ty_s = @{
+    let ty_s = @ast::Ty {
         id: cx.next_id(),
         node: ast::ty_rptr(
             @{
@@ -597,7 +607,7 @@ fn mk_ser_method(
         id: cx.next_id(),
     }];
 
-    let ser_output = @{
+    let ser_output = @ast::Ty {
         id: cx.next_id(),
         node: ast::ty_nil,
         span: span,
@@ -631,7 +641,7 @@ fn mk_deser_method(
     ty: @ast::Ty,
     deser_body: ast::blk
 ) -> @ast::method {
-    let ty_d = @{
+    let ty_d = @ast::Ty {
         id: cx.next_id(),
         node: ast::ty_rptr(
             @{
@@ -670,8 +680,7 @@ fn mk_deser_method(
         ident: cx.ident_of(~"decode"),
         attrs: ~[],
         tps: ~[],
-        self_ty: ast::spanned { node: ast::sty_static,
-                                span: span },
+        self_ty: ast::spanned { node: ast::sty_static, span: span },
         purity: ast::impure_fn,
         decl: deser_decl,
         body: deser_body,
@@ -1181,7 +1190,7 @@ fn mk_enum_deser_body(
             {
                 inputs: ~[{
                     mode: ast::infer(cx.next_id()),
-                    ty: @{
+                    ty: @ast::Ty {
                         id: cx.next_id(),
                         node: ast::ty_infer,
                         span: span
@@ -1196,7 +1205,7 @@ fn mk_enum_deser_body(
                     },
                     id: cx.next_id(),
                 }],
-                output: @{
+                output: @ast::Ty {
                     id: cx.next_id(),
                     node: ast::ty_infer,
                     span: span,
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index a4184bdfda7..20f2f16058f 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -194,7 +194,7 @@ fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
             None),
         span: sp,
     };
-    let ty : @ast::Ty = @{ id: cx.next_id(), node: ast::ty_infer, span: sp };
+    let ty = @ast::Ty { id: cx.next_id(), node: ast::ty_infer, span: sp };
     let local = @ast::spanned {
         node: ast::local_ {
             is_mutbl: mutbl,
@@ -293,7 +293,7 @@ fn mk_ty_path(cx: ext_ctxt,
            -> @ast::Ty {
     let ty = build::mk_raw_path(span, idents);
     let ty = ast::ty_path(ty, cx.next_id());
-    let ty = @{ id: cx.next_id(), node: move ty, span: span };
+    let ty = @ast::Ty { id: cx.next_id(), node: move ty, span: span };
     ty
 }
 fn mk_ty_path_global(cx: ext_ctxt,
@@ -302,7 +302,7 @@ fn mk_ty_path_global(cx: ext_ctxt,
                   -> @ast::Ty {
     let ty = build::mk_raw_path_global(span, idents);
     let ty = ast::ty_path(ty, cx.next_id());
-    let ty = @{ id: cx.next_id(), node: move ty, span: span };
+    let ty = @ast::Ty { id: cx.next_id(), node: move ty, span: span };
     ty
 }
 fn mk_simple_ty_path(cx: ext_ctxt,
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index 83d968bb2ac..b272348244d 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -140,7 +140,11 @@ fn create_eq_method(cx: ext_ctxt,
         arg_region,
         ast::mt { ty: arg_path_type, mutbl: m_imm }
     );
-    let arg_type = @{ id: cx.next_id(), node: move arg_type, span: span };
+    let arg_type = @ast::Ty {
+        id: cx.next_id(),
+        node: arg_type,
+        span: span,
+    };
 
     // Create the `other` parameter.
     let other_ident = cx.ident_of(~"__other");
@@ -150,10 +154,10 @@ fn create_eq_method(cx: ext_ctxt,
     let bool_ident = cx.ident_of(~"bool");
     let output_type = build::mk_raw_path(span, ~[ bool_ident ]);
     let output_type = ty_path(output_type, cx.next_id());
-    let output_type = @{
+    let output_type = @ast::Ty {
         id: cx.next_id(),
-        node: move output_type,
-        span: span
+        node: output_type,
+        span: span,
     };
 
     // Create the function declaration.
@@ -199,7 +203,7 @@ fn create_self_type_with_params(cx: ext_ctxt,
                                         ~[ type_ident ],
                                         move self_ty_params);
     let self_type = ty_path(self_type, cx.next_id());
-    @{ id: cx.next_id(), node: move self_type, span: span }
+    @ast::Ty { id: cx.next_id(), node: self_type, span: span }
 }
 
 fn create_derived_impl(cx: ext_ctxt,
@@ -303,7 +307,7 @@ fn create_iter_bytes_method(cx: ext_ctxt,
     let f_arg = build::mk_arg(cx, span, f_ident, f_arg_type);
 
     // Create the type of the return value.
-    let output_type = @{ id: cx.next_id(), node: ty_nil, span: span };
+    let output_type = @ast::Ty { id: cx.next_id(), node: ty_nil, span: span };
 
     // Create the function declaration.
     let inputs = ~[ move lsb0_arg, move f_arg ];
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 8472e61c196..36ef9ac0cdf 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -176,15 +176,19 @@ impl ext_ctxt: ext_ctxt_ast_builder {
     }
 
     fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty {
-        @{id: self.next_id(),
-          node: ast::ty_rec(fields),
-          span: dummy_sp()}
+        @ast::Ty {
+            id: self.next_id(),
+            node: ast::ty_rec(fields),
+            span: dummy_sp(),
+        }
     }
 
     fn ty_infer() -> @ast::Ty {
-        @{id: self.next_id(),
-          node: ast::ty_infer,
-          span: dummy_sp()}
+        @ast::Ty {
+            id: self.next_id(),
+            node: ast::ty_infer,
+            span: dummy_sp(),
+        }
     }
 
     fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
@@ -340,15 +344,19 @@ impl ext_ctxt: ext_ctxt_ast_builder {
     }
 
     fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty {
-        @{id: self.next_id(),
-          node: ast::ty_path(path, self.next_id()),
-          span: path.span}
+        @ast::Ty {
+            id: self.next_id(),
+            node: ast::ty_path(path, self.next_id()),
+            span: path.span,
+        }
     }
 
     fn ty_nil_ast_builder() -> @ast::Ty {
-        @{id: self.next_id(),
-          node: ast::ty_nil,
-          span: dummy_sp()}
+        @ast::Ty {
+            id: self.next_id(),
+            node: ast::ty_nil,
+            span: dummy_sp(),
+        }
     }
 
     fn item_ty_poly(name: ident,
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 60430b51f0a..aad6afbf434 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -770,7 +770,11 @@ impl ast_fold_fns: ast_fold {
     }
     fn fold_ty(&&x: @Ty) -> @Ty {
         let (n, s) = (self.fold_ty)(x.node, x.span, self as ast_fold);
-        return @{id: (self.new_id)(x.id), node: n, span: (self.new_span)(s)};
+        @Ty {
+            id: (self.new_id)(x.id),
+            node: n,
+            span: (self.new_span)(s),
+        }
     }
     fn fold_mod(x: _mod) -> _mod {
         return (self.fold_mod)(x, self as ast_fold);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 486ec56523b..2db9cdf3c30 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -478,17 +478,27 @@ impl Parser {
         return if self.eat(token::RARROW) {
             let lo = self.span.lo;
             if self.eat(token::NOT) {
-                (noreturn, @{id: self.get_id(),
-                             node: ty_bot,
-                             span: mk_sp(lo, self.last_span.hi)})
+                (
+                    noreturn,
+                    @Ty {
+                        id: self.get_id(),
+                        node: ty_bot,
+                        span: mk_sp(lo, self.last_span.hi)
+                    }
+                )
             } else {
                 (return_val, self.parse_ty(false))
             }
         } else {
             let pos = self.span.lo;
-            (return_val, @{id: self.get_id(),
-                           node: ty_nil,
-                           span: mk_sp(pos, pos)})
+            (
+                return_val,
+                @Ty {
+                    id: self.get_id(),
+                    node: ty_nil,
+                    span: mk_sp(pos, pos),
+                }
+            )
         }
     }
 
@@ -580,7 +590,7 @@ impl Parser {
         } else { self.fatal(~"expected type"); };
 
         let sp = mk_sp(lo, self.last_span.hi);
-        return @{id: self.get_id(), node: t, span: sp};
+        @Ty {id: self.get_id(), node: t, span: sp}
     }
 
     fn parse_box_or_uniq_pointee(
@@ -731,9 +741,11 @@ impl Parser {
             let t = if p.eat(token::COLON) {
                 p.parse_ty(false)
             } else {
-                @{id: p.get_id(),
-                  node: ty_infer,
-                  span: mk_sp(p.span.lo, p.span.hi)}
+                @Ty {
+                    id: p.get_id(),
+                    node: ty_infer,
+                    span: mk_sp(p.span.lo, p.span.hi),
+                }
             };
             either::Left({mode: m, ty: t, pat: pat, id: p.get_id()})
         }
@@ -1565,7 +1577,7 @@ impl Parser {
                     ({
                         {
                             inputs: ~[],
-                            output: @{
+                            output: @Ty {
                                 id: self.get_id(),
                                 node: ty_infer,
                                 span: self.span
@@ -2150,9 +2162,11 @@ impl Parser {
                    allow_init: bool) -> @local {
         let lo = self.span.lo;
         let pat = self.parse_pat(false);
-        let mut ty = @{id: self.get_id(),
-                       node: ty_infer,
-                       span: mk_sp(lo, lo)};
+        let mut ty = @Ty {
+            id: self.get_id(),
+            node: ty_infer,
+            span: mk_sp(lo, lo),
+        };
         if self.eat(token::COLON) { ty = self.parse_ty(false); }
         let init = if allow_init { self.parse_initializer() } else { None };
         @spanned(
@@ -2430,9 +2444,13 @@ impl Parser {
     }
 
     fn mk_ty_path(i: ident) -> @Ty {
-        @{id: self.get_id(), node: ty_path(
-            ident_to_path(copy self.last_span, i),
-            self.get_id()), span: self.last_span}
+        @Ty {
+            id: self.get_id(),
+            node: ty_path(
+                ident_to_path(copy self.last_span, i),
+                self.get_id()),
+            span: self.last_span,
+        }
     }
 
     fn parse_optional_purity() -> ast::purity {
@@ -2650,7 +2668,7 @@ impl Parser {
         let output = if self.eat(token::RARROW) {
             self.parse_ty(false)
         } else {
-            @{id: self.get_id(), node: ty_infer, span: self.span}
+            @Ty { id: self.get_id(), node: ty_infer, span: self.span }
         };
         return ({inputs: either::lefts(inputs_captures),
                  output: output,
@@ -2733,7 +2751,11 @@ impl Parser {
     //    impl<T> ~[T] : to_str { ... }
     fn parse_item_impl() -> item_info {
         fn wrap_path(p: Parser, pt: @path) -> @Ty {
-            @{id: p.get_id(), node: ty_path(pt, p.get_id()), span: pt.span}
+            @Ty {
+                id: p.get_id(),
+                node: ty_path(pt, p.get_id()),
+                span: pt.span,
+            }
         }
 
         // We do two separate paths here: old-style impls and new-style impls.
@@ -2786,7 +2808,7 @@ impl Parser {
              idents: ~[i],
              rp: None,
              types: do typarams.map |tp| {
-                @{
+                @Ty {
                     id: self.get_id(),
                     node: ty_path(ident_to_path(s, tp.ident), self.get_id()),
                     span: s
@@ -2938,13 +2960,19 @@ impl Parser {
             self.obsolete(copy self.span, ObsoleteClassMethod);
             self.parse_method();
             // bogus value
-            @spanned(self.span.lo, self.span.hi,
-                     ast::struct_field_ {
-                       kind: unnamed_field,
-                       id: self.get_id(),
-                       ty: @{id: self.get_id(),
-                             node: ty_nil,
-                             span: copy self.span} })
+            @spanned(
+                self.span.lo,
+                self.span.hi,
+                ast::struct_field_ {
+                    kind: unnamed_field,
+                    id: self.get_id(),
+                    ty: @ast::Ty {
+                        id: self.get_id(),
+                        node: ty_nil,
+                        span: copy self.span,
+                    }
+                }
+            )
         }
     }