diff options
| author | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
| commit | 329eca6044fdf376a7a89ec7a96dba7a8b884cf7 (patch) | |
| tree | 7008814278a066914b6ba36818388d5212ffda9f /src/libsyntax/ext | |
| parent | c087aaf56b1109163126fea4c2760f8414ffbe56 (diff) | |
| download | rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.tar.gz rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.zip | |
Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/auto_serialize.rs | 181 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/earley_parser.rs | 24 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 19 | ||||
| -rw-r--r-- | src/libsyntax/ext/log_syntax.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 49 | ||||
| -rw-r--r-- | src/libsyntax/ext/simplext.rs | 68 |
10 files changed, 199 insertions, 189 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index fe9f59d5538..f3c356923f2 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -84,13 +84,13 @@ mod syntax { export parse; } -type ser_tps_map = map::hashmap<str, fn@(@ast::expr) -> [@ast::stmt]>; +type ser_tps_map = map::hashmap<str, fn@(@ast::expr) -> [@ast::stmt]/~>; type deser_tps_map = map::hashmap<str, fn@() -> @ast::expr>; fn expand(cx: ext_ctxt, span: span, _mitem: ast::meta_item, - in_items: [@ast::item]) -> [@ast::item] { + in_items: [@ast::item]/~) -> [@ast::item]/~ { fn not_auto_serialize(a: ast::attribute) -> bool { attr::get_attr_name(a) != @"auto_serialize" } @@ -103,11 +103,11 @@ fn expand(cx: ext_ctxt, vec::flat_map(in_items) {|in_item| alt in_item.node { ast::item_ty(ty, tps, _) { - [filter_attrs(in_item)] + ty_fns(cx, in_item.ident, ty, tps) + [filter_attrs(in_item)]/~ + ty_fns(cx, in_item.ident, ty, tps) } ast::item_enum(variants, tps, _) { - [filter_attrs(in_item)] + enum_fns(cx, in_item.ident, + [filter_attrs(in_item)]/~ + enum_fns(cx, in_item.ident, in_item.span, variants, tps) } @@ -115,7 +115,7 @@ fn expand(cx: ext_ctxt, cx.span_err(span, "#[auto_serialize] can only be \ applied to type and enum \ definitions"); - [in_item] + [in_item]/~ } } } @@ -126,26 +126,27 @@ impl helpers for ext_ctxt { helper_name: str) -> @ast::path { let head = vec::init(base_path.idents); let tail = vec::last(base_path.idents); - self.path(base_path.span, head + [@(helper_name + "_" + *tail)]) + self.path(base_path.span, head + [@(helper_name + "_" + *tail)]/~) } - fn path(span: span, strs: [ast::ident]) -> @ast::path { - @{span: span, global: false, idents: strs, rp: none, types: []} + fn path(span: span, strs: [ast::ident]/~) -> @ast::path { + @{span: span, global: false, idents: strs, rp: none, types: []/~} } - fn path_tps(span: span, strs: [ast::ident], - tps: [@ast::ty]) -> @ast::path { + fn path_tps(span: span, strs: [ast::ident]/~, + tps: [@ast::ty]/~) -> @ast::path { @{span: span, global: false, idents: strs, rp: none, types: tps} } - fn ty_path(span: span, strs: [ast::ident], tps: [@ast::ty]) -> @ast::ty { + fn ty_path(span: span, strs: [ast::ident]/~, + tps: [@ast::ty]/~) -> @ast::ty { @{id: self.next_id(), node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()), span: span} } fn ty_fn(span: span, - -input_tys: [@ast::ty], + -input_tys: [@ast::ty]/~, -output: @ast::ty) -> @ast::ty { let args = vec::map(input_tys) {|ty| {mode: ast::expl(ast::by_ref), @@ -159,7 +160,7 @@ impl helpers for ext_ctxt { output: output, purity: ast::impure_fn, cf: ast::return_val, - constraints: []}), + constraints: []/~}), span: span} } @@ -172,11 +173,11 @@ impl helpers for ext_ctxt { } fn var_ref(span: span, name: ast::ident) -> @ast::expr { - self.expr(span, ast::expr_path(self.path(span, [name]))) + self.expr(span, ast::expr_path(self.path(span, [name]/~))) } - fn blk(span: span, stmts: [@ast::stmt]) -> ast::blk { - {node: {view_items: [], + fn blk(span: span, stmts: [@ast::stmt]/~) -> ast::blk { + {node: {view_items: []/~, stmts: stmts, expr: none, id: self.next_id(), @@ -185,8 +186,8 @@ impl helpers for ext_ctxt { } fn expr_blk(expr: @ast::expr) -> ast::blk { - {node: {view_items: [], - stmts: [], + {node: {view_items: []/~, + stmts: []/~, expr: some(expr), id: self.next_id(), rules: ast::default_blk}, @@ -194,8 +195,8 @@ impl helpers for ext_ctxt { } fn binder_pat(span: span, nm: ast::ident) -> @ast::pat { - let path = @{span: span, global: false, idents: [nm], - rp: none, types: []}; + let path = @{span: span, global: false, idents: [nm]/~, + rp: none, types: []/~}; @{id: self.next_id(), node: ast::pat_ident(path, none), span: span} @@ -206,7 +207,8 @@ impl helpers for ext_ctxt { span: expr.span} } - fn alt_stmt(arms: [ast::arm], span: span, -v: @ast::expr) -> @ast::stmt { + fn alt_stmt(arms: [ast::arm]/~, + span: span, -v: @ast::expr) -> @ast::stmt { self.stmt( self.expr( span, @@ -277,7 +279,7 @@ impl helpers for ext_ctxt { fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path, -s: @ast::expr, -v: @ast::expr) - -> [@ast::stmt] { + -> [@ast::stmt]/~ { let ext_cx = cx; // required for #ast{} // We want to take a path like a::b::c<...> and generate a call @@ -299,15 +301,15 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path, [cx.stmt( cx.expr( path.span, - ast::expr_call(callee, [s, v] + ty_args, false)))] + ast::expr_call(callee, [s, v]/~ + ty_args, false)))]/~ } fn ser_variant(cx: ext_ctxt, tps: ser_tps_map, - tys: [@ast::ty], + tys: [@ast::ty]/~, span: span, -s: @ast::expr, - pfn: fn([@ast::pat]) -> ast::pat_, + pfn: fn([@ast::pat]/~) -> ast::pat_, bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr, argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) -> ast::arm { @@ -326,9 +328,9 @@ fn ser_variant(cx: ext_ctxt, }; let body_blk = cx.blk(span, stmts); - let body = cx.blk(span, [cx.stmt(bodyfn(s, body_blk))]); + let body = cx.blk(span, [cx.stmt(bodyfn(s, body_blk))]/~); - {pats: [pat], guard: none, body: body} + {pats: [pat]/~, guard: none, body: body} } fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, @@ -338,34 +340,34 @@ fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, -s: @ast::expr, -v: @ast::expr) - -> [@ast::stmt] { + -> [@ast::stmt]/~ { let ext_cx = cx; // required for #ast{} alt ty.node { ast::ty_nil { - [#ast[stmt]{$(s).emit_nil()}] + [#ast[stmt]{$(s).emit_nil()}]/~ } ast::ty_bot { cx.span_err( ty.span, #fmt["Cannot serialize bottom type"]); - [] + []/~ } ast::ty_box(mt) { let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) }); - [#ast(stmt){$(s).emit_box($(l));}] + [#ast(stmt){$(s).emit_box($(l));}]/~ } ast::ty_uniq(mt) { let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) }); - [#ast(stmt){$(s).emit_uniq($(l));}] + [#ast(stmt){$(s).emit_uniq($(l));}]/~ } ast::ty_ptr(_) | ast::ty_rptr(_, _) { cx.span_err(ty.span, "cannot serialize pointer types"); - [] + []/~ } ast::ty_rec(flds) { @@ -374,7 +376,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, let vf = cx.expr(fld.span, ast::expr_field(cx.clone(v), fld.node.ident, - [])); + []/~)); let s = cx.clone(s); let f = cx.lit_str(fld.span, fld.node.ident); let i = cx.lit_uint(fld.span, fidx); @@ -382,12 +384,12 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, #ast(stmt){$(s).emit_rec_field($(f), $(i), $(l));} }; let fld_lambda = cx.lambda(cx.blk(ty.span, fld_stmts)); - [#ast(stmt){$(s).emit_rec($(fld_lambda));}] + [#ast(stmt){$(s).emit_rec($(fld_lambda));}]/~ } ast::ty_fn(_, _) { cx.span_err(ty.span, "cannot serialize function types"); - [] + []/~ } ast::ty_tup(tys) { @@ -420,8 +422,8 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, let body = cx.lambda(blk); #ast{ $(s).emit_tup_elt($(idx), $(body)) } }) - ]; - [cx.alt_stmt(arms, ty.span, v)] + ]/~; + [cx.alt_stmt(arms, ty.span, v)]/~ } ast::ty_path(path, _) { @@ -444,12 +446,12 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, ast::ty_mac(_) { cx.span_err(ty.span, "cannot serialize macro types"); - [] + []/~ } ast::ty_infer { cx.span_err(ty.span, "cannot serialize inferred types"); - [] + []/~ } ast::ty_vstore(@{node: ast::ty_vec(mt),_}, ast::vstore_uniq) | @@ -467,7 +469,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, [#ast(stmt){ std::serialization::emit_from_vec($(s), $(v), {|__e| $(ser_e) }) - }] + }]/~ } ast::ty_vstore(_, _) { @@ -477,20 +479,21 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } } -fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param], +fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, + tps: [ast::ty_param]/~, f: fn(ext_ctxt, ser_tps_map, - -@ast::expr, -@ast::expr) -> [@ast::stmt]) + -@ast::expr, -@ast::expr) -> [@ast::stmt]/~) -> @ast::item { let ext_cx = cx; // required for #ast - let tp_types = vec::map(tps, {|tp| cx.ty_path(span, [tp.ident], [])}); - let v_ty = cx.ty_path(span, [name], tp_types); + let tp_types = vec::map(tps, {|tp| cx.ty_path(span, [tp.ident]/~, []/~)}); + let v_ty = cx.ty_path(span, [name]/~, tp_types); let tp_inputs = vec::map(tps, {|tp| {mode: ast::expl(ast::by_ref), ty: cx.ty_fn(span, - [cx.ty_path(span, [tp.ident], [])], + [cx.ty_path(span, [tp.ident]/~, []/~)]/~, cx.ty_nil(span)), ident: @("__s" + *tp.ident), id: cx.next_id()}}); @@ -498,15 +501,15 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param], #debug["tp_inputs = %?", tp_inputs]; - let ser_inputs: [ast::arg] = + let ser_inputs: [ast::arg]/~ = [{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, [@"__S"], []), + ty: cx.ty_path(span, [@"__S"]/~, []/~), ident: @"__s", id: cx.next_id()}, {mode: ast::expl(ast::by_ref), ty: v_ty, ident: @"__v", - id: cx.next_id()}] + id: cx.next_id()}]/~ + tp_inputs; let tps_map = map::str_hash(); @@ -514,22 +517,23 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param], let arg_ident = arg.ident; tps_map.insert( *tp.ident, - fn@(v: @ast::expr) -> [@ast::stmt] { + fn@(v: @ast::expr) -> [@ast::stmt]/~ { let f = cx.var_ref(span, arg_ident); #debug["serializing type arg %s", *arg_ident]; - [#ast(stmt){$(f)($(v));}] + [#ast(stmt){$(f)($(v));}]/~ }); } let ser_bnds = @[ ast::bound_iface(cx.ty_path(span, - [@"std", @"serialization", @"serializer"], - []))]; + [@"std", @"serialization", + @"serializer"]/~, + []/~))]/~; - let ser_tps: [ast::ty_param] = + let ser_tps: [ast::ty_param]/~ = [{ident: @"__S", id: cx.next_id(), - bounds: ser_bnds}] + + bounds: ser_bnds}]/~ + vec::map(tps) {|tp| cx.clone_ty_param(tp) }; let ser_output: @ast::ty = @{id: cx.next_id(), @@ -540,13 +544,13 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param], f(cx, tps_map, #ast{ __s }, #ast{ __v })); @{ident: @("serialize_" + *name), - attrs: [], + attrs: []/~, id: cx.next_id(), node: ast::item_fn({inputs: ser_inputs, output: ser_output, purity: ast::impure_fn, cf: ast::return_val, - constraints: []}, + constraints: []/~}, ser_tps, ser_blk), vis: ast::public, @@ -571,7 +575,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path, cx.lambda(cx.expr_blk(dv_expr)) }; - cx.expr(path.span, ast::expr_call(callee, [d] + ty_args, false)) + cx.expr(path.span, ast::expr_call(callee, [d]/~ + ty_args, false)) } fn deser_lambda(cx: ext_ctxt, tps: deser_tps_map, ty: @ast::ty, @@ -688,30 +692,30 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, } fn mk_deser_fn(cx: ext_ctxt, span: span, - name: ast::ident, tps: [ast::ty_param], + name: ast::ident, tps: [ast::ty_param]/~, f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr) -> @ast::item { let ext_cx = cx; // required for #ast - let tp_types = vec::map(tps, {|tp| cx.ty_path(span, [tp.ident], [])}); - let v_ty = cx.ty_path(span, [name], tp_types); + let tp_types = vec::map(tps, {|tp| cx.ty_path(span, [tp.ident]/~, []/~)}); + let v_ty = cx.ty_path(span, [name]/~, tp_types); let tp_inputs = vec::map(tps, {|tp| {mode: ast::expl(ast::by_ref), ty: cx.ty_fn(span, - [], - cx.ty_path(span, [tp.ident], [])), + []/~, + cx.ty_path(span, [tp.ident]/~, []/~)), ident: @("__d" + *tp.ident), id: cx.next_id()}}); #debug["tp_inputs = %?", tp_inputs]; - let deser_inputs: [ast::arg] = + let deser_inputs: [ast::arg]/~ = [{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, [@"__D"], []), + ty: cx.ty_path(span, [@"__D"]/~, []/~), ident: @"__d", - id: cx.next_id()}] + id: cx.next_id()}]/~ + tp_inputs; let tps_map = map::str_hash(); @@ -728,46 +732,47 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, let deser_bnds = @[ ast::bound_iface(cx.ty_path( span, - [@"std", @"serialization", @"deserializer"], - []))]; + [@"std", @"serialization", @"deserializer"]/~, + []/~))]/~; - let deser_tps: [ast::ty_param] = + let deser_tps: [ast::ty_param]/~ = [{ident: @"__D", id: cx.next_id(), - bounds: deser_bnds}] + vec::map(tps) {|tp| + bounds: deser_bnds}]/~ + vec::map(tps) {|tp| let cloned = cx.clone_ty_param(tp); - {bounds: @(*cloned.bounds + [ast::bound_copy]) with cloned} + {bounds: @(*cloned.bounds + [ast::bound_copy]/~) with cloned} }; let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); @{ident: @("deserialize_" + *name), - attrs: [], + attrs: []/~, id: cx.next_id(), node: ast::item_fn({inputs: deser_inputs, output: v_ty, purity: ast::impure_fn, cf: ast::return_val, - constraints: []}, + constraints: []/~}, deser_tps, deser_blk), vis: ast::public, span: span} } -fn ty_fns(cx: ext_ctxt, name: ast::ident, ty: @ast::ty, tps: [ast::ty_param]) - -> [@ast::item] { +fn ty_fns(cx: ext_ctxt, name: ast::ident, + ty: @ast::ty, tps: [ast::ty_param]/~) + -> [@ast::item]/~ { let span = ty.span; [ mk_ser_fn(cx, span, name, tps, {|a,b,c,d|ser_ty(a, b, ty, c, d)}), mk_deser_fn(cx, span, name, tps, {|a,b,c|deser_ty(a, b, ty, c)}) - ] + ]/~ } fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, - e_span: span, variants: [ast::variant], - -s: @ast::expr, -v: @ast::expr) -> [@ast::stmt] { + e_span: span, variants: [ast::variant]/~, + -s: @ast::expr, -v: @ast::expr) -> [@ast::stmt]/~ { let ext_cx = cx; let arms = vec::from_fn(vec::len(variants)) {|vidx| let variant = variants[vidx]; @@ -781,9 +786,9 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, // Generate pattern var(v1, v2, v3) {|pats| if vec::is_empty(pats) { - ast::pat_ident(cx.path(v_span, [v_name]), none) + ast::pat_ident(cx.path(v_span, [v_name]/~), none) } else { - ast::pat_enum(cx.path(v_span, [v_name]), some(pats)) + ast::pat_enum(cx.path(v_span, [v_name]/~), some(pats)) } }, @@ -809,16 +814,16 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, } }) }; - let lam = cx.lambda(cx.blk(e_span, [cx.alt_stmt(arms, e_span, v)])); + let lam = cx.lambda(cx.blk(e_span, [cx.alt_stmt(arms, e_span, v)]/~)); let e_name = cx.lit_str(e_span, e_name); - [#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }] + [#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }]/~ } fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, - e_span: span, variants: [ast::variant], + e_span: span, variants: [ast::variant]/~, -d: @ast::expr) -> @ast::expr { let ext_cx = cx; - let arms: [ast::arm] = vec::from_fn(vec::len(variants)) {|vidx| + let arms: [ast::arm]/~ = vec::from_fn(vec::len(variants)) {|vidx| let variant = variants[vidx]; let v_span = variant.span; let v_name = variant.node.name; @@ -843,7 +848,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, {pats: [@{id: cx.next_id(), node: ast::pat_lit(cx.lit_uint(v_span, vidx)), - span: v_span}], + span: v_span}]/~, guard: none, body: cx.expr_blk(body)} }; @@ -859,12 +864,12 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, } fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span, - variants: [ast::variant], tps: [ast::ty_param]) - -> [@ast::item] { + variants: [ast::variant]/~, tps: [ast::ty_param]/~) + -> [@ast::item]/~ { [ mk_ser_fn(cx, e_span, e_name, tps, {|a,b,c,d|ser_enum(a, b, e_name, e_span, variants, c, d)}), mk_deser_fn(cx, e_span, e_name, tps, {|a,b,c|deser_enum(a, b, e_name, e_span, variants, c)}) - ] + ]/~ } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 6c93dbcd7ef..96a1efdfe7a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -12,7 +12,7 @@ type macro_def = {ident: ast::ident, ext: syntax_extension}; type macro_definer = fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def; type item_decorator = - fn@(ext_ctxt, span, ast::meta_item, [@ast::item]) -> [@ast::item]; + fn@(ext_ctxt, span, ast::meta_item, [@ast::item]/~) -> [@ast::item]/~; type syntax_expander_tt = {expander: syntax_expander_tt_, span: option<span>}; type syntax_expander_tt_ = fn@(ext_ctxt, span, ast::token_tree) -> @ast::expr; @@ -72,7 +72,7 @@ iface ext_ctxt { fn backtrace() -> expn_info; fn mod_push(mod_name: ast::ident); fn mod_pop(); - fn mod_path() -> [ast::ident]; + fn mod_path() -> [ast::ident]/~; fn bt_push(ei: codemap::expn_info_); fn bt_pop(); fn span_fatal(sp: span, msg: str) -> !; @@ -88,7 +88,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, type ctxt_repr = {parse_sess: parse::parse_sess, cfg: ast::crate_cfg, mut backtrace: expn_info, - mut mod_path: [ast::ident]}; + mut mod_path: [ast::ident]/~}; impl of ext_ctxt for ctxt_repr { fn codemap() -> codemap { self.parse_sess.cm } fn parse_sess() -> parse::parse_sess { self.parse_sess } @@ -97,7 +97,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, fn backtrace() -> expn_info { self.backtrace } fn mod_push(i: ast::ident) { vec::push(self.mod_path, i); } fn mod_pop() { vec::pop(self.mod_path); } - fn mod_path() -> [ast::ident] { ret self.mod_path; } + fn mod_path() -> [ast::ident]/~ { ret self.mod_path; } fn bt_push(ei: codemap::expn_info_) { alt ei { expanded_from({call_site: cs, callie: callie}) { @@ -145,7 +145,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, parse_sess: parse_sess, cfg: cfg, mut backtrace: none, - mut mod_path: [] + mut mod_path: []/~ }; ret imp as ext_ctxt } @@ -185,12 +185,12 @@ fn make_new_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) -> } fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, name: str) -> [@ast::expr] { + min: uint, name: str) -> [@ast::expr]/~ { ret get_mac_args(cx, sp, arg, min, none, name); } fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, max: option<uint>, name: str) -> [@ast::expr] { + min: uint, max: option<uint>, name: str) -> [@ast::expr]/~ { alt arg { some(expr) { alt expr.node { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 4e0c6889092..2e5fe63eb5a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -28,35 +28,35 @@ fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr) let expr = ast::expr_unary(op, e); ret @{id: cx.next_id(), node: expr, span: sp}; } -fn mk_path(cx: ext_ctxt, sp: span, idents: [ast::ident]) -> +fn mk_path(cx: ext_ctxt, sp: span, idents: [ast::ident]/~) -> @ast::expr { let path = @{span: sp, global: false, idents: idents, - rp: none, types: []}; + rp: none, types: []/~}; let pathexpr = ast::expr_path(path); ret @{id: cx.next_id(), node: pathexpr, span: sp}; } fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident) -> @ast::expr { - let expr = ast::expr_field(p, m, []); + let expr = ast::expr_field(p, m, []/~); ret @{id: cx.next_id(), node: expr, span: sp}; } -fn mk_access(cx: ext_ctxt, sp: span, p: [ast::ident], m: ast::ident) +fn mk_access(cx: ext_ctxt, sp: span, p: [ast::ident]/~, m: ast::ident) -> @ast::expr { let pathexpr = mk_path(cx, sp, p); ret mk_access_(cx, sp, pathexpr, m); } fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr, - args: [@ast::expr]) -> @ast::expr { + args: [@ast::expr]/~) -> @ast::expr { let callexpr = ast::expr_call(fn_expr, args, false); ret @{id: cx.next_id(), node: callexpr, span: sp}; } -fn mk_call(cx: ext_ctxt, sp: span, fn_path: [ast::ident], - args: [@ast::expr]) -> @ast::expr { +fn mk_call(cx: ext_ctxt, sp: span, fn_path: [ast::ident]/~, + args: [@ast::expr]/~) -> @ast::expr { let pathexpr = mk_path(cx, sp, fn_path); ret mk_call_(cx, sp, pathexpr, args); } // e = expr, t = type -fn mk_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]) -> +fn mk_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]/~) -> @ast::expr { let vecexpr = ast::expr_vec(exprs, ast::m_imm); ret @{id: cx.next_id(), node: vecexpr, span: sp}; @@ -72,15 +72,15 @@ fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, exprs: [@ast::expr]/~) -> } fn mk_rec_e(cx: ext_ctxt, sp: span, - fields: [{ident: ast::ident, ex: @ast::expr}]) -> + fields: [{ident: ast::ident, ex: @ast::expr}]/~) -> @ast::expr { - let mut astfields: [ast::field] = []; + let mut astfields: [ast::field]/~ = []/~; for fields.each {|field| let ident = field.ident; let val = field.ex; let astfield = {node: {mutbl: ast::m_imm, ident: ident, expr: val}, span: sp}; - astfields += [astfield]; + astfields += [astfield]/~; } let recexpr = ast::expr_rec(astfields, option::none::<@ast::expr>); ret @{id: cx.next_id(), node: recexpr, span: sp}; diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index faf8e1a0868..9f445218007 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -9,7 +9,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, } ret @{id: cx.next_id(), - node: ast::expr_path(@{span: sp, global: false, idents: [@res], - rp: none, types: []}), + node: ast::expr_path(@{span: sp, global: false, idents: [@res]/~, + rp: none, types: []/~}), span: sp}; } diff --git a/src/libsyntax/ext/earley_parser.rs b/src/libsyntax/ext/earley_parser.rs index b1a2524ca35..223cca25694 100644 --- a/src/libsyntax/ext/earley_parser.rs +++ b/src/libsyntax/ext/earley_parser.rs @@ -32,11 +32,11 @@ fn is_some(&&mpu: matcher_pos_up) -> bool { } type matcher_pos = ~{ - elts: [ast::matcher], // maybe should be /& ? Need to understand regions. + elts: [ast::matcher]/~, // maybe should be /&? Need to understand regions. sep: option<token>, mut idx: uint, mut up: matcher_pos_up, // mutable for swapping only - matches: [dvec<@arb_depth>] + matches: [dvec<@arb_depth>]/~ }; fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { @@ -55,26 +55,26 @@ fn count_names(ms: [matcher]/&) -> uint { }}) } -fn new_matcher_pos(ms: [matcher], sep: option<token>) -> matcher_pos { +fn new_matcher_pos(ms: [matcher]/~, sep: option<token>) -> matcher_pos { ~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(none), matches: copy vec::from_fn(count_names(ms), {|_i| dvec::dvec()}) } } /* logically, an arb_depth should contain only one kind of nonterminal */ -enum arb_depth { leaf(whole_nt), seq([@arb_depth]) } +enum arb_depth { leaf(whole_nt), seq([@arb_depth]/~) } type earley_item = matcher_pos; -fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: [matcher]) - -> [@arb_depth] { - let mut cur_eis = []; +fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: [matcher]/~) + -> [@arb_depth]/~ { + let mut cur_eis = []/~; vec::push(cur_eis, new_matcher_pos(ms, none)); loop { - let mut bb_eis = []; // black-box parsed by parser.rs - let mut next_eis = []; // or proceed normally - let mut eof_eis = []; + let mut bb_eis = []/~; // black-box parsed by parser.rs + let mut next_eis = []/~; // or proceed normally + let mut eof_eis = []/~; let {tok: tok, sp: _} = rdr.peek(); @@ -218,12 +218,12 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: [matcher]) fn parse_nt(p: parser, name: str) -> whole_nt { alt name { - "item" { alt p.parse_item([], ast::public) { + "item" { alt p.parse_item([]/~, ast::public) { some(i) { token::w_item(i) } none { p.fatal("expected an item keyword") } }} "block" { token::w_block(p.parse_block()) } - "stmt" { token::w_stmt(p.parse_stmt([])) } + "stmt" { token::w_stmt(p.parse_stmt([]/~)) } "pat" { token::w_pat(p.parse_pat()) } "expr" { token::w_expr(p.parse_expr()) } "ty" { token::w_ty(p.parse_ty(false /* no need to disambiguate*/)) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d7bb7835822..ca5d7f6bab3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -45,7 +45,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, some(macro_defining(ext)) { let named_extension = ext(cx, pth.span, args, body); exts.insert(*named_extension.ident, named_extension.ext); - (ast::expr_rec([], none), s) + (ast::expr_rec([]/~, none), s) } some(normal_tt(_)) { cx.span_fatal(pth.span, @@ -101,7 +101,7 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, // decorated with "item decorators", then use that function to transform // the item into a new set of items. let new_items = vec::flat_map(module.items) {|item| - vec::foldr(item.attrs, [item]) {|attr, items| + vec::foldr(item.attrs, [item]/~) {|attr, items| let mname = alt attr.node.value.node { ast::meta_word(n) { n } ast::meta_name_value(n, _) { n } diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 24a5aed7d28..43408dec739 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -34,10 +34,11 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, // probably be factored out in common with other code that builds // expressions. Also: Cleanup the naming of these functions. // NOTE: Moved many of the common ones to build.rs --kevina -fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) +fn pieces_to_expr(cx: ext_ctxt, sp: span, + pieces: [piece]/~, args: [@ast::expr]/~) -> @ast::expr { - fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident] { - ret [@"extfmt", @"rt", ident]; + fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident]/~ { + ret [@"extfmt", @"rt", ident]/~; } fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { @@ -48,8 +49,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) // which tells the RT::conv* functions how to perform the conversion fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: conv) -> @ast::expr { - fn make_flags(cx: ext_ctxt, sp: span, flags: [flag]) -> @ast::expr { - let mut flagexprs: [@ast::expr] = []; + fn make_flags(cx: ext_ctxt, sp: span, flags: [flag]/~) -> @ast::expr { + let mut flagexprs: [@ast::expr]/~ = []/~; for flags.each {|f| let mut fstr; alt f { @@ -59,7 +60,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) flag_sign_always { fstr = "flag_sign_always"; } flag_alternate { fstr = "flag_alternate"; } } - flagexprs += [make_rt_path_expr(cx, sp, @fstr)]; + flagexprs += [make_rt_path_expr(cx, sp, @fstr)]/~; } ret mk_uniq_vec_e(cx, sp, flagexprs); } @@ -71,7 +72,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) count_is(c) { let count_lit = mk_int(cx, sp, c); let count_is_path = make_path_vec(cx, @"count_is"); - let count_is_args = [count_lit]; + let count_is_args = [count_lit]/~; ret mk_call(cx, sp, count_is_path, count_is_args); } _ { cx.span_unimpl(sp, "unimplemented #fmt conversion"); } @@ -99,7 +100,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) [{ident: @"flags", ex: flags_expr}, {ident: @"width", ex: width_expr}, {ident: @"precision", ex: precision_expr}, - {ident: @"ty", ex: ty_expr}]); + {ident: @"ty", ex: ty_expr}]/~); } let rt_conv_flags = make_flags(cx, sp, cnv.flags); let rt_conv_width = make_count(cx, sp, cnv.width); @@ -113,7 +114,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) let fname = "conv_" + conv_type; let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); - let args = [cnv_expr, arg]; + let args = [cnv_expr, arg]/~; ret mk_call(cx, arg.span, path, args); } fn make_new_conv(cx: ext_ctxt, sp: span, cnv: conv, arg: @ast::expr) -> diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 5ccbb143b97..50fac765483 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -11,5 +11,6 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, ); //trivial expression - ret @{id: cx.next_id(), node: ast::expr_rec([], option::none), span: sp}; + ret @{id: cx.next_id(), node: ast::expr_rec([]/~, option::none), + span: sp}; } diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index caef1841faf..648532d3024 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -35,7 +35,7 @@ impl of qq_helper for @ast::crate { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_crate"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_crate"]/~) } fn get_fold_fn() -> str {"fold_crate"} } @@ -49,7 +49,7 @@ impl of qq_helper for @ast::expr { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_expr"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_expr"]/~) } fn get_fold_fn() -> str {"fold_expr"} } @@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_ty"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_ty"]/~) } fn get_fold_fn() -> str {"fold_ty"} } @@ -72,7 +72,7 @@ impl of qq_helper for @ast::item { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_item"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_item"]/~) } fn get_fold_fn() -> str {"fold_item"} } @@ -81,7 +81,7 @@ impl of qq_helper for @ast::stmt { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_stmt"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_stmt"]/~) } fn get_fold_fn() -> str {"fold_stmt"} } @@ -90,7 +90,7 @@ impl of qq_helper for @ast::pat { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_pat"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_pat"]/~) } fn get_fold_fn() -> str {"fold_pat"} } @@ -133,12 +133,12 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, { let mut what = "expr"; option::iter(arg) {|arg| - let args: [@ast::expr] = + let args: [@ast::expr]/~ = alt arg.node { ast::expr_vec(elts, _) { elts } _ { ecx.span_fatal - (_sp, "#ast requires arguments of the form `[...]`.") + (_sp, "#ast requires arguments of the form `[...]/~`.") } }; if vec::len::<@ast::expr>(args) != 1u { @@ -163,14 +163,14 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, }; } -fn parse_crate(p: parser) -> @ast::crate { p.parse_crate_mod([]) } +fn parse_crate(p: parser) -> @ast::crate { p.parse_crate_mod([]/~) } fn parse_ty(p: parser) -> @ast::ty { p.parse_ty(false) } -fn parse_stmt(p: parser) -> @ast::stmt { p.parse_stmt([]) } +fn parse_stmt(p: parser) -> @ast::stmt { p.parse_stmt([]/~) } fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() } fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() } fn parse_item(p: parser) -> @ast::item { - alt p.parse_item([], ast::public) { + alt p.parse_item([]/~, ast::public) { some(item) { item } none { fail "parse_item: parsing an item failed"; } } @@ -230,47 +230,48 @@ fn finish<T: qq_helper> let cx = ecx; let cfg_call = {|| - mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"cfg"), []) + mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"]/~, @"cfg"), []/~) }; let parse_sess_call = {|| - mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"parse_sess"), []) + mk_call_(cx, sp, + mk_access(cx, sp, [@"ext_cx"]/~, @"parse_sess"), []/~) }; let pcall = mk_call(cx,sp, [@"syntax", @"parse", @"parser", - @"parse_from_source_str"], + @"parse_from_source_str"]/~, [node.mk_parse_fn(cx,sp), mk_str(cx,sp, fname), mk_call(cx,sp, [@"syntax",@"ext", - @"qquote", @"mk_file_substr"], + @"qquote", @"mk_file_substr"]/~, [mk_str(cx,sp, loc.file.name), mk_uint(cx,sp, loc.line), - mk_uint(cx,sp, loc.col)]), + mk_uint(cx,sp, loc.col)]/~), mk_unary(cx,sp, ast::box(ast::m_imm), mk_str(cx,sp, str2)), cfg_call(), - parse_sess_call()] + parse_sess_call()]/~ ); let mut rcall = pcall; if (g_len > 0u) { rcall = mk_call(cx,sp, - [@"syntax", @"ext", @"qquote", @"replace"], + [@"syntax", @"ext", @"qquote", @"replace"]/~, [pcall, mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec {|g| mk_call(cx,sp, [@"syntax", @"ext", - @"qquote", @g.constr], - [g.e])}), + @"qquote", @g.constr]/~, + [g.e]/~)}), mk_path(cx,sp, [@"syntax", @"ext", @"qquote", - @node.get_fold_fn()])]); + @node.get_fold_fn()]/~)]/~); } ret rcall; } -fn replace<T>(node: T, repls: [fragment], ff: fn (ast_fold, T) -> T) +fn replace<T>(node: T, repls: [fragment]/~, ff: fn (ast_fold, T) -> T) -> T { let aft = default_ast_fold(); @@ -290,7 +291,7 @@ fn fold_item(f: ast_fold, &&n: @ast::item) -> @ast::item {f.fold_item(n)} fn fold_stmt(f: ast_fold, &&n: @ast::stmt) -> @ast::stmt {f.fold_stmt(n)} fn fold_pat(f: ast_fold, &&n: @ast::pat) -> @ast::pat {f.fold_pat(n)} -fn replace_expr(repls: [fragment], +fn replace_expr(repls: [fragment]/~, e: ast::expr_, s: span, fld: ast_fold, orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) @@ -304,7 +305,7 @@ fn replace_expr(repls: [fragment], } } -fn replace_ty(repls: [fragment], +fn replace_ty(repls: [fragment]/~, e: ast::ty_, s: span, fld: ast_fold, orig: fn@(ast::ty_, span, ast_fold)->(ast::ty_, span)) -> (ast::ty_, span) diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 4dad13dc06a..c29b2246993 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -22,7 +22,7 @@ fn path_to_ident(pth: @path) -> option<ident> { type clause = {params: binders, body: @expr}; /* logically, an arb_depth should contain only one kind of matchable */ -enum arb_depth<T> { leaf(T), seq(@[arb_depth<T>], span), } +enum arb_depth<T> { leaf(T), seq(@[arb_depth<T>]/~, span), } enum matchable { @@ -70,8 +70,8 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! { type match_result = option<arb_depth<matchable>>; type selector = fn@(matchable) -> match_result; -fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) -> - {pre: [@expr], rep: option<@expr>, post: [@expr]} { +fn elts_to_ell(cx: ext_ctxt, elts: [@expr]/~) -> + {pre: [@expr]/~, rep: option<@expr>, post: [@expr]/~} { let mut idx: uint = 0u; let mut res = none; for elts.each {|elt| @@ -96,15 +96,15 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) -> } ret alt res { some(val) { val } - none { {pre: elts, rep: none, post: []} } + none { {pre: elts, rep: none, post: []/~} } } } -fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: [T]) -> - option<[U]> { - let mut res = []; +fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: [T]/~) -> + option<[U]/~> { + let mut res = []/~; for v.each {|elem| - alt f(elem) { none { ret none; } some(fv) { res += [fv]; } } + alt f(elem) { none { ret none; } some(fv) { res += [fv]/~; } } } ret some(res); } @@ -182,7 +182,7 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { /* use the bindings on the body to generate the expanded code */ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { - let idx_path: @mut [uint] = @mut []; + let idx_path: @mut [uint]/~ = @mut []/~; fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { ret cx.next_id(); } fn new_span(cx: ext_ctxt, sp: span) -> span { /* this discards information in the case of macro-defining macros */ @@ -214,7 +214,7 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { /* helper: descend into a matcher */ -fn follow(m: arb_depth<matchable>, idx_path: @mut [uint]) -> +fn follow(m: arb_depth<matchable>, idx_path: @mut [uint]/~) -> arb_depth<matchable> { let mut res: arb_depth<matchable> = m; for vec::each(*idx_path) {|idx| @@ -227,7 +227,7 @@ fn follow(m: arb_depth<matchable>, idx_path: @mut [uint]) -> } fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, - idx_path: @mut [uint]) -> option<matchable> { + idx_path: @mut [uint]/~) -> option<matchable> { alt mmaybe { none { ret none } some(m) { @@ -264,8 +264,9 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { /* handle sequences (anywhere in the AST) of exprs, either real or ...ed */ -fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], - recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] { +fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, + recur: fn@(&&@expr) -> @expr, + exprs: [@expr]/~) -> [@expr]/~ { alt elts_to_ell(cx, exprs) { {pre: pre, rep: repeat_me_maybe, post: post} { let mut res = vec::map(pre, recur); @@ -308,8 +309,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], /* Whew, we now know how how many times to repeat */ let mut idx: uint = 0u; while idx < rc { - *idx_path += [idx]; - res += [recur(repeat_me)]; // whew! + *idx_path += [idx]/~; + res += [recur(repeat_me)]/~; // whew! vec::pop(*idx_path); idx += 1u; } @@ -326,7 +327,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], // substitute, in a position that's required to be an ident -fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], +fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, &&i: ident, _fld: ast_fold) -> ident { ret alt follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) { a_id.node } @@ -336,14 +337,14 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], } -fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], +fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, p: path, _fld: ast_fold) -> path { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { ret p; } alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) { some(match_ident(id)) { - {span: id.span, global: false, idents: [id.node], - rp: none, types: []} + {span: id.span, global: false, idents: [id.node]/~, + rp: none, types: []/~} } some(match_path(a_pth)) { *a_pth } some(m) { match_error(cx, m, "a path") } @@ -352,7 +353,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], } -fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], +fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, e: ast::expr_, s: span, fld: ast_fold, orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) @@ -367,9 +368,9 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], some(match_ident(id)) { (expr_path(@{span: id.span, global: false, - idents: [id.node], + idents: [id.node]/~, rp: none, - types: []}), id.span) + types: []/~}), id.span) } some(match_path(a_pth)) { (expr_path(a_pth), s) } some(match_expr(a_exp)) { (a_exp.node, a_exp.span) } @@ -381,7 +382,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], } } -fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], +fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, t: ast::ty_, s: span, fld: ast_fold, orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span)) -> (ast::ty_, span) @@ -407,7 +408,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], /* for parsing reasons, syntax variables bound to blocks must be used like `{v}` */ -fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], +fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut [uint]/~, blk: blk_, s: span, fld: ast_fold, orig: fn@(blk_, span, ast_fold) -> (blk_, span)) -> (blk_, span) @@ -458,7 +459,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { } } {pre: pre, rep: none, post: post} { - if post != [] { + if post != []/~ { cx.bug("elts_to_ell provided an invalid result"); } p_t_s_r_length(cx, vec::len(pre), false, s, b); @@ -606,10 +607,10 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, match_expr(e) { alt e.node { expr_vec(arg_elts, _) { - let mut elts = []; + let mut elts = []/~; let mut idx = offset; while idx < vec::len(arg_elts) { - elts += [leaf(match_expr(arg_elts[idx]))]; + vec::push(elts, leaf(match_expr(arg_elts[idx]))); idx += 1u; } @@ -651,7 +652,7 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, compose_sels(s, {|x|len_select(cx, x, at_least, len)})); } -fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: [@expr], _repeat_after: bool, +fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: [@expr]/~, _repeat_after: bool, s: selector, b: binders) { let mut idx: uint = 0u; while idx < vec::len(elts) { @@ -679,14 +680,14 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro"); let mut macro_name: option<@str> = none; - let mut clauses: [@clause] = []; + let mut clauses: [@clause]/~ = []/~; for args.each {|arg| alt arg.node { expr_vec(elts, mutbl) { if vec::len(elts) != 2u { cx.span_fatal((*arg).span, "extension clause must consist of [" + - "macro invocation, expansion body]"); + "macro invocation, expansion body]/~"); } @@ -719,7 +720,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, }; clauses += [@{params: pattern_to_selectors(cx, arg), - body: elts[1u]}]; + body: elts[1u]}]/~; // FIXME (#2251): check duplicates (or just simplify // the macro arg situation) @@ -739,7 +740,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, } _ { cx.span_fatal((*arg).span, - "extension must be [clause, " + " ...]"); + "extension must be [clause, " + " ...]/~"); } } } @@ -759,7 +760,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, ext: normal({expander: ext, span: some(option::get(arg).span)})}; fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - _body: ast::mac_body, clauses: [@clause]) -> @expr { + _body: ast::mac_body, + clauses: [@clause]/~) -> @expr { let arg = alt arg { some(arg) { arg } none { cx.span_fatal(sp, "macro must have arguments")} |
