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/asm.rs7
-rw-r--r--src/libsyntax/ext/base.rs123
-rw-r--r--src/libsyntax/ext/build.rs527
-rw-r--r--src/libsyntax/ext/bytes.rs2
-rw-r--r--src/libsyntax/ext/cfg.rs4
-rw-r--r--src/libsyntax/ext/concat.rs2
-rw-r--r--src/libsyntax/ext/concat_idents.rs7
-rw-r--r--src/libsyntax/ext/deriving/bounds.rs9
-rw-r--r--src/libsyntax/ext/deriving/clone.rs13
-rw-r--r--src/libsyntax/ext/deriving/cmp/eq.rs13
-rw-r--r--src/libsyntax/ext/deriving/cmp/ord.rs23
-rw-r--r--src/libsyntax/ext/deriving/cmp/totaleq.rs12
-rw-r--r--src/libsyntax/ext/deriving/cmp/totalord.rs13
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs27
-rw-r--r--src/libsyntax/ext/deriving/default.rs12
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs27
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs264
-rw-r--r--src/libsyntax/ext/deriving/generic/ty.rs7
-rw-r--r--src/libsyntax/ext/deriving/hash.rs22
-rw-r--r--src/libsyntax/ext/deriving/mod.rs13
-rw-r--r--src/libsyntax/ext/deriving/primitive.rs20
-rw-r--r--src/libsyntax/ext/deriving/rand.rs22
-rw-r--r--src/libsyntax/ext/deriving/show.rs19
-rw-r--r--src/libsyntax/ext/deriving/zero.rs12
-rw-r--r--src/libsyntax/ext/env.rs22
-rw-r--r--src/libsyntax/ext/expand.rs576
-rw-r--r--src/libsyntax/ext/format.rs232
-rw-r--r--src/libsyntax/ext/quote.rs76
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs4
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs30
30 files changed, 1032 insertions, 1108 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index 8028d51a7b5..4b8c3376cad 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -18,8 +18,7 @@ use ext::base;
 use ext::base::*;
 use parse::token::InternedString;
 use parse::token;
-
-use std::gc::GC;
+use ptr::P;
 
 enum State {
     Asm,
@@ -199,7 +198,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         }
     }
 
-    MacExpr::new(box(GC) ast::Expr {
+    MacExpr::new(P(ast::Expr {
         id: ast::DUMMY_NODE_ID,
         node: ast::ExprInlineAsm(ast::InlineAsm {
             asm: token::intern_and_get_ident(asm.get()),
@@ -212,5 +211,5 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             dialect: dialect
         }),
         span: sp
-    })
+    }))
 }
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 4976e68cc64..6e25b6b73ad 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -18,6 +18,7 @@ use parse;
 use parse::parser;
 use parse::token;
 use parse::token::{InternedString, intern, str_to_ident};
+use ptr::P;
 use util::small_vector::SmallVector;
 use ext::mtwt;
 use fold::Folder;
@@ -43,18 +44,18 @@ pub trait ItemDecorator {
     fn expand(&self,
               ecx: &mut ExtCtxt,
               sp: Span,
-              meta_item: Gc<ast::MetaItem>,
-              item: Gc<ast::Item>,
-              push: |Gc<ast::Item>|);
+              meta_item: &ast::MetaItem,
+              item: &ast::Item,
+              push: |P<ast::Item>|);
 }
 
-impl ItemDecorator for fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>, |Gc<ast::Item>|) {
+impl ItemDecorator for fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, |P<ast::Item>|) {
     fn expand(&self,
               ecx: &mut ExtCtxt,
               sp: Span,
-              meta_item: Gc<ast::MetaItem>,
-              item: Gc<ast::Item>,
-              push: |Gc<ast::Item>|) {
+              meta_item: &ast::MetaItem,
+              item: &ast::Item,
+              push: |P<ast::Item>|) {
         (*self)(ecx, sp, meta_item, item, push)
     }
 }
@@ -63,18 +64,18 @@ pub trait ItemModifier {
     fn expand(&self,
               ecx: &mut ExtCtxt,
               span: Span,
-              meta_item: Gc<ast::MetaItem>,
-              item: Gc<ast::Item>)
-              -> Gc<ast::Item>;
+              meta_item: &ast::MetaItem,
+              item: P<ast::Item>)
+              -> P<ast::Item>;
 }
 
-impl ItemModifier for fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>) -> Gc<ast::Item> {
+impl ItemModifier for fn(&mut ExtCtxt, Span, &ast::MetaItem, P<ast::Item>) -> P<ast::Item> {
     fn expand(&self,
               ecx: &mut ExtCtxt,
               span: Span,
-              meta_item: Gc<ast::MetaItem>,
-              item: Gc<ast::Item>)
-              -> Gc<ast::Item> {
+              meta_item: &ast::MetaItem,
+              item: P<ast::Item>)
+              -> P<ast::Item> {
         (*self)(ecx, span, meta_item, item)
     }
 }
@@ -128,29 +129,29 @@ impl IdentMacroExpander for IdentMacroExpanderFn {
 /// methods are spliced into the AST at the callsite of the macro (or
 /// just into the compiler's internal macro table, for `make_def`).
 pub trait MacResult {
-    /// Define a new macro.
+    /// Attempt to define a new macro.
     // this should go away; the idea that a macro might expand into
     // either a macro definition or an expression, depending on what
     // the context wants, is kind of silly.
-    fn make_def(&self) -> Option<MacroDef> {
+    fn make_def(&mut self) -> Option<MacroDef> {
         None
     }
     /// Create an expression.
-    fn make_expr(&self) -> Option<Gc<ast::Expr>> {
+    fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
         None
     }
     /// Create zero or more items.
-    fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
+    fn make_items(self: Box<Self>) -> Option<SmallVector<P<ast::Item>>> {
         None
     }
 
     /// Create zero or more methods.
-    fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
+    fn make_methods(self: Box<Self>) -> Option<SmallVector<P<ast::Method>>> {
         None
     }
 
     /// Create a pattern.
-    fn make_pat(&self) -> Option<Gc<ast::Pat>> {
+    fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> {
         None
     }
 
@@ -158,69 +159,69 @@ pub trait MacResult {
     ///
     /// By default this attempts to create an expression statement,
     /// returning None if that fails.
-    fn make_stmt(&self) -> Option<Gc<ast::Stmt>> {
+    fn make_stmt(self: Box<Self>) -> Option<P<ast::Stmt>> {
         self.make_expr()
-            .map(|e| box(GC) codemap::respan(e.span, ast::StmtExpr(e, ast::DUMMY_NODE_ID)))
+            .map(|e| P(codemap::respan(e.span, ast::StmtExpr(e, ast::DUMMY_NODE_ID))))
     }
 }
 
 /// A convenience type for macros that return a single expression.
 pub struct MacExpr {
-    e: Gc<ast::Expr>,
+    e: P<ast::Expr>
 }
 impl MacExpr {
-    pub fn new(e: Gc<ast::Expr>) -> Box<MacResult+'static> {
+    pub fn new(e: P<ast::Expr>) -> Box<MacResult+'static> {
         box MacExpr { e: e } as Box<MacResult+'static>
     }
 }
 impl MacResult for MacExpr {
-    fn make_expr(&self) -> Option<Gc<ast::Expr>> {
+    fn make_expr(self: Box<MacExpr>) -> Option<P<ast::Expr>> {
         Some(self.e)
     }
-    fn make_pat(&self) -> Option<Gc<ast::Pat>> {
+    fn make_pat(self: Box<MacExpr>) -> Option<P<ast::Pat>> {
         match self.e.node {
-            ast::ExprLit(_) => Some(box(GC) ast::Pat {
+            ast::ExprLit(_) => Some(P(ast::Pat {
                 id: ast::DUMMY_NODE_ID,
-                node: ast::PatLit(self.e),
-                span: self.e.span
-            }),
+                span: self.e.span,
+                node: ast::PatLit(self.e)
+            })),
             _ => None
         }
     }
 }
 /// A convenience type for macros that return a single pattern.
 pub struct MacPat {
-    p: Gc<ast::Pat>,
+    p: P<ast::Pat>
 }
 impl MacPat {
-    pub fn new(p: Gc<ast::Pat>) -> Box<MacResult+'static> {
+    pub fn new(p: P<ast::Pat>) -> Box<MacResult+'static> {
         box MacPat { p: p } as Box<MacResult+'static>
     }
 }
 impl MacResult for MacPat {
-    fn make_pat(&self) -> Option<Gc<ast::Pat>> {
+    fn make_pat(self: Box<MacPat>) -> Option<P<ast::Pat>> {
         Some(self.p)
     }
 }
 /// A convenience type for macros that return a single item.
 pub struct MacItem {
-    i: Gc<ast::Item>
+    i: P<ast::Item>
 }
 impl MacItem {
-    pub fn new(i: Gc<ast::Item>) -> Box<MacResult+'static> {
+    pub fn new(i: P<ast::Item>) -> Box<MacResult+'static> {
         box MacItem { i: i } as Box<MacResult+'static>
     }
 }
 impl MacResult for MacItem {
-    fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
+    fn make_items(self: Box<MacItem>) -> Option<SmallVector<P<ast::Item>>> {
         Some(SmallVector::one(self.i))
     }
-    fn make_stmt(&self) -> Option<Gc<ast::Stmt>> {
-        Some(box(GC) codemap::respan(
+    fn make_stmt(self: Box<MacItem>) -> Option<P<ast::Stmt>> {
+        Some(P(codemap::respan(
             self.i.span,
             ast::StmtDecl(
-                box(GC) codemap::respan(self.i.span, ast::DeclItem(self.i)),
-                ast::DUMMY_NODE_ID)))
+                P(codemap::respan(self.i.span, ast::DeclItem(self.i))),
+                ast::DUMMY_NODE_ID))))
     }
 }
 
@@ -250,17 +251,17 @@ impl DummyResult {
     }
 
     /// A plain dummy expression.
-    pub fn raw_expr(sp: Span) -> Gc<ast::Expr> {
-        box(GC) ast::Expr {
+    pub fn raw_expr(sp: Span) -> P<ast::Expr> {
+        P(ast::Expr {
             id: ast::DUMMY_NODE_ID,
-            node: ast::ExprLit(box(GC) codemap::respan(sp, ast::LitNil)),
+            node: ast::ExprLit(P(codemap::respan(sp, ast::LitNil))),
             span: sp,
-        }
+        })
     }
 
     /// A plain dummy pattern.
-    pub fn raw_pat(sp: Span) -> Gc<ast::Pat> {
-        box(GC) ast::Pat {
+    pub fn raw_pat(sp: Span) -> ast::Pat {
+        ast::Pat {
             id: ast::DUMMY_NODE_ID,
             node: ast::PatWild(ast::PatWildSingle),
             span: sp,
@@ -270,13 +271,13 @@ impl DummyResult {
 }
 
 impl MacResult for DummyResult {
-    fn make_expr(&self) -> Option<Gc<ast::Expr>> {
+    fn make_expr(self: Box<DummyResult>) -> Option<P<ast::Expr>> {
         Some(DummyResult::raw_expr(self.span))
     }
-    fn make_pat(&self) -> Option<Gc<ast::Pat>> {
-        Some(DummyResult::raw_pat(self.span))
+    fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
+        Some(P(DummyResult::raw_pat(self.span)))
     }
-    fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
+    fn make_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Item>>> {
         // this code needs a comment... why not always just return the Some() ?
         if self.expr_only {
             None
@@ -284,17 +285,17 @@ impl MacResult for DummyResult {
             Some(SmallVector::zero())
         }
     }
-    fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
+    fn make_methods(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Method>>> {
         if self.expr_only {
             None
         } else {
             Some(SmallVector::zero())
         }
     }
-    fn make_stmt(&self) -> Option<Gc<ast::Stmt>> {
-        Some(box(GC) codemap::respan(self.span,
-                              ast::StmtExpr(DummyResult::raw_expr(self.span),
-                                            ast::DUMMY_NODE_ID)))
+    fn make_stmt(self: Box<DummyResult>) -> Option<P<ast::Stmt>> {
+        Some(P(codemap::respan(self.span,
+                               ast::StmtExpr(DummyResult::raw_expr(self.span),
+                                             ast::DUMMY_NODE_ID))))
     }
 }
 
@@ -461,7 +462,7 @@ pub struct ExtCtxt<'a> {
 
     pub mod_path: Vec<ast::Ident> ,
     pub trace_mac: bool,
-    pub exported_macros: Vec<Gc<ast::Item>>,
+    pub exported_macros: Vec<P<ast::Item>>,
 
     pub syntax_env: SyntaxEnv,
 }
@@ -482,7 +483,7 @@ impl<'a> ExtCtxt<'a> {
     }
 
     #[deprecated = "Replaced with `expander().fold_expr()`"]
-    pub fn expand_expr(&mut self, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    pub fn expand_expr(&mut self, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expander().fold_expr(e)
     }
 
@@ -595,12 +596,12 @@ impl<'a> ExtCtxt<'a> {
 /// Extract a string literal from the macro expanded version of `expr`,
 /// emitting `err_msg` if `expr` is not a string literal. This does not stop
 /// compilation on error, merely emits a non-fatal error and returns None.
-pub fn expr_to_string(cx: &mut ExtCtxt, expr: Gc<ast::Expr>, err_msg: &str)
-                   -> Option<(InternedString, ast::StrStyle)> {
+pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
+                      -> Option<(InternedString, ast::StrStyle)> {
     // we want to be able to handle e.g. concat("foo", "bar")
     let expr = cx.expander().fold_expr(expr);
     match expr.node {
-        ast::ExprLit(l) => match l.node {
+        ast::ExprLit(ref l) => match l.node {
             ast::LitStr(ref s, style) => return Some(((*s).clone(), style)),
             _ => cx.span_err(l.span, err_msg)
         },
@@ -651,7 +652,7 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt,
 /// parsing error, emit a non-fatal error and return None.
 pub fn get_exprs_from_tts(cx: &mut ExtCtxt,
                           sp: Span,
-                          tts: &[ast::TokenTree]) -> Option<Vec<Gc<ast::Expr>>> {
+                          tts: &[ast::TokenTree]) -> Option<Vec<P<ast::Expr>>> {
     let mut p = cx.new_parser_from_tts(tts);
     let mut es = Vec::new();
     while p.token != token::EOF {
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 6bd1fba4b58..eda373c4fb8 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -9,19 +9,18 @@
 // except according to those terms.
 
 use abi;
-use ast::{P, Ident, Generics, NodeId, Expr};
+use ast::{Ident, Generics, Expr};
 use ast;
 use ast_util;
 use attr;
 use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
 use ext::base::ExtCtxt;
-use fold::Folder;
 use owned_slice::OwnedSlice;
 use parse::token::special_idents;
 use parse::token::InternedString;
 use parse::token;
+use ptr::P;
 
-use std::gc::{Gc, GC};
 
 // Transitional reexports so qquote can find the paths it is looking for
 mod syntax {
@@ -64,7 +63,6 @@ pub trait AstBuilder {
     fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ;
     fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ;
     fn ty_field_imm(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::TypeField;
-    fn strip_bounds(&self, bounds: &Generics) -> Generics;
 
     fn typaram(&self,
                span: Span,
@@ -83,140 +81,130 @@ pub trait AstBuilder {
                     -> ast::LifetimeDef;
 
     // statements
-    fn stmt_expr(&self, expr: Gc<ast::Expr>) -> Gc<ast::Stmt>;
-    fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
-                ex: Gc<ast::Expr>) -> Gc<ast::Stmt>;
+    fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt>;
+    fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P<ast::Expr>) -> P<ast::Stmt>;
     fn stmt_let_typed(&self,
                       sp: Span,
                       mutbl: bool,
                       ident: ast::Ident,
                       typ: P<ast::Ty>,
-                      ex: Gc<ast::Expr>)
-                      -> Gc<ast::Stmt>;
-    fn stmt_item(&self, sp: Span, item: Gc<ast::Item>) -> Gc<ast::Stmt>;
+                      ex: P<ast::Expr>)
+                      -> P<ast::Stmt>;
+    fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt>;
 
     // blocks
-    fn block(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>,
-             expr: Option<Gc<ast::Expr>>) -> P<ast::Block>;
-    fn block_expr(&self, expr: Gc<ast::Expr>) -> P<ast::Block>;
+    fn block(&self, span: Span, stmts: Vec<P<ast::Stmt>>,
+             expr: Option<P<ast::Expr>>) -> P<ast::Block>;
+    fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block>;
     fn block_all(&self, span: Span,
-                 view_items: Vec<ast::ViewItem> ,
-                 stmts: Vec<Gc<ast::Stmt>> ,
-                 expr: Option<Gc<ast::Expr>>) -> P<ast::Block>;
+                 view_items: Vec<ast::ViewItem>,
+                 stmts: Vec<P<ast::Stmt>>,
+                 expr: Option<P<ast::Expr>>) -> P<ast::Block>;
 
     // expressions
-    fn expr(&self, span: Span, node: ast::Expr_) -> Gc<ast::Expr>;
-    fn expr_path(&self, path: ast::Path) -> Gc<ast::Expr>;
-    fn expr_ident(&self, span: Span, id: ast::Ident) -> Gc<ast::Expr>;
+    fn expr(&self, span: Span, node: ast::Expr_) -> P<ast::Expr>;
+    fn expr_path(&self, path: ast::Path) -> P<ast::Expr>;
+    fn expr_ident(&self, span: Span, id: ast::Ident) -> P<ast::Expr>;
 
-    fn expr_self(&self, span: Span) -> Gc<ast::Expr>;
+    fn expr_self(&self, span: Span) -> P<ast::Expr>;
     fn expr_binary(&self, sp: Span, op: ast::BinOp,
-                   lhs: Gc<ast::Expr>, rhs: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_deref(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_unary(&self, sp: Span, op: ast::UnOp, e: Gc<ast::Expr>) -> Gc<ast::Expr>;
-
-    fn expr_managed(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_mut_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_field_access(&self, span: Span, expr: Gc<ast::Expr>,
-                         ident: ast::Ident) -> Gc<ast::Expr>;
-    fn expr_tup_field_access(&self, sp: Span, expr: Gc<ast::Expr>,
-                             idx: uint) -> Gc<ast::Expr>;
-    fn expr_call(&self, span: Span, expr: Gc<ast::Expr>,
-                 args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr>;
-    fn expr_call_ident(&self, span: Span, id: ast::Ident,
-                       args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr>;
-    fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident> ,
-                        args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr>;
+                   lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>;
+
+    fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_field_access(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
+    fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>,
+                             idx: uint) -> P<ast::Expr>;
+    fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
+    fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
+    fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident>,
+                        args: Vec<P<ast::Expr>> ) -> P<ast::Expr>;
     fn expr_method_call(&self, span: Span,
-                        expr: Gc<ast::Expr>, ident: ast::Ident,
-                        args: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr>;
-    fn expr_block(&self, b: P<ast::Block>) -> Gc<ast::Expr>;
-    fn expr_cast(&self, sp: Span, expr: Gc<ast::Expr>,
-                 ty: P<ast::Ty>) -> Gc<ast::Expr>;
-
-    fn field_imm(&self, span: Span, name: Ident, e: Gc<ast::Expr>) -> ast::Field;
-    fn expr_struct(&self, span: Span, path: ast::Path,
-                   fields: Vec<ast::Field> ) -> Gc<ast::Expr>;
+                        expr: P<ast::Expr>, ident: ast::Ident,
+                        args: Vec<P<ast::Expr>> ) -> P<ast::Expr>;
+    fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr>;
+    fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr>;
+
+    fn field_imm(&self, span: Span, name: Ident, e: P<ast::Expr>) -> ast::Field;
+    fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field>) -> P<ast::Expr>;
     fn expr_struct_ident(&self, span: Span, id: ast::Ident,
-                         fields: Vec<ast::Field> ) -> Gc<ast::Expr>;
+                         fields: Vec<ast::Field>) -> P<ast::Expr>;
 
-    fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> Gc<ast::Expr>;
+    fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr>;
 
-    fn expr_uint(&self, span: Span, i: uint) -> Gc<ast::Expr>;
-    fn expr_int(&self, sp: Span, i: int) -> Gc<ast::Expr>;
-    fn expr_u8(&self, sp: Span, u: u8) -> Gc<ast::Expr>;
-    fn expr_bool(&self, sp: Span, value: bool) -> Gc<ast::Expr>;
+    fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr>;
+    fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr>;
+    fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
+    fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
 
-    fn expr_vec(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr>;
-    fn expr_vec_ng(&self, sp: Span) -> Gc<ast::Expr>;
-    fn expr_vec_slice(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr>;
-    fn expr_str(&self, sp: Span, s: InternedString) -> Gc<ast::Expr>;
+    fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
+    fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr>;
+    fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
+    fn expr_str(&self, sp: Span, s: InternedString) -> P<ast::Expr>;
 
-    fn expr_some(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_none(&self, sp: Span) -> Gc<ast::Expr>;
+    fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_none(&self, sp: Span) -> P<ast::Expr>;
 
-    fn expr_tuple(&self, sp: Span, exprs: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr>;
+    fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
 
-    fn expr_fail(&self, span: Span, msg: InternedString) -> Gc<ast::Expr>;
-    fn expr_unreachable(&self, span: Span) -> Gc<ast::Expr>;
+    fn expr_fail(&self, span: Span, msg: InternedString) -> P<ast::Expr>;
+    fn expr_unreachable(&self, span: Span) -> P<ast::Expr>;
 
-    fn expr_ok(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_err(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn expr_try(&self, span: Span, head: Gc<ast::Expr>) -> Gc<ast::Expr>;
+    fn expr_ok(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_err(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
+    fn expr_try(&self, span: Span, head: P<ast::Expr>) -> P<ast::Expr>;
 
-    fn pat(&self, span: Span, pat: ast::Pat_) -> Gc<ast::Pat>;
-    fn pat_wild(&self, span: Span) -> Gc<ast::Pat>;
-    fn pat_lit(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Pat>;
-    fn pat_ident(&self, span: Span, ident: ast::Ident) -> Gc<ast::Pat>;
+    fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat>;
+    fn pat_wild(&self, span: Span) -> P<ast::Pat>;
+    fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat>;
+    fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat>;
 
     fn pat_ident_binding_mode(&self,
                               span: Span,
                               ident: ast::Ident,
-                              bm: ast::BindingMode) -> Gc<ast::Pat>;
-    fn pat_enum(&self, span: Span, path: ast::Path,
-                subpats: Vec<Gc<ast::Pat>>) -> Gc<ast::Pat>;
+                              bm: ast::BindingMode) -> P<ast::Pat>;
+    fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>> ) -> P<ast::Pat>;
     fn pat_struct(&self, span: Span,
-                  path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> Gc<ast::Pat>;
-    fn pat_tuple(&self, span: Span, pats: Vec<Gc<ast::Pat>>) -> Gc<ast::Pat>;
+                  path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> P<ast::Pat>;
+    fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat>;
 
-    fn pat_some(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat>;
-    fn pat_none(&self, span: Span) -> Gc<ast::Pat>;
+    fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
+    fn pat_none(&self, span: Span) -> P<ast::Pat>;
 
-    fn pat_ok(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat>;
-    fn pat_err(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat>;
+    fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
+    fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
 
-    fn arm(&self, span: Span, pats: Vec<Gc<ast::Pat>> , expr: Gc<ast::Expr>) -> ast::Arm;
+    fn arm(&self, span: Span, pats: Vec<P<ast::Pat>>, expr: P<ast::Expr>) -> ast::Arm;
     fn arm_unreachable(&self, span: Span) -> ast::Arm;
 
-    fn expr_match(&self, span: Span, arg: Gc<ast::Expr>, arms: Vec<ast::Arm> ) -> Gc<ast::Expr>;
+    fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm> ) -> P<ast::Expr>;
     fn expr_if(&self, span: Span,
-               cond: Gc<ast::Expr>, then: Gc<ast::Expr>,
-               els: Option<Gc<ast::Expr>>) -> Gc<ast::Expr>;
-    fn expr_loop(&self, span: Span, block: P<ast::Block>) -> Gc<ast::Expr>;
+               cond: P<ast::Expr>, then: P<ast::Expr>, els: Option<P<ast::Expr>>) -> P<ast::Expr>;
+    fn expr_loop(&self, span: Span, block: P<ast::Block>) -> P<ast::Expr>;
 
     fn lambda_fn_decl(&self, span: Span,
-                      fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> Gc<ast::Expr>;
+                      fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr>;
 
-    fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> Gc<ast::Expr>;
-    fn lambda0(&self, span: Span, blk: P<ast::Block>) -> Gc<ast::Expr>;
-    fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> Gc<ast::Expr>;
+    fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> P<ast::Expr>;
+    fn lambda0(&self, span: Span, blk: P<ast::Block>) -> P<ast::Expr>;
+    fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> P<ast::Expr>;
 
-    fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident> , blk: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn lambda_expr_0(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr>;
-    fn lambda_expr_1(&self, span: Span, expr: Gc<ast::Expr>, ident: ast::Ident) -> Gc<ast::Expr>;
+    fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Expr>) -> P<ast::Expr>;
+    fn lambda_expr_0(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
+    fn lambda_expr_1(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
 
     fn lambda_stmts(&self, span: Span, ids: Vec<ast::Ident>,
-                    blk: Vec<Gc<ast::Stmt>>) -> Gc<ast::Expr>;
-    fn lambda_stmts_0(&self, span: Span,
-                      stmts: Vec<Gc<ast::Stmt>>) -> Gc<ast::Expr>;
-    fn lambda_stmts_1(&self, span: Span,
-                      stmts: Vec<Gc<ast::Stmt>>, ident: ast::Ident) -> Gc<ast::Expr>;
+                    blk: Vec<P<ast::Stmt>>) -> P<ast::Expr>;
+    fn lambda_stmts_0(&self, span: Span, stmts: Vec<P<ast::Stmt>>) -> P<ast::Expr>;
+    fn lambda_stmts_1(&self, span: Span, stmts: Vec<P<ast::Stmt>>,
+                      ident: ast::Ident) -> P<ast::Expr>;
 
     // items
     fn item(&self, span: Span,
-            name: Ident, attrs: Vec<ast::Attribute>,
-            node: ast::Item_) -> Gc<ast::Item>;
+            name: Ident, attrs: Vec<ast::Attribute> , node: ast::Item_) -> P<ast::Item>;
 
     fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg;
     // FIXME unused self
@@ -228,67 +216,64 @@ pub trait AstBuilder {
                     inputs: Vec<ast::Arg> ,
                     output: P<ast::Ty>,
                     generics: Generics,
-                    body: P<ast::Block>) -> Gc<ast::Item>;
+                    body: P<ast::Block>) -> P<ast::Item>;
     fn item_fn(&self,
                span: Span,
                name: Ident,
                inputs: Vec<ast::Arg> ,
                output: P<ast::Ty>,
-               body: P<ast::Block>) -> Gc<ast::Item>;
+               body: P<ast::Block>) -> P<ast::Item>;
 
     fn variant(&self, span: Span, name: Ident, tys: Vec<P<ast::Ty>> ) -> ast::Variant;
     fn item_enum_poly(&self,
                       span: Span,
                       name: Ident,
                       enum_definition: ast::EnumDef,
-                      generics: Generics) -> Gc<ast::Item>;
-    fn item_enum(&self, span: Span, name: Ident,
-                 enum_def: ast::EnumDef) -> Gc<ast::Item>;
+                      generics: Generics) -> P<ast::Item>;
+    fn item_enum(&self, span: Span, name: Ident, enum_def: ast::EnumDef) -> P<ast::Item>;
 
     fn item_struct_poly(&self,
                         span: Span,
                         name: Ident,
                         struct_def: ast::StructDef,
-                        generics: Generics) -> Gc<ast::Item>;
-    fn item_struct(&self, span: Span, name: Ident,
-                   struct_def: ast::StructDef) -> Gc<ast::Item>;
+                        generics: Generics) -> P<ast::Item>;
+    fn item_struct(&self, span: Span, name: Ident, struct_def: ast::StructDef) -> P<ast::Item>;
 
     fn item_mod(&self, span: Span, inner_span: Span,
                 name: Ident, attrs: Vec<ast::Attribute>,
-                vi: Vec<ast::ViewItem>,
-                items: Vec<Gc<ast::Item>>) -> Gc<ast::Item>;
+                vi: Vec<ast::ViewItem> , items: Vec<P<ast::Item>> ) -> P<ast::Item>;
 
     fn item_static(&self,
                    span: Span,
                    name: Ident,
                    ty: P<ast::Ty>,
                    mutbl: ast::Mutability,
-                   expr: Gc<ast::Expr>)
-                   -> Gc<ast::Item>;
+                   expr: P<ast::Expr>)
+                   -> P<ast::Item>;
 
     fn item_ty_poly(&self,
                     span: Span,
                     name: Ident,
                     ty: P<ast::Ty>,
-                    generics: Generics) -> Gc<ast::Item>;
-    fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> Gc<ast::Item>;
+                    generics: Generics) -> P<ast::Item>;
+    fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item>;
 
-    fn attribute(&self, sp: Span, mi: Gc<ast::MetaItem>) -> ast::Attribute;
+    fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute;
 
-    fn meta_word(&self, sp: Span, w: InternedString) -> Gc<ast::MetaItem>;
+    fn meta_word(&self, sp: Span, w: InternedString) -> P<ast::MetaItem>;
     fn meta_list(&self,
                  sp: Span,
                  name: InternedString,
-                 mis: Vec<Gc<ast::MetaItem>>)
-                 -> Gc<ast::MetaItem>;
+                 mis: Vec<P<ast::MetaItem>> )
+                 -> P<ast::MetaItem>;
     fn meta_name_value(&self,
                        sp: Span,
                        name: InternedString,
                        value: ast::Lit_)
-                       -> Gc<ast::MetaItem>;
+                       -> P<ast::MetaItem>;
 
     fn view_use(&self, sp: Span,
-                vis: ast::Visibility, vp: Gc<ast::ViewPath>) -> ast::ViewItem;
+                vis: ast::Visibility, vp: P<ast::ViewPath>) -> ast::ViewItem;
     fn view_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> ast::ViewItem;
     fn view_use_simple_(&self, sp: Span, vis: ast::Visibility,
                         ident: ast::Ident, path: ast::Path) -> ast::ViewItem;
@@ -447,16 +432,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                 self.path_global(DUMMY_SP, vec!(p.ident)), None)).collect()
     }
 
-    fn strip_bounds(&self, generics: &Generics) -> Generics {
-        let new_params = generics.ty_params.map(|ty_param| {
-            ast::TyParam { bounds: OwnedSlice::empty(), unbound: None, ..*ty_param }
-        });
-        Generics {
-            ty_params: new_params,
-            .. (*generics).clone()
-        }
-    }
-
     fn trait_ref(&self, path: ast::Path) -> ast::TraitRef {
         ast::TraitRef {
             path: path,
@@ -483,27 +458,27 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         }
     }
 
-    fn stmt_expr(&self, expr: Gc<ast::Expr>) -> Gc<ast::Stmt> {
-        box(GC) respan(expr.span, ast::StmtSemi(expr, ast::DUMMY_NODE_ID))
+    fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt> {
+        P(respan(expr.span, ast::StmtSemi(expr, ast::DUMMY_NODE_ID)))
     }
 
     fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
-                ex: Gc<ast::Expr>) -> Gc<ast::Stmt> {
+                ex: P<ast::Expr>) -> P<ast::Stmt> {
         let pat = if mutbl {
             self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable))
         } else {
             self.pat_ident(sp, ident)
         };
-        let local = box(GC) ast::Local {
+        let local = P(ast::Local {
             ty: self.ty_infer(sp),
             pat: pat,
             init: Some(ex),
             id: ast::DUMMY_NODE_ID,
             span: sp,
             source: ast::LocalLet,
-        };
+        });
         let decl = respan(sp, ast::DeclLocal(local));
-        box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
+        P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
     }
 
     fn stmt_let_typed(&self,
@@ -511,46 +486,43 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                       mutbl: bool,
                       ident: ast::Ident,
                       typ: P<ast::Ty>,
-                      ex: Gc<ast::Expr>)
-                      -> Gc<ast::Stmt> {
+                      ex: P<ast::Expr>)
+                      -> P<ast::Stmt> {
         let pat = if mutbl {
             self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable))
         } else {
             self.pat_ident(sp, ident)
         };
-        let local = box(GC) ast::Local {
+        let local = P(ast::Local {
             ty: typ,
             pat: pat,
             init: Some(ex),
             id: ast::DUMMY_NODE_ID,
             span: sp,
             source: ast::LocalLet,
-        };
+        });
         let decl = respan(sp, ast::DeclLocal(local));
-        box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
+        P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
     }
 
-    fn block(&self,
-             span: Span,
-             stmts: Vec<Gc<ast::Stmt>>,
-             expr: Option<Gc<Expr>>)
-             -> P<ast::Block> {
+    fn block(&self, span: Span, stmts: Vec<P<ast::Stmt>>,
+             expr: Option<P<Expr>>) -> P<ast::Block> {
         self.block_all(span, Vec::new(), stmts, expr)
     }
 
-    fn stmt_item(&self, sp: Span, item: Gc<ast::Item>) -> Gc<ast::Stmt> {
+    fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt> {
         let decl = respan(sp, ast::DeclItem(item));
-        box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
+        P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
     }
 
-    fn block_expr(&self, expr: Gc<ast::Expr>) -> P<ast::Block> {
+    fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block> {
         self.block_all(expr.span, Vec::new(), Vec::new(), Some(expr))
     }
     fn block_all(&self,
                  span: Span,
-                 view_items: Vec<ast::ViewItem> ,
-                 stmts: Vec<Gc<ast::Stmt>>,
-                 expr: Option<Gc<ast::Expr>>) -> P<ast::Block> {
+                 view_items: Vec<ast::ViewItem>,
+                 stmts: Vec<P<ast::Stmt>>,
+                 expr: Option<P<ast::Expr>>) -> P<ast::Block> {
             P(ast::Block {
                view_items: view_items,
                stmts: stmts,
@@ -561,42 +533,42 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
             })
     }
 
-    fn expr(&self, span: Span, node: ast::Expr_) -> Gc<ast::Expr> {
-        box(GC) ast::Expr {
+    fn expr(&self, span: Span, node: ast::Expr_) -> P<ast::Expr> {
+        P(ast::Expr {
             id: ast::DUMMY_NODE_ID,
             node: node,
             span: span,
-        }
+        })
     }
 
-    fn expr_path(&self, path: ast::Path) -> Gc<ast::Expr> {
+    fn expr_path(&self, path: ast::Path) -> P<ast::Expr> {
         self.expr(path.span, ast::ExprPath(path))
     }
 
-    fn expr_ident(&self, span: Span, id: ast::Ident) -> Gc<ast::Expr> {
+    fn expr_ident(&self, span: Span, id: ast::Ident) -> P<ast::Expr> {
         self.expr_path(self.path_ident(span, id))
     }
-    fn expr_self(&self, span: Span) -> Gc<ast::Expr> {
+    fn expr_self(&self, span: Span) -> P<ast::Expr> {
         self.expr_ident(span, special_idents::self_)
     }
 
     fn expr_binary(&self, sp: Span, op: ast::BinOp,
-                   lhs: Gc<ast::Expr>, rhs: Gc<ast::Expr>) -> Gc<ast::Expr> {
+                   lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprBinary(op, lhs, rhs))
     }
 
-    fn expr_deref(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expr_unary(sp, ast::UnDeref, e)
     }
-    fn expr_unary(&self, sp: Span, op: ast::UnOp, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprUnary(op, e))
     }
 
-    fn expr_managed(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expr_unary(sp, ast::UnBox, e)
     }
 
-    fn expr_field_access(&self, sp: Span, expr: Gc<ast::Expr>, ident: ast::Ident) -> Gc<ast::Expr> {
+    fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
         let field_name = token::get_ident(ident);
         let field_span = Span {
             lo: sp.lo - Pos::from_uint(field_name.get().len()),
@@ -607,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         let id = Spanned { node: ident, span: field_span };
         self.expr(sp, ast::ExprField(expr, id, Vec::new()))
     }
-    fn expr_tup_field_access(&self, sp: Span, expr: Gc<ast::Expr>, idx: uint) -> Gc<ast::Expr> {
+    fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: uint) -> P<ast::Expr> {
         let field_span = Span {
             lo: sp.lo - Pos::from_uint(idx.to_string().len()),
             hi: sp.hi,
@@ -617,68 +589,67 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         let id = Spanned { node: idx, span: field_span };
         self.expr(sp, ast::ExprTupField(expr, id, Vec::new()))
     }
-    fn expr_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e))
     }
-    fn expr_mut_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e))
     }
 
-    fn expr_call(&self, span: Span, expr: Gc<ast::Expr>,
-                 args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr> {
+    fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
         self.expr(span, ast::ExprCall(expr, args))
     }
     fn expr_call_ident(&self, span: Span, id: ast::Ident,
-                       args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr> {
+                       args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
         self.expr(span, ast::ExprCall(self.expr_ident(span, id), args))
     }
     fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident> ,
-                      args: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> {
+                      args: Vec<P<ast::Expr>> ) -> P<ast::Expr> {
         let pathexpr = self.expr_path(self.path_global(sp, fn_path));
         self.expr_call(sp, pathexpr, args)
     }
     fn expr_method_call(&self, span: Span,
-                        expr: Gc<ast::Expr>,
+                        expr: P<ast::Expr>,
                         ident: ast::Ident,
-                        mut args: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> {
+                        mut args: Vec<P<ast::Expr>> ) -> P<ast::Expr> {
         let id = Spanned { node: ident, span: span };
         args.unshift(expr);
         self.expr(span, ast::ExprMethodCall(id, Vec::new(), args))
     }
-    fn expr_block(&self, b: P<ast::Block>) -> Gc<ast::Expr> {
+    fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr> {
         self.expr(b.span, ast::ExprBlock(b))
     }
-    fn field_imm(&self, span: Span, name: Ident, e: Gc<ast::Expr>) -> ast::Field {
+    fn field_imm(&self, span: Span, name: Ident, e: P<ast::Expr>) -> ast::Field {
         ast::Field { ident: respan(span, name), expr: e, span: span }
     }
-    fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field> ) -> Gc<ast::Expr> {
+    fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field>) -> P<ast::Expr> {
         self.expr(span, ast::ExprStruct(path, fields, None))
     }
     fn expr_struct_ident(&self, span: Span,
-                         id: ast::Ident, fields: Vec<ast::Field> ) -> Gc<ast::Expr> {
+                         id: ast::Ident, fields: Vec<ast::Field>) -> P<ast::Expr> {
         self.expr_struct(span, self.path_ident(span, id), fields)
     }
 
-    fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> Gc<ast::Expr> {
-        self.expr(sp, ast::ExprLit(box(GC) respan(sp, lit)))
+    fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
+        self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
     }
-    fn expr_uint(&self, span: Span, i: uint) -> Gc<ast::Expr> {
+    fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr> {
         self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyU)))
     }
-    fn expr_int(&self, sp: Span, i: int) -> Gc<ast::Expr> {
+    fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyI, ast::Sign::new(i))))
     }
-    fn expr_u8(&self, sp: Span, u: u8) -> Gc<ast::Expr> {
+    fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
     }
-    fn expr_bool(&self, sp: Span, value: bool) -> Gc<ast::Expr> {
+    fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitBool(value))
     }
 
-    fn expr_vec(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> {
+    fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprVec(exprs))
     }
-    fn expr_vec_ng(&self, sp: Span) -> Gc<ast::Expr> {
+    fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr> {
         self.expr_call_global(sp,
                               vec!(self.ident_of("std"),
                                    self.ident_of("vec"),
@@ -686,19 +657,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                                    self.ident_of("new")),
                               Vec::new())
     }
-    fn expr_vec_slice(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> {
+    fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
         self.expr_addr_of(sp, self.expr_vec(sp, exprs))
     }
-    fn expr_str(&self, sp: Span, s: InternedString) -> Gc<ast::Expr> {
+    fn expr_str(&self, sp: Span, s: InternedString) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitStr(s, ast::CookedStr))
     }
 
-    fn expr_cast(&self, sp: Span, expr: Gc<ast::Expr>, ty: P<ast::Ty>) -> Gc<ast::Expr> {
+    fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprCast(expr, ty))
     }
 
 
-    fn expr_some(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
         let some = vec!(
             self.ident_of("std"),
             self.ident_of("option"),
@@ -706,7 +677,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.expr_call_global(sp, some, vec!(expr))
     }
 
-    fn expr_none(&self, sp: Span) -> Gc<ast::Expr> {
+    fn expr_none(&self, sp: Span) -> P<ast::Expr> {
         let none = self.path_global(sp, vec!(
             self.ident_of("std"),
             self.ident_of("option"),
@@ -714,11 +685,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.expr_path(none)
     }
 
-    fn expr_tuple(&self, sp: Span, exprs: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr> {
+    fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprTup(exprs))
     }
 
-    fn expr_fail(&self, span: Span, msg: InternedString) -> Gc<ast::Expr> {
+    fn expr_fail(&self, span: Span, msg: InternedString) -> P<ast::Expr> {
         let loc = self.codemap().lookup_char_pos(span.lo);
         let expr_file = self.expr_str(span,
                                       token::intern_and_get_ident(loc.file
@@ -738,13 +709,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                 expr_file_line_ptr))
     }
 
-    fn expr_unreachable(&self, span: Span) -> Gc<ast::Expr> {
+    fn expr_unreachable(&self, span: Span) -> P<ast::Expr> {
         self.expr_fail(span,
                        InternedString::new(
                            "internal error: entered unreachable code"))
     }
 
-    fn expr_ok(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_ok(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
         let ok = vec!(
             self.ident_of("std"),
             self.ident_of("result"),
@@ -752,7 +723,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.expr_call_global(sp, ok, vec!(expr))
     }
 
-    fn expr_err(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_err(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
         let err = vec!(
             self.ident_of("std"),
             self.ident_of("result"),
@@ -760,7 +731,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.expr_call_global(sp, err, vec!(expr))
     }
 
-    fn expr_try(&self, sp: Span, head: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
         let ok = self.ident_of("Ok");
         let ok_path = self.path_ident(sp, ok);
         let err = self.ident_of("Err");
@@ -771,11 +742,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         let binding_expr = self.expr_ident(sp, binding_variable);
 
         // Ok(__try_var) pattern
-        let ok_pat = self.pat_enum(sp, ok_path, vec!(binding_pat));
+        let ok_pat = self.pat_enum(sp, ok_path, vec!(binding_pat.clone()));
 
         // Err(__try_var)  (pattern and expression resp.)
         let err_pat = self.pat_enum(sp, err_path, vec!(binding_pat));
-        let err_inner_expr = self.expr_call_ident(sp, err, vec!(binding_expr));
+        let err_inner_expr = self.expr_call_ident(sp, err, vec!(binding_expr.clone()));
         // return Err(__try_var)
         let err_expr = self.expr(sp, ast::ExprRet(Some(err_inner_expr)));
 
@@ -789,41 +760,41 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
     }
 
 
-    fn pat(&self, span: Span, pat: ast::Pat_) -> Gc<ast::Pat> {
-        box(GC) ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span }
+    fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat> {
+        P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span })
     }
-    fn pat_wild(&self, span: Span) -> Gc<ast::Pat> {
+    fn pat_wild(&self, span: Span) -> P<ast::Pat> {
         self.pat(span, ast::PatWild(ast::PatWildSingle))
     }
-    fn pat_lit(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Pat> {
+    fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
         self.pat(span, ast::PatLit(expr))
     }
-    fn pat_ident(&self, span: Span, ident: ast::Ident) -> Gc<ast::Pat> {
+    fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
         self.pat_ident_binding_mode(span, ident, ast::BindByValue(ast::MutImmutable))
     }
 
     fn pat_ident_binding_mode(&self,
                               span: Span,
                               ident: ast::Ident,
-                              bm: ast::BindingMode) -> Gc<ast::Pat> {
+                              bm: ast::BindingMode) -> P<ast::Pat> {
         let pat = ast::PatIdent(bm, Spanned{span: span, node: ident}, None);
         self.pat(span, pat)
     }
-    fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<Gc<ast::Pat>> ) -> Gc<ast::Pat> {
+    fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
         let pat = ast::PatEnum(path, Some(subpats));
         self.pat(span, pat)
     }
     fn pat_struct(&self, span: Span,
-                  path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> Gc<ast::Pat> {
+                  path: ast::Path, field_pats: Vec<ast::FieldPat>) -> P<ast::Pat> {
         let pat = ast::PatStruct(path, field_pats, false);
         self.pat(span, pat)
     }
-    fn pat_tuple(&self, span: Span, pats: Vec<Gc<ast::Pat>>) -> Gc<ast::Pat> {
+    fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
         let pat = ast::PatTup(pats);
         self.pat(span, pat)
     }
 
-    fn pat_some(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat> {
+    fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
         let some = vec!(
             self.ident_of("std"),
             self.ident_of("option"),
@@ -832,7 +803,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.pat_enum(span, path, vec!(pat))
     }
 
-    fn pat_none(&self, span: Span) -> Gc<ast::Pat> {
+    fn pat_none(&self, span: Span) -> P<ast::Pat> {
         let some = vec!(
             self.ident_of("std"),
             self.ident_of("option"),
@@ -841,7 +812,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.pat_enum(span, path, vec!())
     }
 
-    fn pat_ok(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat> {
+    fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
         let some = vec!(
             self.ident_of("std"),
             self.ident_of("result"),
@@ -850,7 +821,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.pat_enum(span, path, vec!(pat))
     }
 
-    fn pat_err(&self, span: Span, pat: Gc<ast::Pat>) -> Gc<ast::Pat> {
+    fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
         let some = vec!(
             self.ident_of("std"),
             self.ident_of("result"),
@@ -859,7 +830,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.pat_enum(span, path, vec!(pat))
     }
 
-    fn arm(&self, _span: Span, pats: Vec<Gc<ast::Pat>> , expr: Gc<ast::Expr>) -> ast::Arm {
+    fn arm(&self, _span: Span, pats: Vec<P<ast::Pat>>, expr: P<ast::Expr>) -> ast::Arm {
         ast::Arm {
             attrs: vec!(),
             pats: pats,
@@ -872,64 +843,62 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.arm(span, vec!(self.pat_wild(span)), self.expr_unreachable(span))
     }
 
-    fn expr_match(&self, span: Span, arg: Gc<ast::Expr>,
-                  arms: Vec<ast::Arm>) -> Gc<Expr> {
+    fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {
         self.expr(span, ast::ExprMatch(arg, arms))
     }
 
-    fn expr_if(&self, span: Span,
-               cond: Gc<ast::Expr>, then: Gc<ast::Expr>,
-               els: Option<Gc<ast::Expr>>) -> Gc<ast::Expr> {
+    fn expr_if(&self, span: Span, cond: P<ast::Expr>,
+               then: P<ast::Expr>, els: Option<P<ast::Expr>>) -> P<ast::Expr> {
         let els = els.map(|x| self.expr_block(self.block_expr(x)));
         self.expr(span, ast::ExprIf(cond, self.block_expr(then), els))
     }
 
-    fn expr_loop(&self, span: Span, block: P<ast::Block>) -> Gc<ast::Expr> {
+    fn expr_loop(&self, span: Span, block: P<ast::Block>) -> P<ast::Expr> {
         self.expr(span, ast::ExprLoop(block, None))
     }
 
     fn lambda_fn_decl(&self, span: Span,
-                      fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> Gc<ast::Expr> {
+                      fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr> {
         self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk))
     }
-    fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> Gc<ast::Expr> {
+    fn lambda(&self, span: Span, ids: Vec<ast::Ident>, blk: P<ast::Block>) -> P<ast::Expr> {
         let fn_decl = self.fn_decl(
             ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(),
             self.ty_infer(span));
 
         self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk))
     }
-    fn lambda0(&self, span: Span, blk: P<ast::Block>) -> Gc<ast::Expr> {
+    fn lambda0(&self, span: Span, blk: P<ast::Block>) -> P<ast::Expr> {
         self.lambda(span, Vec::new(), blk)
     }
 
-    fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> Gc<ast::Expr> {
+    fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> P<ast::Expr> {
         self.lambda(span, vec!(ident), blk)
     }
 
-    fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident> , expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident>,
+                   expr: P<ast::Expr>) -> P<ast::Expr> {
         self.lambda(span, ids, self.block_expr(expr))
     }
-    fn lambda_expr_0(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn lambda_expr_0(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
         self.lambda0(span, self.block_expr(expr))
     }
-    fn lambda_expr_1(&self, span: Span, expr: Gc<ast::Expr>, ident: ast::Ident) -> Gc<ast::Expr> {
+    fn lambda_expr_1(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
         self.lambda1(span, self.block_expr(expr), ident)
     }
 
     fn lambda_stmts(&self,
                     span: Span,
                     ids: Vec<ast::Ident>,
-                    stmts: Vec<Gc<ast::Stmt>>)
-                    -> Gc<ast::Expr> {
+                    stmts: Vec<P<ast::Stmt>>)
+                    -> P<ast::Expr> {
         self.lambda(span, ids, self.block(span, stmts, None))
     }
-    fn lambda_stmts_0(&self, span: Span,
-                      stmts: Vec<Gc<ast::Stmt>>) -> Gc<ast::Expr> {
+    fn lambda_stmts_0(&self, span: Span, stmts: Vec<P<ast::Stmt>>) -> P<ast::Expr> {
         self.lambda0(span, self.block(span, stmts, None))
     }
-    fn lambda_stmts_1(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>,
-                      ident: ast::Ident) -> Gc<ast::Expr> {
+    fn lambda_stmts_1(&self, span: Span, stmts: Vec<P<ast::Stmt>>,
+                      ident: ast::Ident) -> P<ast::Expr> {
         self.lambda1(span, self.block(span, stmts, None), ident)
     }
 
@@ -952,17 +921,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         })
     }
 
-    fn item(&self, span: Span,
-            name: Ident, attrs: Vec<ast::Attribute>,
-            node: ast::Item_) -> Gc<ast::Item> {
+    fn item(&self, span: Span, name: Ident,
+            attrs: Vec<ast::Attribute>, node: ast::Item_) -> P<ast::Item> {
         // FIXME: Would be nice if our generated code didn't violate
         // Rust coding conventions
-        box(GC) ast::Item { ident: name,
-                    attrs: attrs,
-                    id: ast::DUMMY_NODE_ID,
-                    node: node,
-                    vis: ast::Inherited,
-                    span: span }
+        P(ast::Item {
+            ident: name,
+            attrs: attrs,
+            id: ast::DUMMY_NODE_ID,
+            node: node,
+            vis: ast::Inherited,
+            span: span
+        })
     }
 
     fn item_fn_poly(&self,
@@ -971,7 +941,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                     inputs: Vec<ast::Arg> ,
                     output: P<ast::Ty>,
                     generics: Generics,
-                    body: P<ast::Block>) -> Gc<ast::Item> {
+                    body: P<ast::Block>) -> P<ast::Item> {
         self.item(span,
                   name,
                   Vec::new(),
@@ -988,7 +958,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                inputs: Vec<ast::Arg> ,
                output: P<ast::Ty>,
                body: P<ast::Block>
-              ) -> Gc<ast::Item> {
+              ) -> P<ast::Item> {
         self.item_fn_poly(
             span,
             name,
@@ -1016,18 +986,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
 
     fn item_enum_poly(&self, span: Span, name: Ident,
                       enum_definition: ast::EnumDef,
-                      generics: Generics) -> Gc<ast::Item> {
+                      generics: Generics) -> P<ast::Item> {
         self.item(span, name, Vec::new(), ast::ItemEnum(enum_definition, generics))
     }
 
     fn item_enum(&self, span: Span, name: Ident,
-                 enum_definition: ast::EnumDef) -> Gc<ast::Item> {
+                 enum_definition: ast::EnumDef) -> P<ast::Item> {
         self.item_enum_poly(span, name, enum_definition,
                             ast_util::empty_generics())
     }
 
     fn item_struct(&self, span: Span, name: Ident,
-                   struct_def: ast::StructDef) -> Gc<ast::Item> {
+                   struct_def: ast::StructDef) -> P<ast::Item> {
         self.item_struct_poly(
             span,
             name,
@@ -1037,14 +1007,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
     }
 
     fn item_struct_poly(&self, span: Span, name: Ident,
-        struct_def: ast::StructDef, generics: Generics) -> Gc<ast::Item> {
-        self.item(span, name, Vec::new(), ast::ItemStruct(box(GC) struct_def, generics))
+        struct_def: ast::StructDef, generics: Generics) -> P<ast::Item> {
+        self.item(span, name, Vec::new(), ast::ItemStruct(P(struct_def), generics))
     }
 
     fn item_mod(&self, span: Span, inner_span: Span, name: Ident,
                 attrs: Vec<ast::Attribute> ,
                 vi: Vec<ast::ViewItem> ,
-                items: Vec<Gc<ast::Item>>) -> Gc<ast::Item> {
+                items: Vec<P<ast::Item>> ) -> P<ast::Item> {
         self.item(
             span,
             name,
@@ -1062,21 +1032,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
                    name: Ident,
                    ty: P<ast::Ty>,
                    mutbl: ast::Mutability,
-                   expr: Gc<ast::Expr>)
-                   -> Gc<ast::Item> {
+                   expr: P<ast::Expr>)
+                   -> P<ast::Item> {
         self.item(span, name, Vec::new(), ast::ItemStatic(ty, mutbl, expr))
     }
 
     fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>,
-                    generics: Generics) -> Gc<ast::Item> {
+                    generics: Generics) -> P<ast::Item> {
         self.item(span, name, Vec::new(), ast::ItemTy(ty, generics))
     }
 
-    fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> Gc<ast::Item> {
+    fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item> {
         self.item_ty_poly(span, name, ty, ast_util::empty_generics())
     }
 
-    fn attribute(&self, sp: Span, mi: Gc<ast::MetaItem>) -> ast::Attribute {
+    fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute {
         respan(sp, ast::Attribute_ {
             id: attr::mk_attr_id(),
             style: ast::AttrOuter,
@@ -1085,26 +1055,26 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         })
     }
 
-    fn meta_word(&self, sp: Span, w: InternedString) -> Gc<ast::MetaItem> {
-        box(GC) respan(sp, ast::MetaWord(w))
+    fn meta_word(&self, sp: Span, w: InternedString) -> P<ast::MetaItem> {
+        P(respan(sp, ast::MetaWord(w)))
     }
     fn meta_list(&self,
                  sp: Span,
                  name: InternedString,
-                 mis: Vec<Gc<ast::MetaItem>> )
-                 -> Gc<ast::MetaItem> {
-        box(GC) respan(sp, ast::MetaList(name, mis))
+                 mis: Vec<P<ast::MetaItem>> )
+                 -> P<ast::MetaItem> {
+        P(respan(sp, ast::MetaList(name, mis)))
     }
     fn meta_name_value(&self,
                        sp: Span,
                        name: InternedString,
                        value: ast::Lit_)
-                       -> Gc<ast::MetaItem> {
-        box(GC) respan(sp, ast::MetaNameValue(name, respan(sp, value)))
+                       -> P<ast::MetaItem> {
+        P(respan(sp, ast::MetaNameValue(name, respan(sp, value))))
     }
 
     fn view_use(&self, sp: Span,
-                vis: ast::Visibility, vp: Gc<ast::ViewPath>) -> ast::ViewItem {
+                vis: ast::Visibility, vp: P<ast::ViewPath>) -> ast::ViewItem {
         ast::ViewItem {
             node: ast::ViewItemUse(vp),
             attrs: Vec::new(),
@@ -1121,10 +1091,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
     fn view_use_simple_(&self, sp: Span, vis: ast::Visibility,
                         ident: ast::Ident, path: ast::Path) -> ast::ViewItem {
         self.view_use(sp, vis,
-                      box(GC) respan(sp,
-                           ast::ViewPathSimple(ident,
-                                               path,
-                                               ast::DUMMY_NODE_ID)))
+                      P(respan(sp,
+                               ast::ViewPathSimple(ident,
+                                                   path,
+                                                   ast::DUMMY_NODE_ID))))
     }
 
     fn view_use_list(&self, sp: Span, vis: ast::Visibility,
@@ -1134,41 +1104,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         }).collect();
 
         self.view_use(sp, vis,
-                      box(GC) respan(sp,
-                           ast::ViewPathList(self.path(sp, path),
-                                             imports,
-                                             ast::DUMMY_NODE_ID)))
+                      P(respan(sp,
+                               ast::ViewPathList(self.path(sp, path),
+                                                 imports,
+                                                 ast::DUMMY_NODE_ID))))
     }
 
     fn view_use_glob(&self, sp: Span,
                      vis: ast::Visibility, path: Vec<ast::Ident> ) -> ast::ViewItem {
         self.view_use(sp, vis,
-                      box(GC) respan(sp,
-                           ast::ViewPathGlob(self.path(sp, path), ast::DUMMY_NODE_ID)))
-    }
-}
-
-struct Duplicator<'a>;
-
-impl<'a> Folder for Duplicator<'a> {
-    fn new_id(&mut self, _: NodeId) -> NodeId {
-        ast::DUMMY_NODE_ID
-    }
-}
-
-pub trait Duplicate {
-    //
-    // Duplication functions
-    //
-    // These functions just duplicate AST nodes.
-    //
-
-    fn duplicate(&self, cx: &ExtCtxt) -> Self;
-}
-
-impl Duplicate for Gc<ast::Expr> {
-    fn duplicate(&self, _: &ExtCtxt) -> Gc<ast::Expr> {
-        let mut folder = Duplicator;
-        folder.fold_expr(*self)
+                      P(respan(sp,
+                               ast::ViewPathGlob(self.path(sp, path), ast::DUMMY_NODE_ID))))
     }
 }
diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs
index 18367511495..3e0f340ad7f 100644
--- a/src/libsyntax/ext/bytes.rs
+++ b/src/libsyntax/ext/bytes.rs
@@ -40,7 +40,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
     for expr in exprs.iter() {
         match expr.node {
             // expression is a literal
-            ast::ExprLit(lit) => match lit.node {
+            ast::ExprLit(ref lit) => match lit.node {
                 // string literal, push each byte to vector expression
                 ast::LitStr(ref s, _) => {
                     for byte in s.get().bytes() {
diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs
index 0c3a951c982..79cb47fee7b 100644
--- a/src/libsyntax/ext/cfg.rs
+++ b/src/libsyntax/ext/cfg.rs
@@ -40,10 +40,10 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
     }
 
     // test_cfg searches for meta items looking like `cfg(foo, ...)`
-    let in_cfg = &[cx.meta_list(sp, InternedString::new("cfg"), cfgs)];
+    let in_cfg = Some(cx.meta_list(sp, InternedString::new("cfg"), cfgs));
 
     let matches_cfg = attr::test_cfg(cx.cfg().as_slice(),
-                                     in_cfg.iter().map(|&x| x));
+                                     in_cfg.iter());
     let e = cx.expr_bool(sp, matches_cfg);
     MacExpr::new(e)
 }
diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs
index ea7a4d061c0..455148bfedd 100644
--- a/src/libsyntax/ext/concat.rs
+++ b/src/libsyntax/ext/concat.rs
@@ -27,7 +27,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
     let mut accumulator = String::new();
     for e in es.move_iter() {
         match e.node {
-            ast::ExprLit(lit) => {
+            ast::ExprLit(ref lit) => {
                 match lit.node {
                     ast::LitStr(ref s, _) |
                     ast::LitFloat(ref s, _) |
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index 0ac26a3a904..145412caa0b 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -15,8 +15,7 @@ use ext::base;
 use owned_slice::OwnedSlice;
 use parse::token;
 use parse::token::{str_to_ident};
-
-use std::gc::GC;
+use ptr::P;
 
 pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                               -> Box<base::MacResult+'cx> {
@@ -44,7 +43,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
     }
     let res = str_to_ident(res_str.as_slice());
 
-    let e = box(GC) ast::Expr {
+    let e = P(ast::Expr {
         id: ast::DUMMY_NODE_ID,
         node: ast::ExprPath(
             ast::Path {
@@ -60,6 +59,6 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
             }
         ),
         span: sp,
-    };
+    });
     MacExpr::new(e)
 }
diff --git a/src/libsyntax/ext/deriving/bounds.rs b/src/libsyntax/ext/deriving/bounds.rs
index 7cff6e8ff3c..0595b0bc7f4 100644
--- a/src/libsyntax/ext/deriving/bounds.rs
+++ b/src/libsyntax/ext/deriving/bounds.rs
@@ -13,14 +13,13 @@ use codemap::Span;
 use ext::base::ExtCtxt;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_bound(cx: &mut ExtCtxt,
                              span: Span,
-                             mitem: Gc<MetaItem>,
-                             item: Gc<Item>,
-                             push: |Gc<Item>|) {
+                             mitem: &MetaItem,
+                             item: &Item,
+                             push: |P<Item>|) {
 
     let name = match mitem.node {
         MetaWord(ref tname) => {
diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs
index bbe96018f4b..64607ffd5d4 100644
--- a/src/libsyntax/ext/deriving/clone.rs
+++ b/src/libsyntax/ext/deriving/clone.rs
@@ -15,14 +15,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_clone(cx: &mut ExtCtxt,
                              span: Span,
-                             mitem: Gc<MetaItem>,
-                             item: Gc<Item>,
-                             push: |Gc<Item>|) {
+                             mitem: &MetaItem,
+                             item: &Item,
+                             push: |P<Item>|) {
     let inline = cx.meta_word(span, InternedString::new("inline"));
     let attrs = vec!(cx.attribute(span, inline));
     let trait_def = TraitDef {
@@ -52,12 +51,12 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
 fn cs_clone(
     name: &str,
     cx: &mut ExtCtxt, trait_span: Span,
-    substr: &Substructure) -> Gc<Expr> {
+    substr: &Substructure) -> P<Expr> {
     let clone_ident = substr.method_ident;
     let ctor_ident;
     let all_fields;
     let subcall = |field: &FieldInfo|
-        cx.expr_method_call(field.span, field.self_, clone_ident, Vec::new());
+        cx.expr_method_call(field.span, field.self_.clone(), clone_ident, Vec::new());
 
     match *substr.fields {
         Struct(ref af) => {
diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs
index 19a979a5655..a27016fde61 100644
--- a/src/libsyntax/ext/deriving/cmp/eq.rs
+++ b/src/libsyntax/ext/deriving/cmp/eq.rs
@@ -15,21 +15,20 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_eq(cx: &mut ExtCtxt,
                           span: Span,
-                          mitem: Gc<MetaItem>,
-                          item: Gc<Item>,
-                          push: |Gc<Item>|) {
+                          mitem: &MetaItem,
+                          item: &Item,
+                          push: |P<Item>|) {
     // structures are equal if all fields are equal, and non equal, if
     // any fields are not equal or if the enum variants are different
-    fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> {
+    fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
         cs_and(|cx, span, _, _| cx.expr_bool(span, false),
                                  cx, span, substr)
     }
-    fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> {
+    fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
         cs_or(|cx, span, _, _| cx.expr_bool(span, true),
               cx, span, substr)
     }
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs
index dcf59ba820e..7cb61d295c0 100644
--- a/src/libsyntax/ext/deriving/cmp/ord.rs
+++ b/src/libsyntax/ext/deriving/cmp/ord.rs
@@ -16,14 +16,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_ord(cx: &mut ExtCtxt,
                            span: Span,
-                           mitem: Gc<MetaItem>,
-                           item: Gc<Item>,
-                           push: |Gc<Item>|) {
+                           mitem: &MetaItem,
+                           item: &Item,
+                           push: |P<Item>|) {
     macro_rules! md (
         ($name:expr, $op:expr, $equal:expr) => { {
             let inline = cx.meta_word(span, InternedString::new("inline"));
@@ -87,7 +86,7 @@ pub enum OrderingOp {
 pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
                                span: Span,
                                op: OrderingOp,
-                               self_arg_tags: &[ast::Ident]) -> Gc<ast::Expr> {
+                               self_arg_tags: &[ast::Ident]) -> P<ast::Expr> {
     let lft = cx.expr_ident(span, self_arg_tags[0]);
     let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1]));
     let op_str = match op {
@@ -99,7 +98,7 @@ pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
 }
 
 pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
-              substr: &Substructure) -> Gc<Expr> {
+              substr: &Substructure) -> P<Expr> {
     let test_id = cx.ident_of("__test");
     let ordering = cx.path_global(span,
                                   vec!(cx.ident_of("std"),
@@ -159,8 +158,8 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
 }
 
 /// Strict inequality.
-fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span,
-         substr: &Substructure) -> Gc<Expr> {
+fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
+         span: Span, substr: &Substructure) -> P<Expr> {
     let op = if less {ast::BiLt} else {ast::BiGt};
     cs_fold(
         false, // need foldr,
@@ -183,14 +182,14 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span,
             layers of pointers, if the type includes pointers.
             */
             let other_f = match other_fs {
-                [o_f] => o_f,
+                [ref o_f] => o_f,
                 _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
             };
 
-            let cmp = cx.expr_binary(span, op, self_f, other_f);
+            let cmp = cx.expr_binary(span, op, self_f.clone(), other_f.clone());
 
             let not_cmp = cx.expr_unary(span, ast::UnNot,
-                                        cx.expr_binary(span, op, other_f, self_f));
+                                        cx.expr_binary(span, op, other_f.clone(), self_f));
 
             let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr);
             cx.expr_binary(span, ast::BiOr, cmp, and)
diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs
index 42365936c9d..98c8885f7fa 100644
--- a/src/libsyntax/ext/deriving/cmp/totaleq.rs
+++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs
@@ -15,16 +15,14 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
                                span: Span,
-                               mitem: Gc<MetaItem>,
-                               item: Gc<Item>,
-                               push: |Gc<Item>|) {
-    fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span,
-                          substr: &Substructure) -> Gc<Expr> {
+                               mitem: &MetaItem,
+                               item: &Item,
+                               push: |P<Item>|) {
+    fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
         cs_same_method(|cx, span, exprs| {
             // create `a.<method>(); b.<method>(); c.<method>(); ...`
             // (where method is `assert_receiver_is_total_eq`)
diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs
index e010b635fe4..9ef463f9c63 100644
--- a/src/libsyntax/ext/deriving/cmp/totalord.rs
+++ b/src/libsyntax/ext/deriving/cmp/totalord.rs
@@ -16,14 +16,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
                                 span: Span,
-                                mitem: Gc<MetaItem>,
-                                item: Gc<Item>,
-                                push: |Gc<Item>|) {
+                                mitem: &MetaItem,
+                                item: &Item,
+                                push: |P<Item>|) {
     let inline = cx.meta_word(span, InternedString::new("inline"));
     let attrs = vec!(cx.attribute(span, inline));
     let trait_def = TraitDef {
@@ -53,14 +52,14 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
 
 pub fn ordering_collapsed(cx: &mut ExtCtxt,
                           span: Span,
-                          self_arg_tags: &[ast::Ident]) -> Gc<ast::Expr> {
+                          self_arg_tags: &[ast::Ident]) -> P<ast::Expr> {
     let lft = cx.expr_ident(span, self_arg_tags[0]);
     let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1]));
     cx.expr_method_call(span, lft, cx.ident_of("cmp"), vec![rgt])
 }
 
 pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
-              substr: &Substructure) -> Gc<Expr> {
+              substr: &Substructure) -> P<Expr> {
     let test_id = cx.ident_of("__test");
     let equals_path = cx.path_global(span,
                                      vec!(cx.ident_of("std"),
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index d909ffd2b49..fd24f5e35a4 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -21,14 +21,13 @@ use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
 use parse::token;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
                                  span: Span,
-                                 mitem: Gc<MetaItem>,
-                                 item: Gc<Item>,
-                                 push: |Gc<Item>|) {
+                                 mitem: &MetaItem,
+                                 item: &Item,
+                                 push: |P<Item>|) {
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
@@ -64,15 +63,15 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
 }
 
 fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                          substr: &Substructure) -> Gc<Expr> {
-    let decoder = substr.nonself_args[0];
+                          substr: &Substructure) -> P<Expr> {
+    let decoder = substr.nonself_args[0].clone();
     let recurse = vec!(cx.ident_of("serialize"),
                     cx.ident_of("Decodable"),
                     cx.ident_of("decode"));
     // throw an underscore in front to suppress unused variable warnings
     let blkarg = cx.ident_of("_d");
     let blkdecoder = cx.expr_ident(trait_span, blkarg);
-    let calldecode = cx.expr_call_global(trait_span, recurse, vec!(blkdecoder));
+    let calldecode = cx.expr_call_global(trait_span, recurse, vec!(blkdecoder.clone()));
     let lambdadecode = cx.lambda_expr_1(trait_span, calldecode, blkarg);
 
     return match *substr.fields {
@@ -89,10 +88,10 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                                               summary,
                                               |cx, span, name, field| {
                 cx.expr_try(span,
-                    cx.expr_method_call(span, blkdecoder, read_struct_field,
+                    cx.expr_method_call(span, blkdecoder.clone(), read_struct_field,
                                         vec!(cx.expr_str(span, name),
                                           cx.expr_uint(span, field),
-                                          lambdadecode)))
+                                          lambdadecode.clone())))
             });
             let result = cx.expr_ok(trait_span, result);
             cx.expr_method_call(trait_span,
@@ -121,8 +120,8 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                                                    |cx, span, _, field| {
                     let idx = cx.expr_uint(span, field);
                     cx.expr_try(span,
-                        cx.expr_method_call(span, blkdecoder, rvariant_arg,
-                                            vec!(idx, lambdadecode)))
+                        cx.expr_method_call(span, blkdecoder.clone(), rvariant_arg,
+                                            vec!(idx, lambdadecode.clone())))
                 });
 
                 arms.push(cx.arm(v_span,
@@ -159,8 +158,8 @@ fn decode_static_fields(cx: &mut ExtCtxt,
                         trait_span: Span,
                         outer_pat_ident: Ident,
                         fields: &StaticFields,
-                        getarg: |&mut ExtCtxt, Span, InternedString, uint| -> Gc<Expr>)
-                        -> Gc<Expr> {
+                        getarg: |&mut ExtCtxt, Span, InternedString, uint| -> P<Expr>)
+                        -> P<Expr> {
     match *fields {
         Unnamed(ref fields) => {
             if fields.is_empty() {
diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs
index f7d0308e1bd..f4a66414d89 100644
--- a/src/libsyntax/ext/deriving/default.rs
+++ b/src/libsyntax/ext/deriving/default.rs
@@ -15,14 +15,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_default(cx: &mut ExtCtxt,
                             span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
     let inline = cx.meta_word(span, InternedString::new("inline"));
     let attrs = vec!(cx.attribute(span, inline));
     let trait_def = TraitDef {
@@ -47,8 +46,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
     trait_def.expand(cx, mitem, item, push)
 }
 
-fn default_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                        substr: &Substructure) -> Gc<Expr> {
+fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let default_ident = vec!(
         cx.ident_of("std"),
         cx.ident_of("default"),
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index 02a748eed8e..103253560df 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -86,14 +86,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
                                  span: Span,
-                                 mitem: Gc<MetaItem>,
-                                 item: Gc<Item>,
-                                 push: |Gc<Item>|) {
+                                 mitem: &MetaItem,
+                                 item: &Item,
+                                 push: |P<Item>|) {
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
@@ -131,8 +130,8 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
 }
 
 fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                          substr: &Substructure) -> Gc<Expr> {
-    let encoder = substr.nonself_args[0];
+                          substr: &Substructure) -> P<Expr> {
+    let encoder = substr.nonself_args[0].clone();
     // throw an underscore in front to suppress unused variable warnings
     let blkarg = cx.ident_of("_e");
     let blkencoder = cx.expr_ident(trait_span, blkarg);
@@ -145,7 +144,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
             let last = fields.len() - 1;
             for (i, &FieldInfo {
                     name,
-                    self_,
+                    ref self_,
                     span,
                     ..
                 }) in fields.iter().enumerate() {
@@ -156,9 +155,10 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                                                             i).as_slice())
                     }
                 };
-                let enc = cx.expr_method_call(span, self_, encode, vec!(blkencoder));
+                let enc = cx.expr_method_call(span, self_.clone(),
+                                              encode, vec!(blkencoder.clone()));
                 let lambda = cx.lambda_expr_1(span, enc, blkarg);
-                let call = cx.expr_method_call(span, blkencoder,
+                let call = cx.expr_method_call(span, blkencoder.clone(),
                                                emit_struct_field,
                                                vec!(cx.expr_str(span, name),
                                                  cx.expr_uint(span, i),
@@ -202,10 +202,11 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
             let emit_variant_arg = cx.ident_of("emit_enum_variant_arg");
             let mut stmts = Vec::new();
             let last = fields.len() - 1;
-            for (i, &FieldInfo { self_, span, .. }) in fields.iter().enumerate() {
-                let enc = cx.expr_method_call(span, self_, encode, vec!(blkencoder));
+            for (i, &FieldInfo { ref self_, span, .. }) in fields.iter().enumerate() {
+                let enc = cx.expr_method_call(span, self_.clone(),
+                                              encode, vec!(blkencoder.clone()));
                 let lambda = cx.lambda_expr_1(span, enc, blkarg);
-                let call = cx.expr_method_call(span, blkencoder,
+                let call = cx.expr_method_call(span, blkencoder.clone(),
                                                emit_variant_arg,
                                                vec!(cx.expr_uint(span, i),
                                                  lambda));
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 50bdc296aad..53af5a86ed2 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -181,12 +181,13 @@
 //! ~~~
 
 use std::cell::RefCell;
-use std::gc::{Gc, GC};
+use std::gc::GC;
+use std::vec;
 
 use abi::Abi;
 use abi;
 use ast;
-use ast::{P, EnumDef, Expr, Ident, Generics, StructDef};
+use ast::{EnumDef, Expr, Ident, Generics, StructDef};
 use ast_util;
 use attr;
 use attr::AttrMetaMethods;
@@ -194,9 +195,11 @@ use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
 use codemap;
 use codemap::Span;
+use fold::MoveMap;
 use owned_slice::OwnedSlice;
 use parse::token::InternedString;
 use parse::token::special_idents;
+use ptr::P;
 
 use self::ty::{LifetimeBounds, Path, Ptr, PtrTy, Self, Ty};
 
@@ -251,9 +254,9 @@ pub struct Substructure<'a> {
     /// ident of the method
     pub method_ident: Ident,
     /// dereferenced access to any Self or Ptr(Self, _) arguments
-    pub self_args: &'a [Gc<Expr>],
+    pub self_args: &'a [P<Expr>],
     /// verbatim access to any other arguments
-    pub nonself_args: &'a [Gc<Expr>],
+    pub nonself_args: &'a [P<Expr>],
     pub fields: &'a SubstructureFields<'a>
 }
 
@@ -265,10 +268,10 @@ pub struct FieldInfo {
     pub name: Option<Ident>,
     /// The expression corresponding to this field of `self`
     /// (specifically, a reference to it).
-    pub self_: Gc<Expr>,
+    pub self_: P<Expr>,
     /// The expressions corresponding to references to this field in
     /// the other Self arguments.
-    pub other: Vec<Gc<Expr>>,
+    pub other: Vec<P<Expr>>,
 }
 
 /// Fields for a static method
@@ -298,7 +301,7 @@ pub enum SubstructureFields<'a> {
     Idents bound to the variant index values for each of the actual
     input Self arguments.
     */
-    EnumNonMatchingCollapsed(Vec<Ident>, &'a [Gc<ast::Variant>], &'a [Ident]),
+    EnumNonMatchingCollapsed(Vec<Ident>, &'a [P<ast::Variant>], &'a [Ident]),
 
     /// A static method where Self is a struct.
     StaticStruct(&'a ast::StructDef, StaticFields),
@@ -313,7 +316,7 @@ Combine the values of all the fields together. The last argument is
 all the fields of all the structures, see above for details.
 */
 pub type CombineSubstructureFunc<'a> =
-    |&mut ExtCtxt, Span, &Substructure|: 'a -> Gc<Expr>;
+    |&mut ExtCtxt, Span, &Substructure|: 'a -> P<Expr>;
 
 /**
 Deal with non-matching enum variants.  The tuple is a list of
@@ -324,10 +327,10 @@ last argument is all the non-Self args of the method being derived.
 */
 pub type EnumNonMatchCollapsedFunc<'a> =
     |&mut ExtCtxt,
-           Span,
-           (&[Ident], &[Ident]),
-           &[Gc<Expr>]|: 'a
-           -> Gc<Expr>;
+     Span,
+     (&[Ident], &[Ident]),
+     &[P<Expr>]|: 'a
+     -> P<Expr>;
 
 pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
     -> RefCell<CombineSubstructureFunc<'a>> {
@@ -338,9 +341,9 @@ pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
 impl<'a> TraitDef<'a> {
     pub fn expand(&self,
                   cx: &mut ExtCtxt,
-                  _mitem: Gc<ast::MetaItem>,
-                  item: Gc<ast::Item>,
-                  push: |Gc<ast::Item>|) {
+                  _mitem: &ast::MetaItem,
+                  item: &ast::Item,
+                  push: |P<ast::Item>|) {
         let newitem = match item.node {
             ast::ItemStruct(ref struct_def, ref generics) => {
                 self.expand_struct_def(cx,
@@ -365,10 +368,10 @@ impl<'a> TraitDef<'a> {
                 _ => false,
             }
         }).map(|a| a.clone()));
-        push(box(GC) ast::Item {
+        push(P(ast::Item {
             attrs: attrs,
             ..(*newitem).clone()
-        })
+        }))
     }
 
     /**
@@ -387,7 +390,7 @@ impl<'a> TraitDef<'a> {
                            cx: &mut ExtCtxt,
                            type_ident: Ident,
                            generics: &Generics,
-                           methods: Vec<Gc<ast::Method>> ) -> Gc<ast::Item> {
+                           methods: Vec<P<ast::Method>>) -> P<ast::Item> {
         let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
 
         let Generics { mut lifetimes, ty_params, where_clause: _ } =
@@ -475,7 +478,7 @@ impl<'a> TraitDef<'a> {
                          cx: &mut ExtCtxt,
                          struct_def: &StructDef,
                          type_ident: Ident,
-                         generics: &Generics) -> Gc<ast::Item> {
+                         generics: &Generics) -> P<ast::Item> {
         let methods = self.methods.iter().map(|method_def| {
             let (explicit_self, self_args, nonself_args, tys) =
                 method_def.split_self_nonself_args(
@@ -515,7 +518,7 @@ impl<'a> TraitDef<'a> {
                        cx: &mut ExtCtxt,
                        enum_def: &EnumDef,
                        type_ident: Ident,
-                       generics: &Generics) -> Gc<ast::Item> {
+                       generics: &Generics) -> P<ast::Item> {
         let methods = self.methods.iter().map(|method_def| {
             let (explicit_self, self_args, nonself_args, tys) =
                 method_def.split_self_nonself_args(cx, self,
@@ -534,7 +537,7 @@ impl<'a> TraitDef<'a> {
                                                    self,
                                                    enum_def,
                                                    type_ident,
-                                                   self_args.as_slice(),
+                                                   self_args,
                                                    nonself_args.as_slice())
             };
 
@@ -553,7 +556,7 @@ impl<'a> TraitDef<'a> {
 }
 
 fn variant_to_pat(cx: &mut ExtCtxt, sp: Span, variant: &ast::Variant)
-                  -> Gc<ast::Pat> {
+                  -> P<ast::Pat> {
     let ident = cx.path_ident(sp, variant.node.name);
     cx.pat(sp, match variant.node.kind {
         ast::TupleVariantKind(..) => ast::PatEnum(ident, None),
@@ -566,10 +569,10 @@ impl<'a> MethodDef<'a> {
                                 cx: &mut ExtCtxt,
                                 trait_: &TraitDef,
                                 type_ident: Ident,
-                                self_args: &[Gc<Expr>],
-                                nonself_args: &[Gc<Expr>],
+                                self_args: &[P<Expr>],
+                                nonself_args: &[P<Expr>],
                                 fields: &SubstructureFields)
-        -> Gc<Expr> {
+        -> P<Expr> {
         let substructure = Substructure {
             type_ident: type_ident,
             method_ident: cx.ident_of(self.name),
@@ -600,8 +603,7 @@ impl<'a> MethodDef<'a> {
                                trait_: &TraitDef,
                                type_ident: Ident,
                                generics: &Generics)
-        -> (ast::ExplicitSelf, Vec<Gc<Expr>>, Vec<Gc<Expr>>,
-            Vec<(Ident, P<ast::Ty>)>) {
+        -> (ast::ExplicitSelf, Vec<P<Expr>>, Vec<P<Expr>>, Vec<(Ident, P<ast::Ty>)>) {
 
         let mut self_args = Vec::new();
         let mut nonself_args = Vec::new();
@@ -654,8 +656,7 @@ impl<'a> MethodDef<'a> {
                      abi: Abi,
                      explicit_self: ast::ExplicitSelf,
                      arg_types: Vec<(Ident, P<ast::Ty>)> ,
-                     body: Gc<Expr>)
-                     -> Gc<ast::Method> {
+                     body: P<Expr>) -> P<ast::Method> {
         // create the generics that aren't for Self
         let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics);
 
@@ -678,7 +679,7 @@ impl<'a> MethodDef<'a> {
         let body_block = cx.block_expr(body);
 
         // Create the method.
-        box(GC) ast::Method {
+        P(ast::Method {
             attrs: self.attributes.clone(),
             id: ast::DUMMY_NODE_ID,
             span: trait_.span,
@@ -690,7 +691,7 @@ impl<'a> MethodDef<'a> {
                                 fn_decl,
                                 body_block,
                                 ast::Inherited)
-        }
+        })
     }
 
     /**
@@ -719,9 +720,9 @@ impl<'a> MethodDef<'a> {
                                  trait_: &TraitDef,
                                  struct_def: &StructDef,
                                  type_ident: Ident,
-                                 self_args: &[Gc<Expr>],
-                                 nonself_args: &[Gc<Expr>])
-        -> Gc<Expr> {
+                                 self_args: &[P<Expr>],
+                                 nonself_args: &[P<Expr>])
+        -> P<Expr> {
 
         let mut raw_fields = Vec::new(); // ~[[fields of self],
                                  // [fields of next Self arg], [etc]]
@@ -740,20 +741,20 @@ impl<'a> MethodDef<'a> {
 
         // transpose raw_fields
         let fields = if raw_fields.len() > 0 {
-            raw_fields.get(0)
-                      .iter()
-                      .enumerate()
-                      .map(|(i, &(span, opt_id, field))| {
-                let other_fields = raw_fields.tail().iter().map(|l| {
-                    match l.get(i) {
-                        &(_, _, ex) => ex
-                    }
-                }).collect();
+            let mut raw_fields = raw_fields.move_iter().map(|v| v.move_iter());
+            let first_field = raw_fields.next().unwrap();
+            let mut other_fields: Vec<vec::MoveItems<(Span, Option<Ident>, P<Expr>)>>
+                = raw_fields.collect();
+            first_field.map(|(span, opt_id, field)| {
                 FieldInfo {
                     span: span,
                     name: opt_id,
                     self_: field,
-                    other: other_fields
+                    other: other_fields.mut_iter().map(|l| {
+                        match l.next().unwrap() {
+                            (_, _, ex) => ex
+                        }
+                    }).collect()
                 }
             }).collect()
         } else {
@@ -774,9 +775,9 @@ impl<'a> MethodDef<'a> {
         // make a series of nested matches, to destructure the
         // structs. This is actually right-to-left, but it shouldn't
         // matter.
-        for (&arg_expr, &pat) in self_args.iter().zip(patterns.iter()) {
-            body = cx.expr_match(trait_.span, arg_expr,
-                                     vec!( cx.arm(trait_.span, vec!(pat), body) ))
+        for (arg_expr, pat) in self_args.iter().zip(patterns.iter()) {
+            body = cx.expr_match(trait_.span, arg_expr.clone(),
+                                     vec!( cx.arm(trait_.span, vec!(pat.clone()), body) ))
         }
         body
     }
@@ -786,9 +787,9 @@ impl<'a> MethodDef<'a> {
                                         trait_: &TraitDef,
                                         struct_def: &StructDef,
                                         type_ident: Ident,
-                                        self_args: &[Gc<Expr>],
-                                        nonself_args: &[Gc<Expr>])
-        -> Gc<Expr> {
+                                        self_args: &[P<Expr>],
+                                        nonself_args: &[P<Expr>])
+        -> P<Expr> {
         let summary = trait_.summarise_struct(cx, struct_def);
 
         self.call_substructure_method(cx,
@@ -834,9 +835,9 @@ impl<'a> MethodDef<'a> {
                                trait_: &TraitDef,
                                enum_def: &EnumDef,
                                type_ident: Ident,
-                               self_args: &[Gc<Expr>],
-                               nonself_args: &[Gc<Expr>])
-                               -> Gc<Expr> {
+                               self_args: Vec<P<Expr>>,
+                               nonself_args: &[P<Expr>])
+                               -> P<Expr> {
         self.build_enum_match_tuple(
             cx, trait_, enum_def, type_ident, self_args, nonself_args)
     }
@@ -875,8 +876,8 @@ impl<'a> MethodDef<'a> {
         trait_: &TraitDef,
         enum_def: &EnumDef,
         type_ident: Ident,
-        self_args: &[Gc<Expr>],
-        nonself_args: &[Gc<Expr>]) -> Gc<Expr> {
+        self_args: Vec<P<Expr>>,
+        nonself_args: &[P<Expr>]) -> P<Expr> {
 
         let sp = trait_.span;
         let variants = &enum_def.variants;
@@ -898,7 +899,7 @@ impl<'a> MethodDef<'a> {
         // The `vi_idents` will be bound, solely in the catch-all, to
         // a series of let statements mapping each self_arg to a uint
         // corresponding to its variant index.
-        let vi_idents : Vec<ast::Ident> = self_arg_names.iter()
+        let vi_idents: Vec<ast::Ident> = self_arg_names.iter()
             .map(|name| { let vi_suffix = format!("{:s}_vi", name.as_slice());
                           cx.ident_of(vi_suffix.as_slice()) })
             .collect::<Vec<ast::Ident>>();
@@ -914,24 +915,29 @@ impl<'a> MethodDef<'a> {
         // (Variant2, Variant2, ...) => Body2
         // ...
         // where each tuple has length = self_args.len()
-        let mut match_arms : Vec<ast::Arm> = variants.iter().enumerate()
-            .map(|(index, &variant)| {
-
-                // These self_pats have form Variant1, Variant2, ...
-                let self_pats : Vec<(Gc<ast::Pat>,
-                                     Vec<(Span, Option<Ident>, Gc<Expr>)>)>;
-                self_pats = self_arg_names.iter()
-                    .map(|self_arg_name|
-                         trait_.create_enum_variant_pattern(
-                             cx, &*variant, self_arg_name.as_slice(),
-                             ast::MutImmutable))
-                    .collect();
+        let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
+            .map(|(index, variant)| {
+                let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
+                    let (p, idents) = trait_.create_enum_variant_pattern(cx, &**variant,
+                                                                         self_arg_name,
+                                                                         ast::MutImmutable);
+                    (cx.pat(sp, ast::PatRegion(p)), idents)
+                };
 
                 // A single arm has form (&VariantK, &VariantK, ...) => BodyK
                 // (see "Final wrinkle" note below for why.)
-                let subpats = self_pats.iter()
-                    .map(|&(p, ref _idents)| cx.pat(sp, ast::PatRegion(p)))
-                    .collect::<Vec<Gc<ast::Pat>>>();
+                let mut subpats = Vec::with_capacity(self_arg_names.len());
+                let mut self_pats_idents = Vec::with_capacity(self_arg_names.len() - 1);
+                let first_self_pat_idents = {
+                    let (p, idents) = mk_self_pat(cx, self_arg_names[0].as_slice());
+                    subpats.push(p);
+                    idents
+                };
+                for self_arg_name in self_arg_names.tail().iter() {
+                    let (p, idents) = mk_self_pat(cx, self_arg_name.as_slice());
+                    subpats.push(p);
+                    self_pats_idents.push(idents);
+                }
 
                 // Here is the pat = `(&VariantK, &VariantK, ...)`
                 let single_pat = cx.pat(sp, ast::PatTup(subpats));
@@ -941,39 +947,33 @@ impl<'a> MethodDef<'a> {
                 // we are in.
 
                 // All of the Self args have the same variant in these
-                // cases.  So we transpose the info in self_pats to
-                // gather the getter expressions together, in the form
-                // that EnumMatching expects.
+                // cases.  So we transpose the info in self_pats_idents
+                // to gather the getter expressions together, in the
+                // form that EnumMatching expects.
 
                 // The transposition is driven by walking across the
                 // arg fields of the variant for the first self pat.
-                let &(_, ref self_arg_fields) = self_pats.get(0);
-
-                let field_tuples : Vec<FieldInfo>;
-
-                field_tuples = self_arg_fields.iter().enumerate()
+                let field_tuples = first_self_pat_idents.move_iter().enumerate()
                     // For each arg field of self, pull out its getter expr ...
-                    .map(|(field_index, &(sp, opt_ident, self_getter_expr))| {
+                    .map(|(field_index, (sp, opt_ident, self_getter_expr))| {
                         // ... but FieldInfo also wants getter expr
                         // for matching other arguments of Self type;
-                        // so walk across the *other* self_pats and
-                        // pull out getter for same field in each of
-                        // them (using `field_index` tracked above).
+                        // so walk across the *other* self_pats_idents
+                        // and pull out getter for same field in each
+                        // of them (using `field_index` tracked above).
                         // That is the heart of the transposition.
-                        let others = self_pats.tail().iter()
-                            .map(|&(_pat, ref fields)| {
+                        let others = self_pats_idents.iter().map(|fields| {
+                            let &(_, _opt_ident, ref other_getter_expr) =
+                                fields.get(field_index);
 
-                                let &(_, _opt_ident, other_getter_expr) =
-                                    fields.get(field_index);
+                            // All Self args have same variant, so
+                            // opt_idents are the same.  (Assert
+                            // here to make it self-evident that
+                            // it is okay to ignore `_opt_ident`.)
+                            assert!(opt_ident == _opt_ident);
 
-                                // All Self args have same variant, so
-                                // opt_idents are the same.  (Assert
-                                // here to make it self-evident that
-                                // it is okay to ignore `_opt_ident`.)
-                                assert!(opt_ident == _opt_ident);
-
-                                other_getter_expr
-                            }).collect::<Vec<Gc<Expr>>>();
+                            other_getter_expr.clone()
+                        }).collect::<Vec<P<Expr>>>();
 
                         FieldInfo { span: sp,
                                     name: opt_ident,
@@ -987,10 +987,10 @@ impl<'a> MethodDef<'a> {
                 // Self arg, assuming all are instances of VariantK.
                 // Build up code associated with such a case.
                 let substructure = EnumMatching(index,
-                                                &*variant,
+                                                &**variant,
                                                 field_tuples);
                 let arm_expr = self.call_substructure_method(
-                    cx, trait_, type_ident, self_args, nonself_args,
+                    cx, trait_, type_ident, self_args.as_slice(), nonself_args,
                     &substructure);
 
                 cx.arm(sp, vec![single_pat], arm_expr)
@@ -1012,9 +1012,9 @@ impl<'a> MethodDef<'a> {
         //   unreachable-pattern error.
         //
         if variants.len() > 1 && self_args.len() > 1 {
-            let arms : Vec<ast::Arm> = variants.iter().enumerate()
-                .map(|(index, &variant)| {
-                    let pat = variant_to_pat(cx, sp, &*variant);
+            let arms: Vec<ast::Arm> = variants.iter().enumerate()
+                .map(|(index, variant)| {
+                    let pat = variant_to_pat(cx, sp, &**variant);
                     let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyU));
                     cx.arm(sp, vec![pat], cx.expr_lit(sp, lit))
                 }).collect();
@@ -1035,15 +1035,15 @@ impl<'a> MethodDef<'a> {
             //     A => 0u, B(..) => 1u, C(..) => 2u
             // };
             // ```
-            let mut index_let_stmts : Vec<Gc<ast::Stmt>> = Vec::new();
-            for (&ident, &self_arg) in vi_idents.iter().zip(self_args.iter()) {
-                let variant_idx = cx.expr_match(sp, self_arg, arms.clone());
+            let mut index_let_stmts: Vec<P<ast::Stmt>> = Vec::new();
+            for (&ident, self_arg) in vi_idents.iter().zip(self_args.iter()) {
+                let variant_idx = cx.expr_match(sp, self_arg.clone(), arms.clone());
                 let let_stmt = cx.stmt_let(sp, false, ident, variant_idx);
                 index_let_stmts.push(let_stmt);
             }
 
             let arm_expr = self.call_substructure_method(
-                cx, trait_, type_ident, self_args, nonself_args,
+                cx, trait_, type_ident, self_args.as_slice(), nonself_args,
                 &catch_all_substructure);
 
             // Builds the expression:
@@ -1124,9 +1124,7 @@ impl<'a> MethodDef<'a> {
         // them when they are fed as r-values into a tuple
         // expression; here add a layer of borrowing, turning
         // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
-        let borrowed_self_args = self_args.iter()
-            .map(|&self_arg| cx.expr_addr_of(sp, self_arg))
-            .collect::<Vec<Gc<ast::Expr>>>();
+        let borrowed_self_args = self_args.move_map(|self_arg| cx.expr_addr_of(sp, self_arg));
         let match_arg = cx.expr(sp, ast::ExprTup(borrowed_self_args));
         cx.expr_match(sp, match_arg, match_arms)
     }
@@ -1136,9 +1134,9 @@ impl<'a> MethodDef<'a> {
                                       trait_: &TraitDef,
                                       enum_def: &EnumDef,
                                       type_ident: Ident,
-                                      self_args: &[Gc<Expr>],
-                                      nonself_args: &[Gc<Expr>])
-        -> Gc<Expr> {
+                                      self_args: &[P<Expr>],
+                                      nonself_args: &[P<Expr>])
+        -> P<Expr> {
         let summary = enum_def.variants.iter().map(|v| {
             let ident = v.node.name;
             let summary = match v.node.kind {
@@ -1210,11 +1208,11 @@ impl<'a> TraitDef<'a> {
                           cx: &mut ExtCtxt,
                           field_paths: Vec<ast::SpannedIdent> ,
                           mutbl: ast::Mutability)
-                          -> Vec<Gc<ast::Pat>> {
+                          -> Vec<P<ast::Pat>> {
         field_paths.iter().map(|path| {
             cx.pat(path.span,
                         ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None))
-            }).collect()
+        }).collect()
     }
 
     fn create_struct_pattern(&self,
@@ -1223,7 +1221,7 @@ impl<'a> TraitDef<'a> {
                              struct_def: &StructDef,
                              prefix: &str,
                              mutbl: ast::Mutability)
-                             -> (Gc<ast::Pat>, Vec<(Span, Option<Ident>, Gc<Expr>)>) {
+                             -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
         if struct_def.fields.is_empty() {
             return (
                 cx.pat_ident_binding_mode(
@@ -1266,7 +1264,7 @@ impl<'a> TraitDef<'a> {
         // struct_type is definitely not Unknown, since struct_def.fields
         // must be nonempty to reach here
         let pattern = if struct_type == Record {
-            let field_pats = subpats.iter().zip(ident_expr.iter()).map(|(&pat, &(_, id, _))| {
+            let field_pats = subpats.move_iter().zip(ident_expr.iter()).map(|(pat, &(_, id, _))| {
                 // id is guaranteed to be Some
                 ast::FieldPat { ident: id.unwrap(), pat: pat }
             }).collect();
@@ -1283,7 +1281,7 @@ impl<'a> TraitDef<'a> {
                                    variant: &ast::Variant,
                                    prefix: &str,
                                    mutbl: ast::Mutability)
-        -> (Gc<ast::Pat>, Vec<(Span, Option<Ident>, Gc<Expr>)> ) {
+        -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
         let variant_ident = variant.node.name;
         match variant.node.kind {
             ast::TupleVariantKind(ref variant_args) => {
@@ -1327,13 +1325,13 @@ Fold the fields. `use_foldl` controls whether this is done
 left-to-right (`true`) or right-to-left (`false`).
 */
 pub fn cs_fold(use_foldl: bool,
-               f: |&mut ExtCtxt, Span, Gc<Expr>, Gc<Expr>, &[Gc<Expr>]| -> Gc<Expr>,
-               base: Gc<Expr>,
+               f: |&mut ExtCtxt, Span, P<Expr>, P<Expr>, &[P<Expr>]| -> P<Expr>,
+               base: P<Expr>,
                enum_nonmatch_f: EnumNonMatchCollapsedFunc,
                cx: &mut ExtCtxt,
                trait_span: Span,
                substructure: &Substructure)
-               -> Gc<Expr> {
+               -> P<Expr> {
     match *substructure.fields {
         EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
             if use_foldl {
@@ -1341,7 +1339,7 @@ pub fn cs_fold(use_foldl: bool,
                     f(cx,
                       field.span,
                       old,
-                      field.self_,
+                      field.self_.clone(),
                       field.other.as_slice())
                 })
             } else {
@@ -1349,7 +1347,7 @@ pub fn cs_fold(use_foldl: bool,
                     f(cx,
                       field.span,
                       old,
-                      field.self_,
+                      field.self_.clone(),
                       field.other.as_slice())
                 })
             }
@@ -1374,21 +1372,21 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
 ~~~
 */
 #[inline]
-pub fn cs_same_method(f: |&mut ExtCtxt, Span, Vec<Gc<Expr>>| -> Gc<Expr>,
+pub fn cs_same_method(f: |&mut ExtCtxt, Span, Vec<P<Expr>>| -> P<Expr>,
                       enum_nonmatch_f: EnumNonMatchCollapsedFunc,
                       cx: &mut ExtCtxt,
                       trait_span: Span,
                       substructure: &Substructure)
-                      -> Gc<Expr> {
+                      -> P<Expr> {
     match *substructure.fields {
         EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
             // call self_n.method(other_1_n, other_2_n, ...)
             let called = all_fields.iter().map(|field| {
                 cx.expr_method_call(field.span,
-                                    field.self_,
+                                    field.self_.clone(),
                                     substructure.method_ident,
                                     field.other.iter()
-                                               .map(|e| cx.expr_addr_of(field.span, *e))
+                                               .map(|e| cx.expr_addr_of(field.span, e.clone()))
                                                .collect())
             }).collect();
 
@@ -1410,21 +1408,21 @@ fields. `use_foldl` controls whether this is done left-to-right
 */
 #[inline]
 pub fn cs_same_method_fold(use_foldl: bool,
-                           f: |&mut ExtCtxt, Span, Gc<Expr>, Gc<Expr>| -> Gc<Expr>,
-                           base: Gc<Expr>,
+                           f: |&mut ExtCtxt, Span, P<Expr>, P<Expr>| -> P<Expr>,
+                           base: P<Expr>,
                            enum_nonmatch_f: EnumNonMatchCollapsedFunc,
                            cx: &mut ExtCtxt,
                            trait_span: Span,
                            substructure: &Substructure)
-                           -> Gc<Expr> {
+                           -> P<Expr> {
     cs_same_method(
         |cx, span, vals| {
             if use_foldl {
-                vals.iter().fold(base, |old, &new| {
+                vals.move_iter().fold(base.clone(), |old, new| {
                     f(cx, span, old, new)
                 })
             } else {
-                vals.iter().rev().fold(base, |old, &new| {
+                vals.move_iter().rev().fold(base.clone(), |old, new| {
                     f(cx, span, old, new)
                 })
             }
@@ -1438,10 +1436,10 @@ Use a given binop to combine the result of calling the derived method
 on all the fields.
 */
 #[inline]
-pub fn cs_binop(binop: ast::BinOp, base: Gc<Expr>,
+pub fn cs_binop(binop: ast::BinOp, base: P<Expr>,
                 enum_nonmatch_f: EnumNonMatchCollapsedFunc,
                 cx: &mut ExtCtxt, trait_span: Span,
-                substructure: &Substructure) -> Gc<Expr> {
+                substructure: &Substructure) -> P<Expr> {
     cs_same_method_fold(
         true, // foldl is good enough
         |cx, span, old, new| {
@@ -1459,7 +1457,7 @@ pub fn cs_binop(binop: ast::BinOp, base: Gc<Expr>,
 #[inline]
 pub fn cs_or(enum_nonmatch_f: EnumNonMatchCollapsedFunc,
              cx: &mut ExtCtxt, span: Span,
-             substructure: &Substructure) -> Gc<Expr> {
+             substructure: &Substructure) -> P<Expr> {
     cs_binop(ast::BiOr, cx.expr_bool(span, false),
              enum_nonmatch_f,
              cx, span, substructure)
@@ -1469,7 +1467,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchCollapsedFunc,
 #[inline]
 pub fn cs_and(enum_nonmatch_f: EnumNonMatchCollapsedFunc,
               cx: &mut ExtCtxt, span: Span,
-              substructure: &Substructure) -> Gc<Expr> {
+              substructure: &Substructure) -> P<Expr> {
     cs_binop(ast::BiAnd, cx.expr_bool(span, true),
              enum_nonmatch_f,
              cx, span, substructure)
diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs
index 8b4a9c51cf0..a90618a30b6 100644
--- a/src/libsyntax/ext/deriving/generic/ty.rs
+++ b/src/libsyntax/ext/deriving/generic/ty.rs
@@ -14,14 +14,13 @@ explicit `Self` type to use when specifying impls to be derived.
 */
 
 use ast;
-use ast::{P,Expr,Generics,Ident};
+use ast::{Expr,Generics,Ident};
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
 use codemap::{Span,respan};
 use owned_slice::OwnedSlice;
 use parse::token::special_idents;
-
-use std::gc::Gc;
+use ptr::P;
 
 /// The types of pointers
 #[deriving(Clone)]
@@ -260,7 +259,7 @@ impl<'a> LifetimeBounds<'a> {
 }
 
 pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
-    -> (Gc<Expr>, ast::ExplicitSelf) {
+    -> (P<Expr>, ast::ExplicitSelf) {
     // this constructs a fresh `self` path, which will match the fresh `self` binding
     // created below.
     let self_path = cx.expr_self(span);
diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs
index f469139177a..b7f11c25825 100644
--- a/src/libsyntax/ext/deriving/hash.rs
+++ b/src/libsyntax/ext/deriving/hash.rs
@@ -15,14 +15,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_hash(cx: &mut ExtCtxt,
                             span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
 
     let (path, generics, args) = if cx.ecfg.deriving_hash_type_parameter {
         (Path::new_(vec!("std", "hash", "Hash"), None,
@@ -64,15 +63,14 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
     hash_trait_def.expand(cx, mitem, item, push);
 }
 
-fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                     substr: &Substructure) -> Gc<Expr> {
+fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let state_expr = match substr.nonself_args {
-        [state_expr] => state_expr,
+        [ref state_expr] => state_expr,
         _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(Hash)`")
     };
     let hash_ident = substr.method_ident;
     let call_hash = |span, thing_expr| {
-        let expr = cx.expr_method_call(span, thing_expr, hash_ident, vec!(state_expr));
+        let expr = cx.expr_method_call(span, thing_expr, hash_ident, vec!(state_expr.clone()));
         cx.stmt_expr(expr)
     };
     let mut stmts = Vec::new();
@@ -83,7 +81,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span,
             // Determine the discriminant. We will feed this value to the byte
             // iteration function.
             let discriminant = match variant.node.disr_expr {
-                Some(d) => d,
+                Some(ref d) => d.clone(),
                 None => cx.expr_uint(trait_span, index)
             };
 
@@ -94,8 +92,8 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span,
         _ => cx.span_bug(trait_span, "impossible substructure in `deriving(Hash)`")
     };
 
-    for &FieldInfo { self_, span, .. } in fields.iter() {
-        stmts.push(call_hash(span, self_));
+    for &FieldInfo { ref self_, span, .. } in fields.iter() {
+        stmts.push(call_hash(span, self_.clone()));
     }
 
     if stmts.len() == 0 {
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index a9b5c8a4134..b8cebd8ea20 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -21,8 +21,7 @@ library.
 use ast::{Item, MetaItem, MetaList, MetaNameValue, MetaWord};
 use ext::base::ExtCtxt;
 use codemap::Span;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub mod bounds;
 pub mod clone;
@@ -49,9 +48,9 @@ pub mod generic;
 
 pub fn expand_meta_deriving(cx: &mut ExtCtxt,
                             _span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
     match mitem.node {
         MetaNameValue(_, ref l) => {
             cx.span_err(l.span, "unexpected value in `deriving`");
@@ -63,13 +62,13 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
             cx.span_warn(mitem.span, "empty trait list in `deriving`");
         }
         MetaList(_, ref titems) => {
-            for &titem in titems.iter().rev() {
+            for titem in titems.iter().rev() {
                 match titem.node {
                     MetaNameValue(ref tname, _) |
                     MetaList(ref tname, _) |
                     MetaWord(ref tname) => {
                         macro_rules! expand(($func:path) => ($func(cx, titem.span,
-                                                                   titem, item,
+                                                                   &**titem, item,
                                                                    |i| push(i))));
                         match tname.get() {
                             "Clone" => expand!(clone::expand_deriving_clone),
diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs
index 30dd8e9683a..044a2812c00 100644
--- a/src/libsyntax/ext/deriving/primitive.rs
+++ b/src/libsyntax/ext/deriving/primitive.rs
@@ -16,14 +16,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
                                       span: Span,
-                                      mitem: Gc<MetaItem>,
-                                      item: Gc<Item>,
-                                      push: |Gc<Item>|) {
+                                      mitem: &MetaItem,
+                                      item: &Item,
+                                      push: |P<Item>|) {
     let inline = cx.meta_word(span, InternedString::new("inline"));
     let attrs = vec!(cx.attribute(span, inline));
     let trait_def = TraitDef {
@@ -70,10 +69,9 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
     trait_def.expand(cx, mitem, item, push)
 }
 
-fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span,
-           substr: &Substructure) -> Gc<Expr> {
+fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let n = match substr.nonself_args {
-        [n] => n,
+        [ref n] => n,
         _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(FromPrimitive)`")
     };
 
@@ -106,8 +104,8 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span,
                         // expr for `$n == $variant as $name`
                         let variant = cx.expr_ident(span, variant.node.name);
                         let ty = cx.ty_ident(span, cx.ident_of(name));
-                        let cast = cx.expr_cast(span, variant, ty);
-                        let guard = cx.expr_binary(span, ast::BiEq, n, cast);
+                        let cast = cx.expr_cast(span, variant.clone(), ty);
+                        let guard = cx.expr_binary(span, ast::BiEq, n.clone(), cast);
 
                         // expr for `Some($variant)`
                         let body = cx.expr_some(span, variant);
@@ -141,7 +139,7 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span,
             };
             arms.push(arm);
 
-            cx.expr_match(trait_span, n, arms)
+            cx.expr_match(trait_span, n.clone(), arms)
         }
         _ => cx.span_bug(trait_span, "expected StaticEnum in deriving(FromPrimitive)")
     }
diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs
index c652b5a5bed..584645bb306 100644
--- a/src/libsyntax/ext/deriving/rand.rs
+++ b/src/libsyntax/ext/deriving/rand.rs
@@ -15,14 +15,13 @@ use ext::base::ExtCtxt;
 use ext::build::{AstBuilder};
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_rand(cx: &mut ExtCtxt,
                             span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
@@ -54,10 +53,9 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt,
     trait_def.expand(cx, mitem, item, push)
 }
 
-fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                     substr: &Substructure) -> Gc<Expr> {
+fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let rng = match substr.nonself_args {
-        [rng] => vec!( rng ),
+        [ref rng] => rng,
         _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
     };
     let rand_ident = vec!(
@@ -69,7 +67,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span,
     let rand_call = |cx: &mut ExtCtxt, span| {
         cx.expr_call_global(span,
                             rand_ident.clone(),
-                            vec!( *rng.get(0) ))
+                            vec!(rng.clone()))
     };
 
     return match *substr.fields {
@@ -95,7 +93,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span,
             // ::rand::Rand::rand(rng)
             let rv_call = cx.expr_call(trait_span,
                                        rand_name,
-                                       vec!( *rng.get(0) ));
+                                       vec!(rng.clone()));
 
             // need to specify the uint-ness of the random number
             let uint_ty = cx.ty_ident(trait_span, cx.ident_of("uint"));
@@ -136,8 +134,8 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span,
                   trait_span: Span,
                   ctor_ident: Ident,
                   summary: &StaticFields,
-                  rand_call: |&mut ExtCtxt, Span| -> Gc<Expr>)
-                  -> Gc<Expr> {
+                  rand_call: |&mut ExtCtxt, Span| -> P<Expr>)
+                  -> P<Expr> {
         match *summary {
             Unnamed(ref fields) => {
                 if fields.is_empty() {
diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs
index e0dfbb232f5..16ce264fe71 100644
--- a/src/libsyntax/ext/deriving/show.rs
+++ b/src/libsyntax/ext/deriving/show.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use ast;
-use ast::{MetaItem, Item, Expr};
+use ast::{MetaItem, Item, Expr,};
 use codemap::Span;
 use ext::format;
 use ext::base::ExtCtxt;
@@ -17,16 +17,15 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token;
+use ptr::P;
 
 use std::collections::HashMap;
-use std::string::String;
-use std::gc::Gc;
 
 pub fn expand_deriving_show(cx: &mut ExtCtxt,
                             span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
     // &mut ::std::fmt::Formatter
     let fmtr = Ptr(box Literal(Path::new(vec!("std", "fmt", "Formatter"))),
                    Borrowed(None, ast::MutMutable));
@@ -57,7 +56,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
 /// We construct a format string and then defer to std::fmt, since that
 /// knows what's up with formatting and so on.
 fn show_substructure(cx: &mut ExtCtxt, span: Span,
-                     substr: &Substructure) -> Gc<Expr> {
+                     substr: &Substructure) -> P<Expr> {
     // build `<name>`, `<name>({}, {}, ...)` or `<name> { <field>: {},
     // <field>: {}, ... }` based on the "shape".
     //
@@ -91,7 +90,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
 
                     format_string.push_str("{}");
 
-                    exprs.push(field.self_);
+                    exprs.push(field.self_.clone());
                 }
 
                 format_string.push_str(")");
@@ -108,7 +107,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                     format_string.push_str(name.get());
                     format_string.push_str(": {}");
 
-                    exprs.push(field.self_);
+                    exprs.push(field.self_.clone());
                 }
 
                 format_string.push_str(" }}");
@@ -123,7 +122,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
     // format_arg_method!(fmt, write_fmt, "<format_string>", exprs...)
     //
     // but doing it directly via ext::format.
-    let formatter = substr.nonself_args[0];
+    let formatter = substr.nonself_args[0].clone();
 
     let meth = cx.ident_of("write_fmt");
     let s = token::intern_and_get_ident(format_string.as_slice());
diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs
index 973f9d518cd..7f265b529ff 100644
--- a/src/libsyntax/ext/deriving/zero.rs
+++ b/src/libsyntax/ext/deriving/zero.rs
@@ -15,14 +15,13 @@ use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 use ext::deriving::generic::ty::*;
 use parse::token::InternedString;
-
-use std::gc::Gc;
+use ptr::P;
 
 pub fn expand_deriving_zero(cx: &mut ExtCtxt,
                             span: Span,
-                            mitem: Gc<MetaItem>,
-                            item: Gc<Item>,
-                            push: |Gc<Item>|) {
+                            mitem: &MetaItem,
+                            item: &Item,
+                            push: |P<Item>|) {
     let inline = cx.meta_word(span, InternedString::new("inline"));
     let attrs = vec!(cx.attribute(span, inline));
     let trait_def = TraitDef {
@@ -63,8 +62,7 @@ pub fn expand_deriving_zero(cx: &mut ExtCtxt,
     trait_def.expand(cx, mitem, item, push)
 }
 
-fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span,
-                     substr: &Substructure) -> Gc<Expr> {
+fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let zero_ident = vec!(
         cx.ident_of("std"),
         cx.ident_of("num"),
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs
index aae92ae85fc..69574ee6696 100644
--- a/src/libsyntax/ext/env.rs
+++ b/src/libsyntax/ext/env.rs
@@ -61,38 +61,42 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
 
 pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                        -> Box<base::MacResult+'cx> {
-    let exprs = match get_exprs_from_tts(cx, sp, tts) {
+    let mut exprs = match get_exprs_from_tts(cx, sp, tts) {
         Some(ref exprs) if exprs.len() == 0 => {
             cx.span_err(sp, "env! takes 1 or 2 arguments");
             return DummyResult::expr(sp);
         }
         None => return DummyResult::expr(sp),
-        Some(exprs) => exprs
+        Some(exprs) => exprs.move_iter()
     };
 
     let var = match expr_to_string(cx,
-                                *exprs.get(0),
+                                exprs.next().unwrap(),
                                 "expected string literal") {
         None => return DummyResult::expr(sp),
         Some((v, _style)) => v
     };
-    let msg = match exprs.len() {
-        1 => {
+    let msg = match exprs.next() {
+        None => {
             token::intern_and_get_ident(format!("environment variable `{}` \
                                                  not defined",
                                                 var).as_slice())
         }
-        2 => {
-            match expr_to_string(cx, *exprs.get(1), "expected string literal") {
+        Some(second) => {
+            match expr_to_string(cx, second, "expected string literal") {
                 None => return DummyResult::expr(sp),
                 Some((s, _style)) => s
             }
         }
-        _ => {
+    };
+
+    match exprs.next() {
+        None => {}
+        Some(_) => {
             cx.span_err(sp, "env! takes 1 or 2 arguments");
             return DummyResult::expr(sp);
         }
-    };
+    }
 
     let e = match os::getenv(var.get()) {
         None => {
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index d15d6b3f8f1..db28872de37 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{P, Block, Crate, DeclLocal, ExprMac, PatMac};
+use ast::{Block, Crate, DeclLocal, ExprMac, PatMac};
 use ast::{Local, Ident, MacInvocTT};
 use ast::{ItemMac, Mrk, Stmt, StmtDecl, StmtMac, StmtExpr, StmtSemi};
 use ast::TokenTree;
@@ -25,103 +25,106 @@ use fold::*;
 use parse;
 use parse::token::{fresh_mark, fresh_name, intern};
 use parse::token;
+use ptr::P;
+use util::small_vector::SmallVector;
 use visit;
 use visit::Visitor;
-use util::small_vector::SmallVector;
 
-use std::gc::{Gc, GC};
+use std::gc::Gc;
 
 enum Either<L,R> {
     Left(L),
     Right(R)
 }
 
-fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
-    match e.node {
+pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
+    e.and_then(|ast::Expr {id, node, span}| match node {
         // expr_mac should really be expr_ext or something; it's the
         // entry-point for all syntax extensions.
-        ExprMac(ref mac) => {
-            let expanded_expr = match expand_mac_invoc(mac,&e.span,
-                                                       |r|{r.make_expr()},
-                                                       |expr,fm|{mark_expr(expr,fm)},
-                                                       fld) {
+        ExprMac(mac) => {
+            let expanded_expr = match expand_mac_invoc(mac, span,
+                                                       |r| r.make_expr(),
+                                                       mark_expr, fld) {
                 Some(expr) => expr,
                 None => {
-                    return DummyResult::raw_expr(e.span);
+                    return DummyResult::raw_expr(span);
                 }
             };
 
             // Keep going, outside-in.
             //
-            // FIXME(pcwalton): Is it necessary to clone the
-            // node here?
-            let fully_expanded =
-                fld.fold_expr(expanded_expr).node.clone();
+            let fully_expanded = fld.fold_expr(expanded_expr);
             fld.cx.bt_pop();
 
-            box(GC) ast::Expr {
+            fully_expanded.map(|e| ast::Expr {
                 id: ast::DUMMY_NODE_ID,
-                node: fully_expanded,
-                span: e.span,
-            }
+                node: e.node,
+                span: span,
+            })
         }
 
         ast::ExprWhile(cond, body, opt_ident) => {
             let cond = fld.fold_expr(cond);
             let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);
-            fld.cx.expr(e.span, ast::ExprWhile(cond, body, opt_ident))
+            fld.cx.expr(span, ast::ExprWhile(cond, body, opt_ident))
         }
 
         ast::ExprLoop(loop_block, opt_ident) => {
             let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);
-            fld.cx.expr(e.span, ast::ExprLoop(loop_block, opt_ident))
+            fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident))
         }
 
         ast::ExprForLoop(pat, head, body, opt_ident) => {
             let pat = fld.fold_pat(pat);
             let head = fld.fold_expr(head);
             let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);
-            fld.cx.expr(e.span, ast::ExprForLoop(pat, head, body, opt_ident))
+            fld.cx.expr(span, ast::ExprForLoop(pat, head, body, opt_ident))
         }
 
         ast::ExprFnBlock(capture_clause, fn_decl, block) => {
             let (rewritten_fn_decl, rewritten_block)
-                = expand_and_rename_fn_decl_and_block(&*fn_decl, block, fld);
+                = expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
             let new_node = ast::ExprFnBlock(capture_clause,
                                             rewritten_fn_decl,
                                             rewritten_block);
-            box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
+            P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)})
         }
 
         ast::ExprProc(fn_decl, block) => {
             let (rewritten_fn_decl, rewritten_block)
-                = expand_and_rename_fn_decl_and_block(&*fn_decl, block, fld);
+                = expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
             let new_node = ast::ExprProc(rewritten_fn_decl, rewritten_block);
-            box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
+            P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)})
         }
 
-        _ => noop_fold_expr(e, fld)
-    }
+        _ => {
+            P(noop_fold_expr(ast::Expr {
+                id: id,
+                node: node,
+                span: span
+            }, fld))
+        }
+    })
 }
 
 /// Expand a (not-ident-style) macro invocation. Returns the result
 /// of expansion and the mark which must be applied to the result.
 /// Our current interface doesn't allow us to apply the mark to the
 /// result until after calling make_expr, make_items, etc.
-fn expand_mac_invoc<T>(mac: &ast::Mac, span: &codemap::Span,
+fn expand_mac_invoc<T>(mac: ast::Mac, span: codemap::Span,
                        parse_thunk: |Box<MacResult>|->Option<T>,
                        mark_thunk: |T,Mrk|->T,
                        fld: &mut MacroExpander)
                        -> Option<T>
 {
-    match (*mac).node {
+    match mac.node {
         // it would almost certainly be cleaner to pass the whole
         // macro invocation in, rather than pulling it apart and
         // marking the tts and the ctxt separately. This also goes
         // for the other three macro invocation chunks of code
         // in this file.
         // Token-tree macros:
-        MacInvocTT(ref pth, ref tts, _) => {
+        MacInvocTT(pth, tts, _) => {
             if pth.segments.len() > 1u {
                 fld.cx.span_err(pth.span,
                                 "expected macro name without module \
@@ -144,7 +147,7 @@ fn expand_mac_invoc<T>(mac: &ast::Mac, span: &codemap::Span,
                 Some(rc) => match *rc {
                     NormalTT(ref expandfun, exp_span) => {
                         fld.cx.bt_push(ExpnInfo {
-                                call_site: *span,
+                                call_site: span,
                                 callee: NameAndSpan {
                                     name: extnamestr.get().to_string(),
                                     format: MacroBang,
@@ -218,7 +221,7 @@ fn expand_loop_block(loop_block: P<Block>,
             // in a block enclosed by loop head.
             fld.cx.syntax_env.push_frame();
             fld.cx.syntax_env.info().pending_renames.push(rename);
-            let expanded_block = expand_block_elts(&*loop_block, fld);
+            let expanded_block = expand_block_elts(loop_block, fld);
             fld.cx.syntax_env.pop_frame();
 
             (expanded_block, Some(renamed_ident))
@@ -240,8 +243,8 @@ macro_rules! with_exts_frame (
 )
 
 // When we enter a module, record it, for the sake of `module!`
-fn expand_item(it: Gc<ast::Item>, fld: &mut MacroExpander)
-                   -> SmallVector<Gc<ast::Item>> {
+pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)
+                   -> SmallVector<P<ast::Item>> {
     let it = expand_item_modifiers(it, fld);
 
     let mut decorator_items = SmallVector::zero();
@@ -265,8 +268,9 @@ fn expand_item(it: Gc<ast::Item>, fld: &mut MacroExpander)
 
                     // we'd ideally decorator_items.push_all(expand_item(item, fld)),
                     // but that double-mut-borrows fld
-                    let mut items: SmallVector<Gc<ast::Item>> = SmallVector::zero();
-                    dec.expand(fld.cx, attr.span, attr.node.value, it, |item| items.push(item));
+                    let mut items: SmallVector<P<ast::Item>> = SmallVector::zero();
+                    dec.expand(fld.cx, attr.span, &*attr.node.value, &*it,
+                               |item| items.push(item));
                     decorator_items.extend(items.move_iter()
                         .flat_map(|item| expand_item(item, fld).move_iter()));
 
@@ -285,17 +289,16 @@ fn expand_item(it: Gc<ast::Item>, fld: &mut MacroExpander)
             let macro_escape = contains_macro_escape(new_attrs.as_slice());
             let result = with_exts_frame!(fld.cx.syntax_env,
                                           macro_escape,
-                                          noop_fold_item(&*it, fld));
+                                          noop_fold_item(it, fld));
             fld.cx.mod_pop();
             result
         },
         _ => {
-            let it = box(GC) ast::Item {
+            let it = P(ast::Item {
                 attrs: new_attrs,
                 ..(*it).clone()
-
-            };
-            noop_fold_item(&*it, fld)
+            });
+            noop_fold_item(it, fld)
         }
     };
 
@@ -303,8 +306,8 @@ fn expand_item(it: Gc<ast::Item>, fld: &mut MacroExpander)
     new_items
 }
 
-fn expand_item_modifiers(mut it: Gc<ast::Item>, fld: &mut MacroExpander)
-                         -> Gc<ast::Item> {
+fn expand_item_modifiers(mut it: P<ast::Item>, fld: &mut MacroExpander)
+                         -> P<ast::Item> {
     // partition the attributes into ItemModifiers and others
     let (modifiers, other_attrs) = it.attrs.partitioned(|attr| {
         match fld.cx.syntax_env.find(&intern(attr.name().get())) {
@@ -313,10 +316,10 @@ fn expand_item_modifiers(mut it: Gc<ast::Item>, fld: &mut MacroExpander)
         }
     });
     // update the attrs, leave everything else alone. Is this mutation really a good idea?
-    it = box(GC) ast::Item {
+    it = P(ast::Item {
         attrs: other_attrs,
         ..(*it).clone()
-    };
+    });
 
     if modifiers.is_empty() {
         return it;
@@ -337,7 +340,7 @@ fn expand_item_modifiers(mut it: Gc<ast::Item>, fld: &mut MacroExpander)
                             span: None,
                         }
                     });
-                    it = mac.expand(fld.cx, attr.span, attr.node.value, it);
+                    it = mac.expand(fld.cx, attr.span, &*attr.node.value, it);
                     fld.cx.bt_pop();
                 }
                 _ => unreachable!()
@@ -351,15 +354,15 @@ fn expand_item_modifiers(mut it: Gc<ast::Item>, fld: &mut MacroExpander)
 }
 
 /// Expand item_underscore
-fn expand_item_underscore(item: &ast::Item_, fld: &mut MacroExpander) -> ast::Item_ {
-    match *item {
-        ast::ItemFn(decl, fn_style, abi, ref generics, body) => {
+fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Item_ {
+    match item {
+        ast::ItemFn(decl, fn_style, abi, generics, body) => {
             let (rewritten_fn_decl, rewritten_body)
-                = expand_and_rename_fn_decl_and_block(&*decl, body, fld);
+                = expand_and_rename_fn_decl_and_block(decl, body, fld);
             let expanded_generics = fold::noop_fold_generics(generics,fld);
             ast::ItemFn(rewritten_fn_decl, fn_style, abi, expanded_generics, rewritten_body)
         }
-        _ => noop_fold_item_underscore(&*item, fld)
+        _ => noop_fold_item_underscore(item, fld)
     }
 }
 
@@ -370,26 +373,24 @@ fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool {
 
 // Support for item-position macro invocations, exactly the same
 // logic as for expression-position macro invocations.
-fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
-                   -> SmallVector<Gc<ast::Item>>
-{
-    let (pth, tts) = match it.node {
+pub fn expand_item_mac(it: P<ast::Item>, fld: &mut MacroExpander)
+                       -> SmallVector<P<ast::Item>> {
+    let (extname, path_span, tts) = match it.node {
         ItemMac(codemap::Spanned {
             node: MacInvocTT(ref pth, ref tts, _),
             ..
         }) => {
-            (pth, (*tts).clone())
+            (pth.segments.get(0).identifier, pth.span, (*tts).clone())
         }
         _ => fld.cx.span_bug(it.span, "invalid item macro invocation")
     };
 
-    let extname = pth.segments.get(0).identifier;
     let extnamestr = token::get_ident(extname);
     let fm = fresh_mark();
     let def_or_items = {
-        let expanded = match fld.cx.syntax_env.find(&extname.name) {
+        let mut expanded = match fld.cx.syntax_env.find(&extname.name) {
             None => {
-                fld.cx.span_err(pth.span,
+                fld.cx.span_err(path_span,
                                 format!("macro undefined: '{}!'",
                                         extnamestr).as_slice());
                 // let compilation continue
@@ -400,7 +401,7 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
                 NormalTT(ref expander, span) => {
                     if it.ident.name != parse::token::special_idents::invalid.name {
                         fld.cx
-                            .span_err(pth.span,
+                            .span_err(path_span,
                                       format!("macro {}! expects no ident argument, \
                                         given '{}'",
                                       extnamestr,
@@ -421,7 +422,7 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
                 }
                 IdentTT(ref expander, span) => {
                     if it.ident.name == parse::token::special_idents::invalid.name {
-                        fld.cx.span_err(pth.span,
+                        fld.cx.span_err(path_span,
                                         format!("macro {}! expects an ident argument",
                                                 extnamestr.get()).as_slice());
                         return SmallVector::zero();
@@ -440,7 +441,7 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
                 }
                 LetSyntaxTT(ref expander, span) => {
                     if it.ident.name == parse::token::special_idents::invalid.name {
-                        fld.cx.span_err(pth.span,
+                        fld.cx.span_err(path_span,
                                         format!("macro {}! expects an ident argument",
                                                 extnamestr.get()).as_slice());
                         return SmallVector::zero();
@@ -490,7 +491,7 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
                 .collect()
         }
         Right(None) => {
-            fld.cx.span_err(pth.span,
+            fld.cx.span_err(path_span,
                             format!("non-item macro in item position: {}",
                                     extnamestr.get()).as_slice());
             return SmallVector::zero();
@@ -498,24 +499,21 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
     };
 
     fld.cx.bt_pop();
-    return items;
+    items
 }
 
 /// Expand a stmt
 //
 // I don't understand why this returns a vector... it looks like we're
 // half done adding machinery to allow macros to expand into multiple statements.
-fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<Gc<Stmt>> {
+fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
     let (mac, semi) = match s.node {
-        StmtMac(ref mac, semi) => (mac, semi),
+        StmtMac(mac, semi) => (mac, semi),
         _ => return expand_non_macro_stmt(s, fld)
     };
-    let expanded_stmt = match expand_mac_invoc(mac,&s.span,
-                                                |r|{r.make_stmt()},
-                                                |sts,mrk| {
-                                                    mark_stmt(&*sts,mrk)
-                                                },
-                                                fld) {
+    let expanded_stmt = match expand_mac_invoc(mac, s.span,
+                                                |r| r.make_stmt(),
+                                                mark_stmt, fld) {
         Some(stmt) => stmt,
         None => {
             return SmallVector::zero();
@@ -523,46 +521,34 @@ fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<Gc<Stmt>> {
     };
 
     // Keep going, outside-in.
-    let fully_expanded = fld.fold_stmt(&*expanded_stmt);
+    let fully_expanded = fld.fold_stmt(expanded_stmt);
     fld.cx.bt_pop();
-    let fully_expanded: SmallVector<Gc<Stmt>> = fully_expanded.move_iter()
-            .map(|s| box(GC) Spanned { span: s.span, node: s.node.clone() })
-            .collect();
-
-    fully_expanded.move_iter().map(|s| {
-        match s.node {
-            StmtExpr(e, stmt_id) if semi => {
-                box(GC) Spanned {
-                    span: s.span,
-                    node: StmtSemi(e, stmt_id)
-                }
+
+    if semi {
+        fully_expanded.move_iter().map(|s| s.map(|Spanned {node, span}| {
+            Spanned {
+                node: match node {
+                    StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id),
+                    _ => node /* might already have a semi */
+                },
+                span: span
             }
-            _ => s /* might already have a semi */
-        }
-    }).collect()
+        })).collect()
+    } else {
+        fully_expanded
+    }
 }
 
 // expand a non-macro stmt. this is essentially the fallthrough for
 // expand_stmt, above.
-fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
-                         -> SmallVector<Gc<Stmt>> {
+fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroExpander)
+                         -> SmallVector<P<Stmt>> {
     // is it a let?
-    match s.node {
-        StmtDecl(decl, node_id) => {
-            match *decl {
-                Spanned {
-                    node: DeclLocal(ref local),
-                    span: stmt_span
-                } => {
-                    // take it apart:
-                    let Local {
-                        ty: ty,
-                        pat: pat,
-                        init: init,
-                        id: id,
-                        span: span,
-                        source: source,
-                    } = **local;
+    match node {
+        StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl {
+            DeclLocal(local) => {
+                // take it apart:
+                let rewritten_local = local.map(|Local {id, pat, ty, init, source, span}| {
                     // expand the ty since TyFixedLengthVec contains an Expr
                     // and thus may have a macro use
                     let expanded_ty = fld.fold_ty(ty);
@@ -585,57 +571,66 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
                     };
                     // add them to the existing pending renames:
                     fld.cx.syntax_env.info().pending_renames.push_all_move(new_pending_renames);
-                    // also, don't forget to expand the init:
-                    let new_init_opt = init.map(|e| fld.fold_expr(e));
-                    let rewritten_local =
-                        box(GC) Local {
-                            ty: expanded_ty,
-                            pat: rewritten_pat,
-                            init: new_init_opt,
-                            id: id,
-                            span: span,
-                            source: source
-                        };
-                    SmallVector::one(box(GC) Spanned {
-                        node: StmtDecl(box(GC) Spanned {
-                                node: DeclLocal(rewritten_local),
-                                span: stmt_span
-                            },
-                            node_id),
+                    Local {
+                        id: id,
+                        ty: expanded_ty,
+                        pat: rewritten_pat,
+                        // also, don't forget to expand the init:
+                        init: init.map(|e| fld.fold_expr(e)),
+                        source: source,
                         span: span
-                    })
-                }
-                _ => noop_fold_stmt(s, fld),
+                    }
+                });
+                SmallVector::one(P(Spanned {
+                    node: StmtDecl(P(Spanned {
+                            node: DeclLocal(rewritten_local),
+                            span: span
+                        }),
+                        node_id),
+                    span: stmt_span
+                }))
             }
-        },
-        _ => noop_fold_stmt(s, fld),
+            _ => {
+                noop_fold_stmt(Spanned {
+                    node: StmtDecl(P(Spanned {
+                            node: decl,
+                            span: span
+                        }),
+                        node_id),
+                    span: stmt_span
+                }, fld)
+            }
+        }),
+        _ => {
+            noop_fold_stmt(Spanned {
+                node: node,
+                span: stmt_span
+            }, fld)
+        }
     }
 }
 
 // expand the arm of a 'match', renaming for macro hygiene
-fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
+fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
     // expand pats... they might contain macro uses:
-    let expanded_pats : Vec<Gc<ast::Pat>> = arm.pats.iter().map(|pat| fld.fold_pat(*pat)).collect();
+    let expanded_pats = arm.pats.move_map(|pat| fld.fold_pat(pat));
     if expanded_pats.len() == 0 {
         fail!("encountered match arm with 0 patterns");
     }
     // all of the pats must have the same set of bindings, so use the
     // first one to extract them and generate new names:
-    let first_pat = expanded_pats.get(0);
-    let idents = pattern_bindings(&**first_pat);
-    let new_renames =
-        idents.iter().map(|id| (*id,fresh_name(id))).collect();
+    let idents = pattern_bindings(&**expanded_pats.get(0));
+    let new_renames = idents.move_iter().map(|id| (id, fresh_name(&id))).collect();
     // apply the renaming, but only to the PatIdents:
     let mut rename_pats_fld = PatIdentRenamer{renames:&new_renames};
-    let rewritten_pats =
-        expanded_pats.iter().map(|pat| rename_pats_fld.fold_pat(*pat)).collect();
+    let rewritten_pats = expanded_pats.move_map(|pat| rename_pats_fld.fold_pat(pat));
     // apply renaming and then expansion to the guard and the body:
     let mut rename_fld = IdentRenamer{renames:&new_renames};
     let rewritten_guard =
         arm.guard.map(|g| fld.fold_expr(rename_fld.fold_expr(g)));
     let rewritten_body = fld.fold_expr(rename_fld.fold_expr(arm.body));
     ast::Arm {
-        attrs: arm.attrs.iter().map(|x| fld.fold_attribute(*x)).collect(),
+        attrs: arm.attrs.move_map(|x| fld.fold_attribute(x)),
         pats: rewritten_pats,
         guard: rewritten_guard,
         body: rewritten_body,
@@ -683,121 +678,126 @@ fn fn_decl_arg_bindings(fn_decl: &ast::FnDecl) -> Vec<ast::Ident> {
 }
 
 // expand a block. pushes a new exts_frame, then calls expand_block_elts
-fn expand_block(blk: &Block, fld: &mut MacroExpander) -> P<Block> {
+pub fn expand_block(blk: P<Block>, fld: &mut MacroExpander) -> P<Block> {
     // see note below about treatment of exts table
     with_exts_frame!(fld.cx.syntax_env,false,
                      expand_block_elts(blk, fld))
 }
 
 // expand the elements of a block.
-fn expand_block_elts(b: &Block, fld: &mut MacroExpander) -> P<Block> {
-    let new_view_items = b.view_items.iter().map(|x| fld.fold_view_item(x)).collect();
-    let new_stmts =
-        b.stmts.iter().flat_map(|x| {
+pub fn expand_block_elts(b: P<Block>, fld: &mut MacroExpander) -> P<Block> {
+    b.map(|Block {id, view_items, stmts, expr, rules, span}| {
+        let new_view_items = view_items.move_iter().map(|x| fld.fold_view_item(x)).collect();
+        let new_stmts = stmts.move_iter().flat_map(|x| {
             // perform all pending renames
             let renamed_stmt = {
                 let pending_renames = &mut fld.cx.syntax_env.info().pending_renames;
                 let mut rename_fld = IdentRenamer{renames:pending_renames};
-                rename_fld.fold_stmt(&**x).expect_one("rename_fold didn't return one value")
+                rename_fld.fold_stmt(x).expect_one("rename_fold didn't return one value")
             };
             // expand macros in the statement
-            fld.fold_stmt(&*renamed_stmt).move_iter()
+            fld.fold_stmt(renamed_stmt).move_iter()
         }).collect();
-    let new_expr = b.expr.map(|x| {
-        let expr = {
-            let pending_renames = &mut fld.cx.syntax_env.info().pending_renames;
-            let mut rename_fld = IdentRenamer{renames:pending_renames};
-            rename_fld.fold_expr(x)
-        };
-        fld.fold_expr(expr)
-    });
-    P(Block {
-        view_items: new_view_items,
-        stmts: new_stmts,
-        expr: new_expr,
-        id: fld.new_id(b.id),
-        rules: b.rules,
-        span: b.span,
+        let new_expr = expr.map(|x| {
+            let expr = {
+                let pending_renames = &mut fld.cx.syntax_env.info().pending_renames;
+                let mut rename_fld = IdentRenamer{renames:pending_renames};
+                rename_fld.fold_expr(x)
+            };
+            fld.fold_expr(expr)
+        });
+        Block {
+            id: fld.new_id(id),
+            view_items: new_view_items,
+            stmts: new_stmts,
+            expr: new_expr,
+            rules: rules,
+            span: span
+        }
     })
 }
 
-fn expand_pat(p: Gc<ast::Pat>, fld: &mut MacroExpander) -> Gc<ast::Pat> {
-    let (pth, tts) = match p.node {
-        PatMac(ref mac) => {
-            match mac.node {
-                MacInvocTT(ref pth, ref tts, _) => {
-                    (pth, (*tts).clone())
-                }
-            }
-        }
-        _ => return noop_fold_pat(p, fld),
-    };
-    if pth.segments.len() > 1u {
-        fld.cx.span_err(pth.span, "expected macro name without module separators");
-        return DummyResult::raw_pat(p.span);
+fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
+    match p.node {
+        PatMac(_) => {}
+        _ => return noop_fold_pat(p, fld)
     }
-    let extname = pth.segments.get(0).identifier;
-    let extnamestr = token::get_ident(extname);
-    let marked_after = match fld.cx.syntax_env.find(&extname.name) {
-        None => {
-            fld.cx.span_err(pth.span,
-                            format!("macro undefined: '{}!'",
-                                    extnamestr).as_slice());
-            // let compilation continue
-            return DummyResult::raw_pat(p.span);
+    p.map(|ast::Pat {node, span, ..}| {
+        let (pth, tts) = match node {
+            PatMac(mac) => match mac.node {
+                MacInvocTT(pth, tts, _) => {
+                    (pth, tts)
+                }
+            },
+            _ => unreachable!()
+        };
+        if pth.segments.len() > 1u {
+            fld.cx.span_err(pth.span, "expected macro name without module separators");
+            return DummyResult::raw_pat(span);
         }
+        let extname = pth.segments.get(0).identifier;
+        let extnamestr = token::get_ident(extname);
+        let marked_after = match fld.cx.syntax_env.find(&extname.name) {
+            None => {
+                fld.cx.span_err(pth.span,
+                                format!("macro undefined: '{}!'",
+                                        extnamestr).as_slice());
+                // let compilation continue
+                return DummyResult::raw_pat(span);
+            }
 
-        Some(rc) => match *rc {
-            NormalTT(ref expander, span) => {
-                fld.cx.bt_push(ExpnInfo {
-                    call_site: p.span,
-                    callee: NameAndSpan {
-                        name: extnamestr.get().to_string(),
-                        format: MacroBang,
-                        span: span
-                    }
-                });
+            Some(rc) => match *rc {
+                NormalTT(ref expander, tt_span) => {
+                    fld.cx.bt_push(ExpnInfo {
+                        call_site: span,
+                        callee: NameAndSpan {
+                            name: extnamestr.get().to_string(),
+                            format: MacroBang,
+                            span: tt_span
+                        }
+                    });
 
-                let fm = fresh_mark();
-                let marked_before = mark_tts(tts.as_slice(), fm);
-                let mac_span = original_span(fld.cx);
-                let expanded = match expander.expand(fld.cx,
-                                    mac_span.call_site,
-                                    marked_before.as_slice()).make_pat() {
-                    Some(e) => e,
-                    None => {
-                        fld.cx.span_err(
-                            pth.span,
-                            format!(
-                                "non-pattern macro in pattern position: {}",
-                                extnamestr.get()
-                            ).as_slice()
-                        );
-                        return DummyResult::raw_pat(p.span);
-                    }
-                };
+                    let fm = fresh_mark();
+                    let marked_before = mark_tts(tts.as_slice(), fm);
+                    let mac_span = original_span(fld.cx);
+                    let expanded = match expander.expand(fld.cx,
+                                        mac_span.call_site,
+                                        marked_before.as_slice()).make_pat() {
+                        Some(e) => e,
+                        None => {
+                            fld.cx.span_err(
+                                pth.span,
+                                format!(
+                                    "non-pattern macro in pattern position: {}",
+                                    extnamestr.get()
+                                ).as_slice()
+                            );
+                            return DummyResult::raw_pat(span);
+                        }
+                    };
 
-                // mark after:
-                mark_pat(expanded,fm)
-            }
-            _ => {
-                fld.cx.span_err(p.span,
-                                format!("{}! is not legal in pattern position",
-                                        extnamestr.get()).as_slice());
-                return DummyResult::raw_pat(p.span);
+                    // mark after:
+                    mark_pat(expanded,fm)
+                }
+                _ => {
+                    fld.cx.span_err(span,
+                                    format!("{}! is not legal in pattern position",
+                                            extnamestr.get()).as_slice());
+                    return DummyResult::raw_pat(span);
+                }
             }
-        }
-    };
+        };
 
-    let fully_expanded =
-        fld.fold_pat(marked_after).node.clone();
-    fld.cx.bt_pop();
+        let fully_expanded =
+            fld.fold_pat(marked_after).node.clone();
+        fld.cx.bt_pop();
 
-    box(GC) ast::Pat {
-        id: ast::DUMMY_NODE_ID,
-        node: fully_expanded,
-        span: p.span,
-    }
+        ast::Pat {
+            id: ast::DUMMY_NODE_ID,
+            node: fully_expanded,
+            span: span
+        }
+    })
 }
 
 /// A tree-folder that applies every rename in its (mutable) list
@@ -814,7 +814,7 @@ impl<'a> Folder for IdentRenamer<'a> {
             ctxt: mtwt::apply_renames(self.renames, id.ctxt),
         }
     }
-    fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac {
+    fn fold_mac(&mut self, macro: ast::Mac) -> ast::Mac {
         fold::noop_fold_mac(macro, self)
     }
 }
@@ -828,45 +828,50 @@ pub struct PatIdentRenamer<'a> {
 }
 
 impl<'a> Folder for PatIdentRenamer<'a> {
-    fn fold_pat(&mut self, pat: Gc<ast::Pat>) -> Gc<ast::Pat> {
+    fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {
         match pat.node {
-            ast::PatIdent(binding_mode, Spanned{span: ref sp, node: id}, ref sub) => {
-                let new_ident = Ident{name: id.name,
-                                      ctxt: mtwt::apply_renames(self.renames, id.ctxt)};
+            ast::PatIdent(..) => {},
+            _ => return noop_fold_pat(pat, self)
+        }
+
+        pat.map(|ast::Pat {id, node, span}| match node {
+            ast::PatIdent(binding_mode, Spanned{span: sp, node: ident}, sub) => {
+                let new_ident = Ident{name: ident.name,
+                                      ctxt: mtwt::apply_renames(self.renames, ident.ctxt)};
                 let new_node =
                     ast::PatIdent(binding_mode,
-                                  Spanned{span: self.new_span(*sp), node: new_ident},
+                                  Spanned{span: self.new_span(sp), node: new_ident},
                                   sub.map(|p| self.fold_pat(p)));
-                box(GC) ast::Pat {
-                    id: pat.id,
-                    span: self.new_span(pat.span),
+                ast::Pat {
+                    id: id,
                     node: new_node,
+                    span: self.new_span(span)
                 }
             },
-            _ => noop_fold_pat(pat, self)
-        }
+            _ => unreachable!()
+        })
     }
-    fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac {
+    fn fold_mac(&mut self, macro: ast::Mac) -> ast::Mac {
         fold::noop_fold_mac(macro, self)
     }
 }
 
 // expand a method
-fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast::Method>> {
-    let id = fld.new_id(m.id);
-    match m.node {
+fn expand_method(m: P<ast::Method>, fld: &mut MacroExpander) -> SmallVector<P<ast::Method>> {
+    m.and_then(|m| match m.node {
         ast::MethDecl(ident,
-                      ref generics,
+                      generics,
                       abi,
-                      ref explicit_self,
+                      explicit_self,
                       fn_style,
                       decl,
                       body,
                       vis) => {
+            let id = fld.new_id(m.id);
             let (rewritten_fn_decl, rewritten_body)
-                = expand_and_rename_fn_decl_and_block(&*decl,body,fld);
-            SmallVector::one(box(GC) ast::Method {
-                    attrs: m.attrs.iter().map(|a| fld.fold_attribute(*a)).collect(),
+                = expand_and_rename_fn_decl_and_block(decl,body,fld);
+            SmallVector::one(P(ast::Method {
+                    attrs: m.attrs.move_map(|a| fld.fold_attribute(a)),
                     id: id,
                     span: fld.new_span(m.span),
                     node: ast::MethDecl(fld.fold_ident(ident),
@@ -877,15 +882,13 @@ fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast
                                         rewritten_fn_decl,
                                         rewritten_body,
                                         vis)
-                })
+                }))
         },
-        ast::MethMac(ref mac) => {
+        ast::MethMac(mac) => {
             let maybe_new_methods =
-                expand_mac_invoc(mac, &m.span,
-                                 |r|{r.make_methods()},
-                                 |meths,mark|{
-                    meths.move_iter().map(|m|{mark_method(m,mark)})
-                        .collect()},
+                expand_mac_invoc(mac, m.span,
+                                 |r| r.make_methods(),
+                                 |meths, mark| meths.move_map(|m| mark_method(m, mark)),
                                  fld);
 
             let new_methods = match maybe_new_methods {
@@ -896,22 +899,22 @@ fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast
             // expand again if necessary
             new_methods.move_iter().flat_map(|m| fld.fold_method(m).move_iter()).collect()
         }
-    }
+    })
 }
 
 /// Given a fn_decl and a block and a MacroExpander, expand the fn_decl, then use the
 /// PatIdents in its arguments to perform renaming in the FnDecl and
 /// the block, returning both the new FnDecl and the new Block.
-fn expand_and_rename_fn_decl_and_block(fn_decl: &ast::FnDecl, block: Gc<ast::Block>,
+fn expand_and_rename_fn_decl_and_block(fn_decl: P<ast::FnDecl>, block: P<ast::Block>,
                                        fld: &mut MacroExpander)
-    -> (Gc<ast::FnDecl>, Gc<ast::Block>) {
+    -> (P<ast::FnDecl>, P<ast::Block>) {
     let expanded_decl = fld.fold_fn_decl(fn_decl);
     let idents = fn_decl_arg_bindings(&*expanded_decl);
     let renames =
         idents.iter().map(|id : &ast::Ident| (*id,fresh_name(id))).collect();
     // first, a renamer for the PatIdents, for the fn_decl:
     let mut rename_pat_fld = PatIdentRenamer{renames: &renames};
-    let rewritten_fn_decl = rename_pat_fld.fold_fn_decl(&*expanded_decl);
+    let rewritten_fn_decl = rename_pat_fld.fold_fn_decl(expanded_decl);
     // now, a renamer for *all* idents, for the body:
     let mut rename_fld = IdentRenamer{renames: &renames};
     let rewritten_body = fld.fold_block(rename_fld.fold_block(block));
@@ -924,36 +927,36 @@ pub struct MacroExpander<'a, 'b:'a> {
 }
 
 impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
-    fn fold_expr(&mut self, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+    fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
         expand_expr(expr, self)
     }
 
-    fn fold_pat(&mut self, pat: Gc<ast::Pat>) -> Gc<ast::Pat> {
+    fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {
         expand_pat(pat, self)
     }
 
-    fn fold_item(&mut self, item: Gc<ast::Item>) -> SmallVector<Gc<ast::Item>> {
+    fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> {
         expand_item(item, self)
     }
 
-    fn fold_item_underscore(&mut self, item: &ast::Item_) -> ast::Item_ {
+    fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ {
         expand_item_underscore(item, self)
     }
 
-    fn fold_stmt(&mut self, stmt: &ast::Stmt) -> SmallVector<Gc<ast::Stmt>> {
-        expand_stmt(stmt, self)
+    fn fold_stmt(&mut self, stmt: P<ast::Stmt>) -> SmallVector<P<ast::Stmt>> {
+        stmt.and_then(|stmt| expand_stmt(stmt, self))
     }
 
     fn fold_block(&mut self, block: P<Block>) -> P<Block> {
-        expand_block(&*block, self)
+        expand_block(block, self)
     }
 
-    fn fold_arm(&mut self, arm: &ast::Arm) -> ast::Arm {
+    fn fold_arm(&mut self, arm: ast::Arm) -> ast::Arm {
         expand_arm(arm, self)
     }
 
-    fn fold_method(&mut self, method: Gc<ast::Method>) -> SmallVector<Gc<ast::Method>> {
-        expand_method(&*method, self)
+    fn fold_method(&mut self, method: P<ast::Method>) -> SmallVector<P<ast::Method>> {
+        expand_method(method, self)
     }
 
     fn new_span(&mut self, span: Span) -> Span {
@@ -1033,17 +1036,16 @@ impl Folder for Marker {
             ctxt: mtwt::apply_mark(self.mark, id.ctxt)
         }
     }
-    fn fold_mac(&mut self, m: &ast::Mac) -> ast::Mac {
-        let macro = match m.node {
-            MacInvocTT(ref path, ref tts, ctxt) => {
-                MacInvocTT(self.fold_path(path),
-                           self.fold_tts(tts.as_slice()),
-                           mtwt::apply_mark(self.mark, ctxt))
-            }
-        };
+    fn fold_mac(&mut self, Spanned {node, span}: ast::Mac) -> ast::Mac {
         Spanned {
-            node: macro,
-            span: m.span,
+            node: match node {
+                MacInvocTT(path, tts, ctxt) => {
+                    MacInvocTT(self.fold_path(path),
+                               self.fold_tts(tts.as_slice()),
+                               mtwt::apply_mark(self.mark, ctxt))
+                }
+            },
+            span: span,
         }
     }
 }
@@ -1054,29 +1056,29 @@ fn mark_tts(tts: &[TokenTree], m: Mrk) -> Vec<TokenTree> {
 }
 
 // apply a given mark to the given expr. Used following the expansion of a macro.
-fn mark_expr(expr: Gc<ast::Expr>, m: Mrk) -> Gc<ast::Expr> {
+fn mark_expr(expr: P<ast::Expr>, m: Mrk) -> P<ast::Expr> {
     Marker{mark:m}.fold_expr(expr)
 }
 
 // apply a given mark to the given pattern. Used following the expansion of a macro.
-fn mark_pat(pat: Gc<ast::Pat>, m: Mrk) -> Gc<ast::Pat> {
+fn mark_pat(pat: P<ast::Pat>, m: Mrk) -> P<ast::Pat> {
     Marker{mark:m}.fold_pat(pat)
 }
 
 // apply a given mark to the given stmt. Used following the expansion of a macro.
-fn mark_stmt(expr: &ast::Stmt, m: Mrk) -> Gc<ast::Stmt> {
+fn mark_stmt(expr: P<ast::Stmt>, m: Mrk) -> P<ast::Stmt> {
     Marker{mark:m}.fold_stmt(expr)
         .expect_one("marking a stmt didn't return exactly one stmt")
 }
 
 // apply a given mark to the given item. Used following the expansion of a macro.
-fn mark_item(expr: Gc<ast::Item>, m: Mrk) -> Gc<ast::Item> {
+fn mark_item(expr: P<ast::Item>, m: Mrk) -> P<ast::Item> {
     Marker{mark:m}.fold_item(expr)
         .expect_one("marking an item didn't return exactly one item")
 }
 
 // apply a given mark to the given item. Used following the expansion of a macro.
-fn mark_method(expr: Gc<ast::Method>, m: Mrk) -> Gc<ast::Method> {
+fn mark_method(expr: P<ast::Method>, m: Mrk) -> P<ast::Method> {
     Marker{mark:m}.fold_method(expr)
         .expect_one("marking an item didn't return exactly one method")
 }
@@ -1133,8 +1135,6 @@ mod test {
     use visit;
     use visit::Visitor;
 
-    use std::gc::GC;
-
     // a visitor that extracts the paths
     // from a given thingy and puts them in a mutable
     // array (passed in to the traversal)
@@ -1252,10 +1252,10 @@ mod test {
             node: Attribute_ {
                 id: attr::mk_attr_id(),
                 style: AttrOuter,
-                value: box(GC) Spanned {
+                value: P(Spanned {
                     node: MetaWord(token::intern_and_get_ident(s)),
                     span: codemap::DUMMY_SP,
-                },
+                }),
                 is_sugared_doc: false,
             }
         }
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 0bb32c73ca2..271a5137bbf 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 use ast;
-use ast::P;
 use codemap::{Span, respan};
 use ext::base::*;
 use ext::base;
@@ -17,9 +16,9 @@ use ext::build::AstBuilder;
 use fmt_macros as parse;
 use parse::token::InternedString;
 use parse::token;
+use ptr::P;
 
 use std::collections::HashMap;
-use std::gc::{Gc, GC};
 
 #[deriving(PartialEq)]
 enum ArgumentType {
@@ -39,13 +38,13 @@ struct Context<'a, 'b:'a> {
 
     /// Parsed argument expressions and the types that we've found so far for
     /// them.
-    args: Vec<Gc<ast::Expr>>,
+    args: Vec<P<ast::Expr>>,
     arg_types: Vec<Option<ArgumentType>>,
     /// Parsed named expressions and the types that we've found for them so far.
     /// Note that we keep a side-array of the ordering of the named arguments
     /// found to be sure that we can translate them in the same order that they
     /// were declared in.
-    names: HashMap<String, Gc<ast::Expr>>,
+    names: HashMap<String, P<ast::Expr>>,
     name_types: HashMap<String, ArgumentType>,
     name_ordering: Vec<String>,
 
@@ -53,14 +52,14 @@ struct Context<'a, 'b:'a> {
     literal: String,
 
     /// Collection of the compiled `rt::Argument` structures
-    pieces: Vec<Gc<ast::Expr>>,
+    pieces: Vec<P<ast::Expr>>,
     /// Collection of string literals
-    str_pieces: Vec<Gc<ast::Expr>>,
+    str_pieces: Vec<P<ast::Expr>>,
     /// Stays `true` if all formatting parameters are default (as in "{}{}").
     all_pieces_simple: bool,
 
     name_positions: HashMap<String, uint>,
-    method_statics: Vec<Gc<ast::Item>>,
+    method_statics: Vec<P<ast::Item>>,
 
     /// Updated as arguments are consumed or methods are entered
     nest_level: uint,
@@ -68,8 +67,8 @@ struct Context<'a, 'b:'a> {
 }
 
 pub enum Invocation {
-    Call(Gc<ast::Expr>),
-    MethodCall(Gc<ast::Expr>, ast::Ident),
+    Call(P<ast::Expr>),
+    MethodCall(P<ast::Expr>, ast::Ident),
 }
 
 /// Parses the arguments from the given list of tokens, returning None
@@ -82,10 +81,10 @@ pub enum Invocation {
 ///           named arguments))
 fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
               tts: &[ast::TokenTree])
-    -> (Invocation, Option<(Gc<ast::Expr>, Vec<Gc<ast::Expr>>, Vec<String>,
-                            HashMap<String, Gc<ast::Expr>>)>) {
+    -> (Invocation, Option<(P<ast::Expr>, Vec<P<ast::Expr>>, Vec<String>,
+                            HashMap<String, P<ast::Expr>>)>) {
     let mut args = Vec::new();
-    let mut names = HashMap::<String, Gc<ast::Expr>>::new();
+    let mut names = HashMap::<String, P<ast::Expr>>::new();
     let mut order = Vec::new();
 
     let mut p = ecx.new_parser_from_tts(tts);
@@ -323,44 +322,44 @@ impl<'a, 'b> Context<'a, 'b> {
 
     /// These attributes are applied to all statics that this syntax extension
     /// will generate.
-    fn static_attrs(&self) -> Vec<ast::Attribute> {
+    fn static_attrs(ecx: &ExtCtxt, fmtsp: Span) -> Vec<ast::Attribute> {
         // Flag statics as `inline` so LLVM can merge duplicate globals as much
         // as possible (which we're generating a whole lot of).
-        let unnamed = self.ecx.meta_word(self.fmtsp, InternedString::new("inline"));
-        let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
+        let unnamed = ecx.meta_word(fmtsp, InternedString::new("inline"));
+        let unnamed = ecx.attribute(fmtsp, unnamed);
 
         // Do not warn format string as dead code
-        let dead_code = self.ecx.meta_word(self.fmtsp,
-                                           InternedString::new("dead_code"));
-        let allow_dead_code = self.ecx.meta_list(self.fmtsp,
-                                                 InternedString::new("allow"),
-                                                 vec!(dead_code));
-        let allow_dead_code = self.ecx.attribute(self.fmtsp, allow_dead_code);
-        return vec!(unnamed, allow_dead_code);
+        let dead_code = ecx.meta_word(fmtsp, InternedString::new("dead_code"));
+        let allow_dead_code = ecx.meta_list(fmtsp,
+                                            InternedString::new("allow"),
+                                            vec![dead_code]);
+        let allow_dead_code = ecx.attribute(fmtsp, allow_dead_code);
+        vec![unnamed, allow_dead_code]
     }
 
-    fn rtpath(&self, s: &str) -> Vec<ast::Ident> {
-        vec!(self.ecx.ident_of("std"), self.ecx.ident_of("fmt"),
-          self.ecx.ident_of("rt"), self.ecx.ident_of(s))
+    fn rtpath(ecx: &ExtCtxt, s: &str) -> Vec<ast::Ident> {
+        vec![ecx.ident_of("std"), ecx.ident_of("fmt"), ecx.ident_of("rt"), ecx.ident_of(s)]
     }
 
-    fn trans_count(&self, c: parse::Count) -> Gc<ast::Expr> {
+    fn trans_count(&self, c: parse::Count) -> P<ast::Expr> {
         let sp = self.fmtsp;
         match c {
             parse::CountIs(i) => {
-                self.ecx.expr_call_global(sp, self.rtpath("CountIs"),
+                self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIs"),
                                           vec!(self.ecx.expr_uint(sp, i)))
             }
             parse::CountIsParam(i) => {
-                self.ecx.expr_call_global(sp, self.rtpath("CountIsParam"),
+                self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
                                           vec!(self.ecx.expr_uint(sp, i)))
             }
             parse::CountImplied => {
-                let path = self.ecx.path_global(sp, self.rtpath("CountImplied"));
+                let path = self.ecx.path_global(sp, Context::rtpath(self.ecx,
+                                                                    "CountImplied"));
                 self.ecx.expr_path(path)
             }
             parse::CountIsNextParam => {
-                let path = self.ecx.path_global(sp, self.rtpath("CountIsNextParam"));
+                let path = self.ecx.path_global(sp, Context::rtpath(self.ecx,
+                                                                    "CountIsNextParam"));
                 self.ecx.expr_path(path)
             }
             parse::CountIsName(n) => {
@@ -369,14 +368,14 @@ impl<'a, 'b> Context<'a, 'b> {
                     None => 0, // error already emitted elsewhere
                 };
                 let i = i + self.args.len();
-                self.ecx.expr_call_global(sp, self.rtpath("CountIsParam"),
+                self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
                                           vec!(self.ecx.expr_uint(sp, i)))
             }
         }
     }
 
     /// Translate the accumulated string literals to a literal expression
-    fn trans_literal_string(&mut self) -> Gc<ast::Expr> {
+    fn trans_literal_string(&mut self) -> P<ast::Expr> {
         let sp = self.fmtsp;
         let s = token::intern_and_get_ident(self.literal.as_slice());
         self.literal.clear();
@@ -385,7 +384,7 @@ impl<'a, 'b> Context<'a, 'b> {
 
     /// Translate a `parse::Piece` to a static `rt::Argument` or append
     /// to the `literal` string.
-    fn trans_piece(&mut self, piece: &parse::Piece) -> Option<Gc<ast::Expr>> {
+    fn trans_piece(&mut self, piece: &parse::Piece) -> Option<P<ast::Expr>> {
         let sp = self.fmtsp;
         match *piece {
             parse::String(s) => {
@@ -397,12 +396,12 @@ impl<'a, 'b> Context<'a, 'b> {
                 let pos = match arg.position {
                     // These two have a direct mapping
                     parse::ArgumentNext => {
-                        let path = self.ecx.path_global(sp,
-                                                        self.rtpath("ArgumentNext"));
+                        let path = self.ecx.path_global(sp, Context::rtpath(self.ecx,
+                                                                            "ArgumentNext"));
                         self.ecx.expr_path(path)
                     }
                     parse::ArgumentIs(i) => {
-                        self.ecx.expr_call_global(sp, self.rtpath("ArgumentIs"),
+                        self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
                                                   vec!(self.ecx.expr_uint(sp, i)))
                     }
                     // Named arguments are converted to positional arguments at
@@ -413,7 +412,7 @@ impl<'a, 'b> Context<'a, 'b> {
                             None => 0, // error already emitted elsewhere
                         };
                         let i = i + self.args.len();
-                        self.ecx.expr_call_global(sp, self.rtpath("ArgumentIs"),
+                        self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
                                                   vec!(self.ecx.expr_uint(sp, i)))
                     }
                 };
@@ -440,23 +439,23 @@ impl<'a, 'b> Context<'a, 'b> {
                 let fill = self.ecx.expr_lit(sp, ast::LitChar(fill));
                 let align = match arg.format.align {
                     parse::AlignLeft => {
-                        self.ecx.path_global(sp, self.rtpath("AlignLeft"))
+                        self.ecx.path_global(sp, Context::rtpath(self.ecx, "AlignLeft"))
                     }
                     parse::AlignRight => {
-                        self.ecx.path_global(sp, self.rtpath("AlignRight"))
+                        self.ecx.path_global(sp, Context::rtpath(self.ecx, "AlignRight"))
                     }
                     parse::AlignCenter => {
-                        self.ecx.path_global(sp, self.rtpath("AlignCenter"))
+                        self.ecx.path_global(sp, Context::rtpath(self.ecx, "AlignCenter"))
                     }
                     parse::AlignUnknown => {
-                        self.ecx.path_global(sp, self.rtpath("AlignUnknown"))
+                        self.ecx.path_global(sp, Context::rtpath(self.ecx, "AlignUnknown"))
                     }
                 };
                 let align = self.ecx.expr_path(align);
                 let flags = self.ecx.expr_uint(sp, arg.format.flags);
                 let prec = self.trans_count(arg.format.precision);
                 let width = self.trans_count(arg.format.width);
-                let path = self.ecx.path_global(sp, self.rtpath("FormatSpec"));
+                let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "FormatSpec"));
                 let fmt = self.ecx.expr_struct(sp, path, vec!(
                     self.ecx.field_imm(sp, self.ecx.ident_of("fill"), fill),
                     self.ecx.field_imm(sp, self.ecx.ident_of("align"), align),
@@ -464,7 +463,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     self.ecx.field_imm(sp, self.ecx.ident_of("precision"), prec),
                     self.ecx.field_imm(sp, self.ecx.ident_of("width"), width)));
 
-                let path = self.ecx.path_global(sp, self.rtpath("Argument"));
+                let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "Argument"));
                 Some(self.ecx.expr_struct(sp, path, vec!(
                     self.ecx.field_imm(sp, self.ecx.ident_of("position"), pos),
                     self.ecx.field_imm(sp, self.ecx.ident_of("format"), fmt))))
@@ -472,29 +471,28 @@ impl<'a, 'b> Context<'a, 'b> {
         }
     }
 
-    fn item_static_array(&self,
+    fn item_static_array(ecx: &mut ExtCtxt,
                          name: ast::Ident,
-                         piece_ty: Gc<ast::Ty>,
-                         pieces: Vec<Gc<ast::Expr>>)
-        -> ast::Stmt
-    {
-        let pieces_len = self.ecx.expr_uint(self.fmtsp, pieces.len());
-        let fmt = self.ecx.expr_vec(self.fmtsp, pieces);
+                         piece_ty: P<ast::Ty>,
+                         pieces: Vec<P<ast::Expr>>)
+                         -> P<ast::Stmt> {
+        let fmtsp = piece_ty.span;
+        let pieces_len = ecx.expr_uint(fmtsp, pieces.len());
+        let fmt = ecx.expr_vec(fmtsp, pieces);
         let ty = ast::TyFixedLengthVec(
             piece_ty,
             pieces_len
         );
-        let ty = self.ecx.ty(self.fmtsp, ty);
+        let ty = ecx.ty(fmtsp, ty);
         let st = ast::ItemStatic(ty, ast::MutImmutable, fmt);
-        let item = self.ecx.item(self.fmtsp, name,
-                                 self.static_attrs(), st);
-        let decl = respan(self.fmtsp, ast::DeclItem(item));
-        respan(self.fmtsp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
+        let item = ecx.item(fmtsp, name, Context::static_attrs(ecx, fmtsp), st);
+        let decl = respan(fmtsp, ast::DeclItem(item));
+        P(respan(fmtsp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
     }
 
     /// Actually builds the expression which the iformat! block will be expanded
     /// to
-    fn to_expr(&self, invocation: Invocation) -> Gc<ast::Expr> {
+    fn to_expr(mut self, invocation: Invocation) -> P<ast::Expr> {
         let mut lets = Vec::new();
         let mut locals = Vec::new();
         let mut names = Vec::from_fn(self.name_positions.len(), |_| None);
@@ -502,10 +500,10 @@ impl<'a, 'b> Context<'a, 'b> {
         let mut heads = Vec::new();
 
         // First, declare all of our methods that are statics
-        for &method in self.method_statics.iter() {
+        for method in self.method_statics.move_iter() {
             let decl = respan(self.fmtsp, ast::DeclItem(method));
-            lets.push(box(GC) respan(self.fmtsp,
-                              ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID)));
+            lets.push(P(respan(self.fmtsp,
+                               ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))));
         }
 
         // Next, build up the static array which will become our precompiled
@@ -517,9 +515,10 @@ impl<'a, 'b> Context<'a, 'b> {
                 self.ecx.ty_ident(self.fmtsp, self.ecx.ident_of("str")),
                 Some(static_lifetime),
                 ast::MutImmutable);
-        lets.push(box(GC) self.item_static_array(static_str_name,
-                                                 piece_ty,
-                                                 self.str_pieces.clone()));
+        lets.push(Context::item_static_array(self.ecx,
+                                             static_str_name,
+                                             piece_ty,
+                                             self.str_pieces));
 
         // Then, build up the static array which will store our precompiled
         // nonstandard placeholders, if there are any.
@@ -527,13 +526,14 @@ impl<'a, 'b> Context<'a, 'b> {
         if !self.all_pieces_simple {
             let piece_ty = self.ecx.ty_path(self.ecx.path_all(
                     self.fmtsp,
-                    true, self.rtpath("Argument"),
+                    true, Context::rtpath(self.ecx, "Argument"),
                     vec![static_lifetime],
                     vec![]
                 ), None);
-            lets.push(box(GC) self.item_static_array(static_args_name,
-                                                     piece_ty,
-                                                     self.pieces.clone()));
+            lets.push(Context::item_static_array(self.ecx,
+                                                 static_args_name,
+                                                 piece_ty,
+                                                 self.pieces));
         }
 
         // Right now there is a bug such that for the expression:
@@ -543,31 +543,35 @@ impl<'a, 'b> Context<'a, 'b> {
         // format! string are shoved into locals. Furthermore, we shove the address
         // of each variable because we don't want to move out of the arguments
         // passed to this function.
-        for (i, &e) in self.args.iter().enumerate() {
-            if self.arg_types.get(i).is_none() {
-                continue // error already generated
-            }
+        for (i, e) in self.args.move_iter().enumerate() {
+            let arg_ty = match self.arg_types.get(i).as_ref() {
+                Some(ty) => ty,
+                None => continue // error already generated
+            };
 
             let name = self.ecx.ident_of(format!("__arg{}", i).as_slice());
             pats.push(self.ecx.pat_ident(e.span, name));
+            locals.push(Context::format_arg(self.ecx, e.span, arg_ty,
+                                            self.ecx.expr_ident(e.span, name)));
             heads.push(self.ecx.expr_addr_of(e.span, e));
-            locals.push(self.format_arg(e.span, Exact(i),
-                                        self.ecx.expr_ident(e.span, name)));
         }
         for name in self.name_ordering.iter() {
-            let e = match self.names.find(name) {
-                Some(&e) if self.name_types.contains_key(name) => e,
-                Some(..) | None => continue
+            let e = match self.names.pop(name) {
+                Some(e) => e,
+                None => continue
+            };
+            let arg_ty = match self.name_types.find(name) {
+                Some(ty) => ty,
+                None => continue
             };
 
             let lname = self.ecx.ident_of(format!("__arg{}",
                                                   *name).as_slice());
             pats.push(self.ecx.pat_ident(e.span, lname));
-            heads.push(self.ecx.expr_addr_of(e.span, e));
             *names.get_mut(*self.name_positions.get(name)) =
-                Some(self.format_arg(e.span,
-                                     Named((*name).clone()),
-                                     self.ecx.expr_ident(e.span, lname)));
+                Some(Context::format_arg(self.ecx, e.span, arg_ty,
+                                         self.ecx.expr_ident(e.span, lname)));
+            heads.push(self.ecx.expr_addr_of(e.span, e));
         }
 
         // Now create a vector containing all the arguments
@@ -611,12 +615,14 @@ impl<'a, 'b> Context<'a, 'b> {
         let res = self.ecx.expr_ident(self.fmtsp, resname);
         let result = match invocation {
             Call(e) => {
-                self.ecx.expr_call(e.span, e,
-                                   vec!(self.ecx.expr_addr_of(e.span, res)))
+                let span = e.span;
+                self.ecx.expr_call(span, e,
+                                   vec!(self.ecx.expr_addr_of(span, res)))
             }
             MethodCall(e, m) => {
-                self.ecx.expr_method_call(e.span, e, m,
-                                          vec!(self.ecx.expr_addr_of(e.span, res)))
+                let span = e.span;
+                self.ecx.expr_method_call(span, e, m,
+                                          vec!(self.ecx.expr_addr_of(span, res)))
             }
         };
         let body = self.ecx.expr_block(self.ecx.block(self.fmtsp, lets,
@@ -655,13 +661,9 @@ impl<'a, 'b> Context<'a, 'b> {
         self.ecx.expr_match(self.fmtsp, head, vec!(arm))
     }
 
-    fn format_arg(&self, sp: Span, argno: Position, arg: Gc<ast::Expr>)
-                  -> Gc<ast::Expr> {
-        let ty = match argno {
-            Exact(ref i) => self.arg_types.get(*i).get_ref(),
-            Named(ref s) => self.name_types.get(s)
-        };
-
+    fn format_arg(ecx: &ExtCtxt, sp: Span,
+                  ty: &ArgumentType, arg: P<ast::Expr>)
+                  -> P<ast::Expr> {
         let (krate, fmt_fn) = match *ty {
             Known(ref tyname) => {
                 match tyname.as_slice() {
@@ -681,36 +683,35 @@ impl<'a, 'b> Context<'a, 'b> {
                     "x" => ("std", "secret_lower_hex"),
                     "X" => ("std", "secret_upper_hex"),
                     _ => {
-                        self.ecx
-                            .span_err(sp,
-                                      format!("unknown format trait `{}`",
-                                              *tyname).as_slice());
+                        ecx.span_err(sp,
+                                     format!("unknown format trait `{}`",
+                                             *tyname).as_slice());
                         ("std", "dummy")
                     }
                 }
             }
             String => {
-                return self.ecx.expr_call_global(sp, vec!(
-                        self.ecx.ident_of("std"),
-                        self.ecx.ident_of("fmt"),
-                        self.ecx.ident_of("argumentstr")), vec!(arg))
+                return ecx.expr_call_global(sp, vec![
+                        ecx.ident_of("std"),
+                        ecx.ident_of("fmt"),
+                        ecx.ident_of("argumentstr")], vec![arg])
             }
             Unsigned => {
-                return self.ecx.expr_call_global(sp, vec!(
-                        self.ecx.ident_of("std"),
-                        self.ecx.ident_of("fmt"),
-                        self.ecx.ident_of("argumentuint")), vec!(arg))
+                return ecx.expr_call_global(sp, vec![
+                        ecx.ident_of("std"),
+                        ecx.ident_of("fmt"),
+                        ecx.ident_of("argumentuint")], vec![arg])
             }
         };
 
-        let format_fn = self.ecx.path_global(sp, vec!(
-                self.ecx.ident_of(krate),
-                self.ecx.ident_of("fmt"),
-                self.ecx.ident_of(fmt_fn)));
-        self.ecx.expr_call_global(sp, vec!(
-                self.ecx.ident_of("std"),
-                self.ecx.ident_of("fmt"),
-                self.ecx.ident_of("argument")), vec!(self.ecx.expr_path(format_fn), arg))
+        let format_fn = ecx.path_global(sp, vec![
+                ecx.ident_of(krate),
+                ecx.ident_of("fmt"),
+                ecx.ident_of(fmt_fn)]);
+        ecx.expr_call_global(sp, vec![
+                ecx.ident_of("std"),
+                ecx.ident_of("fmt"),
+                ecx.ident_of("argument")], vec![ecx.expr_path(format_fn), arg])
     }
 }
 
@@ -744,12 +745,11 @@ pub fn expand_format_args_method<'cx>(ecx: &'cx mut ExtCtxt, sp: Span,
 /// expression.
 pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
                                     invocation: Invocation,
-                                    efmt: Gc<ast::Expr>,
-                                    args: Vec<Gc<ast::Expr>>,
+                                    efmt: P<ast::Expr>,
+                                    args: Vec<P<ast::Expr>>,
                                     name_ordering: Vec<String>,
-                                    names: HashMap<String, Gc<ast::Expr>>)
-    -> Gc<ast::Expr>
-{
+                                    names: HashMap<String, P<ast::Expr>>)
+                                    -> P<ast::Expr> {
     let arg_types = Vec::from_fn(args.len(), |_| None);
     let mut cx = Context {
         ecx: ecx,
@@ -796,7 +796,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
     }
     match parser.errors.shift() {
         Some(error) => {
-            cx.ecx.span_err(efmt.span,
+            cx.ecx.span_err(cx.fmtsp,
                             format!("invalid format string: {}",
                                     error).as_slice());
             return DummyResult::raw_expr(sp);
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 808e671f868..6f13a2e6a51 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -15,8 +15,7 @@ use ext::base;
 use ext::build::AstBuilder;
 use parse::token::*;
 use parse::token;
-
-use std::gc::Gc;
+use ptr::P;
 
 /**
 *
@@ -36,14 +35,13 @@ pub mod rt {
     use parse::token;
     use parse;
     use print::pprust;
+    use ptr::P;
 
     use ast::{TokenTree, Generics, Expr};
 
     pub use parse::new_parser_from_tts;
     pub use codemap::{BytePos, Span, dummy_spanned};
 
-    use std::gc::Gc;
-
     pub trait ToTokens {
         fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> ;
     }
@@ -107,13 +105,13 @@ pub mod rt {
     }
 
     macro_rules! impl_to_source(
-        (Gc<$t:ty>, $pp:ident) => (
-            impl ToSource for Gc<$t> {
+        (P<$t:ty>, $pp:ident) => (
+            impl ToSource for P<$t> {
                 fn to_source(&self) -> String {
                     pprust::$pp(&**self)
                 }
             }
-            impl ToSourceWithHygiene for Gc<$t> {
+            impl ToSourceWithHygiene for P<$t> {
                 fn to_source_with_hygiene(&self) -> String {
                     pprust::with_hygiene::$pp(&**self)
                 }
@@ -182,18 +180,18 @@ pub mod rt {
     impl_to_source!(ast::Block, block_to_string)
     impl_to_source!(ast::Arg, arg_to_string)
     impl_to_source!(Generics, generics_to_string)
-    impl_to_source!(Gc<ast::Item>, item_to_string)
-    impl_to_source!(Gc<ast::Method>, method_to_string)
-    impl_to_source!(Gc<ast::Stmt>, stmt_to_string)
-    impl_to_source!(Gc<ast::Expr>, expr_to_string)
-    impl_to_source!(Gc<ast::Pat>, pat_to_string)
+    impl_to_source!(P<ast::Item>, item_to_string)
+    impl_to_source!(P<ast::Method>, method_to_string)
+    impl_to_source!(P<ast::Stmt>, stmt_to_string)
+    impl_to_source!(P<ast::Expr>, expr_to_string)
+    impl_to_source!(P<ast::Pat>, pat_to_string)
     impl_to_source!(ast::Arm, arm_to_string)
     impl_to_source_slice!(ast::Ty, ", ")
-    impl_to_source_slice!(Gc<ast::Item>, "\n\n")
+    impl_to_source_slice!(P<ast::Item>, "\n\n")
 
     impl ToSource for ast::Attribute_ {
         fn to_source(&self) -> String {
-            pprust::attribute_to_string(&dummy_spanned(*self))
+            pprust::attribute_to_string(&dummy_spanned(self.clone()))
         }
     }
     impl ToSourceWithHygiene for ast::Attribute_ {
@@ -315,16 +313,16 @@ pub mod rt {
     )
 
     impl_to_tokens!(ast::Ident)
-    impl_to_tokens!(Gc<ast::Item>)
-    impl_to_tokens!(Gc<ast::Pat>)
+    impl_to_tokens!(P<ast::Item>)
+    impl_to_tokens!(P<ast::Pat>)
     impl_to_tokens!(ast::Arm)
-    impl_to_tokens!(Gc<ast::Method>)
-    impl_to_tokens_lifetime!(&'a [Gc<ast::Item>])
+    impl_to_tokens!(P<ast::Method>)
+    impl_to_tokens_lifetime!(&'a [P<ast::Item>])
     impl_to_tokens!(ast::Ty)
     impl_to_tokens_lifetime!(&'a [ast::Ty])
     impl_to_tokens!(Generics)
-    impl_to_tokens!(Gc<ast::Stmt>)
-    impl_to_tokens!(Gc<ast::Expr>)
+    impl_to_tokens!(P<ast::Stmt>)
+    impl_to_tokens!(P<ast::Expr>)
     impl_to_tokens!(ast::Block)
     impl_to_tokens!(ast::Arg)
     impl_to_tokens!(ast::Attribute_)
@@ -344,9 +342,9 @@ pub mod rt {
     impl_to_tokens!(u64)
 
     pub trait ExtParseUtils {
-        fn parse_item(&self, s: String) -> Gc<ast::Item>;
-        fn parse_expr(&self, s: String) -> Gc<ast::Expr>;
-        fn parse_stmt(&self, s: String) -> Gc<ast::Stmt>;
+        fn parse_item(&self, s: String) -> P<ast::Item>;
+        fn parse_expr(&self, s: String) -> P<ast::Expr>;
+        fn parse_stmt(&self, s: String) -> P<ast::Stmt>;
         fn parse_tts(&self, s: String) -> Vec<ast::TokenTree>;
     }
 
@@ -358,7 +356,7 @@ pub mod rt {
 
     impl<'a> ExtParseUtils for ExtCtxt<'a> {
 
-        fn parse_item(&self, s: String) -> Gc<ast::Item> {
+        fn parse_item(&self, s: String) -> P<ast::Item> {
             let res = parse::parse_item_from_source_str(
                 "<quote expansion>".to_string(),
                 s,
@@ -373,7 +371,7 @@ pub mod rt {
             }
         }
 
-        fn parse_stmt(&self, s: String) -> Gc<ast::Stmt> {
+        fn parse_stmt(&self, s: String) -> P<ast::Stmt> {
             parse::parse_stmt_from_source_str("<quote expansion>".to_string(),
                                               s,
                                               self.cfg(),
@@ -381,7 +379,7 @@ pub mod rt {
                                               self.parse_sess())
         }
 
-        fn parse_expr(&self, s: String) -> Gc<ast::Expr> {
+        fn parse_expr(&self, s: String) -> P<ast::Expr> {
             parse::parse_expr_from_source_str("<quote expansion>".to_string(),
                                               s,
                                               self.cfg(),
@@ -491,7 +489,7 @@ fn id_ext(str: &str) -> ast::Ident {
 }
 
 // Lift an ident to the expr that evaluates to that ident.
-fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> Gc<ast::Expr> {
+fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> P<ast::Expr> {
     let e_str = cx.expr_str(sp, token::get_ident(ident));
     cx.expr_method_call(sp,
                         cx.expr_ident(sp, id_ext("ext_cx")),
@@ -500,7 +498,7 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> Gc<ast::Expr> {
 }
 
 // Lift a name to the expr that evaluates to that name
-fn mk_name(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> Gc<ast::Expr> {
+fn mk_name(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> P<ast::Expr> {
     let e_str = cx.expr_str(sp, token::get_ident(ident));
     cx.expr_method_call(sp,
                         cx.expr_ident(sp, id_ext("ext_cx")),
@@ -508,17 +506,17 @@ fn mk_name(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> Gc<ast::Expr> {
                         vec!(e_str))
 }
 
-fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> Gc<ast::Expr> {
+fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
     let idents = vec!(id_ext("syntax"), id_ext("ast"), id_ext(name));
     cx.expr_path(cx.path_global(sp, idents))
 }
 
-fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> Gc<ast::Expr> {
+fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
     let idents = vec!(id_ext("syntax"), id_ext("parse"), id_ext("token"), id_ext(name));
     cx.expr_path(cx.path_global(sp, idents))
 }
 
-fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> Gc<ast::Expr> {
+fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> P<ast::Expr> {
     let name = match bop {
         PLUS => "PLUS",
         MINUS => "MINUS",
@@ -534,7 +532,7 @@ fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> Gc<ast::Expr> {
     mk_token_path(cx, sp, name)
 }
 
-fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> Gc<ast::Expr> {
+fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
 
     match *tok {
         BINOP(binop) => {
@@ -640,7 +638,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> Gc<ast::Expr> {
 }
 
 
-fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<Gc<ast::Stmt>> {
+fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> {
     match *tt {
         ast::TTTok(sp, ref tok) => {
             let e_sp = cx.expr_ident(sp, id_ext("_sp"));
@@ -680,7 +678,7 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<Gc<ast::Stmt>> {
 }
 
 fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-    -> Vec<Gc<ast::Stmt>> {
+    -> Vec<P<ast::Stmt>> {
     let mut ss = Vec::new();
     for tt in tts.iter() {
         ss.push_all_move(mk_tt(cx, sp, tt));
@@ -689,7 +687,7 @@ fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 }
 
 fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-              -> (Gc<ast::Expr>, Gc<ast::Expr>) {
+              -> (P<ast::Expr>, P<ast::Expr>) {
     // NB: It appears that the main parser loses its mind if we consider
     // $foo as a TTNonterminal during the main parse, so we have to re-parse
     // under quote_depth > 0. This is silly and should go away; the _guess_ is
@@ -757,8 +755,8 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
 fn expand_wrapper(cx: &ExtCtxt,
                   sp: Span,
-                  cx_expr: Gc<ast::Expr>,
-                  expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
+                  cx_expr: P<ast::Expr>,
+                  expr: P<ast::Expr>) -> P<ast::Expr> {
     let uses = [
         &["syntax", "ext", "quote", "rt"],
     ].iter().map(|path| {
@@ -776,8 +774,8 @@ fn expand_wrapper(cx: &ExtCtxt,
 fn expand_parse_call(cx: &ExtCtxt,
                      sp: Span,
                      parse_method: &str,
-                     arg_exprs: Vec<Gc<ast::Expr>>,
-                     tts: &[ast::TokenTree]) -> Gc<ast::Expr> {
+                     arg_exprs: Vec<P<ast::Expr>> ,
+                     tts: &[ast::TokenTree]) -> P<ast::Expr> {
     let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
 
     let cfg_call = || cx.expr_method_call(
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 509d5bd4421..3006bcaf6f8 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -87,9 +87,9 @@ use parse::attr::ParserAttr;
 use parse::parser::{LifetimeAndTypesWithoutColons, Parser};
 use parse::token::{Token, EOF, Nonterminal};
 use parse::token;
+use ptr::P;
 
 use std::rc::Rc;
-use std::gc::GC;
 use std::collections::HashMap;
 
 /* to avoid costly uniqueness checks, we require that `MatchSeq` always has a
@@ -451,7 +451,7 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
       "meta" => token::NtMeta(p.parse_meta_item()),
       "tt" => {
         p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
-        let res = token::NtTT(box(GC) p.parse_token_tree());
+        let res = token::NtTT(P(p.parse_token_tree()));
         p.quote_depth -= 1u;
         res
       }
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index d8f0eb32ad7..6c7bbb2384c 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq};
-use ast::{TTDelim};
+use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq, TTDelim};
 use ast;
 use codemap::{Span, Spanned, DUMMY_SP};
 use ext::base::{ExtCtxt, MacResult, MacroDef};
@@ -24,11 +23,12 @@ use parse::token::{special_idents, gensym_ident};
 use parse::token::{FAT_ARROW, SEMI, NtMatchers, NtTT, EOF};
 use parse::token;
 use print;
+use ptr::P;
+
 use util::small_vector::SmallVector;
 
 use std::cell::RefCell;
 use std::rc::Rc;
-use std::gc::Gc;
 
 struct ParserAnyMacro<'a> {
     parser: RefCell<Parser<'a>>,
@@ -58,17 +58,17 @@ impl<'a> ParserAnyMacro<'a> {
 }
 
 impl<'a> MacResult for ParserAnyMacro<'a> {
-    fn make_expr(&self) -> Option<Gc<ast::Expr>> {
+    fn make_expr(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Expr>> {
         let ret = self.parser.borrow_mut().parse_expr();
         self.ensure_complete_parse(true);
         Some(ret)
     }
-    fn make_pat(&self) -> Option<Gc<ast::Pat>> {
+    fn make_pat(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Pat>> {
         let ret = self.parser.borrow_mut().parse_pat();
         self.ensure_complete_parse(false);
         Some(ret)
     }
-    fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
+    fn make_items(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<P<ast::Item>>> {
         let mut ret = SmallVector::zero();
         loop {
             let mut parser = self.parser.borrow_mut();
@@ -84,7 +84,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
         Some(ret)
     }
 
-    fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
+    fn make_methods(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<P<ast::Method>>> {
         let mut ret = SmallVector::zero();
         loop {
             let mut parser = self.parser.borrow_mut();
@@ -97,7 +97,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
         Some(ret)
     }
 
-    fn make_stmt(&self) -> Option<Gc<ast::Stmt>> {
+    fn make_stmt(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Stmt>> {
         let attrs = self.parser.borrow_mut().parse_outer_attributes();
         let ret = self.parser.borrow_mut().parse_stmt(attrs);
         self.ensure_complete_parse(true);
@@ -127,11 +127,11 @@ impl TTMacroExpander for MacroRulesMacroExpander {
 }
 
 struct MacroRulesDefiner {
-    def: RefCell<Option<MacroDef>>
+    def: Option<MacroDef>
 }
 impl MacResult for MacroRulesDefiner {
-    fn make_def(&self) -> Option<MacroDef> {
-        Some(self.def.borrow_mut().take().expect("MacroRulesDefiner expanded twice"))
+    fn make_def(&mut self) -> Option<MacroDef> {
+        Some(self.def.take().expect("empty MacroRulesDefiner"))
     }
 }
 
@@ -170,8 +170,8 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
               Success(named_matches) => {
                 let rhs = match *rhses[i] {
                     // okay, what's your transcriber?
-                    MatchedNonterminal(NtTT(tt)) => {
-                        match *tt {
+                    MatchedNonterminal(NtTT(ref tt)) => {
+                        match **tt {
                             // cut off delimiters; don't parse 'em
                             TTDelim(ref tts) => {
                                 (*tts).slice(1u,(*tts).len()-1u)
@@ -269,9 +269,9 @@ pub fn add_new_extension<'cx>(cx: &'cx mut ExtCtxt,
     };
 
     box MacroRulesDefiner {
-        def: RefCell::new(Some(MacroDef {
+        def: Some(MacroDef {
             name: token::get_ident(name).to_string(),
             ext: NormalTT(exp, Some(sp))
-        }))
+        })
     } as Box<MacResult+'cx>
 }