From 54c2a1e1ce7f32576f0692a1de3fe2763d13bac9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 16 May 2014 10:15:33 -0700 Subject: rustc: Move the AST from @T to Gc --- src/libsyntax/ext/base.rs | 12 ++++++------ src/libsyntax/ext/expand.rs | 11 ++++++----- src/libsyntax/ext/quote.rs | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index f9a9e276eb0..7ba517a3aed 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -113,7 +113,7 @@ pub trait MacResult { None } /// Create a pattern. - fn make_pat(&self) -> Option<@ast::Pat> { + fn make_pat(&self) -> Option> { None } @@ -143,15 +143,15 @@ impl MacResult for MacExpr { } /// A convenience type for macros that return a single pattern. pub struct MacPat { - p: @ast::Pat + p: Gc, } impl MacPat { - pub fn new(p: @ast::Pat) -> Box { + pub fn new(p: Gc) -> Box { box MacPat { p: p } as Box } } impl MacResult for MacPat { - fn make_pat(&self) -> Option<@ast::Pat> { + fn make_pat(&self) -> Option> { Some(self.p) } } @@ -212,8 +212,8 @@ impl DummyResult { } /// A plain dummy pattern. - pub fn raw_pat(sp: Span) -> @ast::Pat { - @ast::Pat { + pub fn raw_pat(sp: Span) -> Gc { + box(GC) ast::Pat { id: ast::DUMMY_NODE_ID, node: ast::PatWild, span: sp, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9efcb81e844..fffaa12fa1f 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -174,7 +174,7 @@ pub fn expand_expr(e: Gc, fld: &mut MacroExpander) -> Gc { let value_ident = token::gensym_ident("__value"); // this is careful to use src_pat.span so that error // messages point exact at that. - let local = @ast::Local { + let local = box(GC) ast::Local { ty: fld.cx.ty_infer(src_pat.span), pat: src_pat, init: Some(fld.cx.expr_ident(src_pat.span, value_ident)), @@ -183,7 +183,8 @@ pub fn expand_expr(e: Gc, fld: &mut MacroExpander) -> Gc { source: ast::LocalFor }; let local = codemap::respan(src_pat.span, ast::DeclLocal(local)); - let local = @codemap::respan(span, ast::StmtDecl(@local, ast::DUMMY_NODE_ID)); + let local = box(GC) codemap::respan(span, ast::StmtDecl(box(GC) local, + ast::DUMMY_NODE_ID)); // { let ...; } let block = fld.cx.block(span, vec![local], @@ -749,7 +750,7 @@ pub fn expand_block_elts(b: &Block, fld: &mut MacroExpander) -> P { }) } -pub fn expand_pat(p: @ast::Pat, fld: &mut MacroExpander) -> @ast::Pat { +pub fn expand_pat(p: Gc, fld: &mut MacroExpander) -> Gc { let (pth, tts) = match p.node { PatMac(ref mac) => { match mac.node { @@ -819,7 +820,7 @@ pub fn expand_pat(p: @ast::Pat, fld: &mut MacroExpander) -> @ast::Pat { fld.fold_pat(marked_after).node.clone(); fld.cx.bt_pop(); - @ast::Pat { + box(GC) ast::Pat { id: ast::DUMMY_NODE_ID, node: fully_expanded, span: p.span, @@ -983,7 +984,7 @@ fn mark_expr(expr: Gc, m: Mrk) -> Gc { } // apply a given mark to the given pattern. Used following the expansion of a macro. -fn mark_pat(pat: @ast::Pat, m: Mrk) -> @ast::Pat { +fn mark_pat(pat: Gc, m: Mrk) -> Gc { new_mark_folder(m).fold_pat(pat) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 5906f480d42..185924f704c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -90,7 +90,7 @@ pub mod rt { impl ToSource for Gc { fn to_source(&self) -> String { - pprust::item_to_str(*self) + pprust::item_to_str(&**self) } } @@ -128,7 +128,7 @@ pub mod rt { impl ToSource for Gc { fn to_source(&self) -> String { - pprust::expr_to_str(*self) + pprust::expr_to_str(&**self) } } -- cgit 1.4.1-3-g733a5