From 4dcf84e4f4a9a54254fd426609ad9f1ccffae3b9 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 19 Jun 2012 19:34:01 -0700 Subject: Remove bind. Issue #2189 --- src/libsyntax/ext/auto_serialize.rs | 10 ++++---- src/libsyntax/ext/expand.rs | 8 +++--- src/libsyntax/ext/fmt.rs | 4 ++- src/libsyntax/ext/qquote.rs | 8 +++--- src/libsyntax/ext/simplext.rs | 50 +++++++++++++++++++++---------------- 5 files changed, 45 insertions(+), 35 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 888ff7d4ef2..75a88fb221b 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -267,7 +267,7 @@ impl helpers for ext_ctxt { } let fld = fold::make_fold(@{ - new_span: repl_sp(_, ast_util::dummy_sp(), span) + new_span: {|a|repl_sp(a, ast_util::dummy_sp(), span)} with *fold::default_ast_fold() }); @@ -757,8 +757,8 @@ fn ty_fns(cx: ext_ctxt, name: ast::ident, ty: @ast::ty, tps: [ast::ty_param]) let span = ty.span; [ - mk_ser_fn(cx, span, name, tps, ser_ty(_, _, ty, _, _)), - mk_deser_fn(cx, span, name, tps, deser_ty(_, _, ty, _)) + 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)}) ] } @@ -860,8 +860,8 @@ fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span, -> [@ast::item] { [ mk_ser_fn(cx, e_span, e_name, tps, - ser_enum(_, _, e_name, e_span, variants, _, _)), + {|a,b,c,d|ser_enum(a, b, e_name, e_span, variants, c, d)}), mk_deser_fn(cx, e_span, e_name, tps, - deser_enum(_, _, e_name, e_span, variants, _)) + {|a,b,c|deser_enum(a, b, e_name, e_span, variants, c)}) ] } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1704e3afc54..ba44404fe24 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -130,10 +130,10 @@ fn expand_crate(parse_sess: parse::parse_sess, let afp = default_ast_fold(); let cx: ext_ctxt = mk_ctxt(parse_sess, cfg); let f_pre = - @{fold_expr: bind expand_expr(exts, cx, _, _, _, afp.fold_expr), - fold_mod: bind expand_mod_items(exts, cx, _, _, afp.fold_mod), - fold_item: bind expand_item(cx, _, _, afp.fold_item), - new_span: bind new_span(cx, _) + @{fold_expr: {|a,b,c|expand_expr(exts, cx, a, b, c, afp.fold_expr)}, + fold_mod: {|a,b|expand_mod_items(exts, cx, a, b, afp.fold_mod)}, + fold_item: {|a,b|expand_item(cx, a, b, afp.fold_item)}, + new_span: {|a|new_span(cx, a)} with *afp}; let f = make_fold(f_pre); let cm = parse_expr_from_source_str("", diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 4725f5a1977..5ea8b677675 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -23,7 +23,9 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: str) -> ! { cx.span_fatal(sp, msg); } - let parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _); + let parse_fmt_err = fn@(s: str) -> ! { + parse_fmt_err_(cx, fmtspan, s) + }; let pieces = parse_fmt_string(fmt, parse_fmt_err); ret pieces_to_expr(cx, sp, pieces, args); } diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 316ac7603fb..9830c379ef6 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -274,10 +274,10 @@ fn replace(node: T, repls: [fragment], ff: fn (ast_fold, T) -> T) -> T { let aft = default_ast_fold(); - let f_pre = @{fold_expr: bind replace_expr(repls, _, _, _, - aft.fold_expr), - fold_ty: bind replace_ty(repls, _, _, _, - aft.fold_ty) + let f_pre = @{fold_expr: {|a,b,c|replace_expr(repls, a, b, c, + aft.fold_expr)}, + fold_ty: {|a,b,c|replace_ty(repls, a, b, c, + aft.fold_ty)} with *aft}; ret ff(make_fold(f_pre), node); } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index e6b1c84965e..bf3014d1621 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -113,7 +113,7 @@ fn a_d_map(ad: arb_depth, f: selector) -> match_result { alt ad { leaf(x) { ret f(x); } seq(ads, span) { - alt option_flatten_map(bind a_d_map(_, f), *ads) { + alt option_flatten_map({|x| a_d_map(x, f)}, *ads) { none { ret none; } some(ts) { ret some(seq(@ts, span)); } } @@ -128,7 +128,7 @@ fn compose_sels(s1: selector, s2: selector) -> selector { some(matches) { a_d_map(matches, s2) } } } - ret bind scomp(s1, s2, _); + ret {|x|scomp(s1, s2, x)}; } @@ -190,16 +190,22 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { } let afp = default_ast_fold(); let f_pre = - @{fold_ident: bind transcribe_ident(cx, b, idx_path, _, _), - fold_path: bind transcribe_path(cx, b, idx_path, _, _), - fold_expr: - bind transcribe_expr(cx, b, idx_path, _, _, _, afp.fold_expr), - fold_ty: bind transcribe_type(cx, b, idx_path, - _, _, _, afp.fold_ty), - fold_block: - bind transcribe_block(cx, b, idx_path, _, _, _, afp.fold_block), - map_exprs: bind transcribe_exprs(cx, b, idx_path, _, _), - new_id: bind new_id(_, cx) + @{fold_ident: {|x,y|transcribe_ident(cx, b, idx_path, x, y)}, + fold_path: {|x,y|transcribe_path(cx, b, idx_path, x, y)}, + fold_expr: {|x,y,z| + transcribe_expr(cx, b, idx_path, x, y, z, afp.fold_expr) + }, + fold_ty: {|x,y,z| + transcribe_type(cx, b, idx_path, + x, y, z, afp.fold_ty) + }, + fold_block: {|x,y,z| + transcribe_block(cx, b, idx_path, x, y, z, afp.fold_block) + }, + map_exprs: {|x,y| + transcribe_exprs(cx, b, idx_path, x, y) + }, + new_id: {|x|new_id(x, cx)} with *afp}; let f = make_fold(f_pre); let result = f.fold_expr(body); @@ -249,7 +255,7 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { // using fold is a hack: we want visit, but it doesn't hit idents ) : // solve this with macros let f_pre = - @{fold_ident: bind mark_ident(_, _, b, idents) + @{fold_ident: {|x,y|mark_ident(x, y, b, idents)} with *default_ast_fold()}; let f = make_fold(f_pre); f.fold_expr(e); // ignore result @@ -475,7 +481,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { _ { cx.bug("broken traversal in p_t_s_r") } } } - b.literal_ast_matchers.push(bind select(cx, _, e)); + b.literal_ast_matchers.push({|x|select(cx, x, e)}); } } } @@ -517,7 +523,7 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { if b.real_binders.contains_key(p_id) { cx.span_fatal(p.span, "duplicate binding identifier"); } - b.real_binders.insert(p_id, compose_sels(s, bind select(cx, _))); + b.real_binders.insert(p_id, compose_sels(s, {|x|select(cx, x)})); } none { } } @@ -562,7 +568,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { _ { none } } } - let final_step = bind select_pt_1(cx, _, select_pt_2); + let final_step = {|x|select_pt_1(cx, x, select_pt_2)}; b.real_binders.insert(id, compose_sels(s, final_step)); } none { no_des(cx, pth.span, "under `#<>`"); } @@ -582,7 +588,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { _ { none } } } - let final_step = bind select_pt_1(cx, _, select_pt_2); + let final_step = {|x|select_pt_1(cx, x, select_pt_2)}; b.real_binders.insert(id, compose_sels(s, final_step)); } none { no_des(cx, blk.span, "under `#{}`"); } @@ -619,7 +625,7 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, } } p_t_s_rec(cx, match_expr(repeat_me), - compose_sels(s, bind select(cx, repeat_me, offset, _)), b); + compose_sels(s, {|x|select(cx, repeat_me, offset, x)}), b); } @@ -643,7 +649,7 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, } } b.literal_ast_matchers.push( - compose_sels(s, bind len_select(cx, _, at_least, len))); + 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, @@ -664,7 +670,7 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: [@expr], _repeat_after: bool, } } p_t_s_rec(cx, match_expr(elts[idx]), - compose_sels(s, bind select(cx, _, idx)), b); + compose_sels(s, {|x, copy idx|select(cx, x, idx)}), b); idx += 1u; } } @@ -739,7 +745,9 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, } } - let ext = bind generic_extension(_, _, _, _, clauses); + let ext = {|a,b,c,d, move clauses| + generic_extension(a,b,c,d,clauses) + }; ret {ident: alt macro_name { -- cgit 1.4.1-3-g733a5