about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/auto_encode.rs44
-rw-r--r--src/libsyntax/ext/build.rs49
-rw-r--r--src/libsyntax/ext/deriving.rs12
-rw-r--r--src/libsyntax/ext/expand.rs7
-rw-r--r--src/libsyntax/ext/pipes/ast_builder.rs31
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs6
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs2
7 files changed, 79 insertions, 72 deletions
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 152c49461b8..a3f208a3f07 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -299,8 +299,8 @@ priv impl ext_ctxt {
     }
 
     fn stmt(expr: @ast::expr) -> @ast::stmt {
-        @{node: ast::stmt_semi(expr, self.next_id()),
-          span: expr.span}
+        @ast::spanned { node: ast::stmt_semi(expr, self.next_id()),
+                       span: expr.span }
     }
 
     fn lit_str(span: span, s: @~str) -> @ast::expr {
@@ -310,8 +310,8 @@ priv impl ext_ctxt {
                 self.expr(
                     span,
                     ast::expr_lit(
-                        @{node: ast::lit_str(s),
-                          span: span})),
+                        @ast::spanned { node: ast::lit_str(s),
+                                        span: span})),
                 ast::expr_vstore_uniq))
     }
 
@@ -319,8 +319,8 @@ priv impl ext_ctxt {
         self.expr(
             span,
             ast::expr_lit(
-                @{node: ast::lit_uint(i as u64, ast::ty_u),
-                  span: span}))
+                @ast::spanned { node: ast::lit_uint(i as u64, ast::ty_u),
+                                span: span}))
     }
 
     fn lambda(blk: ast::blk) -> @ast::expr {
@@ -330,21 +330,21 @@ priv impl ext_ctxt {
     }
 
     fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
-        {node: {view_items: ~[],
-                stmts: stmts,
-                expr: None,
-                id: self.next_id(),
-                rules: ast::default_blk},
-         span: span}
+        ast::spanned { node: { view_items: ~[],
+                               stmts: stmts,
+                               expr: None,
+                               id: self.next_id(),
+                               rules: ast::default_blk},
+                       span: span }
     }
 
     fn expr_blk(expr: @ast::expr) -> ast::blk {
-        {node: {view_items: ~[],
-                stmts: ~[],
-                expr: Some(expr),
-                id: self.next_id(),
-                rules: ast::default_blk},
-         span: expr.span}
+        ast::spanned { node: { view_items: ~[],
+                               stmts: ~[],
+                               expr: Some(expr),
+                               id: self.next_id(),
+                               rules: ast::default_blk},
+                       span: expr.span }
     }
 
     fn expr_path(span: span, strs: ~[ast::ident]) -> @ast::expr {
@@ -570,7 +570,8 @@ fn mk_ser_method(
         ident: cx.ident_of(~"encode"),
         attrs: ~[],
         tps: ~[],
-        self_ty: { node: ast::sty_region(ast::m_imm), span: span },
+        self_ty: ast::spanned { node: ast::sty_region(ast::m_imm),
+                                span: span },
         purity: ast::impure_fn,
         decl: ser_decl,
         body: ser_body,
@@ -624,7 +625,8 @@ fn mk_deser_method(
         ident: cx.ident_of(~"decode"),
         attrs: ~[],
         tps: ~[],
-        self_ty: { 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,
@@ -862,7 +864,7 @@ fn mk_deser_fields(
             ]
         );
 
-        {
+        ast::spanned {
             node: { 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 4a3c8ee2259..288ef1b273e 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -26,7 +26,7 @@ fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) ->
 }
 
 fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
-    let sp_lit = @{node: lit, span: sp};
+    let sp_lit = @ast::spanned { node: lit, span: sp };
     mk_expr(cx, sp, ast::expr_lit(sp_lit))
 }
 fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr {
@@ -136,7 +136,8 @@ 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 {
-    {node: {mutbl: ast::m_imm, ident: f.ident, expr: f.ex}, span: sp}
+    ast::spanned { node: {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] {
@@ -159,9 +160,10 @@ fn mk_struct_e(cx: ext_ctxt, sp: span,
 }
 fn mk_glob_use(cx: ext_ctxt, sp: span,
                path: ~[ast::ident]) -> @ast::view_item {
-    let glob = @{node: ast::view_path_glob(mk_raw_path(sp, path),
-                                          cx.next_id()),
-                span: sp};
+    let glob = @ast::spanned {
+        node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()),
+        span: sp,
+    };
     @{node: ast::view_item_import(~[glob]),
       attrs: ~[],
       vis: ast::private,
@@ -176,29 +178,29 @@ 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 local : @ast::local = @{node: {is_mutbl: mutbl,
-                                       ty: ty,
-                                       pat: pat,
-                                       init: Some(ex),
-                                       id: cx.next_id()},
-                                span: sp};
-    let decl = {node: ast::decl_local(~[local]), span: sp};
-    @{ node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
+    let local : @ast::local = @ast::spanned { node: { is_mutbl: mutbl,
+                                                      ty: ty,
+                                                      pat: pat,
+                                                      init: Some(ex),
+                                                      id: cx.next_id()},
+                                              span: sp};
+    let decl = ast::spanned {node: ast::decl_local(~[local]), span: sp};
+    @ast::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
 }
 fn mk_block(cx: ext_ctxt, sp: span,
             view_items: ~[@ast::view_item],
             stmts: ~[@ast::stmt],
             expr: Option<@ast::expr>) -> @ast::expr {
-    let blk = {node: {view_items: view_items,
-                      stmts: stmts,
-                      expr: expr,
-                      id: cx.next_id(),
-                      rules: ast::default_blk },
-               span: sp };
+    let blk = ast::spanned { node: { view_items: view_items,
+                                     stmts: stmts,
+                                     expr: expr,
+                                     id: cx.next_id(),
+                                     rules: ast::default_blk },
+                             span: sp };
     mk_expr(cx, sp, ast::expr_block(blk))
 }
 fn mk_block_(cx: ext_ctxt, sp: span, +stmts: ~[@ast::stmt]) -> ast::blk {
-    {
+    ast::spanned {
         node: {
             view_items: ~[],
             stmts: move stmts,
@@ -217,7 +219,7 @@ fn mk_simple_block(cx: ext_ctxt, span: span, expr: @ast::expr) -> ast::blk {
         id: cx.next_id(),
         rules: ast::default_blk
     };
-    { node: move block, span: span }
+    ast::spanned { node: block, span: span }
 }
 fn mk_copy(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
     mk_expr(cx, sp, ast::expr_copy(e))
@@ -250,12 +252,13 @@ fn mk_pat_struct(cx: ext_ctxt,
     mk_pat(cx, span, move pat)
 }
 fn mk_bool(cx: ext_ctxt, span: span, value: bool) -> @ast::expr {
-    let lit_expr = ast::expr_lit(@{ node: ast::lit_bool(value), span: span });
+    let lit_expr = ast::expr_lit(@ast::spanned { node: ast::lit_bool(value),
+                                                 span: span });
     build::mk_expr(cx, span, move lit_expr)
 }
 fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
     let stmt_ = ast::stmt_semi(expr, cx.next_id());
-    @{ node: move stmt_, span: span }
+    @ast::spanned { node: move stmt_, span: span }
 }
 fn mk_ty_path(cx: ext_ctxt,
               span: span,
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index 41804b1022a..8e36dc01e2a 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -16,10 +16,10 @@ use core::prelude::*;
 use ast::{Ty, and, bind_by_ref, binop, deref, enum_def, enum_variant_kind};
 use ast::{expr, expr_match, ident, item, item_, item_struct, item_enum};
 use ast::{item_impl, m_imm, meta_item, method, named_field, or, pat};
-use ast::{pat_ident, pat_wild, public, pure_fn, re_anon, stmt, struct_def};
-use ast::{struct_variant_kind, sty_by_ref, sty_region, tuple_variant_kind};
-use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_rptr, unnamed_field};
-use ast::{variant};
+use ast::{pat_ident, pat_wild, public, pure_fn, re_anon, spanned, stmt};
+use ast::{struct_def, struct_variant_kind, sty_by_ref, sty_region};
+use ast::{tuple_variant_kind, ty_nil, ty_param, ty_param_bound, ty_path};
+use ast::{ty_rptr, unnamed_field, variant};
 use ext::base::ext_ctxt;
 use ext::build;
 use codemap::span;
@@ -159,7 +159,7 @@ fn create_eq_method(cx: ext_ctxt,
     let body_block = build::mk_simple_block(cx, span, body);
 
     // Create the method.
-    let self_ty = { node: sty_region(m_imm), span: span };
+    let self_ty = spanned { node: sty_region(m_imm), span: span };
     return @{
         ident: method_ident,
         attrs: ~[],
@@ -309,7 +309,7 @@ fn create_iter_bytes_method(cx: ext_ctxt,
     let body_block = build::mk_block_(cx, span, move statements);
 
     // Create the method.
-    let self_ty = { node: sty_region(m_imm), span: span };
+    let self_ty = spanned { node: sty_region(m_imm), span: span };
     let method_ident = cx.ident_of(~"iter_bytes");
     return @{
         ident: method_ident,
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 8faeb167191..82dae3e26b3 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -156,7 +156,9 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
                    fld: ast_fold) -> Option<@ast::item> {
 
     let (pth, tts) = match it.node {
-        item_mac({node: mac_invoc_tt(pth, ref tts), _}) => (pth, (*tts)),
+        item_mac(ast::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
+            (pth, (*tts))
+        }
         _ => cx.span_bug(it.span, ~"invalid item macro invocation")
     };
 
@@ -234,7 +236,8 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
                 {call_site: sp, callie: {name: *extname, span: exp_sp}}));
             let expanded = match exp(cx, mac.span, tts) {
                 mr_expr(e) =>
-                    @{node: stmt_expr(e, cx.next_id()), span: e.span},
+                    @ast::spanned { node: stmt_expr(e, cx.next_id()),
+                                    span: e.span},
                 mr_any(_,_,stmt_mkr) => stmt_mkr(),
                 _ => cx.span_fatal(
                     pth.span,
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 56ace4aac1b..3e265de04a3 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -136,8 +136,8 @@ impl ext_ctxt: ext_ctxt_ast_builder {
     }
 
     fn stmt_expr(e: @ast::expr) -> @ast::stmt {
-        @{node: ast::stmt_expr(e, self.next_id()),
-          span: dummy_sp()}
+        @spanned { node: ast::stmt_expr(e, self.next_id()),
+                   span: dummy_sp()}
     }
 
     fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt {
@@ -146,8 +146,8 @@ impl ext_ctxt: ext_ctxt_ast_builder {
     }
 
     fn field_imm(name: ident, e: @ast::expr) -> ast::field {
-        {node: {mutbl: ast::m_imm, ident: name, expr: e},
-         span: dummy_sp()}
+        spanned { node: { mutbl: ast::m_imm, ident: name, expr: e },
+                  span: dummy_sp()}
     }
 
     fn rec(+fields: ~[ast::field]) -> @ast::expr {
@@ -158,8 +158,8 @@ impl ext_ctxt: ext_ctxt_ast_builder {
     }
 
     fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
-        {node: {ident: name, mt: { ty: ty, mutbl: ast::m_imm } },
-          span: dummy_sp()}
+        spanned { node: { ident: name, mt: { ty: ty, mutbl: ast::m_imm } },
+                  span: dummy_sp() }
     }
 
     fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty {
@@ -199,8 +199,7 @@ impl ext_ctxt: ext_ctxt_ast_builder {
                    id: self.next_id(),
                    rules: ast::default_blk};
 
-        {node: blk,
-         span: dummy_sp()}
+        spanned { node: blk, span: dummy_sp() }
     }
 
     fn expr_block(e: @ast::expr) -> ast::blk {
@@ -275,13 +274,13 @@ impl ext_ctxt: ext_ctxt_ast_builder {
                +tys: ~[@ast::Ty]) -> ast::variant {
         let args = tys.map(|ty| {ty: *ty, id: self.next_id()});
 
-        {node: {name: name,
-                attrs: ~[],
-                kind: ast::tuple_variant_kind(args),
-                id: self.next_id(),
-                disr_expr: None,
-                vis: ast::public},
-         span: span}
+        spanned { node: { 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,
@@ -290,7 +289,7 @@ impl ext_ctxt: ext_ctxt_ast_builder {
         // XXX: Total hack: import `core::kinds::Owned` to work around a
         // parser bug whereby `fn f<T: ::kinds::Owned>` doesn't parse.
         let vi = ast::view_item_import(~[
-            @{
+            @ast::spanned {
                 node: ast::view_path_simple(
                     self.ident_of(~"Owned"),
                     path(
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 724e2fc9dba..2449db17c0f 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -189,13 +189,13 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match])
     fn n_rec(p_s: parse_sess, m: matcher, res: ~[@named_match],
              ret_val: HashMap<ident, @named_match>) {
         match m {
-          {node: match_tok(_), span: _} => (),
-          {node: match_seq(ref more_ms, _, _, _, _), span: _} => {
+          spanned {node: match_tok(_), _} => (),
+          spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
             for (*more_ms).each() |next_m| {
                 n_rec(p_s, *next_m, res, ret_val)
             };
           }
-          {node: match_nonterminal(bind_name, _, idx), span: sp} => {
+          spanned {node: match_nonterminal(bind_name, _, idx), span: sp} => {
             if ret_val.contains_key(bind_name) {
                 p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+
                                                *p_s.interner.get(bind_name))
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 1f1efdfe165..069eb1e0d82 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -33,7 +33,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
                      arg: ~[ast::token_tree]) -> base::mac_result {
     // these spans won't matter, anyways
     fn ms(m: matcher_) -> matcher {
-        {node: m, span: dummy_sp()}
+        ast::spanned { node: m, span: dummy_sp() }
     }
 
     let lhs_nm =  cx.parse_sess().interner.gensym(@~"lhs");