about summary refs log tree commit diff
path: root/src/libsyntax/ext/quote.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-02-28 13:09:09 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-03-01 22:40:52 -0800
commit58fd6ab90db3eb68c94695e1254a73e57bc44658 (patch)
tree51078e799ec82df848205dce6f32a8f1c0c312f5 /src/libsyntax/ext/quote.rs
parentdf40aeccdbfcfb0cc7851c6df24f28fbeccfe046 (diff)
downloadrust-58fd6ab90db3eb68c94695e1254a73e57bc44658.tar.gz
rust-58fd6ab90db3eb68c94695e1254a73e57bc44658.zip
libsyntax: Mechanically change `~[T]` to `Vec<T>`
Diffstat (limited to 'src/libsyntax/ext/quote.rs')
-rw-r--r--src/libsyntax/ext/quote.rs104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 35a5cbd235a..3b8df84acc3 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -41,11 +41,11 @@ pub mod rt {
     pub use codemap::{BytePos, Span, dummy_spanned};
 
     pub trait ToTokens {
-        fn to_tokens(&self, _cx: &ExtCtxt) -> ~[TokenTree];
+        fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> ;
     }
 
-    impl ToTokens for ~[TokenTree] {
-        fn to_tokens(&self, _cx: &ExtCtxt) -> ~[TokenTree] {
+    impl ToTokens for Vec<TokenTree> {
+        fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
             (*self).clone()
         }
     }
@@ -201,7 +201,7 @@ pub mod rt {
     macro_rules! impl_to_tokens(
         ($t:ty) => (
             impl ToTokens for $t {
-                fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] {
+                fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
                     cx.parse_tts(self.to_source())
                 }
             }
@@ -211,7 +211,7 @@ pub mod rt {
     macro_rules! impl_to_tokens_self(
         ($t:ty) => (
             impl<'a> ToTokens for $t {
-                fn to_tokens(&self, cx: &ExtCtxt) -> ~[TokenTree] {
+                fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
                     cx.parse_tts(self.to_source())
                 }
             }
@@ -242,7 +242,7 @@ pub mod rt {
         fn parse_item(&self, s: ~str) -> @ast::Item;
         fn parse_expr(&self, s: ~str) -> @ast::Expr;
         fn parse_stmt(&self, s: ~str) -> @ast::Stmt;
-        fn parse_tts(&self, s: ~str) -> ~[ast::TokenTree];
+        fn parse_tts(&self, s: ~str) -> Vec<ast::TokenTree> ;
     }
 
     impl<'a> ExtParseUtils for ExtCtxt<'a> {
@@ -266,7 +266,7 @@ pub mod rt {
             parse::parse_stmt_from_source_str("<quote expansion>".to_str(),
                                               s,
                                               self.cfg(),
-                                              ~[],
+                                              Vec::new(),
                                               self.parse_sess())
         }
 
@@ -277,7 +277,7 @@ pub mod rt {
                                               self.parse_sess())
         }
 
-        fn parse_tts(&self, s: ~str) -> ~[ast::TokenTree] {
+        fn parse_tts(&self, s: ~str) -> Vec<ast::TokenTree> {
             parse::parse_tts_from_source_str("<quote expansion>".to_str(),
                                              s,
                                              self.cfg(),
@@ -298,16 +298,16 @@ pub fn expand_quote_tokens(cx: &mut ExtCtxt,
 pub fn expand_quote_expr(cx: &mut ExtCtxt,
                          sp: Span,
                          tts: &[ast::TokenTree]) -> base::MacResult {
-    let expanded = expand_parse_call(cx, sp, "parse_expr", ~[], tts);
+    let expanded = expand_parse_call(cx, sp, "parse_expr", Vec::new(), tts);
     base::MRExpr(expanded)
 }
 
 pub fn expand_quote_item(cx: &mut ExtCtxt,
                          sp: Span,
                          tts: &[ast::TokenTree]) -> base::MacResult {
-    let e_attrs = cx.expr_vec_uniq(sp, ~[]);
+    let e_attrs = cx.expr_vec_uniq(sp, Vec::new());
     let expanded = expand_parse_call(cx, sp, "parse_item",
-                                    ~[e_attrs], tts);
+                                    vec!(e_attrs), tts);
     base::MRExpr(expanded)
 }
 
@@ -316,7 +316,7 @@ pub fn expand_quote_pat(cx: &mut ExtCtxt,
                         tts: &[ast::TokenTree]) -> base::MacResult {
     let e_refutable = cx.expr_lit(sp, ast::LitBool(true));
     let expanded = expand_parse_call(cx, sp, "parse_pat",
-                                    ~[e_refutable], tts);
+                                    vec!(e_refutable), tts);
     base::MRExpr(expanded)
 }
 
@@ -325,20 +325,20 @@ pub fn expand_quote_ty(cx: &mut ExtCtxt,
                        tts: &[ast::TokenTree]) -> base::MacResult {
     let e_param_colons = cx.expr_lit(sp, ast::LitBool(false));
     let expanded = expand_parse_call(cx, sp, "parse_ty",
-                                     ~[e_param_colons], tts);
+                                     vec!(e_param_colons), tts);
     base::MRExpr(expanded)
 }
 
 pub fn expand_quote_stmt(cx: &mut ExtCtxt,
                          sp: Span,
                          tts: &[ast::TokenTree]) -> base::MacResult {
-    let e_attrs = cx.expr_vec_uniq(sp, ~[]);
+    let e_attrs = cx.expr_vec_uniq(sp, Vec::new());
     let expanded = expand_parse_call(cx, sp, "parse_stmt",
-                                    ~[e_attrs], tts);
+                                    vec!(e_attrs), tts);
     base::MRExpr(expanded)
 }
 
-fn ids_ext(strs: ~[~str]) -> ~[ast::Ident] {
+fn ids_ext(strs: Vec<~str> ) -> Vec<ast::Ident> {
     strs.map(|str| str_to_ident(*str))
 }
 
@@ -352,7 +352,7 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr {
     cx.expr_method_call(sp,
                         cx.expr_ident(sp, id_ext("ext_cx")),
                         id_ext("ident_of"),
-                        ~[e_str])
+                        vec!(e_str))
 }
 
 fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> @ast::Expr {
@@ -377,18 +377,18 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
         BINOP(binop) => {
             return cx.expr_call_ident(sp,
                                       id_ext("BINOP"),
-                                      ~[mk_binop(cx, sp, binop)]);
+                                      vec!(mk_binop(cx, sp, binop)));
         }
         BINOPEQ(binop) => {
             return cx.expr_call_ident(sp,
                                       id_ext("BINOPEQ"),
-                                      ~[mk_binop(cx, sp, binop)]);
+                                      vec!(mk_binop(cx, sp, binop)));
         }
 
         LIT_CHAR(i) => {
             let e_char = cx.expr_lit(sp, ast::LitChar(i));
 
-            return cx.expr_call_ident(sp, id_ext("LIT_CHAR"), ~[e_char]);
+            return cx.expr_call_ident(sp, id_ext("LIT_CHAR"), vec!(e_char));
         }
 
         LIT_INT(i, ity) => {
@@ -405,7 +405,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
 
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_INT"),
-                                      ~[e_i64, e_ity]);
+                                      vec!(e_i64, e_ity));
         }
 
         LIT_UINT(u, uty) => {
@@ -422,7 +422,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
 
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_UINT"),
-                                      ~[e_u64, e_uty]);
+                                      vec!(e_u64, e_uty));
         }
 
         LIT_INT_UNSUFFIXED(i) => {
@@ -430,7 +430,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
 
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_INT_UNSUFFIXED"),
-                                      ~[e_i64]);
+                                      vec!(e_i64));
         }
 
         LIT_FLOAT(fident, fty) => {
@@ -444,39 +444,39 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
 
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_FLOAT"),
-                                      ~[e_fident, e_fty]);
+                                      vec!(e_fident, e_fty));
         }
 
         LIT_STR(ident) => {
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_STR"),
-                                      ~[mk_ident(cx, sp, ident)]);
+                                      vec!(mk_ident(cx, sp, ident)));
         }
 
         LIT_STR_RAW(ident, n) => {
             return cx.expr_call_ident(sp,
                                       id_ext("LIT_STR_RAW"),
-                                      ~[mk_ident(cx, sp, ident),
-                                        cx.expr_uint(sp, n)]);
+                                      vec!(mk_ident(cx, sp, ident),
+                                        cx.expr_uint(sp, n)));
         }
 
         IDENT(ident, b) => {
             return cx.expr_call_ident(sp,
                                       id_ext("IDENT"),
-                                      ~[mk_ident(cx, sp, ident),
-                                        cx.expr_bool(sp, b)]);
+                                      vec!(mk_ident(cx, sp, ident),
+                                        cx.expr_bool(sp, b)));
         }
 
         LIFETIME(ident) => {
             return cx.expr_call_ident(sp,
                                       id_ext("LIFETIME"),
-                                      ~[mk_ident(cx, sp, ident)]);
+                                      vec!(mk_ident(cx, sp, ident)));
         }
 
         DOC_COMMENT(ident) => {
             return cx.expr_call_ident(sp,
                                       id_ext("DOC_COMMENT"),
-                                      ~[mk_ident(cx, sp, ident)]);
+                                      vec!(mk_ident(cx, sp, ident)));
         }
 
         INTERPOLATED(_) => fail!("quote! with interpolated token"),
@@ -523,7 +523,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
 }
 
 
-fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> ~[@ast::Stmt] {
+fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<@ast::Stmt> {
 
     match *tt {
 
@@ -531,13 +531,13 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> ~[@ast::Stmt] {
             let e_sp = cx.expr_ident(sp, id_ext("_sp"));
             let e_tok = cx.expr_call_ident(sp,
                                            id_ext("TTTok"),
-                                           ~[e_sp, mk_token(cx, sp, tok)]);
+                                           vec!(e_sp, mk_token(cx, sp, tok)));
             let e_push =
                 cx.expr_method_call(sp,
                                     cx.expr_ident(sp, id_ext("tt")),
                                     id_ext("push"),
-                                    ~[e_tok]);
-            ~[cx.stmt_expr(e_push)]
+                                    vec!(e_tok));
+            vec!(cx.stmt_expr(e_push))
         }
 
         ast::TTDelim(ref tts) => mk_tts(cx, sp, **tts),
@@ -551,22 +551,22 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> ~[@ast::Stmt] {
                 cx.expr_method_call(sp,
                                     cx.expr_ident(sp, ident),
                                     id_ext("to_tokens"),
-                                    ~[cx.expr_ident(sp, id_ext("ext_cx"))]);
+                                    vec!(cx.expr_ident(sp, id_ext("ext_cx"))));
 
             let e_push =
                 cx.expr_method_call(sp,
                                     cx.expr_ident(sp, id_ext("tt")),
                                     id_ext("push_all_move"),
-                                    ~[e_to_toks]);
+                                    vec!(e_to_toks));
 
-            ~[cx.stmt_expr(e_push)]
+            vec!(cx.stmt_expr(e_push))
         }
     }
 }
 
 fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-    -> ~[@ast::Stmt] {
-    let mut ss = ~[];
+    -> Vec<@ast::Stmt> {
+    let mut ss = Vec::new();
     for tt in tts.iter() {
         ss.push_all_move(mk_tt(cx, sp, tt));
     }
@@ -623,7 +623,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let e_sp = cx.expr_method_call(sp,
                                    cx.expr_ident(sp, id_ext("ext_cx")),
                                    id_ext("call_site"),
-                                   ~[]);
+                                   Vec::new());
 
     let stmt_let_sp = cx.stmt_let(sp, false,
                                   id_ext("_sp"),
@@ -631,12 +631,12 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
     let stmt_let_tt = cx.stmt_let(sp, true,
                                   id_ext("tt"),
-                                  cx.expr_vec_uniq(sp, ~[]));
+                                  cx.expr_vec_uniq(sp, Vec::new()));
 
     let block = cx.expr_block(
         cx.block_all(sp,
-                     ~[],
-                     ~[stmt_let_sp, stmt_let_tt] + mk_tts(cx, sp, tts),
+                     Vec::new(),
+                     vec!(stmt_let_sp, stmt_let_tt) + mk_tts(cx, sp, tts),
                      Some(cx.expr_ident(sp, id_ext("tt")))));
 
     (cx_expr, block)
@@ -646,36 +646,36 @@ fn expand_wrapper(cx: &ExtCtxt,
                   sp: Span,
                   cx_expr: @ast::Expr,
                   expr: @ast::Expr) -> @ast::Expr {
-    let uses = ~[ cx.view_use_glob(sp, ast::Inherited,
-                                   ids_ext(~[~"syntax",
+    let uses = vec!( cx.view_use_glob(sp, ast::Inherited,
+                                   ids_ext(vec!(~"syntax",
                                              ~"ext",
                                              ~"quote",
-                                             ~"rt"])) ];
+                                             ~"rt"))) );
 
     let stmt_let_ext_cx = cx.stmt_let(sp, false, id_ext("ext_cx"), cx_expr);
 
-    cx.expr_block(cx.block_all(sp, uses, ~[stmt_let_ext_cx], Some(expr)))
+    cx.expr_block(cx.block_all(sp, uses, vec!(stmt_let_ext_cx), Some(expr)))
 }
 
 fn expand_parse_call(cx: &ExtCtxt,
                      sp: Span,
                      parse_method: &str,
-                     arg_exprs: ~[@ast::Expr],
+                     arg_exprs: Vec<@ast::Expr> ,
                      tts: &[ast::TokenTree]) -> @ast::Expr {
     let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
 
     let cfg_call = || cx.expr_method_call(
         sp, cx.expr_ident(sp, id_ext("ext_cx")),
-        id_ext("cfg"), ~[]);
+        id_ext("cfg"), Vec::new());
 
     let parse_sess_call = || cx.expr_method_call(
         sp, cx.expr_ident(sp, id_ext("ext_cx")),
-        id_ext("parse_sess"), ~[]);
+        id_ext("parse_sess"), Vec::new());
 
     let new_parser_call =
         cx.expr_call(sp,
                      cx.expr_ident(sp, id_ext("new_parser_from_tts")),
-                     ~[parse_sess_call(), cfg_call(), tts_expr]);
+                     vec!(parse_sess_call(), cfg_call(), tts_expr));
 
     let expr = cx.expr_method_call(sp, new_parser_call, id_ext(parse_method),
                                    arg_exprs);