From ccd8498afbb371939b7decdbee712f726ccbded3 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sat, 13 Sep 2014 19:06:01 +0300 Subject: syntax: fix fallout from using ptr::P. --- src/libsyntax/ext/tt/macro_parser.rs | 4 ++-- src/libsyntax/ext/tt/macro_rules.rs | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/libsyntax/ext/tt') diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 509d5bd4421..3006bcaf6f8 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -87,9 +87,9 @@ use parse::attr::ParserAttr; use parse::parser::{LifetimeAndTypesWithoutColons, Parser}; use parse::token::{Token, EOF, Nonterminal}; use parse::token; +use ptr::P; use std::rc::Rc; -use std::gc::GC; use std::collections::HashMap; /* to avoid costly uniqueness checks, we require that `MatchSeq` always has a @@ -451,7 +451,7 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { "meta" => token::NtMeta(p.parse_meta_item()), "tt" => { p.quote_depth += 1u; //but in theory, non-quoted tts might be useful - let res = token::NtTT(box(GC) p.parse_token_tree()); + let res = token::NtTT(P(p.parse_token_tree())); p.quote_depth -= 1u; res } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index d8f0eb32ad7..6c7bbb2384c 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq}; -use ast::{TTDelim}; +use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq, TTDelim}; use ast; use codemap::{Span, Spanned, DUMMY_SP}; use ext::base::{ExtCtxt, MacResult, MacroDef}; @@ -24,11 +23,12 @@ use parse::token::{special_idents, gensym_ident}; use parse::token::{FAT_ARROW, SEMI, NtMatchers, NtTT, EOF}; use parse::token; use print; +use ptr::P; + use util::small_vector::SmallVector; use std::cell::RefCell; use std::rc::Rc; -use std::gc::Gc; struct ParserAnyMacro<'a> { parser: RefCell>, @@ -58,17 +58,17 @@ impl<'a> ParserAnyMacro<'a> { } impl<'a> MacResult for ParserAnyMacro<'a> { - fn make_expr(&self) -> Option> { + fn make_expr(self: Box>) -> Option> { let ret = self.parser.borrow_mut().parse_expr(); self.ensure_complete_parse(true); Some(ret) } - fn make_pat(&self) -> Option> { + fn make_pat(self: Box>) -> Option> { let ret = self.parser.borrow_mut().parse_pat(); self.ensure_complete_parse(false); Some(ret) } - fn make_items(&self) -> Option>> { + fn make_items(self: Box>) -> Option>> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); @@ -84,7 +84,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { Some(ret) } - fn make_methods(&self) -> Option>> { + fn make_methods(self: Box>) -> Option>> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); @@ -97,7 +97,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { Some(ret) } - fn make_stmt(&self) -> Option> { + fn make_stmt(self: Box>) -> Option> { let attrs = self.parser.borrow_mut().parse_outer_attributes(); let ret = self.parser.borrow_mut().parse_stmt(attrs); self.ensure_complete_parse(true); @@ -127,11 +127,11 @@ impl TTMacroExpander for MacroRulesMacroExpander { } struct MacroRulesDefiner { - def: RefCell> + def: Option } impl MacResult for MacroRulesDefiner { - fn make_def(&self) -> Option { - Some(self.def.borrow_mut().take().expect("MacroRulesDefiner expanded twice")) + fn make_def(&mut self) -> Option { + Some(self.def.take().expect("empty MacroRulesDefiner")) } } @@ -170,8 +170,8 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, Success(named_matches) => { let rhs = match *rhses[i] { // okay, what's your transcriber? - MatchedNonterminal(NtTT(tt)) => { - match *tt { + MatchedNonterminal(NtTT(ref tt)) => { + match **tt { // cut off delimiters; don't parse 'em TTDelim(ref tts) => { (*tts).slice(1u,(*tts).len()-1u) @@ -269,9 +269,9 @@ pub fn add_new_extension<'cx>(cx: &'cx mut ExtCtxt, }; box MacroRulesDefiner { - def: RefCell::new(Some(MacroDef { + def: Some(MacroDef { name: token::get_ident(name).to_string(), ext: NormalTT(exp, Some(sp)) - })) + }) } as Box } -- cgit 1.4.1-3-g733a5