From 198cc3d850136582651489328fec221a2b98bfef Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 28 Feb 2014 12:54:01 -0800 Subject: libsyntax: Fix errors arising from the automated `~[T]` conversion --- src/libsyntax/ext/quote.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/ext/quote.rs') diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 3b8df84acc3..e96597d4159 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -17,6 +17,8 @@ use parse::token::*; use parse::token; use parse; +use std::vec_ng::Vec; + /** * * Quasiquoting works via token trees. @@ -35,6 +37,8 @@ pub mod rt { use parse; use print::pprust; + use std::vec_ng::Vec; + pub use ast::*; pub use parse::token::*; pub use parse::new_parser_from_tts; @@ -305,7 +309,7 @@ pub fn expand_quote_expr(cx: &mut ExtCtxt, pub fn expand_quote_item(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { - let e_attrs = cx.expr_vec_uniq(sp, Vec::new()); + let e_attrs = cx.expr_vec_ng(sp); let expanded = expand_parse_call(cx, sp, "parse_item", vec!(e_attrs), tts); base::MRExpr(expanded) @@ -332,7 +336,7 @@ pub fn expand_quote_ty(cx: &mut ExtCtxt, pub fn expand_quote_stmt(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { - let e_attrs = cx.expr_vec_uniq(sp, Vec::new()); + let e_attrs = cx.expr_vec_ng(sp); let expanded = expand_parse_call(cx, sp, "parse_stmt", vec!(e_attrs), tts); base::MRExpr(expanded) @@ -540,7 +544,7 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<@ast::Stmt> { vec!(cx.stmt_expr(e_push)) } - ast::TTDelim(ref tts) => mk_tts(cx, sp, **tts), + ast::TTDelim(ref tts) => mk_tts(cx, sp, tts.as_slice()), ast::TTSeq(..) => fail!("TTSeq in quote!"), ast::TTNonterminal(sp, ident) => { @@ -583,7 +587,9 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let mut p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), - tts.to_owned()); + tts.iter() + .map(|x| (*x).clone()) + .collect()); p.quote_depth += 1u; let cx_expr = p.parse_expr(); @@ -629,14 +635,14 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) id_ext("_sp"), e_sp); - let stmt_let_tt = cx.stmt_let(sp, true, - id_ext("tt"), - cx.expr_vec_uniq(sp, Vec::new())); + let stmt_let_tt = cx.stmt_let(sp, true, id_ext("tt"), cx.expr_vec_ng(sp)); + let mut vector = vec!(stmt_let_sp, stmt_let_tt); + vector.push_all_move(mk_tts(cx, sp, tts.as_slice())); let block = cx.expr_block( cx.block_all(sp, Vec::new(), - vec!(stmt_let_sp, stmt_let_tt) + mk_tts(cx, sp, tts), + vector, Some(cx.expr_ident(sp, id_ext("tt"))))); (cx_expr, block) -- cgit 1.4.1-3-g733a5