summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorJohn Clements <clements@racket-lang.org>2013-01-30 09:56:33 -0800
committerJohn Clements <clements@racket-lang.org>2013-01-31 23:05:12 -0800
commit53688addaa4484f1a317bb0938cf453381810427 (patch)
tree2c025b1dc64129e4651df886918a07af9896a14f /src/libsyntax/ext
parente343abd0ed11227425eca16e186367eced39cd82 (diff)
downloadrust-53688addaa4484f1a317bb0938cf453381810427.tar.gz
rust-53688addaa4484f1a317bb0938cf453381810427.zip
test cases, cleanup
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/auto_encode.rs16
-rw-r--r--src/libsyntax/ext/base.rs3
-rw-r--r--src/libsyntax/ext/build.rs25
-rw-r--r--src/libsyntax/ext/deriving.rs4
-rw-r--r--src/libsyntax/ext/expand.rs4
-rw-r--r--src/libsyntax/ext/pipes/ast_builder.rs13
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs11
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs5
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs9
10 files changed, 46 insertions, 46 deletions
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index e406e09aac0..4dddb66995b 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -311,7 +311,7 @@ priv impl ext_ctxt {
     }
 
     fn stmt(expr: @ast::expr) -> @ast::stmt {
-        @ast::spanned { node: ast::stmt_semi(expr, self.next_id()),
+        @codemap::spanned { node: ast::stmt_semi(expr, self.next_id()),
                        span: expr.span }
     }
 
@@ -322,7 +322,7 @@ priv impl ext_ctxt {
                 self.expr(
                     span,
                     ast::expr_lit(
-                        @ast::spanned { node: ast::lit_str(s),
+                        @codemap::spanned { node: ast::lit_str(s),
                                         span: span})),
                 ast::expr_vstore_uniq))
     }
@@ -331,7 +331,7 @@ priv impl ext_ctxt {
         self.expr(
             span,
             ast::expr_lit(
-                @ast::spanned { node: ast::lit_uint(i as u64, ast::ty_u),
+                @codemap::spanned { node: ast::lit_uint(i as u64, ast::ty_u),
                                 span: span}))
     }
 
@@ -342,7 +342,7 @@ priv impl ext_ctxt {
     }
 
     fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
-        ast::spanned {
+        codemap::spanned {
             node: ast::blk_ {
                 view_items: ~[],
                 stmts: stmts,
@@ -355,7 +355,7 @@ priv impl ext_ctxt {
     }
 
     fn expr_blk(expr: @ast::expr) -> ast::blk {
-        ast::spanned {
+        codemap::spanned {
             node: ast::blk_ {
                 view_items: ~[],
                 stmts: ~[],
@@ -593,7 +593,7 @@ fn mk_ser_method(
         ident: cx.ident_of(~"encode"),
         attrs: ~[],
         tps: ~[],
-        self_ty: ast::spanned { node: ast::sty_region(ast::m_imm),
+        self_ty: codemap::spanned { node: ast::sty_region(ast::m_imm),
                                 span: span },
         purity: ast::impure_fn,
         decl: ser_decl,
@@ -651,7 +651,7 @@ fn mk_deser_method(
         ident: cx.ident_of(~"decode"),
         attrs: ~[],
         tps: ~[],
-        self_ty: ast::spanned { node: ast::sty_static, span: span },
+        self_ty: codemap::spanned { node: ast::sty_static, span: span },
         purity: ast::impure_fn,
         decl: deser_decl,
         body: deser_body,
@@ -762,7 +762,7 @@ fn mk_struct_deser_impl(
             ]
         );
 
-        ast::spanned {
+        codemap::spanned {
             node: ast::field_ {
                 mutbl: field.mutbl,
                 ident: field.ident,
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index d0974e0654c..a37ce512ac1 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -11,9 +11,8 @@
 use core::prelude::*;
 
 use ast;
-use ast_util::dummy_sp;
 use codemap;
-use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom};
+use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom, dummy_sp};
 use diagnostic::span_handler;
 use ext;
 use parse;
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 6d44a412742..4d8fd39c960 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -32,7 +32,7 @@ pub fn mk_expr(cx: ext_ctxt,
 }
 
 pub fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
-    let sp_lit = @ast::spanned { node: lit, span: sp };
+    let sp_lit = @codemap::spanned { node: lit, span: sp };
     mk_expr(cx, sp, ast::expr_lit(sp_lit))
 }
 pub fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr {
@@ -149,7 +149,7 @@ pub fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr {
 }
 pub fn mk_field(sp: span, f: &{ident: ast::ident, ex: @ast::expr})
              -> ast::field {
-    ast::spanned {
+    codemap::spanned {
         node: ast::field_ { mutbl: ast::m_imm, ident: f.ident, expr: f.ex },
         span: sp,
     }
@@ -188,7 +188,7 @@ pub fn mk_global_struct_e(cx: ext_ctxt,
 pub fn mk_glob_use(cx: ext_ctxt,
                    sp: span,
                    path: ~[ast::ident]) -> @ast::view_item {
-    let glob = @ast::spanned {
+    let glob = @codemap::spanned {
         node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()),
         span: sp,
     };
@@ -209,7 +209,7 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
         span: sp,
     };
     let ty = @ast::Ty { id: cx.next_id(), node: ast::ty_infer, span: sp };
-    let local = @ast::spanned {
+    let local = @codemap::spanned {
         node: ast::local_ {
             is_mutbl: mutbl,
             ty: ty,
@@ -219,14 +219,14 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
         },
         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 }
+    let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp};
+    @codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
 }
 pub fn mk_block(cx: ext_ctxt, span: span,
                 view_items: ~[@ast::view_item],
                 stmts: ~[@ast::stmt],
                 expr: Option<@ast::expr>) -> @ast::expr {
-    let blk = ast::spanned {
+    let blk = codemap::spanned {
         node: ast::blk_ {
              view_items: view_items,
              stmts: stmts,
@@ -242,7 +242,7 @@ pub fn mk_block_(cx: ext_ctxt,
                  span: span,
                  +stmts: ~[@ast::stmt])
               -> ast::blk {
-    ast::spanned {
+    codemap::spanned {
         node: ast::blk_ {
             view_items: ~[],
             stmts: stmts,
@@ -257,7 +257,7 @@ pub fn mk_simple_block(cx: ext_ctxt,
                        span: span,
                        expr: @ast::expr)
                     -> ast::blk {
-    ast::spanned {
+    codemap::spanned {
         node: ast::blk_ {
             view_items: ~[],
             stmts: ~[],
@@ -307,13 +307,14 @@ pub fn mk_pat_struct(cx: ext_ctxt,
     mk_pat(cx, span, move pat)
 }
 pub fn mk_bool(cx: ext_ctxt, span: span, value: bool) -> @ast::expr {
-    let lit_expr = ast::expr_lit(@ast::spanned { node: ast::lit_bool(value),
-                                                 span: span });
+    let lit_expr = ast::expr_lit(@codemap::spanned {
+        node: ast::lit_bool(value),
+        span: span });
     build::mk_expr(cx, span, move lit_expr)
 }
 pub fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
     let stmt_ = ast::stmt_semi(expr, cx.next_id());
-    @ast::spanned { node: move stmt_, span: span }
+    @codemap::spanned { node: move stmt_, span: span }
 }
 pub fn mk_ty_path(cx: ext_ctxt,
                   span: span,
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index d542b104e54..8e87357f8b5 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -18,12 +18,12 @@ use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def};
 use ast::{enum_variant_kind, expr, expr_match, ident, item, item_};
 use ast::{item_enum, item_impl, item_struct, m_imm, meta_item, method};
 use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn};
-use ast::{re_anon, spanned, stmt, struct_def, struct_variant_kind};
+use ast::{re_anon, stmt, struct_def, struct_variant_kind};
 use ast::{sty_by_ref, sty_region, tuple_variant_kind, ty_nil, ty_param};
 use ast::{ty_param_bound, ty_path, ty_rptr, unnamed_field, variant};
 use ext::base::ext_ctxt;
 use ext::build;
-use codemap::span;
+use codemap::{span, spanned};
 use parse::token::special_idents::clownshoes_extensions;
 
 use core::dvec;
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 0ab94710f40..be768650ef7 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -154,7 +154,7 @@ pub fn expand_item_mac(exts: HashMap<~str, SyntaxExtension>,
                        fld: ast_fold) -> Option<@ast::item> {
 
     let (pth, tts) = match it.node {
-        item_mac(ast::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
+        item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
             (pth, (*tts))
         }
         _ => cx.span_bug(it.span, ~"invalid item macro invocation")
@@ -234,7 +234,7 @@ pub fn expand_stmt(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt,
                 {call_site: sp, callie: {name: *extname, span: exp_sp}}));
             let expanded = match exp(cx, mac.span, tts) {
                 MRExpr(e) =>
-                    @ast::spanned { node: stmt_expr(e, cx.next_id()),
+                    @codemap::spanned { node: stmt_expr(e, cx.next_id()),
                                     span: e.span},
                 MRAny(_,_,stmt_mkr) => stmt_mkr(),
                 _ => cx.span_fatal(
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 8abca3d97f9..58ab05987a6 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -17,10 +17,11 @@ use core::prelude::*;
 
 use ast::{ident, node_id};
 use ast;
-use ast_util::{ident_to_path, respan, dummy_sp};
+use ast_util::{ident_to_path};
 use ast_util;
 use attr;
-use codemap::span;
+use codemap::{span, respan, dummy_sp};
+use codemap;
 use ext::base::{ext_ctxt, mk_ctxt};
 use ext::quote::rt::*;
 
@@ -310,7 +311,7 @@ pub 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 {
+            @codemap::spanned {
                 node: ast::view_path_simple(
                     self.ident_of(~"Owned"),
                     path(
@@ -319,19 +320,19 @@ pub impl ext_ctxt: ext_ctxt_ast_builder {
                             self.ident_of(~"kinds"),
                             self.ident_of(~"Owned")
                         ],
-                        ast_util::dummy_sp()
+                        codemap::dummy_sp()
                     ),
                     ast::type_value_ns,
                     self.next_id()
                 ),
-                span: ast_util::dummy_sp()
+                span: codemap::dummy_sp()
             }
         ]);
         let vi = @ast::view_item {
             node: vi,
             attrs: ~[],
             vis: ast::private,
-            span: ast_util::dummy_sp()
+            span: codemap::dummy_sp()
         };
 
         self.item(
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 928885cf817..8c73dcfc04f 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -11,7 +11,7 @@
 // A protocol compiler for Rust.
 
 use ast::ident;
-use ast_util::dummy_sp;
+use codemap::dummy_sp;
 use ext::base::ext_ctxt;
 use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
 use ext::pipes::ast_builder::{path_global};
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 1c7a12a4282..a31af36cc54 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -10,8 +10,7 @@
 
 // Earley-like parser for macros.
 use ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
-use ast_util::mk_sp;
-use codemap::BytePos;
+use codemap::{BytePos, mk_sp};
 use codemap;
 use parse::common::*; //resolve bug?
 use parse::lexer::*; //resolve bug?
@@ -189,13 +188,13 @@ pub 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 {
-          ast::spanned {node: match_tok(_), _} => (),
-          ast::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
+          codemap::spanned {node: match_tok(_), _} => (),
+          codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
             for (*more_ms).each() |next_m| {
                 n_rec(p_s, *next_m, res, ret_val)
             };
           }
-          ast::spanned {
+          codemap::spanned {
                 node: match_nonterminal(bind_name, _, idx), span: sp
           } => {
             if ret_val.contains_key(bind_name) {
@@ -239,7 +238,7 @@ pub fn parse(sess: parse_sess,
         let mut next_eis = ~[]; // or proceed normally
         let mut eof_eis = ~[];
 
-        let {tok: tok, sp: sp} = rdr.peek();
+        let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
 
         /* we append new items to this while we go */
         while cur_eis.len() > 0u { /* for each Earley Item */
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index f7ef79db466..115cb4f5f94 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -13,8 +13,7 @@ use core::prelude::*;
 use ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq};
 use ast::{tt_delim};
 use ast;
-use ast_util::dummy_sp;
-use codemap::span;
+use codemap::{span, spanned, dummy_sp};
 use ext::base::{ext_ctxt, MacResult, MRAny, MRDef, MacroDef, NormalTT};
 use ext::base;
 use ext::tt::macro_parser::{error};
@@ -33,7 +32,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
                          arg: ~[ast::token_tree]) -> base::MacResult {
     // these spans won't matter, anyways
     fn ms(m: matcher_) -> matcher {
-        ast::spanned { node: m, span: dummy_sp() }
+        spanned { node: m, span: dummy_sp() }
     }
 
     let lhs_nm =  cx.parse_sess().interner.gensym(@~"lhs");
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index b3b1e04976a..504a17237dc 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -13,10 +13,11 @@ use core::prelude::*;
 use ast;
 use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,ident};
 use ast_util;
-use codemap::span;
+use codemap::{span, dummy_sp};
 use diagnostic::span_handler;
 use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
 use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident, ident_interner};
+use parse::lexer::TokenAndSpan;
 
 use core::option;
 use core::vec;
@@ -69,7 +70,7 @@ pub fn new_tt_reader(sp_diag: span_handler, itr: @ident_interner,
               mut repeat_len: ~[],
               /* dummy values, never read: */
               mut cur_tok: EOF,
-              mut cur_span: ast_util::dummy_sp()
+              mut cur_span: dummy_sp()
              };
     tt_next_token(r); /* get cur_tok and cur_span set up */
     return r;
@@ -149,8 +150,8 @@ fn lockstep_iter_size(t: token_tree, r: tt_reader) -> lis {
 }
 
 
-pub fn tt_next_token(&&r: tt_reader) -> {tok: Token, sp: span} {
-    let ret_val = { tok: r.cur_tok, sp: r.cur_span };
+pub fn tt_next_token(&&r: tt_reader) -> TokenAndSpan {
+    let ret_val = TokenAndSpan { tok: r.cur_tok, sp: r.cur_span };
     while r.cur.idx >= r.cur.readme.len() {
         /* done with this set; pop or repeat? */
         if ! r.cur.dotdotdoted