From c087aaf56b1109163126fea4c2760f8414ffbe56 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 25 Jun 2012 20:00:39 -0700 Subject: [PATCH] When we cons up vector asts, generate evecs. --- src/libsyntax/ext/build.rs | 10 ++++++++++ src/libsyntax/ext/fmt.rs | 2 +- src/libsyntax/ext/qquote.rs | 2 +- src/rustc/front/test.rs | 22 ++++++++++++++++------ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 69f7f2b69cd..4e0c6889092 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -61,6 +61,16 @@ fn mk_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]) -> let vecexpr = ast::expr_vec(exprs, ast::m_imm); ret @{id: cx.next_id(), node: vecexpr, span: sp}; } +fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr, vst: ast::vstore) -> + @ast::expr { + let vstoreexpr = ast::expr_vstore(expr, vst); + ret @{id: cx.next_id(), node: vstoreexpr, span: sp}; +} +fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]/~) -> + @ast::expr { + mk_vstore_e(cx, sp, mk_vec_e(cx, sp, exprs), ast::vstore_uniq) +} + fn mk_rec_e(cx: ext_ctxt, sp: span, fields: [{ident: ast::ident, ex: @ast::expr}]) -> @ast::expr { diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 0cc4ba0a570..24a5aed7d28 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -61,7 +61,7 @@ fn make_flags(cx: ext_ctxt, sp: span, flags: [flag]) -> @ast::expr { } flagexprs += [make_rt_path_expr(cx, sp, @fstr)]; } - ret mk_vec_e(cx, sp, flagexprs); + ret mk_uniq_vec_e(cx, sp, flagexprs); } fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { alt cnt { diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 3f3eb001250..caef1841faf 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -258,7 +258,7 @@ fn finish rcall = mk_call(cx,sp, [@"syntax", @"ext", @"qquote", @"replace"], [pcall, - mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g| + mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec {|g| mk_call(cx,sp, [@"syntax", @"ext", @"qquote", @g.constr], diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 2c40db16a45..3f5fca12e2a 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -265,8 +265,11 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { let vec_mt: ast::mt = {ty: @test_desc_ty, mutbl: ast::m_imm}; + let inner_ty = @{id: cx.sess.next_node_id(), + node: ast::ty_vec(vec_mt), + span: dummy_sp()}; ret @{id: cx.sess.next_node_id(), - node: ast::ty_vec(vec_mt), + node: ast::ty_vstore(inner_ty, ast::vstore_uniq), span: dummy_sp()}; } @@ -277,8 +280,11 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { descs += [mk_test_desc_rec(cx, test)]; } + let inner_expr = @{id: cx.sess.next_node_id(), + node: ast::expr_vec(descs, ast::m_imm), + span: dummy_sp()}; ret @{id: cx.sess.next_node_id(), - node: ast::expr_vec(descs, ast::m_imm), + node: ast::expr_vstore(inner_expr, ast::vstore_uniq), span: dummy_sp()}; } @@ -384,10 +390,14 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let str_ty = @{id: cx.sess.next_node_id(), node: ast::ty_path(str_pt, cx.sess.next_node_id()), span: dummy_sp()}; - let args_mt: ast::mt = {ty: str_ty, mutbl: ast::m_imm}; - let args_ty: ast::ty = {id: cx.sess.next_node_id(), - node: ast::ty_vec(args_mt), - span: dummy_sp()}; + let args_mt = {ty: str_ty, mutbl: ast::m_imm}; + let args_ty_inner = @{id: cx.sess.next_node_id(), + node: ast::ty_vec(args_mt), + span: dummy_sp()}; + let args_ty = {id: cx.sess.next_node_id(), + node: ast::ty_vstore(args_ty_inner, ast::vstore_uniq), + span: dummy_sp()}; + let args_arg: ast::arg = {mode: ast::expl(ast::by_val),