diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-02-11 23:33:09 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-02-11 23:33:09 +0300 |
| commit | 77cc5764b9d8b53e01788886d3b3882dffc0001e (patch) | |
| tree | abbe5a51d013a64fb25383641311689011b7d03f /src/libsyntax/ext | |
| parent | aa1dc0975a43e224386ec0ed1bb7ae09cfd0dd7e (diff) | |
| download | rust-77cc5764b9d8b53e01788886d3b3882dffc0001e.tar.gz rust-77cc5764b9d8b53e01788886d3b3882dffc0001e.zip | |
Remove some unnecessary indirection from AST structures
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 32 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 46 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 89 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 4 |
6 files changed, 101 insertions, 98 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 381d952ea88..b4e86e4cfd3 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -82,16 +82,16 @@ impl Annotatable { } } - pub fn expect_trait_item(self) -> P<ast::TraitItem> { + pub fn expect_trait_item(self) -> ast::TraitItem { match self { - Annotatable::TraitItem(i) => i, + Annotatable::TraitItem(i) => i.unwrap(), _ => panic!("expected Item") } } - pub fn expect_impl_item(self) -> P<ast::ImplItem> { + pub fn expect_impl_item(self) -> ast::ImplItem { match self { - Annotatable::ImplItem(i) => i, + Annotatable::ImplItem(i) => i.unwrap(), _ => panic!("expected Item") } } @@ -204,8 +204,8 @@ impl<F> IdentMacroExpander for F macro_rules! make_stmts_default { ($me:expr) => { $me.make_expr().map(|e| { - SmallVector::one(P(codemap::respan( - e.span, ast::StmtKind::Expr(e, ast::DUMMY_NODE_ID)))) + SmallVector::one(codemap::respan( + e.span, ast::StmtKind::Expr(e, ast::DUMMY_NODE_ID))) }) } } @@ -223,7 +223,7 @@ pub trait MacResult { } /// Create zero or more impl items. - fn make_impl_items(self: Box<Self>) -> Option<SmallVector<P<ast::ImplItem>>> { + fn make_impl_items(self: Box<Self>) -> Option<SmallVector<ast::ImplItem>> { None } @@ -236,7 +236,7 @@ pub trait MacResult { /// /// By default this attempts to create an expression statement, /// returning None if that fails. - fn make_stmts(self: Box<Self>) -> Option<SmallVector<P<ast::Stmt>>> { + fn make_stmts(self: Box<Self>) -> Option<SmallVector<ast::Stmt>> { make_stmts_default!(self) } @@ -273,8 +273,8 @@ make_MacEager! { expr: P<ast::Expr>, pat: P<ast::Pat>, items: SmallVector<P<ast::Item>>, - impl_items: SmallVector<P<ast::ImplItem>>, - stmts: SmallVector<P<ast::Stmt>>, + impl_items: SmallVector<ast::ImplItem>, + stmts: SmallVector<ast::Stmt>, ty: P<ast::Ty>, } @@ -287,11 +287,11 @@ impl MacResult for MacEager { self.items } - fn make_impl_items(self: Box<Self>) -> Option<SmallVector<P<ast::ImplItem>>> { + fn make_impl_items(self: Box<Self>) -> Option<SmallVector<ast::ImplItem>> { self.impl_items } - fn make_stmts(self: Box<Self>) -> Option<SmallVector<P<ast::Stmt>>> { + fn make_stmts(self: Box<Self>) -> Option<SmallVector<ast::Stmt>> { match self.stmts.as_ref().map_or(0, |s| s.len()) { 0 => make_stmts_default!(self), _ => self.stmts, @@ -391,7 +391,7 @@ impl MacResult for DummyResult { } } - fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::ImplItem>>> { + fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVector<ast::ImplItem>> { if self.expr_only { None } else { @@ -399,11 +399,11 @@ impl MacResult for DummyResult { } } - fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Stmt>>> { - Some(SmallVector::one(P( + fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<ast::Stmt>> { + Some(SmallVector::one( codemap::respan(self.span, ast::StmtKind::Expr(DummyResult::raw_expr(self.span), - ast::DUMMY_NODE_ID))))) + ast::DUMMY_NODE_ID)))) } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 31d5521799e..38af8353aea 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -34,7 +34,7 @@ pub trait AstBuilder { idents: Vec<ast::Ident> , lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, - bindings: Vec<P<ast::TypeBinding>> ) + bindings: Vec<ast::TypeBinding> ) -> ast::Path; fn qpath(&self, self_type: P<ast::Ty>, @@ -46,7 +46,7 @@ pub trait AstBuilder { ident: ast::Ident, lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, - bindings: Vec<P<ast::TypeBinding>>) + bindings: Vec<ast::TypeBinding>) -> (ast::QSelf, ast::Path); // types @@ -88,8 +88,8 @@ pub trait AstBuilder { -> ast::LifetimeDef; // statements - fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt>; - fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P<ast::Expr>) -> P<ast::Stmt>; + fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt; + fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P<ast::Expr>) -> ast::Stmt; fn stmt_let_typed(&self, sp: Span, mutbl: bool, @@ -97,14 +97,14 @@ pub trait AstBuilder { typ: P<ast::Ty>, ex: P<ast::Expr>) -> P<ast::Stmt>; - fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt>; + fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt; // blocks - fn block(&self, span: Span, stmts: Vec<P<ast::Stmt>>, + fn block(&self, span: Span, stmts: Vec<ast::Stmt>, expr: Option<P<ast::Expr>>) -> P<ast::Block>; fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block>; fn block_all(&self, span: Span, - stmts: Vec<P<ast::Stmt>>, + stmts: Vec<ast::Stmt>, expr: Option<P<ast::Expr>>) -> P<ast::Block>; // expressions @@ -206,9 +206,9 @@ pub trait AstBuilder { fn lambda_expr_1(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>; fn lambda_stmts(&self, span: Span, ids: Vec<ast::Ident>, - blk: Vec<P<ast::Stmt>>) -> P<ast::Expr>; - fn lambda_stmts_0(&self, span: Span, stmts: Vec<P<ast::Stmt>>) -> P<ast::Expr>; - fn lambda_stmts_1(&self, span: Span, stmts: Vec<P<ast::Stmt>>, + blk: Vec<ast::Stmt>) -> P<ast::Expr>; + fn lambda_stmts_0(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Expr>; + fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>, ident: ast::Ident) -> P<ast::Expr>; // items @@ -315,7 +315,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mut idents: Vec<ast::Ident> , lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, - bindings: Vec<P<ast::TypeBinding>> ) + bindings: Vec<ast::TypeBinding> ) -> ast::Path { let last_identifier = idents.pop().unwrap(); let mut segments: Vec<ast::PathSegment> = idents.into_iter() @@ -360,7 +360,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ident: ast::Ident, lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, - bindings: Vec<P<ast::TypeBinding>>) + bindings: Vec<ast::TypeBinding>) -> (ast::QSelf, ast::Path) { let mut path = trait_path; path.segments.push(ast::PathSegment { @@ -505,12 +505,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } } - fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt> { - P(respan(expr.span, ast::StmtKind::Semi(expr, ast::DUMMY_NODE_ID))) + fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt { + respan(expr.span, ast::StmtKind::Semi(expr, ast::DUMMY_NODE_ID)) } fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, - ex: P<ast::Expr>) -> P<ast::Stmt> { + ex: P<ast::Expr>) -> ast::Stmt { let pat = if mutbl { let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable); self.pat_ident_binding_mode(sp, ident, binding_mode) @@ -526,7 +526,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { attrs: None, }); let decl = respan(sp, ast::DeclKind::Local(local)); - P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) + respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)) } fn stmt_let_typed(&self, @@ -554,14 +554,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } - fn block(&self, span: Span, stmts: Vec<P<ast::Stmt>>, + fn block(&self, span: Span, stmts: Vec<ast::Stmt>, expr: Option<P<Expr>>) -> P<ast::Block> { self.block_all(span, stmts, expr) } - fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt> { + fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt { let decl = respan(sp, ast::DeclKind::Item(item)); - P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) + respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)) } fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block> { @@ -569,7 +569,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn block_all(&self, span: Span, - stmts: Vec<P<ast::Stmt>>, + stmts: Vec<ast::Stmt>, expr: Option<P<ast::Expr>>) -> P<ast::Block> { P(ast::Block { stmts: stmts, @@ -923,14 +923,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn lambda_stmts(&self, span: Span, ids: Vec<ast::Ident>, - stmts: Vec<P<ast::Stmt>>) + stmts: Vec<ast::Stmt>) -> P<ast::Expr> { self.lambda(span, ids, self.block(span, stmts, None)) } - fn lambda_stmts_0(&self, span: Span, stmts: Vec<P<ast::Stmt>>) -> P<ast::Expr> { + fn lambda_stmts_0(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Expr> { self.lambda0(span, self.block(span, stmts, None)) } - fn lambda_stmts_1(&self, span: Span, stmts: Vec<P<ast::Stmt>>, + fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>, ident: ast::Ident) -> P<ast::Expr> { self.lambda1(span, self.block(span, stmts, None), ident) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c4bbe709f34..1ee108217c6 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -503,8 +503,7 @@ pub fn expand_item_mac(it: P<ast::Item>, } /// Expand a stmt -fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { - let stmt = stmt.and_then(|stmt| stmt); +fn expand_stmt(stmt: Stmt, fld: &mut MacroExpander) -> SmallVector<Stmt> { let (mac, style, attrs) = match stmt.node { StmtKind::Mac(mac, style, attrs) => (mac, style, attrs), _ => return expand_non_macro_stmt(stmt, fld) @@ -514,7 +513,7 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { drop(attrs); let maybe_new_items = - expand_mac_invoc(mac.and_then(|m| m), stmt.span, + expand_mac_invoc(mac.unwrap(), stmt.span, |r| r.make_stmts(), |stmts, mark| stmts.move_map(|m| mark_stmt(m, mark)), fld); @@ -535,15 +534,13 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { // semicolon to the final statement produced by expansion. if style == MacStmtStyle::Semicolon { if let Some(stmt) = fully_expanded.pop() { - let new_stmt = stmt.map(|Spanned {node, span}| { - Spanned { - node: match node { - StmtKind::Expr(e, stmt_id) => StmtKind::Semi(e, stmt_id), - _ => node /* might already have a semi */ - }, - span: span - } - }); + let new_stmt = Spanned { + node: match stmt.node { + StmtKind::Expr(e, stmt_id) => StmtKind::Semi(e, stmt_id), + _ => stmt.node /* might already have a semi */ + }, + span: stmt.span + }; fully_expanded.push(new_stmt); } } @@ -554,7 +551,7 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { // expand a non-macro stmt. this is essentially the fallthrough for // expand_stmt, above. fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroExpander) - -> SmallVector<P<Stmt>> { + -> SmallVector<Stmt> { // is it a let? match node { StmtKind::Decl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl { @@ -594,14 +591,14 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE attrs: fold::fold_thin_attrs(attrs, fld), } }); - SmallVector::one(P(Spanned { + SmallVector::one(Spanned { node: StmtKind::Decl(P(Spanned { node: DeclKind::Local(rewritten_local), span: span }), node_id), span: stmt_span - })) + }) } _ => { noop_fold_stmt(Spanned { @@ -919,24 +916,28 @@ fn expand_annotatable(a: Annotatable, }, Annotatable::TraitItem(it) => match it.node { - ast::TraitItemKind::Method(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem { - id: ti.id, - ident: ti.ident, - attrs: ti.attrs, - node: match ti.node { - ast::TraitItemKind::Method(sig, Some(body)) => { - let (sig, body) = expand_and_rename_method(sig, body, fld); - ast::TraitItemKind::Method(sig, Some(body)) - } - _ => unreachable!() - }, - span: fld.new_span(ti.span) - })), - _ => fold::noop_fold_trait_item(it, fld) - }.into_iter().map(Annotatable::TraitItem).collect(), + ast::TraitItemKind::Method(_, Some(_)) => { + let ti = it.unwrap(); + SmallVector::one(ast::TraitItem { + id: ti.id, + ident: ti.ident, + attrs: ti.attrs, + node: match ti.node { + ast::TraitItemKind::Method(sig, Some(body)) => { + let (sig, body) = expand_and_rename_method(sig, body, fld); + ast::TraitItemKind::Method(sig, Some(body)) + } + _ => unreachable!() + }, + span: fld.new_span(ti.span) + }) + } + _ => fold::noop_fold_trait_item(it.unwrap(), fld) + }.into_iter().map(|ti| Annotatable::TraitItem(P(ti))).collect(), Annotatable::ImplItem(ii) => { - expand_impl_item(ii, fld).into_iter().map(Annotatable::ImplItem).collect() + expand_impl_item(ii.unwrap(), fld).into_iter(). + map(|ii| Annotatable::ImplItem(P(ii))).collect() } }; @@ -1052,10 +1053,10 @@ fn expand_item_multi_modifier(mut it: Annotatable, expand_item_multi_modifier(it, fld) } -fn expand_impl_item(ii: P<ast::ImplItem>, fld: &mut MacroExpander) - -> SmallVector<P<ast::ImplItem>> { +fn expand_impl_item(ii: ast::ImplItem, fld: &mut MacroExpander) + -> SmallVector<ast::ImplItem> { match ii.node { - ast::ImplItemKind::Method(..) => SmallVector::one(ii.map(|ii| ast::ImplItem { + ast::ImplItemKind::Method(..) => SmallVector::one(ast::ImplItem { id: ii.id, ident: ii.ident, attrs: ii.attrs, @@ -1068,12 +1069,12 @@ fn expand_impl_item(ii: P<ast::ImplItem>, fld: &mut MacroExpander) _ => unreachable!() }, span: fld.new_span(ii.span) - })), + }), ast::ImplItemKind::Macro(_) => { - let (span, mac) = ii.and_then(|ii| match ii.node { + let (span, mac) = match ii.node { ast::ImplItemKind::Macro(mac) => (ii.span, mac), _ => unreachable!() - }); + }; let maybe_new_items = expand_mac_invoc(mac, span, |r| r.make_impl_items(), @@ -1198,7 +1199,7 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> { expand_item_kind(item, self) } - fn fold_stmt(&mut self, stmt: P<ast::Stmt>) -> SmallVector<P<ast::Stmt>> { + fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVector<ast::Stmt> { expand_stmt(stmt, self) } @@ -1210,13 +1211,13 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> { expand_arm(arm, self) } - fn fold_trait_item(&mut self, i: P<ast::TraitItem>) -> SmallVector<P<ast::TraitItem>> { - expand_annotatable(Annotatable::TraitItem(i), self) + fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVector<ast::TraitItem> { + expand_annotatable(Annotatable::TraitItem(P(i)), self) .into_iter().map(|i| i.expect_trait_item()).collect() } - fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> { - expand_annotatable(Annotatable::ImplItem(i), self) + fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVector<ast::ImplItem> { + expand_annotatable(Annotatable::ImplItem(P(i)), self) .into_iter().map(|i| i.expect_impl_item()).collect() } @@ -1359,7 +1360,7 @@ fn mark_pat(pat: P<ast::Pat>, m: Mrk) -> P<ast::Pat> { } // apply a given mark to the given stmt. Used following the expansion of a macro. -fn mark_stmt(stmt: P<ast::Stmt>, m: Mrk) -> P<ast::Stmt> { +fn mark_stmt(stmt: ast::Stmt, m: Mrk) -> ast::Stmt { Marker{mark:m}.fold_stmt(stmt) .expect_one("marking a stmt didn't return exactly one stmt") } @@ -1371,7 +1372,7 @@ fn mark_item(expr: P<ast::Item>, m: Mrk) -> P<ast::Item> { } // apply a given mark to the given item. Used following the expansion of a macro. -fn mark_impl_item(ii: P<ast::ImplItem>, m: Mrk) -> P<ast::ImplItem> { +fn mark_impl_item(ii: ast::ImplItem, m: Mrk) -> ast::ImplItem { Marker{mark:m}.fold_impl_item(ii) .expect_one("marking an impl item didn't return exactly one impl item") } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 57db1347021..d0eaa89e4ae 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -114,22 +114,24 @@ pub mod rt { } } - impl ToTokens for P<ast::ImplItem> { + impl ToTokens for ast::ImplItem { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> { - vec![TokenTree::Token(self.span, token::Interpolated(token::NtImplItem(self.clone())))] + vec![TokenTree::Token(self.span, + token::Interpolated(token::NtImplItem(P(self.clone()))))] } } - impl ToTokens for P<ast::TraitItem> { + impl ToTokens for ast::TraitItem { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> { - vec![TokenTree::Token(self.span, token::Interpolated(token::NtTraitItem(self.clone())))] + vec![TokenTree::Token(self.span, + token::Interpolated(token::NtTraitItem(P(self.clone()))))] } } - impl ToTokens for P<ast::Stmt> { + impl ToTokens for ast::Stmt { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> { let mut tts = vec![ - TokenTree::Token(self.span, token::Interpolated(token::NtStmt(self.clone()))) + TokenTree::Token(self.span, token::Interpolated(token::NtStmt(P(self.clone())))) ]; // Some statements require a trailing semicolon. @@ -312,7 +314,7 @@ pub mod rt { pub trait ExtParseUtils { fn parse_item(&self, s: String) -> P<ast::Item>; fn parse_expr(&self, s: String) -> P<ast::Expr>; - fn parse_stmt(&self, s: String) -> P<ast::Stmt>; + fn parse_stmt(&self, s: String) -> ast::Stmt; fn parse_tts(&self, s: String) -> Vec<TokenTree>; } @@ -326,7 +328,7 @@ pub mod rt { self.parse_sess()).expect("parse error") } - fn parse_stmt(&self, s: String) -> P<ast::Stmt> { + fn parse_stmt(&self, s: String) -> ast::Stmt { parse::parse_stmt_from_source_str("<quote expansion>".to_string(), s, self.cfg(), @@ -371,7 +373,7 @@ pub fn parse_ty_panic(parser: &mut Parser) -> P<Ty> { panictry!(parser.parse_ty()) } -pub fn parse_stmt_panic(parser: &mut Parser) -> Option<P<Stmt>> { +pub fn parse_stmt_panic(parser: &mut Parser) -> Option<Stmt> { panictry!(parser.parse_stmt()) } @@ -710,7 +712,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> { mk_token_path(cx, sp, name) } -fn statements_mk_tt(cx: &ExtCtxt, tt: &TokenTree, matcher: bool) -> Vec<P<ast::Stmt>> { +fn statements_mk_tt(cx: &ExtCtxt, tt: &TokenTree, matcher: bool) -> Vec<ast::Stmt> { match *tt { TokenTree::Token(sp, SubstNt(ident, _)) => { // tt.extend($ident.to_tokens(ext_cx)) @@ -831,7 +833,7 @@ fn parse_arguments_to_quote(cx: &ExtCtxt, tts: &[TokenTree]) (cx_expr, tts) } -fn mk_stmts_let(cx: &ExtCtxt, sp: Span) -> Vec<P<ast::Stmt>> { +fn mk_stmts_let(cx: &ExtCtxt, sp: Span) -> Vec<ast::Stmt> { // We also bind a single value, sp, to ext_cx.call_site() // // This causes every span in a token-tree quote to be attributed to the @@ -872,7 +874,7 @@ fn mk_stmts_let(cx: &ExtCtxt, sp: Span) -> Vec<P<ast::Stmt>> { vec!(stmt_let_sp, stmt_let_tt) } -fn statements_mk_tts(cx: &ExtCtxt, tts: &[TokenTree], matcher: bool) -> Vec<P<ast::Stmt>> { +fn statements_mk_tts(cx: &ExtCtxt, tts: &[TokenTree], matcher: bool) -> Vec<ast::Stmt> { let mut ss = Vec::new(); for tt in tts { ss.extend(statements_mk_tt(cx, tt, matcher)); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 9c8ae9460e4..c4e1f32a52c 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -523,7 +523,7 @@ pub fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { }, "block" => token::NtBlock(panictry!(p.parse_block())), "stmt" => match panictry!(p.parse_stmt()) { - Some(s) => token::NtStmt(s), + Some(s) => token::NtStmt(P(s)), None => { p.fatal("expected a statement").emit(); panic!(FatalError); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 1e9178a55c5..c641c478a6b 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -87,7 +87,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { } fn make_impl_items(self: Box<ParserAnyMacro<'a>>) - -> Option<SmallVector<P<ast::ImplItem>>> { + -> Option<SmallVector<ast::ImplItem>> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); @@ -101,7 +101,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { } fn make_stmts(self: Box<ParserAnyMacro<'a>>) - -> Option<SmallVector<P<ast::Stmt>>> { + -> Option<SmallVector<ast::Stmt>> { let mut ret = SmallVector::zero(); loop { let mut parser = self.parser.borrow_mut(); |
