about summary refs log tree commit diff
path: root/src/libsyntax/ext/build.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-08-08 11:38:10 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-08-27 18:47:57 -0700
commit8693943676487c01fa09f5f3daf0df6a1f71e24d (patch)
tree5aa978e4144d51f320d069d88fe0fad4ed40705e /src/libsyntax/ext/build.rs
parent3b6314c39bfc13b5a41c53f13c3fafa7ad91e062 (diff)
librustc: Ensure that type parameters are in the right positions in paths.
This removes the stacking of type parameters that occurs when invoking
trait methods, and fixes all places in the standard library that were
relying on it. It is somewhat awkward in places; I think we'll probably
want something like the `Foo::<for T>::new()` syntax.
Diffstat (limited to 'src/libsyntax/ext/build.rs')
-rw-r--r--src/libsyntax/ext/build.rs31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index a62a1d121e2..21d67493cbf 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -74,6 +74,13 @@ pub trait AstBuilder {
     // statements
     fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt;
     fn stmt_let(&self, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt;
+    fn stmt_let_typed(&self,
+                      sp: span,
+                      mutbl: bool,
+                      ident: ast::ident,
+                      typ: ast::Ty,
+                      ex: @ast::expr)
+                      -> @ast::stmt;
 
     // blocks
     fn block(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block;
@@ -241,8 +248,8 @@ impl AstBuilder for @ExtCtxt {
                 types: ~[ast::Ty])
                 -> ast::Path {
         let last_identifier = idents.pop();
-        let mut segments: ~[ast::PathSegment] = idents.consume_iter()
-                                                      .transform(|ident| {
+        let mut segments: ~[ast::PathSegment] = idents.move_iter()
+                                                      .map(|ident| {
             ast::PathSegment {
                 identifier: ident,
                 lifetime: None,
@@ -400,6 +407,26 @@ impl AstBuilder for @ExtCtxt {
         @respan(sp, ast::stmt_decl(@decl, self.next_id()))
     }
 
+    fn stmt_let_typed(&self,
+                      sp: span,
+                      mutbl: bool,
+                      ident: ast::ident,
+                      typ: ast::Ty,
+                      ex: @ast::expr)
+                      -> @ast::stmt {
+        let pat = self.pat_ident(sp, ident);
+        let local = @ast::Local {
+            is_mutbl: mutbl,
+            ty: typ,
+            pat: pat,
+            init: Some(ex),
+            id: self.next_id(),
+            span: sp,
+        };
+        let decl = respan(sp, ast::decl_local(local));
+        @respan(sp, ast::stmt_decl(@decl, self.next_id()))
+    }
+
     fn block(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block {
         self.block_all(span, ~[], stmts, expr)
     }