diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-02-28 12:54:01 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-03-01 22:40:52 -0800 |
| commit | 198cc3d850136582651489328fec221a2b98bfef (patch) | |
| tree | fe47f6fab3d4ead61053684613d0b1852ec7e311 /src/libsyntax/ext/quote.rs | |
| parent | 58fd6ab90db3eb68c94695e1254a73e57bc44658 (diff) | |
| download | rust-198cc3d850136582651489328fec221a2b98bfef.tar.gz rust-198cc3d850136582651489328fec221a2b98bfef.zip | |
libsyntax: Fix errors arising from the automated `~[T]` conversion
Diffstat (limited to 'src/libsyntax/ext/quote.rs')
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 22 |
1 files changed, 14 insertions, 8 deletions
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) |
