diff options
Diffstat (limited to 'src/libsyntax/ext')
27 files changed, 532 insertions, 452 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 06916d5ac09..665d9da664d 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -20,7 +20,6 @@ use parse; use parse::token::InternedString; use parse::token; - enum State { Asm, Outputs, @@ -214,7 +213,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) out)); } - MacExpr::new(@ast::Expr { + MacExpr::new(box(GC) ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprInlineAsm(ast::InlineAsm { asm: token::intern_and_get_ident(asm.get()), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b656b0c06a0..f9a9e276eb0 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -20,6 +20,7 @@ use parse::token::{InternedString, intern, str_to_ident}; use util::small_vector::SmallVector; use std::collections::HashMap; +use std::gc::Gc; // new-style macro! tt code: // @@ -35,10 +36,10 @@ pub struct MacroDef { } pub type ItemDecorator = - fn(&mut ExtCtxt, Span, @ast::MetaItem, @ast::Item, |@ast::Item|); + fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>, |Gc<ast::Item>|); pub type ItemModifier = - fn(&mut ExtCtxt, Span, @ast::MetaItem, @ast::Item) -> @ast::Item; + fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>) -> Gc<ast::Item>; pub struct BasicMacroExpander { pub expander: MacroExpanderFn, @@ -104,11 +105,11 @@ pub trait MacResult { None } /// Create an expression. - fn make_expr(&self) -> Option<@ast::Expr> { + fn make_expr(&self) -> Option<Gc<ast::Expr>> { None } /// Create zero or more items. - fn make_items(&self) -> Option<SmallVector<@ast::Item>> { + fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> { None } /// Create a pattern. @@ -120,23 +121,23 @@ pub trait MacResult { /// /// By default this attempts to create an expression statement, /// returning None if that fails. - fn make_stmt(&self) -> Option<@ast::Stmt> { + fn make_stmt(&self) -> Option<Gc<ast::Stmt>> { self.make_expr() - .map(|e| @codemap::respan(e.span, ast::StmtExpr(e, ast::DUMMY_NODE_ID))) + .map(|e| box(GC) 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: @ast::Expr + e: Gc<ast::Expr>, } impl MacExpr { - pub fn new(e: @ast::Expr) -> Box<MacResult> { + pub fn new(e: Gc<ast::Expr>) -> Box<MacResult> { box MacExpr { e: e } as Box<MacResult> } } impl MacResult for MacExpr { - fn make_expr(&self) -> Option<@ast::Expr> { + fn make_expr(&self) -> Option<Gc<ast::Expr>> { Some(self.e) } } @@ -156,22 +157,22 @@ impl MacResult for MacPat { } /// A convenience type for macros that return a single item. pub struct MacItem { - i: @ast::Item + i: Gc<ast::Item> } impl MacItem { - pub fn new(i: @ast::Item) -> Box<MacResult> { + pub fn new(i: Gc<ast::Item>) -> Box<MacResult> { box MacItem { i: i } as Box<MacResult> } } impl MacResult for MacItem { - fn make_items(&self) -> Option<SmallVector<@ast::Item>> { + fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> { Some(SmallVector::one(self.i)) } - fn make_stmt(&self) -> Option<@ast::Stmt> { - Some(@codemap::respan( + fn make_stmt(&self) -> Option<Gc<ast::Stmt>> { + Some(box(GC) codemap::respan( self.i.span, ast::StmtDecl( - @codemap::respan(self.i.span, ast::DeclItem(self.i)), + box(GC) codemap::respan(self.i.span, ast::DeclItem(self.i)), ast::DUMMY_NODE_ID))) } } @@ -202,10 +203,10 @@ impl DummyResult { } /// A plain dummy expression. - pub fn raw_expr(sp: Span) -> @ast::Expr { - @ast::Expr { + pub fn raw_expr(sp: Span) -> Gc<ast::Expr> { + box(GC) ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprLit(@codemap::respan(sp, ast::LitNil)), + node: ast::ExprLit(box(GC) codemap::respan(sp, ast::LitNil)), span: sp, } } @@ -221,21 +222,21 @@ impl DummyResult { } impl MacResult for DummyResult { - fn make_expr(&self) -> Option<@ast::Expr> { + fn make_expr(&self) -> Option<Gc<ast::Expr>> { Some(DummyResult::raw_expr(self.span)) } - fn make_pat(&self) -> Option<@ast::Pat> { + fn make_pat(&self) -> Option<Gc<ast::Pat>> { Some(DummyResult::raw_pat(self.span)) } - fn make_items(&self) -> Option<SmallVector<@ast::Item>> { + fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> { if self.expr_only { None } else { Some(SmallVector::zero()) } } - fn make_stmt(&self) -> Option<@ast::Stmt> { - Some(@codemap::respan(self.span, + 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))) } @@ -397,7 +398,7 @@ pub fn syntax_expander_table() -> SyntaxEnv { pub struct ExtCtxt<'a> { pub parse_sess: &'a parse::ParseSess, pub cfg: ast::CrateConfig, - pub backtrace: Option<@ExpnInfo>, + pub backtrace: Option<Gc<ExpnInfo>>, pub ecfg: expand::ExpansionConfig, pub mod_path: Vec<ast::Ident> , @@ -417,7 +418,7 @@ impl<'a> ExtCtxt<'a> { } } - pub fn expand_expr(&mut self, mut e: @ast::Expr) -> @ast::Expr { + pub fn expand_expr(&mut self, mut e: Gc<ast::Expr>) -> Gc<ast::Expr> { loop { match e.node { ast::ExprMac(..) => { @@ -442,7 +443,7 @@ impl<'a> ExtCtxt<'a> { } } pub fn print_backtrace(&self) { } - pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace } + pub fn backtrace(&self) -> Option<Gc<ExpnInfo>> { self.backtrace } pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); } pub fn mod_pop(&mut self) { self.mod_path.pop().unwrap(); } pub fn mod_path(&self) -> Vec<ast::Ident> { @@ -455,9 +456,9 @@ impl<'a> ExtCtxt<'a> { match ei { ExpnInfo {call_site: cs, callee: ref callee} => { self.backtrace = - Some(@ExpnInfo { + Some(box(GC) ExpnInfo { call_site: Span {lo: cs.lo, hi: cs.hi, - expn_info: self.backtrace}, + expn_info: self.backtrace.clone()}, callee: (*callee).clone() }); } @@ -528,7 +529,7 @@ 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_str(cx: &mut ExtCtxt, expr: @ast::Expr, err_msg: &str) +pub fn expr_to_str(cx: &mut ExtCtxt, expr: Gc<ast::Expr>, err_msg: &str) -> Option<(InternedString, ast::StrStyle)> { // we want to be able to handle e.g. concat("foo", "bar") let expr = cx.expand_expr(expr); @@ -584,7 +585,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<@ast::Expr> > { + tts: &[ast::TokenTree]) -> Option<Vec<Gc<ast::Expr>>> { let mut p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.iter() diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 14769e3e510..148b653b61c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -21,6 +21,8 @@ use parse::token::special_idents; use parse::token::InternedString; use parse::token; +use std::gc::Gc; + // Transitional reexports so qquote can find the paths it is looking for mod syntax { pub use ext; @@ -73,115 +75,129 @@ pub trait AstBuilder { fn lifetime(&self, span: Span, ident: ast::Name) -> ast::Lifetime; // statements - fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt; - fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt; + fn stmt_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_let_typed(&self, sp: Span, mutbl: bool, ident: ast::Ident, typ: P<ast::Ty>, - ex: @ast::Expr) - -> @ast::Stmt; + ex: Gc<ast::Expr>) + -> Gc<ast::Stmt>; // blocks - fn block(&self, span: Span, stmts: Vec<@ast::Stmt> , expr: Option<@ast::Expr>) -> P<ast::Block>; - fn block_expr(&self, expr: @ast::Expr) -> P<ast::Block>; + 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_all(&self, span: Span, view_items: Vec<ast::ViewItem> , - stmts: Vec<@ast::Stmt> , - expr: Option<@ast::Expr>) -> P<ast::Block>; + stmts: Vec<Gc<ast::Stmt>> , + expr: Option<Gc<ast::Expr>>) -> P<ast::Block>; // expressions - fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr; - fn expr_path(&self, path: ast::Path) -> @ast::Expr; - fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr; + 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(&self, span: Span) -> @ast::Expr; + fn expr_self(&self, span: Span) -> Gc<ast::Expr>; fn expr_binary(&self, sp: Span, op: ast::BinOp, - lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr; - fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; - fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) -> @ast::Expr; - - fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; - fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; - fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr; - fn expr_field_access(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr; - fn expr_call(&self, span: Span, expr: @ast::Expr, args: Vec<@ast::Expr> ) -> @ast::Expr; - fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec<@ast::Expr> ) -> @ast::Expr; + 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_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<@ast::Expr> ) -> @ast::Expr; + args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr>; fn expr_method_call(&self, span: Span, - expr: @ast::Expr, ident: ast::Ident, - args: Vec<@ast::Expr> ) -> @ast::Expr; - fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr; - fn expr_cast(&self, sp: Span, expr: @ast::Expr, ty: P<ast::Ty>) -> @ast::Expr; - - fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field; - fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field> ) -> @ast::Expr; - fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: Vec<ast::Field> ) -> @ast::Expr; - - fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> @ast::Expr; - - fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr; - fn expr_int(&self, sp: Span, i: int) -> @ast::Expr; - fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr; - fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr; - - fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr; - fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr; - fn expr_vec_ng(&self, sp: Span) -> @ast::Expr; - fn expr_vec_slice(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr; - fn expr_str(&self, sp: Span, s: InternedString) -> @ast::Expr; - fn expr_str_uniq(&self, sp: Span, s: InternedString) -> @ast::Expr; - - fn expr_some(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr; - fn expr_none(&self, sp: Span) -> @ast::Expr; - - fn expr_fail(&self, span: Span, msg: InternedString) -> @ast::Expr; - fn expr_unreachable(&self, span: Span) -> @ast::Expr; - - fn expr_ok(&self, span: Span, expr: @ast::Expr) -> @ast::Expr; - fn expr_err(&self, span: Span, expr: @ast::Expr) -> @ast::Expr; - fn expr_try(&self, span: Span, head: @ast::Expr) -> @ast::Expr; - - fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat; - fn pat_wild(&self, span: Span) -> @ast::Pat; - fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat; - fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat; + 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>; + fn expr_struct_ident(&self, span: Span, id: ast::Ident, + fields: Vec<ast::Field> ) -> Gc<ast::Expr>; + + fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> Gc<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_vstore(&self, sp: Span, expr: Gc<ast::Expr>, vst: ast::ExprVstore) -> Gc<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_str_uniq(&self, sp: Span, s: InternedString) -> Gc<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_fail(&self, span: Span, msg: InternedString) -> Gc<ast::Expr>; + fn expr_unreachable(&self, span: Span) -> Gc<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 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_ident_binding_mode(&self, span: Span, ident: ast::Ident, - bm: ast::BindingMode) -> @ast::Pat; - fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<@ast::Pat> ) -> @ast::Pat; + bm: ast::BindingMode) -> Gc<ast::Pat>; + fn pat_enum(&self, span: Span, path: ast::Path, + subpats: Vec<Gc<ast::Pat>>) -> Gc<ast::Pat>; fn pat_struct(&self, span: Span, - path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> @ast::Pat; + path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> Gc<ast::Pat>; - fn arm(&self, span: Span, pats: Vec<@ast::Pat> , expr: @ast::Expr) -> ast::Arm; + fn arm(&self, span: Span, pats: Vec<Gc<ast::Pat>> , expr: Gc<ast::Expr>) -> ast::Arm; fn arm_unreachable(&self, span: Span) -> ast::Arm; - fn expr_match(&self, span: Span, arg: @ast::Expr, arms: Vec<ast::Arm> ) -> @ast::Expr; + fn expr_match(&self, span: Span, arg: Gc<ast::Expr>, arms: Vec<ast::Arm> ) -> Gc<ast::Expr>; fn expr_if(&self, span: Span, - cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr; + cond: Gc<ast::Expr>, then: Gc<ast::Expr>, + els: Option<Gc<ast::Expr>>) -> Gc<ast::Expr>; fn lambda_fn_decl(&self, span: Span, - fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> @ast::Expr; + fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> Gc<ast::Expr>; - fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> @ast::Expr; - fn lambda0(&self, span: Span, blk: P<ast::Block>) -> @ast::Expr; - fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> @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_expr(&self, span: Span, ids: Vec<ast::Ident> , blk: @ast::Expr) -> @ast::Expr; - fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr; - fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @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_stmts(&self, span: Span, ids: Vec<ast::Ident> , blk: Vec<@ast::Stmt> ) -> @ast::Expr; - fn lambda_stmts_0(&self, span: Span, stmts: Vec<@ast::Stmt> ) -> @ast::Expr; - fn lambda_stmts_1(&self, span: Span, stmts: Vec<@ast::Stmt> , ident: ast::Ident) -> @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>; // items fn item(&self, span: Span, - name: Ident, attrs: Vec<ast::Attribute> , node: ast::Item_) -> @ast::Item; + name: Ident, attrs: Vec<ast::Attribute>, + node: ast::Item_) -> Gc<ast::Item>; fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg; // FIXME unused self @@ -193,56 +209,59 @@ pub trait AstBuilder { inputs: Vec<ast::Arg> , output: P<ast::Ty>, generics: Generics, - body: P<ast::Block>) -> @ast::Item; + body: P<ast::Block>) -> Gc<ast::Item>; fn item_fn(&self, span: Span, name: Ident, inputs: Vec<ast::Arg> , output: P<ast::Ty>, - body: P<ast::Block>) -> @ast::Item; + body: P<ast::Block>) -> Gc<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) -> @ast::Item; - fn item_enum(&self, span: Span, name: Ident, enum_def: ast::EnumDef) -> @ast::Item; + generics: Generics) -> Gc<ast::Item>; + fn item_enum(&self, span: Span, name: Ident, + enum_def: ast::EnumDef) -> Gc<ast::Item>; fn item_struct_poly(&self, span: Span, name: Ident, struct_def: ast::StructDef, - generics: Generics) -> @ast::Item; - fn item_struct(&self, span: Span, name: Ident, struct_def: ast::StructDef) -> @ast::Item; + generics: Generics) -> Gc<ast::Item>; + fn item_struct(&self, span: Span, name: Ident, + struct_def: ast::StructDef) -> Gc<ast::Item>; fn item_mod(&self, span: Span, inner_span: Span, - name: Ident, attrs: Vec<ast::Attribute> , - vi: Vec<ast::ViewItem> , items: Vec<@ast::Item> ) -> @ast::Item; + name: Ident, attrs: Vec<ast::Attribute>, + vi: Vec<ast::ViewItem>, + items: Vec<Gc<ast::Item>>) -> Gc<ast::Item>; fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>, - generics: Generics) -> @ast::Item; - fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::Item; + generics: Generics) -> Gc<ast::Item>; + fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> Gc<ast::Item>; - fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute; + fn attribute(&self, sp: Span, mi: Gc<ast::MetaItem>) -> ast::Attribute; - fn meta_word(&self, sp: Span, w: InternedString) -> @ast::MetaItem; + fn meta_word(&self, sp: Span, w: InternedString) -> Gc<ast::MetaItem>; fn meta_list(&self, sp: Span, name: InternedString, - mis: Vec<@ast::MetaItem> ) - -> @ast::MetaItem; + mis: Vec<Gc<ast::MetaItem>>) + -> Gc<ast::MetaItem>; fn meta_name_value(&self, sp: Span, name: InternedString, value: ast::Lit_) - -> @ast::MetaItem; + -> Gc<ast::MetaItem>; fn view_use(&self, sp: Span, - vis: ast::Visibility, vp: @ast::ViewPath) -> ast::ViewItem; + vis: ast::Visibility, vp: Gc<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; @@ -418,17 +437,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::Lifetime { id: ast::DUMMY_NODE_ID, span: span, name: name } } - fn stmt_expr(&self, expr: @ast::Expr) -> @ast::Stmt { - @respan(expr.span, ast::StmtSemi(expr, ast::DUMMY_NODE_ID)) + 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_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::Expr) -> @ast::Stmt { + fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, + ex: Gc<ast::Expr>) -> Gc<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 = @ast::Local { + let local = box(GC) ast::Local { ty: self.ty_infer(sp), pat: pat, init: Some(ex), @@ -437,7 +457,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { source: ast::LocalLet, }; let decl = respan(sp, ast::DeclLocal(local)); - @respan(sp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID)) + box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID)) } fn stmt_let_typed(&self, @@ -445,14 +465,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: bool, ident: ast::Ident, typ: P<ast::Ty>, - ex: @ast::Expr) - -> @ast::Stmt { + ex: Gc<ast::Expr>) + -> Gc<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 = @ast::Local { + let local = box(GC) ast::Local { ty: typ, pat: pat, init: Some(ex), @@ -461,21 +481,22 @@ impl<'a> AstBuilder for ExtCtxt<'a> { source: ast::LocalLet, }; let decl = respan(sp, ast::DeclLocal(local)); - @respan(sp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID)) + box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID)) } - fn block(&self, span: Span, stmts: Vec<@ast::Stmt> , expr: Option<@Expr>) -> P<ast::Block> { + fn block(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>, + expr: Option<Gc<Expr>>) -> P<ast::Block> { self.block_all(span, Vec::new(), stmts, expr) } - fn block_expr(&self, expr: @ast::Expr) -> P<ast::Block> { + fn block_expr(&self, expr: Gc<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<@ast::Stmt> , - expr: Option<@ast::Expr>) -> P<ast::Block> { + stmts: Vec<Gc<ast::Stmt>>, + expr: Option<Gc<ast::Expr>>) -> P<ast::Block> { P(ast::Block { view_items: view_items, stmts: stmts, @@ -486,107 +507,109 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }) } - fn expr(&self, span: Span, node: ast::Expr_) -> @ast::Expr { - @ast::Expr { + fn expr(&self, span: Span, node: ast::Expr_) -> Gc<ast::Expr> { + box(GC) ast::Expr { id: ast::DUMMY_NODE_ID, node: node, span: span, } } - fn expr_path(&self, path: ast::Path) -> @ast::Expr { + fn expr_path(&self, path: ast::Path) -> Gc<ast::Expr> { self.expr(path.span, ast::ExprPath(path)) } - fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::Expr { + fn expr_ident(&self, span: Span, id: ast::Ident) -> Gc<ast::Expr> { self.expr_path(self.path_ident(span, id)) } - fn expr_self(&self, span: Span) -> @ast::Expr { + fn expr_self(&self, span: Span) -> Gc<ast::Expr> { self.expr_ident(span, special_idents::self_) } fn expr_binary(&self, sp: Span, op: ast::BinOp, - lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr { + lhs: Gc<ast::Expr>, rhs: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr(sp, ast::ExprBinary(op, lhs, rhs)) } - fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + fn expr_deref(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr_unary(sp, ast::UnDeref, e) } - fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) -> @ast::Expr { + fn expr_unary(&self, sp: Span, op: ast::UnOp, e: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr(sp, ast::ExprUnary(op, e)) } - fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + fn expr_managed(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr_unary(sp, ast::UnBox, e) } - fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr { + fn expr_field_access(&self, sp: Span, expr: Gc<ast::Expr>, ident: ast::Ident) -> Gc<ast::Expr> { self.expr(sp, ast::ExprField(expr, ident, Vec::new())) } - fn expr_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + fn expr_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e)) } - fn expr_mut_addr_of(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { + fn expr_mut_addr_of(&self, sp: Span, e: Gc<ast::Expr>) -> Gc<ast::Expr> { self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e)) } - fn expr_call(&self, span: Span, expr: @ast::Expr, args: Vec<@ast::Expr> ) -> @ast::Expr { + fn expr_call(&self, span: Span, expr: Gc<ast::Expr>, + args: Vec<Gc<ast::Expr>>) -> Gc<ast::Expr> { self.expr(span, ast::ExprCall(expr, args)) } - fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec<@ast::Expr> ) -> @ast::Expr { + fn expr_call_ident(&self, span: Span, id: ast::Ident, + args: Vec<Gc<ast::Expr>>) -> Gc<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<@ast::Expr> ) -> @ast::Expr { + args: Vec<Gc<ast::Expr>> ) -> Gc<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: @ast::Expr, + expr: Gc<ast::Expr>, ident: ast::Ident, - mut args: Vec<@ast::Expr> ) -> @ast::Expr { + mut args: Vec<Gc<ast::Expr>> ) -> Gc<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>) -> @ast::Expr { + fn expr_block(&self, b: P<ast::Block>) -> Gc<ast::Expr> { self.expr(b.span, ast::ExprBlock(b)) } - fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field { + fn field_imm(&self, span: Span, name: Ident, e: Gc<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> ) -> @ast::Expr { + fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field> ) -> Gc<ast::Expr> { self.expr(span, ast::ExprStruct(path, fields, None)) } fn expr_struct_ident(&self, span: Span, - id: ast::Ident, fields: Vec<ast::Field> ) -> @ast::Expr { + id: ast::Ident, fields: Vec<ast::Field> ) -> Gc<ast::Expr> { self.expr_struct(span, self.path_ident(span, id), fields) } - fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> @ast::Expr { - self.expr(sp, ast::ExprLit(@respan(sp, lit))) + fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> Gc<ast::Expr> { + self.expr(sp, ast::ExprLit(box(GC) respan(sp, lit))) } - fn expr_uint(&self, span: Span, i: uint) -> @ast::Expr { + fn expr_uint(&self, span: Span, i: uint) -> Gc<ast::Expr> { self.expr_lit(span, ast::LitUint(i as u64, ast::TyU)) } - fn expr_int(&self, sp: Span, i: int) -> @ast::Expr { + fn expr_int(&self, sp: Span, i: int) -> Gc<ast::Expr> { self.expr_lit(sp, ast::LitInt(i as i64, ast::TyI)) } - fn expr_u8(&self, sp: Span, u: u8) -> @ast::Expr { + fn expr_u8(&self, sp: Span, u: u8) -> Gc<ast::Expr> { self.expr_lit(sp, ast::LitUint(u as u64, ast::TyU8)) } - fn expr_bool(&self, sp: Span, value: bool) -> @ast::Expr { + fn expr_bool(&self, sp: Span, value: bool) -> Gc<ast::Expr> { self.expr_lit(sp, ast::LitBool(value)) } - fn expr_vstore(&self, sp: Span, expr: @ast::Expr, vst: ast::ExprVstore) -> @ast::Expr { + fn expr_vstore(&self, sp: Span, expr: Gc<ast::Expr>, vst: ast::ExprVstore) -> Gc<ast::Expr> { self.expr(sp, ast::ExprVstore(expr, vst)) } - fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr { + fn expr_vec(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> { self.expr(sp, ast::ExprVec(exprs)) } - fn expr_vec_ng(&self, sp: Span) -> @ast::Expr { + fn expr_vec_ng(&self, sp: Span) -> Gc<ast::Expr> { self.expr_call_global(sp, vec!(self.ident_of("std"), self.ident_of("vec"), @@ -594,23 +617,23 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ident_of("new")), Vec::new()) } - fn expr_vec_slice(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr { + fn expr_vec_slice(&self, sp: Span, exprs: Vec<Gc<ast::Expr>> ) -> Gc<ast::Expr> { self.expr_vstore(sp, self.expr_vec(sp, exprs), ast::ExprVstoreSlice) } - fn expr_str(&self, sp: Span, s: InternedString) -> @ast::Expr { + fn expr_str(&self, sp: Span, s: InternedString) -> Gc<ast::Expr> { self.expr_lit(sp, ast::LitStr(s, ast::CookedStr)) } - fn expr_str_uniq(&self, sp: Span, s: InternedString) -> @ast::Expr { + fn expr_str_uniq(&self, sp: Span, s: InternedString) -> Gc<ast::Expr> { self.expr_vstore(sp, self.expr_str(sp, s), ast::ExprVstoreUniq) } - fn expr_cast(&self, sp: Span, expr: @ast::Expr, ty: P<ast::Ty>) -> @ast::Expr { + fn expr_cast(&self, sp: Span, expr: Gc<ast::Expr>, ty: P<ast::Ty>) -> Gc<ast::Expr> { self.expr(sp, ast::ExprCast(expr, ty)) } - fn expr_some(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr { + fn expr_some(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> { let some = vec!( self.ident_of("std"), self.ident_of("option"), @@ -618,7 +641,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_call_global(sp, some, vec!(expr)) } - fn expr_none(&self, sp: Span) -> @ast::Expr { + fn expr_none(&self, sp: Span) -> Gc<ast::Expr> { let none = self.path_global(sp, vec!( self.ident_of("std"), self.ident_of("option"), @@ -626,7 +649,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_path(none) } - fn expr_fail(&self, span: Span, msg: InternedString) -> @ast::Expr { + fn expr_fail(&self, span: Span, msg: InternedString) -> Gc<ast::Expr> { let loc = self.codemap().lookup_char_pos(span.lo); self.expr_call_global( span, @@ -643,13 +666,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_uint(span, loc.line))) } - fn expr_unreachable(&self, span: Span) -> @ast::Expr { + fn expr_unreachable(&self, span: Span) -> Gc<ast::Expr> { self.expr_fail(span, InternedString::new( "internal error: entered unreachable code")) } - fn expr_ok(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr { + fn expr_ok(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> { let ok = vec!( self.ident_of("std"), self.ident_of("result"), @@ -657,7 +680,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_call_global(sp, ok, vec!(expr)) } - fn expr_err(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr { + fn expr_err(&self, sp: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> { let err = vec!( self.ident_of("std"), self.ident_of("result"), @@ -665,7 +688,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_call_global(sp, err, vec!(expr)) } - fn expr_try(&self, sp: Span, head: @ast::Expr) -> @ast::Expr { + fn expr_try(&self, sp: Span, head: Gc<ast::Expr>) -> Gc<ast::Expr> { let ok = self.ident_of("Ok"); let ok_path = self.path_ident(sp, ok); let err = self.ident_of("Err"); @@ -694,38 +717,38 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } - fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat { - @ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span } + 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_wild(&self, span: Span) -> @ast::Pat { + fn pat_wild(&self, span: Span) -> Gc<ast::Pat> { self.pat(span, ast::PatWild) } - fn pat_lit(&self, span: Span, expr: @ast::Expr) -> @ast::Pat { + fn pat_lit(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Pat> { self.pat(span, ast::PatLit(expr)) } - fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::Pat { + fn pat_ident(&self, span: Span, ident: ast::Ident) -> Gc<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) -> @ast::Pat { + bm: ast::BindingMode) -> Gc<ast::Pat> { let path = self.path_ident(span, ident); let pat = ast::PatIdent(bm, path, None); self.pat(span, pat) } - fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<@ast::Pat> ) -> @ast::Pat { + fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<Gc<ast::Pat>> ) -> Gc<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> ) -> @ast::Pat { + path: ast::Path, field_pats: Vec<ast::FieldPat> ) -> Gc<ast::Pat> { let pat = ast::PatStruct(path, field_pats, false); self.pat(span, pat) } - fn arm(&self, _span: Span, pats: Vec<@ast::Pat> , expr: @ast::Expr) -> ast::Arm { + fn arm(&self, _span: Span, pats: Vec<Gc<ast::Pat>> , expr: Gc<ast::Expr>) -> ast::Arm { ast::Arm { attrs: vec!(), pats: pats, @@ -738,56 +761,60 @@ 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: @ast::Expr, arms: Vec<ast::Arm> ) -> @Expr { + fn expr_match(&self, span: Span, arg: Gc<ast::Expr>, + arms: Vec<ast::Arm>) -> Gc<Expr> { self.expr(span, ast::ExprMatch(arg, arms)) } fn expr_if(&self, span: Span, - cond: @ast::Expr, then: @ast::Expr, els: Option<@ast::Expr>) -> @ast::Expr { + cond: Gc<ast::Expr>, then: Gc<ast::Expr>, + els: Option<Gc<ast::Expr>>) -> Gc<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 lambda_fn_decl(&self, span: Span, - fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> @ast::Expr { + fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> Gc<ast::Expr> { self.expr(span, ast::ExprFnBlock(fn_decl, blk)) } - fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> @ast::Expr { + fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> Gc<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(fn_decl, blk)) } - fn lambda0(&self, span: Span, blk: P<ast::Block>) -> @ast::Expr { + fn lambda0(&self, span: Span, blk: P<ast::Block>) -> Gc<ast::Expr> { self.lambda(span, Vec::new(), blk) } - fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> @ast::Expr { + fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> Gc<ast::Expr> { self.lambda(span, vec!(ident), blk) } - fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident> , expr: @ast::Expr) -> @ast::Expr { + fn lambda_expr(&self, span: Span, ids: Vec<ast::Ident> , expr: Gc<ast::Expr>) -> Gc<ast::Expr> { self.lambda(span, ids, self.block_expr(expr)) } - fn lambda_expr_0(&self, span: Span, expr: @ast::Expr) -> @ast::Expr { + fn lambda_expr_0(&self, span: Span, expr: Gc<ast::Expr>) -> Gc<ast::Expr> { self.lambda0(span, self.block_expr(expr)) } - fn lambda_expr_1(&self, span: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr { + fn lambda_expr_1(&self, span: Span, expr: Gc<ast::Expr>, ident: ast::Ident) -> Gc<ast::Expr> { self.lambda1(span, self.block_expr(expr), ident) } fn lambda_stmts(&self, span: Span, ids: Vec<ast::Ident>, - stmts: Vec<@ast::Stmt>) - -> @ast::Expr { + stmts: Vec<Gc<ast::Stmt>>) + -> Gc<ast::Expr> { self.lambda(span, ids, self.block(span, stmts, None)) } - fn lambda_stmts_0(&self, span: Span, stmts: Vec<@ast::Stmt> ) -> @ast::Expr { + fn lambda_stmts_0(&self, span: Span, + stmts: Vec<Gc<ast::Stmt>>) -> Gc<ast::Expr> { self.lambda0(span, self.block(span, stmts, None)) } - fn lambda_stmts_1(&self, span: Span, stmts: Vec<@ast::Stmt> , ident: ast::Ident) -> @ast::Expr { + fn lambda_stmts_1(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>, + ident: ast::Ident) -> Gc<ast::Expr> { self.lambda1(span, self.block(span, stmts, None), ident) } @@ -811,10 +838,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn item(&self, span: Span, - name: Ident, attrs: Vec<ast::Attribute> , node: ast::Item_) -> @ast::Item { + name: Ident, attrs: Vec<ast::Attribute>, + node: ast::Item_) -> Gc<ast::Item> { // FIXME: Would be nice if our generated code didn't violate // Rust coding conventions - @ast::Item { ident: name, + box(GC) ast::Item { ident: name, attrs: attrs, id: ast::DUMMY_NODE_ID, node: node, @@ -828,7 +856,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { inputs: Vec<ast::Arg> , output: P<ast::Ty>, generics: Generics, - body: P<ast::Block>) -> @ast::Item { + body: P<ast::Block>) -> Gc<ast::Item> { self.item(span, name, Vec::new(), @@ -845,7 +873,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { inputs: Vec<ast::Arg> , output: P<ast::Ty>, body: P<ast::Block> - ) -> @ast::Item { + ) -> Gc<ast::Item> { self.item_fn_poly( span, name, @@ -873,18 +901,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn item_enum_poly(&self, span: Span, name: Ident, enum_definition: ast::EnumDef, - generics: Generics) -> @ast::Item { + generics: Generics) -> Gc<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) -> @ast::Item { + enum_definition: ast::EnumDef) -> Gc<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) -> @ast::Item { + struct_def: ast::StructDef) -> Gc<ast::Item> { self.item_struct_poly( span, name, @@ -894,14 +922,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn item_struct_poly(&self, span: Span, name: Ident, - struct_def: ast::StructDef, generics: Generics) -> @ast::Item { - self.item(span, name, Vec::new(), ast::ItemStruct(@struct_def, generics)) + struct_def: ast::StructDef, generics: Generics) -> Gc<ast::Item> { + self.item(span, name, Vec::new(), ast::ItemStruct(box(GC) struct_def, generics)) } fn item_mod(&self, span: Span, inner_span: Span, name: Ident, attrs: Vec<ast::Attribute> , vi: Vec<ast::ViewItem> , - items: Vec<@ast::Item> ) -> @ast::Item { + items: Vec<Gc<ast::Item>>) -> Gc<ast::Item> { self.item( span, name, @@ -915,15 +943,15 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>, - generics: Generics) -> @ast::Item { + generics: Generics) -> Gc<ast::Item> { self.item(span, name, Vec::new(), ast::ItemTy(ty, generics)) } - fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> @ast::Item { + fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> Gc<ast::Item> { self.item_ty_poly(span, name, ty, ast_util::empty_generics()) } - fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute { + fn attribute(&self, sp: Span, mi: Gc<ast::MetaItem>) -> ast::Attribute { respan(sp, ast::Attribute_ { id: attr::mk_attr_id(), style: ast::AttrOuter, @@ -932,26 +960,26 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }) } - fn meta_word(&self, sp: Span, w: InternedString) -> @ast::MetaItem { - @respan(sp, ast::MetaWord(w)) + fn meta_word(&self, sp: Span, w: InternedString) -> Gc<ast::MetaItem> { + box(GC) respan(sp, ast::MetaWord(w)) } fn meta_list(&self, sp: Span, name: InternedString, - mis: Vec<@ast::MetaItem> ) - -> @ast::MetaItem { - @respan(sp, ast::MetaList(name, mis)) + mis: Vec<Gc<ast::MetaItem>> ) + -> Gc<ast::MetaItem> { + box(GC) respan(sp, ast::MetaList(name, mis)) } fn meta_name_value(&self, sp: Span, name: InternedString, value: ast::Lit_) - -> @ast::MetaItem { - @respan(sp, ast::MetaNameValue(name, respan(sp, value))) + -> Gc<ast::MetaItem> { + box(GC) respan(sp, ast::MetaNameValue(name, respan(sp, value))) } fn view_use(&self, sp: Span, - vis: ast::Visibility, vp: @ast::ViewPath) -> ast::ViewItem { + vis: ast::Visibility, vp: Gc<ast::ViewPath>) -> ast::ViewItem { ast::ViewItem { node: ast::ViewItemUse(vp), attrs: Vec::new(), @@ -968,7 +996,7 @@ 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, - @respan(sp, + box(GC) respan(sp, ast::ViewPathSimple(ident, path, ast::DUMMY_NODE_ID))) @@ -981,7 +1009,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }).collect(); self.view_use(sp, vis, - @respan(sp, + box(GC) respan(sp, ast::ViewPathList(self.path(sp, path), imports, ast::DUMMY_NODE_ID))) @@ -990,7 +1018,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn view_use_glob(&self, sp: Span, vis: ast::Visibility, path: Vec<ast::Ident> ) -> ast::ViewItem { self.view_use(sp, vis, - @respan(sp, + box(GC) respan(sp, ast::ViewPathGlob(self.path(sp, path), ast::DUMMY_NODE_ID))) } } @@ -1013,8 +1041,8 @@ pub trait Duplicate { fn duplicate(&self, cx: &ExtCtxt) -> Self; } -impl Duplicate for @ast::Expr { - fn duplicate(&self, _: &ExtCtxt) -> @ast::Expr { +impl Duplicate for Gc<ast::Expr> { + fn duplicate(&self, _: &ExtCtxt) -> Gc<ast::Expr> { let mut folder = Duplicator; folder.fold_expr(*self) } diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index dad7f3e6979..3522095ed70 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -44,7 +44,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } let res = str_to_ident(res_str.as_slice()); - let e = @ast::Expr { + let e = box(GC) ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprPath( ast::Path { diff --git a/src/libsyntax/ext/deriving/bounds.rs b/src/libsyntax/ext/deriving/bounds.rs index 81fb1e46bba..fac9f37c462 100644 --- a/src/libsyntax/ext/deriving/bounds.rs +++ b/src/libsyntax/ext/deriving/bounds.rs @@ -14,11 +14,13 @@ use ext::base::ExtCtxt; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; +use std::gc::Gc; + pub fn expand_deriving_bound(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<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 6ddfedfeb4f..93e4920bc1d 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -16,11 +16,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_clone(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { @@ -51,7 +53,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, fn cs_clone( name: &str, cx: &mut ExtCtxt, trait_span: Span, - substr: &Substructure) -> @Expr { + substr: &Substructure) -> Gc<Expr> { let clone_ident = substr.method_ident; let ctor_ident; let all_fields; diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index e7a6cb35582..ef8d477a98e 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -16,18 +16,20 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_eq(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<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) -> @Expr { + fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<Expr> { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } - fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> Gc<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 24cc286b190..88ebe8a60fa 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -17,11 +17,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { macro_rules! md ( ($name:expr, $op:expr, $equal:expr) => { { let inline = cx.meta_word(span, InternedString::new("inline")); @@ -58,7 +60,8 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, } /// Strict inequality. -fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span, + substr: &Substructure) -> Gc<Expr> { let op = if less {ast::BiLt} else {ast::BiGt}; cs_fold( false, // need foldr, diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index fb7be4c14b6..8b1e0498d25 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -16,12 +16,15 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { - fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { + fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, + substr: &Substructure) -> Gc<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 03ac4c9ab03..271aa90cd24 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -18,12 +18,13 @@ use ext::deriving::generic::ty::*; use parse::token::InternedString; use std::cmp::{Ordering, Equal, Less, Greater}; +use std::gc::Gc; pub fn expand_deriving_totalord(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { @@ -65,7 +66,7 @@ pub fn ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> ast::Path } pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, - substr: &Substructure) -> @Expr { + substr: &Substructure) -> Gc<Expr> { let test_id = cx.ident_of("__test"); let equals_path = ordering_const(cx, span, Equal); diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index fe198749384..0c23d65fde0 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -23,11 +23,13 @@ use ext::deriving::generic::ty::*; use parse::token::InternedString; use parse::token; +use std::gc::Gc; + pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let trait_def = TraitDef { span: span, attributes: Vec::new(), @@ -64,7 +66,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt, } fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span, - substr: &Substructure) -> @Expr { + substr: &Substructure) -> Gc<Expr> { let decoder = substr.nonself_args[0]; let recurse = vec!(cx.ident_of("serialize"), cx.ident_of("Decodable"), @@ -159,8 +161,8 @@ fn decode_static_fields(cx: &mut ExtCtxt, trait_span: Span, outer_pat_ident: Ident, fields: &StaticFields, - getarg: |&mut ExtCtxt, Span, InternedString, uint| -> @Expr) - -> @Expr { + getarg: |&mut ExtCtxt, Span, InternedString, uint| -> Gc<Expr>) + -> Gc<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 28547a5a494..dfebc0f5e64 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -16,11 +16,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { @@ -46,7 +48,8 @@ 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) -> @Expr { +fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, + substr: &Substructure) -> Gc<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 e189cc682f6..f57670af199 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -91,11 +91,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token; +use std::gc::Gc; + pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let trait_def = TraitDef { span: span, attributes: Vec::new(), @@ -134,7 +136,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt, } fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, - substr: &Substructure) -> @Expr { + substr: &Substructure) -> Gc<Expr> { let encoder = substr.nonself_args[0]; // throw an underscore in front to suppress unused variable warnings let blkarg = cx.ident_of("_e"); diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index bf0da94e3e3..251eae75ee5 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -178,6 +178,7 @@ StaticEnum(<ast::EnumDef of C>, ~[(<ident of C0>, <span of C0>, Unnamed(~[<span */ use std::cell::RefCell; +use std::gc::Gc; use ast; use ast::{P, EnumDef, Expr, Ident, Generics, StructDef}; @@ -248,9 +249,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 [@Expr], + pub self_args: &'a [Gc<Expr>], /// verbatim access to any other arguments - pub nonself_args: &'a [@Expr], + pub nonself_args: &'a [Gc<Expr>], pub fields: &'a SubstructureFields<'a> } @@ -262,42 +263,43 @@ pub struct FieldInfo { pub name: Option<Ident>, /// The expression corresponding to this field of `self` /// (specifically, a reference to it). - pub self_: @Expr, + pub self_: Gc<Expr>, /// The expressions corresponding to references to this field in /// the other Self arguments. - pub other: Vec<@Expr>, + pub other: Vec<Gc<Expr>>, } /// Fields for a static method pub enum StaticFields { /// Tuple structs/enum variants like this - Unnamed(Vec<Span> ), + Unnamed(Vec<Span>), /// Normal structs/struct variants. - Named(Vec<(Ident, Span)> ) + Named(Vec<(Ident, Span)>), } /// A summary of the possible sets of fields. See above for details /// and examples pub enum SubstructureFields<'a> { - Struct(Vec<FieldInfo> ), + Struct(Vec<FieldInfo>), /** Matching variants of the enum: variant index, ast::Variant, fields: the field name is only non-`None` in the case of a struct variant. */ - EnumMatching(uint, &'a ast::Variant, Vec<FieldInfo> ), + EnumMatching(uint, &'a ast::Variant, Vec<FieldInfo>), /** non-matching variants of the enum, [(variant index, ast::Variant, [field span, field ident, fields])] \(i.e. all fields for self are in the first tuple, for other1 are in the second tuple, etc.) */ - EnumNonMatching(&'a [(uint, P<ast::Variant>, Vec<(Span, Option<Ident>, @Expr)> )]), + EnumNonMatching(&'a [(uint, P<ast::Variant>, + Vec<(Span, Option<Ident>, Gc<Expr>)>)]), /// A static method where Self is a struct. StaticStruct(&'a ast::StructDef, StaticFields), /// A static method where Self is an enum. - StaticEnum(&'a ast::EnumDef, Vec<(Ident, Span, StaticFields)> ) + StaticEnum(&'a ast::EnumDef, Vec<(Ident, Span, StaticFields)>), } @@ -307,7 +309,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 -> @Expr; + |&mut ExtCtxt, Span, &Substructure|: 'a -> Gc<Expr>; /** Deal with non-matching enum variants, the arguments are a list @@ -317,9 +319,9 @@ representing each variant: (variant index, ast::Variant instance, pub type EnumNonMatchFunc<'a> = |&mut ExtCtxt, Span, - &[(uint, P<ast::Variant>, Vec<(Span, Option<Ident>, @Expr)> )], - &[@Expr]|: 'a - -> @Expr; + &[(uint, P<ast::Variant>, Vec<(Span, Option<Ident>, Gc<Expr>)>)], + &[Gc<Expr>]|: 'a + -> Gc<Expr>; pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>) -> RefCell<CombineSubstructureFunc<'a>> { @@ -330,13 +332,13 @@ pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>) impl<'a> TraitDef<'a> { pub fn expand(&self, cx: &mut ExtCtxt, - _mitem: @ast::MetaItem, - item: @ast::Item, - push: |@ast::Item|) { + _mitem: Gc<ast::MetaItem>, + item: Gc<ast::Item>, + push: |Gc<ast::Item>|) { let newitem = match item.node { - ast::ItemStruct(struct_def, ref generics) => { + ast::ItemStruct(ref struct_def, ref generics) => { self.expand_struct_def(cx, - struct_def, + &**struct_def, item.ident, generics) } @@ -357,7 +359,7 @@ impl<'a> TraitDef<'a> { _ => false, } }).map(|a| a.clone())); - push(@ast::Item { + push(box(GC) ast::Item { attrs: attrs, ..(*newitem).clone() }) @@ -379,7 +381,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, type_ident: Ident, generics: &Generics, - methods: Vec<@ast::Method> ) -> @ast::Item { + methods: Vec<Gc<ast::Method>> ) -> Gc<ast::Item> { let trait_path = self.path.to_path(cx, self.span, type_ident, generics); let Generics { mut lifetimes, ty_params } = @@ -435,7 +437,7 @@ impl<'a> TraitDef<'a> { // Just mark it now since we know that it'll end up used downstream attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); - let ident = ast_util::impl_pretty_name(&opt_trait_ref, self_type); + let ident = ast_util::impl_pretty_name(&opt_trait_ref, &*self_type); cx.item( self.span, ident, @@ -448,7 +450,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, struct_def: &StructDef, type_ident: Ident, - generics: &Generics) -> @ast::Item { + generics: &Generics) -> Gc<ast::Item> { let methods = self.methods.iter().map(|method_def| { let (explicit_self, self_args, nonself_args, tys) = method_def.split_self_nonself_args( @@ -484,7 +486,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, enum_def: &EnumDef, type_ident: Ident, - generics: &Generics) -> @ast::Item { + generics: &Generics) -> Gc<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, @@ -522,10 +524,10 @@ impl<'a> MethodDef<'a> { cx: &mut ExtCtxt, trait_: &TraitDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr], + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>], fields: &SubstructureFields) - -> @Expr { + -> Gc<Expr> { let substructure = Substructure { type_ident: type_ident, method_ident: cx.ident_of(self.name), @@ -556,7 +558,8 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, type_ident: Ident, generics: &Generics) - -> (ast::ExplicitSelf, Vec<@Expr> , Vec<@Expr> , Vec<(Ident, P<ast::Ty>)> ) { + -> (ast::ExplicitSelf, Vec<Gc<Expr>>, Vec<Gc<Expr>>, + Vec<(Ident, P<ast::Ty>)>) { let mut self_args = Vec::new(); let mut nonself_args = Vec::new(); @@ -608,7 +611,7 @@ impl<'a> MethodDef<'a> { generics: &Generics, explicit_self: ast::ExplicitSelf, arg_types: Vec<(Ident, P<ast::Ty>)> , - body: @Expr) -> @ast::Method { + body: Gc<Expr>) -> Gc<ast::Method> { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics); @@ -630,7 +633,7 @@ impl<'a> MethodDef<'a> { let body_block = cx.block_expr(body); // Create the method. - @ast::Method { + box(GC) ast::Method { ident: method_ident, attrs: self.attributes.clone(), generics: fn_generics, @@ -670,9 +673,9 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, struct_def: &StructDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr]) - -> @Expr { + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>]) + -> Gc<Expr> { let mut raw_fields = Vec::new(); // ~[[fields of self], // [fields of next Self arg], [etc]] @@ -737,9 +740,9 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, struct_def: &StructDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr]) - -> @Expr { + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>]) + -> Gc<Expr> { let summary = trait_.summarise_struct(cx, struct_def); self.call_substructure_method(cx, @@ -780,9 +783,9 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, enum_def: &EnumDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr]) - -> @Expr { + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>]) + -> Gc<Expr> { let mut matches = Vec::new(); self.build_enum_match(cx, trait_, enum_def, type_ident, self_args, nonself_args, @@ -816,12 +819,12 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, enum_def: &EnumDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr], + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>], matching: Option<uint>, matches_so_far: &mut Vec<(uint, P<ast::Variant>, - Vec<(Span, Option<Ident>, @Expr)> )> , - match_count: uint) -> @Expr { + Vec<(Span, Option<Ident>, Gc<Expr>)>)> , + match_count: uint) -> Gc<Expr> { if match_count == self_args.len() { // we've matched against all arguments, so make the final // expression at the bottom of the match tree @@ -871,7 +874,7 @@ impl<'a> MethodDef<'a> { other: (*other).clone() } }).collect(); - EnumMatching(variant_index, variant, field_tuples) + EnumMatching(variant_index, &*variant, field_tuples) } None => { EnumNonMatching(matches_so_far.as_slice()) @@ -905,7 +908,7 @@ impl<'a> MethodDef<'a> { let variant = *enum_def.variants.get(index); let (pattern, idents) = trait_.create_enum_variant_pattern( cx, - variant, + &*variant, current_match_str.as_slice(), ast::MutImmutable); @@ -938,7 +941,7 @@ impl<'a> MethodDef<'a> { let (pattern, idents) = trait_.create_enum_variant_pattern( cx, - variant, + &*variant, current_match_str.as_slice(), ast::MutImmutable); @@ -974,17 +977,17 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef, enum_def: &EnumDef, type_ident: Ident, - self_args: &[@Expr], - nonself_args: &[@Expr]) - -> @Expr { + self_args: &[Gc<Expr>], + nonself_args: &[Gc<Expr>]) + -> Gc<Expr> { let summary = enum_def.variants.iter().map(|v| { let ident = v.node.name; let summary = match v.node.kind { ast::TupleVariantKind(ref args) => { Unnamed(args.iter().map(|va| trait_.set_expn_info(cx, va.ty.span)).collect()) } - ast::StructVariantKind(struct_def) => { - trait_.summarise_struct(cx, struct_def) + ast::StructVariantKind(ref struct_def) => { + trait_.summarise_struct(cx, &**struct_def) } }; (ident, v.span, summary) @@ -1009,7 +1012,7 @@ impl<'a> TraitDef<'a> { None => cx.span_bug(self.span, "trait with empty path in generic `deriving`"), Some(name) => *name }; - to_set.expn_info = Some(@codemap::ExpnInfo { + to_set.expn_info = Some(box(GC) codemap::ExpnInfo { call_site: to_set, callee: codemap::NameAndSpan { name: format!("deriving({})", trait_name).to_string(), @@ -1048,7 +1051,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, field_paths: Vec<ast::Path> , mutbl: ast::Mutability) - -> Vec<@ast::Pat> { + -> Vec<Gc<ast::Pat>> { field_paths.iter().map(|path| { cx.pat(path.span, ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None)) @@ -1061,7 +1064,7 @@ impl<'a> TraitDef<'a> { struct_def: &StructDef, prefix: &str, mutbl: ast::Mutability) - -> (@ast::Pat, Vec<(Span, Option<Ident>, @Expr)> ) { + -> (Gc<ast::Pat>, Vec<(Span, Option<Ident>, Gc<Expr>)>) { if struct_def.fields.is_empty() { return ( cx.pat_ident_binding_mode( @@ -1126,7 +1129,7 @@ impl<'a> TraitDef<'a> { variant: &ast::Variant, prefix: &str, mutbl: ast::Mutability) - -> (@ast::Pat, Vec<(Span, Option<Ident>, @Expr)> ) { + -> (Gc<ast::Pat>, Vec<(Span, Option<Ident>, Gc<Expr>)> ) { let variant_ident = variant.node.name; match variant.node.kind { ast::TupleVariantKind(ref variant_args) => { @@ -1159,8 +1162,8 @@ impl<'a> TraitDef<'a> { (cx.pat_enum(variant.span, matching_path, subpats), ident_expr) } - ast::StructVariantKind(struct_def) => { - self.create_struct_pattern(cx, variant_ident, struct_def, + ast::StructVariantKind(ref struct_def) => { + self.create_struct_pattern(cx, variant_ident, &**struct_def, prefix, mutbl) } } @@ -1174,13 +1177,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, @Expr, @Expr, &[@Expr]| -> @Expr, - base: @Expr, + f: |&mut ExtCtxt, Span, Gc<Expr>, Gc<Expr>, &[Gc<Expr>]| -> Gc<Expr>, + base: Gc<Expr>, enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) - -> @Expr { + -> Gc<Expr> { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { if use_foldl { @@ -1221,12 +1224,12 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), ~~~ */ #[inline] -pub fn cs_same_method(f: |&mut ExtCtxt, Span, Vec<@Expr> | -> @Expr, +pub fn cs_same_method(f: |&mut ExtCtxt, Span, Vec<Gc<Expr>>| -> Gc<Expr>, enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) - -> @Expr { + -> Gc<Expr> { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) @@ -1257,13 +1260,13 @@ 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, @Expr, @Expr| -> @Expr, - base: @Expr, + f: |&mut ExtCtxt, Span, Gc<Expr>, Gc<Expr>| -> Gc<Expr>, + base: Gc<Expr>, enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) - -> @Expr { + -> Gc<Expr> { cs_same_method( |cx, span, vals| { if use_foldl { @@ -1285,10 +1288,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: @Expr, +pub fn cs_binop(binop: ast::BinOp, base: Gc<Expr>, enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, trait_span: Span, - substructure: &Substructure) -> @Expr { + substructure: &Substructure) -> Gc<Expr> { cs_same_method_fold( true, // foldl is good enough |cx, span, old, new| { @@ -1306,7 +1309,7 @@ pub fn cs_binop(binop: ast::BinOp, base: @Expr, #[inline] pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, span: Span, - substructure: &Substructure) -> @Expr { + substructure: &Substructure) -> Gc<Expr> { cs_binop(ast::BiOr, cx.expr_bool(span, false), enum_nonmatch_f, cx, span, substructure) @@ -1316,7 +1319,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, #[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, cx: &mut ExtCtxt, span: Span, - substructure: &Substructure) -> @Expr { + substructure: &Substructure) -> Gc<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 602245b4c47..7501b950770 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -20,6 +20,7 @@ use ext::build::AstBuilder; use codemap::{Span,respan}; use owned_slice::OwnedSlice; +use std::gc::Gc; /// The types of pointers pub enum PtrTy<'a> { @@ -81,7 +82,7 @@ impl<'a> Path<'a> { /// A type. Supports pointers (except for *), Self, and literals pub enum Ty<'a> { Self, - // &/Box/@ Ty + // &/Box/ Ty Ptr(Box<Ty<'a>>, PtrTy<'a>), // mod::mod::Type<[lifetime], [Params...]>, including a plain type // parameter, and things like `int` @@ -244,7 +245,7 @@ impl<'a> LifetimeBounds<'a> { pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) - -> (@Expr, ast::ExplicitSelf) { + -> (Gc<Expr>, ast::ExplicitSelf) { let self_path = cx.expr_self(span); match *self_ptr { None => { diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index a9d5f156a99..77fb013b269 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -17,11 +17,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_hash(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let (path, generics, args) = if cx.ecfg.deriving_hash_type_parameter { (Path::new_(vec!("std", "hash", "Hash"), None, @@ -64,7 +66,8 @@ 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) -> @Expr { +fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, + substr: &Substructure) -> Gc<Expr> { let state_expr = match substr.nonself_args { [state_expr] => state_expr, _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(Hash)`") diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 445b21551fd..1833e56dbfb 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -22,6 +22,8 @@ use ast::{Item, MetaItem, MetaList, MetaNameValue, MetaWord}; use ext::base::ExtCtxt; use codemap::Span; +use std::gc::Gc; + pub mod bounds; pub mod clone; pub mod encodable; @@ -47,9 +49,9 @@ pub mod generic; pub fn expand_meta_deriving(cx: &mut ExtCtxt, _span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { match mitem.node { MetaNameValue(_, ref l) => { cx.span_err(l.span, "unexpected value in `deriving`"); diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 0db3233c475..735497d9a2c 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -17,11 +17,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { @@ -70,7 +72,8 @@ 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) -> @Expr { +fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, + substr: &Substructure) -> Gc<Expr> { let n = match substr.nonself_args { [n] => n, _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(FromPrimitive)`") diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 86620f1aa1b..f6a15ea917e 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -16,11 +16,13 @@ use ext::build::{AstBuilder}; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; +use std::gc::Gc; + pub fn expand_deriving_rand(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let trait_def = TraitDef { span: span, attributes: Vec::new(), @@ -53,7 +55,8 @@ 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) -> @Expr { +fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, + substr: &Substructure) -> Gc<Expr> { let rng = match substr.nonself_args { [rng] => vec!( rng ), _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") @@ -134,8 +137,8 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) trait_span: Span, ctor_ident: Ident, summary: &StaticFields, - rand_call: |&mut ExtCtxt, Span| -> @Expr) - -> @Expr { + rand_call: |&mut ExtCtxt, Span| -> Gc<Expr>) + -> Gc<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 1124cf6d7cb..9c5e41c8f60 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -20,12 +20,13 @@ use parse::token; use std::collections::HashMap; use std::string::String; +use std::gc::Gc; pub fn expand_deriving_show(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { // &mut ::std::fmt::Formatter let fmtr = Ptr(box Literal(Path::new(vec!("std", "fmt", "Formatter"))), Borrowed(None, ast::MutMutable)); @@ -57,7 +58,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 at so on. fn show_substructure(cx: &mut ExtCtxt, span: Span, - substr: &Substructure) -> @Expr { + substr: &Substructure) -> Gc<Expr> { // build `<name>`, `<name>({}, {}, ...)` or `<name> { <field>: {}, // <field>: {}, ... }` based on the "shape". // diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 0328f7b470c..93947251223 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -16,11 +16,13 @@ use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; +use std::gc::Gc; + pub fn expand_deriving_zero(cx: &mut ExtCtxt, span: Span, - mitem: @MetaItem, - item: @Item, - push: |@Item|) { + mitem: Gc<MetaItem>, + item: Gc<Item>, + push: |Gc<Item>|) { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { @@ -63,7 +65,8 @@ 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) -> @Expr { +fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, + substr: &Substructure) -> Gc<Expr> { let zero_ident = vec!( cx.ident_of("std"), cx.ident_of("num"), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index bb335e7bed0..9efcb81e844 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -29,7 +29,9 @@ use visit; use visit::Visitor; use util::small_vector::SmallVector; -pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { +use std::gc::Gc; + +pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> { match e.node { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. @@ -115,7 +117,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { fld.fold_expr(marked_after).node.clone(); fld.cx.bt_pop(); - @ast::Expr { + box(GC) ast::Expr { id: ast::DUMMY_NODE_ID, node: fully_expanded, span: e.span, @@ -256,7 +258,7 @@ fn expand_loop_block(loop_block: P<Block>, // in a block enclosed by loop head. fld.extsbox.push_frame(); fld.extsbox.info().pending_renames.push(rename); - let expanded_block = expand_block_elts(loop_block, fld); + let expanded_block = expand_block_elts(&*loop_block, fld); fld.extsbox.pop_frame(); (expanded_block, Some(renamed_ident)) @@ -277,8 +279,8 @@ macro_rules! with_exts_frame ( ) // When we enter a module, record it, for the sake of `module!` -pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander) - -> SmallVector<@ast::Item> { +pub fn expand_item(it: Gc<ast::Item>, fld: &mut MacroExpander) + -> SmallVector<Gc<ast::Item>> { let it = expand_item_modifiers(it, fld); let mut decorator_items = SmallVector::zero(); @@ -301,7 +303,7 @@ pub fn expand_item(it: @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<@ast::Item> = SmallVector::zero(); + let mut items: SmallVector<Gc<ast::Item>> = SmallVector::zero(); dec_fn(fld.cx, attr.span, attr.node.value, it, |item| items.push(item)); decorator_items.extend(items.move_iter() @@ -320,17 +322,17 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander) let macro_escape = contains_macro_escape(new_attrs.as_slice()); let result = with_exts_frame!(fld.extsbox, macro_escape, - noop_fold_item(it, fld)); + noop_fold_item(&*it, fld)); fld.cx.mod_pop(); result }, _ => { - let it = @ast::Item { + let it = box(GC) ast::Item { attrs: new_attrs, ..(*it).clone() }; - noop_fold_item(it, fld) + noop_fold_item(&*it, fld) } }; @@ -338,8 +340,8 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander) new_items } -fn expand_item_modifiers(mut it: @ast::Item, fld: &mut MacroExpander) - -> @ast::Item { +fn expand_item_modifiers(mut it: Gc<ast::Item>, fld: &mut MacroExpander) + -> Gc<ast::Item> { let (modifiers, attrs) = it.attrs.partitioned(|attr| { match fld.extsbox.find(&intern(attr.name().get())) { Some(&ItemModifier(_)) => true, @@ -347,7 +349,7 @@ fn expand_item_modifiers(mut it: @ast::Item, fld: &mut MacroExpander) } }); - it = @ast::Item { + it = box(GC) ast::Item { attrs: attrs, ..(*it).clone() }; @@ -388,8 +390,8 @@ pub fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool { // Support for item-position macro invocations, exactly the same // logic as for expression-position macro invocations. -pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander) - -> SmallVector<@ast::Item> { +pub fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander) + -> SmallVector<Gc<ast::Item>> { let (pth, tts) = match it.node { ItemMac(codemap::Spanned { node: MacInvocTT(ref pth, ref tts, _), @@ -494,7 +496,7 @@ pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander) } // expand a stmt -pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> { +pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<Gc<Stmt>> { // why the copying here and not in expand_expr? // looks like classic changed-in-only-one-place let (pth, tts, semi) = match s.node { @@ -550,7 +552,7 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> { } }; - mark_stmt(expanded,fm) + mark_stmt(&*expanded,fm) } _ => { @@ -561,20 +563,20 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> { }; // Keep going, outside-in. - let fully_expanded = fld.fold_stmt(marked_after); + let fully_expanded = fld.fold_stmt(&*marked_after); if fully_expanded.is_empty() { fld.cx.span_err(pth.span, "macro didn't expand to a statement"); return SmallVector::zero(); } fld.cx.bt_pop(); - let fully_expanded: SmallVector<@Stmt> = fully_expanded.move_iter() - .map(|s| @Spanned { span: s.span, node: s.node.clone() }) + 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 => { - @Spanned { + box(GC) Spanned { span: s.span, node: StmtSemi(e, stmt_id) } @@ -587,7 +589,7 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> { // 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<@Stmt> { + -> SmallVector<Gc<Stmt>> { // is it a let? match s.node { StmtDecl(decl, node_id) => { @@ -612,7 +614,7 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) // names, as well... but that should be okay, as long as // the new names are gensyms for the old ones. let mut name_finder = new_name_finder(Vec::new()); - name_finder.visit_pat(expanded_pat,()); + name_finder.visit_pat(&*expanded_pat,()); // generate fresh names, push them to a new pending list let mut new_pending_renames = Vec::new(); for ident in name_finder.ident_accumulator.iter() { @@ -631,7 +633,7 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) // also, don't forget to expand the init: let new_init_opt = init.map(|e| fld.fold_expr(e)); let rewritten_local = - @Local { + box(GC) Local { ty: local.ty, pat: rewritten_pat, init: new_init_opt, @@ -639,8 +641,8 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) span: span, source: source }; - SmallVector::one(@Spanned { - node: StmtDecl(@Spanned { + SmallVector::one(box(GC) Spanned { + node: StmtDecl(box(GC) Spanned { node: DeclLocal(rewritten_local), span: stmt_span }, @@ -687,7 +689,7 @@ impl Visitor<()> for NewNameFinderContext { } // visit optional subpattern of pat_ident: for subpat in inner.iter() { - self.visit_pat(*subpat, ()) + self.visit_pat(&**subpat, ()) } } // use the default traversal for non-pat_idents @@ -725,9 +727,9 @@ pub fn expand_block_elts(b: &Block, fld: &mut MacroExpander) -> P<Block> { let renamed_stmt = { let pending_renames = &mut fld.extsbox.info().pending_renames; let mut rename_fld = renames_to_fold(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") }; - fld.fold_stmt(renamed_stmt).move_iter() + fld.fold_stmt(&*renamed_stmt).move_iter() }).collect(); let new_expr = b.expr.map(|x| { let expr = { @@ -863,24 +865,24 @@ pub struct MacroExpander<'a, 'b> { } impl<'a, 'b> Folder for MacroExpander<'a, 'b> { - fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr { + fn fold_expr(&mut self, expr: Gc<ast::Expr>) -> Gc<ast::Expr> { expand_expr(expr, self) } - fn fold_pat(&mut self, pat: @ast::Pat) -> @ast::Pat { + fn fold_pat(&mut self, pat: Gc<ast::Pat>) -> Gc<ast::Pat> { expand_pat(pat, self) } - fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> { + fn fold_item(&mut self, item: Gc<ast::Item>) -> SmallVector<Gc<ast::Item>> { expand_item(item, self) } - fn fold_stmt(&mut self, stmt: &ast::Stmt) -> SmallVector<@ast::Stmt> { + fn fold_stmt(&mut self, stmt: &ast::Stmt) -> SmallVector<Gc<ast::Stmt>> { expand_stmt(stmt, self) } fn fold_block(&mut self, block: P<Block>) -> P<Block> { - expand_block(block, self) + expand_block(&*block, self) } fn new_span(&mut self, span: Span) -> Span { @@ -976,7 +978,7 @@ 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: @ast::Expr, m: Mrk) -> @ast::Expr { +fn mark_expr(expr: Gc<ast::Expr>, m: Mrk) -> Gc<ast::Expr> { new_mark_folder(m).fold_expr(expr) } @@ -986,17 +988,17 @@ fn mark_pat(pat: @ast::Pat, m: Mrk) -> @ast::Pat { } // apply a given mark to the given stmt. Used following the expansion of a macro. -fn mark_stmt(expr: &ast::Stmt, m: Mrk) -> @ast::Stmt { +fn mark_stmt(expr: &ast::Stmt, m: Mrk) -> Gc<ast::Stmt> { new_mark_folder(m).fold_stmt(expr) .expect_one("marking a stmt didn't return a stmt") } // apply a given mark to the given item. Used following the expansion of a macro. -fn mark_item(expr: @ast::Item, m: Mrk) -> SmallVector<@ast::Item> { +fn mark_item(expr: Gc<ast::Item>, m: Mrk) -> SmallVector<Gc<ast::Item>> { new_mark_folder(m).fold_item(expr) } -fn original_span(cx: &ExtCtxt) -> @codemap::ExpnInfo { +fn original_span(cx: &ExtCtxt) -> Gc<codemap::ExpnInfo> { let mut relevant_info = cx.backtrace(); let mut einfo = relevant_info.unwrap(); loop { @@ -1134,7 +1136,7 @@ mod test { node: Attribute_ { id: attr::mk_attr_id(), style: AttrOuter, - value: @Spanned { + value: box(GC) Spanned { node: MetaWord(token::intern_and_get_ident(s)), span: codemap::DUMMY_SP, }, diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 2db0d047942..8cf290b826b 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -20,6 +20,7 @@ use rsparse = parse; use parse = fmt_macros; use std::collections::{HashMap, HashSet}; +use std::gc::Gc; #[deriving(PartialEq)] enum ArgumentType { @@ -39,20 +40,20 @@ struct Context<'a, 'b> { // Parsed argument expressions and the types that we've found so far for // them. - args: Vec<@ast::Expr>, + args: Vec<Gc<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, @ast::Expr>, + names: HashMap<String, Gc<ast::Expr>>, name_types: HashMap<String, ArgumentType>, name_ordering: Vec<String>, // Collection of the compiled `rt::Piece` structures - pieces: Vec<@ast::Expr> , + pieces: Vec<Gc<ast::Expr>>, name_positions: HashMap<String, uint>, - method_statics: Vec<@ast::Item> , + method_statics: Vec<Gc<ast::Item>>, // Updated as arguments are consumed or methods are entered nest_level: uint, @@ -60,8 +61,8 @@ struct Context<'a, 'b> { } pub enum Invocation { - Call(@ast::Expr), - MethodCall(@ast::Expr, ast::Ident), + Call(Gc<ast::Expr>), + MethodCall(Gc<ast::Expr>, ast::Ident), } /// Parses the arguments from the given list of tokens, returning None @@ -74,10 +75,10 @@ pub enum Invocation { /// named arguments)) fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool, tts: &[ast::TokenTree]) - -> (Invocation, Option<(@ast::Expr, Vec<@ast::Expr>, Vec<String>, - HashMap<String, @ast::Expr>)>) { + -> (Invocation, Option<(Gc<ast::Expr>, Vec<Gc<ast::Expr>>, Vec<String>, + HashMap<String, Gc<ast::Expr>>)>) { let mut args = Vec::new(); - let mut names = HashMap::<String, @ast::Expr>::new(); + let mut names = HashMap::<String, Gc<ast::Expr>>::new(); let mut order = Vec::new(); let mut p = rsparse::new_parser_from_tts(ecx.parse_sess(), @@ -399,7 +400,7 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.ident_of("rt"), self.ecx.ident_of(s)) } - fn none(&self) -> @ast::Expr { + fn none(&self) -> Gc<ast::Expr> { let none = self.ecx.path_global(self.fmtsp, vec!( self.ecx.ident_of("std"), self.ecx.ident_of("option"), @@ -407,7 +408,7 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.expr_path(none) } - fn some(&self, e: @ast::Expr) -> @ast::Expr { + fn some(&self, e: Gc<ast::Expr>) -> Gc<ast::Expr> { let p = self.ecx.path_global(self.fmtsp, vec!( self.ecx.ident_of("std"), self.ecx.ident_of("option"), @@ -416,7 +417,7 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.expr_call(self.fmtsp, p, vec!(e)) } - fn trans_count(&self, c: parse::Count) -> @ast::Expr { + fn trans_count(&self, c: parse::Count) -> Gc<ast::Expr> { let sp = self.fmtsp; match c { parse::CountIs(i) => { @@ -447,7 +448,7 @@ impl<'a, 'b> Context<'a, 'b> { } } - fn trans_method(&mut self, method: &parse::Method) -> @ast::Expr { + fn trans_method(&mut self, method: &parse::Method) -> Gc<ast::Expr> { let sp = self.fmtsp; let method = match *method { parse::Select(ref arms, ref default) => { @@ -528,7 +529,7 @@ impl<'a, 'b> Context<'a, 'b> { } /// Translate a `parse::Piece` to a static `rt::Piece` - fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr { + fn trans_piece(&mut self, piece: &parse::Piece) -> Gc<ast::Expr> { let sp = self.fmtsp; match *piece { parse::String(s) => { @@ -615,7 +616,7 @@ impl<'a, 'b> Context<'a, 'b> { /// Actually builds the expression which the iformat! block will be expanded /// to - fn to_expr(&self, invocation: Invocation) -> @ast::Expr { + fn to_expr(&self, invocation: Invocation) -> Gc<ast::Expr> { let mut lets = Vec::new(); let mut locals = Vec::new(); let mut names = Vec::from_fn(self.name_positions.len(), |_| None); @@ -625,8 +626,8 @@ impl<'a, 'b> Context<'a, 'b> { // First, declare all of our methods that are statics for &method in self.method_statics.iter() { let decl = respan(self.fmtsp, ast::DeclItem(method)); - lets.push(@respan(self.fmtsp, - ast::StmtDecl(@decl, ast::DUMMY_NODE_ID))); + lets.push(box(GC) respan(self.fmtsp, + ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))); } // Next, build up the static array which will become our precompiled @@ -653,7 +654,8 @@ impl<'a, 'b> Context<'a, 'b> { let item = self.ecx.item(self.fmtsp, static_name, self.static_attrs(), st); let decl = respan(self.fmtsp, ast::DeclItem(item)); - lets.push(@respan(self.fmtsp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID))); + lets.push(box(GC) respan(self.fmtsp, + ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))); // Right now there is a bug such that for the expression: // foo(bar(&1)) @@ -766,8 +768,8 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.expr_match(self.fmtsp, head, vec!(arm)) } - fn format_arg(&self, sp: Span, argno: Position, arg: @ast::Expr) - -> @ast::Expr { + 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) @@ -854,9 +856,12 @@ pub fn expand_format_args_method(ecx: &mut ExtCtxt, sp: Span, /// expression. pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, invocation: Invocation, - efmt: @ast::Expr, args: Vec<@ast::Expr>, + efmt: Gc<ast::Expr>, + args: Vec<Gc<ast::Expr>>, name_ordering: Vec<String>, - names: HashMap<String, @ast::Expr>) -> @ast::Expr { + names: HashMap<String, Gc<ast::Expr>>) + -> Gc<ast::Expr> +{ let arg_types = Vec::from_fn(args.len(), |_| None); let mut cx = Context { ecx: ecx, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 0f5928ee198..5906f480d42 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -17,6 +17,7 @@ use parse::token::*; use parse::token; use parse; +use std::gc::Gc; /** * @@ -50,6 +51,8 @@ pub mod rt { 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> ; } @@ -85,13 +88,13 @@ pub mod rt { } } - impl ToSource for @ast::Item { + impl ToSource for Gc<ast::Item> { fn to_source(&self) -> String { pprust::item_to_str(*self) } } - impl<'a> ToSource for &'a [@ast::Item] { + impl<'a> ToSource for &'a [Gc<ast::Item>] { fn to_source(&self) -> String { self.iter() .map(|i| i.to_source()) @@ -123,7 +126,7 @@ pub mod rt { } } - impl ToSource for @ast::Expr { + impl ToSource for Gc<ast::Expr> { fn to_source(&self) -> String { pprust::expr_to_str(*self) } @@ -263,12 +266,12 @@ pub mod rt { ) impl_to_tokens!(ast::Ident) - impl_to_tokens!(@ast::Item) - impl_to_tokens_self!(&'a [@ast::Item]) + impl_to_tokens!(Gc<ast::Item>) + impl_to_tokens_self!(&'a [Gc<ast::Item>]) impl_to_tokens!(ast::Ty) impl_to_tokens_self!(&'a [ast::Ty]) impl_to_tokens!(Generics) - impl_to_tokens!(@ast::Expr) + impl_to_tokens!(Gc<ast::Expr>) impl_to_tokens!(ast::Block) impl_to_tokens!(ast::Arg) impl_to_tokens_self!(&'a str) @@ -287,15 +290,15 @@ pub mod rt { impl_to_tokens!(u64) pub trait ExtParseUtils { - fn parse_item(&self, s: String) -> @ast::Item; - fn parse_expr(&self, s: String) -> @ast::Expr; - fn parse_stmt(&self, s: String) -> @ast::Stmt; + 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_tts(&self, s: String) -> Vec<ast::TokenTree> ; } impl<'a> ExtParseUtils for ExtCtxt<'a> { - fn parse_item(&self, s: String) -> @ast::Item { + fn parse_item(&self, s: String) -> Gc<ast::Item> { let res = parse::parse_item_from_source_str( "<quote expansion>".to_string(), s, @@ -310,7 +313,7 @@ pub mod rt { } } - fn parse_stmt(&self, s: String) -> @ast::Stmt { + fn parse_stmt(&self, s: String) -> Gc<ast::Stmt> { parse::parse_stmt_from_source_str("<quote expansion>".to_string(), s, self.cfg(), @@ -318,7 +321,7 @@ pub mod rt { self.parse_sess()) } - fn parse_expr(&self, s: String) -> @ast::Expr { + fn parse_expr(&self, s: String) -> Gc<ast::Expr> { parse::parse_expr_from_source_str("<quote expansion>".to_string(), s, self.cfg(), @@ -400,7 +403,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) -> @ast::Expr { +fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> Gc<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")), @@ -408,17 +411,17 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { vec!(e_str)) } -fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> @ast::Expr { +fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> Gc<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) -> @ast::Expr { +fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> Gc<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) -> @ast::Expr { +fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> Gc<ast::Expr> { let name = match bop { PLUS => "PLUS", MINUS => "MINUS", @@ -434,7 +437,7 @@ fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> @ast::Expr { mk_token_path(cx, sp, name) } -fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { +fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> Gc<ast::Expr> { match *tok { BINOP(binop) => { @@ -565,7 +568,8 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { mk_token_path(cx, sp, name) } -fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<@ast::Stmt> { + +fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<Gc<ast::Stmt>> { match *tt { ast::TTTok(sp, ref tok) => { let e_sp = cx.expr_ident(sp, id_ext("_sp")); @@ -605,7 +609,7 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<@ast::Stmt> { } fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Vec<@ast::Stmt> { + -> Vec<Gc<ast::Stmt>> { let mut ss = Vec::new(); for tt in tts.iter() { ss.push_all_move(mk_tt(cx, sp, tt)); @@ -614,7 +618,7 @@ fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> (@ast::Expr, @ast::Expr) { + -> (Gc<ast::Expr>, Gc<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 @@ -686,8 +690,8 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) fn expand_wrapper(cx: &ExtCtxt, sp: Span, - cx_expr: @ast::Expr, - expr: @ast::Expr) -> @ast::Expr { + cx_expr: Gc<ast::Expr>, + expr: Gc<ast::Expr>) -> Gc<ast::Expr> { let uses = [ &["syntax", "ext", "quote", "rt"], ].iter().map(|path| { @@ -703,8 +707,8 @@ fn expand_wrapper(cx: &ExtCtxt, fn expand_parse_call(cx: &ExtCtxt, sp: Span, parse_method: &str, - arg_exprs: Vec<@ast::Expr> , - tts: &[ast::TokenTree]) -> @ast::Expr { + arg_exprs: Vec<Gc<ast::Expr>>, + tts: &[ast::TokenTree]) -> Gc<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/source_util.rs b/src/libsyntax/ext/source_util.rs index 93b66ede267..915fc16c156 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -19,6 +19,7 @@ use parse; use parse::token; use print::pprust; +use std::gc::Gc; use std::io::File; use std::rc::Rc; use std::str; @@ -163,7 +164,7 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } // recur along an ExpnInfo chain to find the original expression -fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { +fn topmost_expn_info(expn_info: Gc<codemap::ExpnInfo>) -> Gc<codemap::ExpnInfo> { match *expn_info { ExpnInfo { call_site: ref call_site, .. } => { match call_site.expn_info { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e74861f6efe..85035a8d38e 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -452,7 +452,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(@p.parse_token_tree()); + let res = token::NtTT(box(GC) 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 c78d4d258f6..6607b6451c0 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -29,6 +29,7 @@ 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 +59,17 @@ impl<'a> ParserAnyMacro<'a> { } impl<'a> MacResult for ParserAnyMacro<'a> { - fn make_expr(&self) -> Option<@ast::Expr> { + fn make_expr(&self) -> Option<Gc<ast::Expr>> { let ret = self.parser.borrow_mut().parse_expr(); self.ensure_complete_parse(true); Some(ret) } - fn make_pat(&self) -> Option<@ast::Pat> { + fn make_pat(&self) -> Option<Gc<ast::Pat>> { let ret = self.parser.borrow_mut().parse_pat(); self.ensure_complete_parse(false); Some(ret) } - fn make_items(&self) -> Option<SmallVector<@ast::Item>> { + fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); @@ -81,7 +82,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { self.ensure_complete_parse(false); Some(ret) } - fn make_stmt(&self) -> Option<@ast::Stmt> { + fn make_stmt(&self) -> Option<Gc<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); |
