about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-01 20:35:55 -0800
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-01 20:35:55 -0800
commitaa3505d8ff043f0c1da62de4f517eed6defb6187 (patch)
treed0f82e2e5dd7b3dfeeb8b593ed0d76393e41ff05 /src/libsyntax
parent85fecd0ba77066e604cec9d3866b76edc626b5d3 (diff)
parent0fd1b58f236b4fe653d164836e94feebb2972931 (diff)
downloadrust-aa3505d8ff043f0c1da62de4f517eed6defb6187.tar.gz
rust-aa3505d8ff043f0c1da62de4f517eed6defb6187.zip
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/auto_encode.rs4
-rw-r--r--src/libsyntax/ext/pipes/ast_builder.rs10
-rw-r--r--src/libsyntax/opt_vec.rs18
-rw-r--r--src/libsyntax/parse/parser.rs12
-rw-r--r--src/libsyntax/syntax.rc3
5 files changed, 29 insertions, 18 deletions
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 8cebe3cd187..0e2f3c2c856 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -469,8 +469,8 @@ fn mk_impl(
     let ty = cx.ty_path(
         span,
         ~[ident],
-        generics.ty_params.map(
-            |tp| cx.ty_path(span, ~[tp.ident], ~[])).to_vec()
+        opt_vec::take_vec(generics.ty_params.map(
+            |tp| cx.ty_path(span, ~[tp.ident], ~[])))
     );
 
     let generics = ast::Generics {
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 40d0e2c5db2..3b885b7a7b9 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -434,13 +434,15 @@ impl ext_ctxt_ast_builder for ext_ctxt {
     }
 
     fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
-        ty_params.map(|p| self.ty_path_ast_builder(
-            path(~[p.ident], dummy_sp()))).to_vec()
+        opt_vec::take_vec(
+            ty_params.map(|p| self.ty_path_ast_builder(
+                path(~[p.ident], dummy_sp()))))
     }
 
     fn ty_vars_global(&self,
                       ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
-        ty_params.map(|p| self.ty_path_ast_builder(
-            path(~[p.ident], dummy_sp()))).to_vec()
+        opt_vec::take_vec(
+            ty_params.map(|p| self.ty_path_ast_builder(
+                path(~[p.ident], dummy_sp()))))
     }
 }
diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs
index 052a3e48791..16db384bb06 100644
--- a/src/libsyntax/opt_vec.rs
+++ b/src/libsyntax/opt_vec.rs
@@ -31,6 +31,14 @@ pub fn with<T>(+t: T) -> OptVec<T> {
     Vec(~[t])
 }
 
+pub fn from<T>(+t: ~[T]) -> OptVec<T> {
+    if t.len() == 0 {
+        Empty
+    } else {
+        Vec(t)
+    }
+}
+
 impl<T> OptVec<T> {
     fn push(&mut self, +t: T) {
         match *self {
@@ -70,12 +78,12 @@ impl<T> OptVec<T> {
             Vec(ref v) => v.len()
         }
     }
+}
 
-    pure fn to_vec(self) -> ~[T] {
-        match self {
-            Empty => ~[],
-            Vec(v) => v
-        }
+pub fn take_vec<T>(+v: OptVec<T>) -> ~[T] {
+    match v {
+        Empty => ~[],
+        Vec(v) => v
     }
 }
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index b0b2107703c..127af5b73ac 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1195,7 +1195,7 @@ pub impl Parser {
                         &token::RBRACKET,
                         seq_sep_trailing_allowed(token::COMMA),
                         |p| p.parse_expr()
-                    ).to_vec();
+                    );
                     ex = expr_vec(~[first_expr] + remaining_exprs, mutbl);
                 } else {
                     // Vector with one element.
@@ -1478,7 +1478,7 @@ pub impl Parser {
                                 &ket,
                                 seq_sep_none(),
                                 |p| p.parse_token_tree()
-                            ).to_vec(),
+                            ),
                             // the close delimiter:
                             ~[parse_any_tt_tok(&self)]
                         )
@@ -2806,7 +2806,7 @@ pub impl Parser {
         let result = self.parse_seq_to_gt(
             Some(token::COMMA),
             |p| p.parse_ty(false));
-        result.to_vec()
+        opt_vec::take_vec(result)
     }
 
     fn parse_fn_decl(parse_arg_fn: fn(&Parser) -> arg_or_capture_item)
@@ -2908,7 +2908,7 @@ pub impl Parser {
                         &token::RPAREN,
                         sep,
                         parse_arg_fn
-                    ).to_vec();
+                    );
                 }
                 token::RPAREN => {
                     args_or_capture_items = ~[];
@@ -2928,7 +2928,7 @@ pub impl Parser {
                 &token::RPAREN,
                 sep,
                 parse_arg_fn
-            ).to_vec();
+            );
         }
 
         self.expect(&token::RPAREN);
@@ -3130,7 +3130,7 @@ pub impl Parser {
             ket,
             seq_sep_none(),
             |p| p.parse_trait_ref()
-        ).to_vec()
+        )
     }
 
     fn parse_item_struct() -> item_info {
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index 9eb7507f3d0..f6e358e535f 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -14,6 +14,7 @@
 
 
 
+#[license = "MIT/ASL2"];
 #[crate_type = "lib"];
 
 #[legacy_modes];