diff options
116 files changed, 384 insertions, 806 deletions
diff --git a/doc/rust.md b/doc/rust.md index 13b46367a96..b30932ef5c5 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -980,7 +980,7 @@ fn pure_foldl<T, U: copy>(ls: list<T>, u: U, f: fn(&&T, &&U) -> U) -> U { pure fn pure_length<T>(ls: list<T>) -> uint { fn count<T>(_t: T, &&u: uint) -> uint { u + 1u } unchecked { - pure_foldl(ls, 0u, count(_, _)) + pure_foldl(ls, 0u, count) } } ~~~~ @@ -1941,49 +1941,6 @@ An example of a call expression: let x: int = add(1, 2); ~~~~ - -### Bind expressions - -A _bind expression_ constructs a new function from an existing function.^[The -`bind` expression is analogous to the `bind` expression in the Sather -language.] The new function has zero or more of its arguments *bound* into a -new, hidden boxed tuple that holds the bindings. For each concrete argument -passed in the `bind` expression, the corresponding parameter in the existing -function is *omitted* as a parameter of the new function. For each argument -passed the placeholder symbol `_` in the `bind` expression, the corresponding -parameter of the existing function is *retained* as a parameter of the new -function. - -Any subsequent invocation of the new function with residual arguments causes -invocation of the existing function with the combination of bound arguments -and residual arguments that was specified during the binding. - -An example of a `bind` expression: - -~~~~{.xfail-test} -fn add(x: int, y: int) -> int { - ret x + y; -} -type single_param_fn = fn(int) -> int; - -let add4: single_param_fn = bind add(4, _); - -let add5: single_param_fn = bind add(_, 5); - -assert (add(4,5) == add4(5)); -assert (add(4,5) == add5(4)); - -~~~~ - -A `bind` expression generally stores a copy of the bound arguments in a -hidden, boxed tuple, owned by the resulting first-class function. For each -bound slot in the bound function's signature, space is allocated in the hidden -tuple and populated with a copy of the bound value. - -A `bind` expression is an alternative way of constructing a shared function -closure; the [`fn@` expression](#shared-function-expressions) form is another -way. - ### Shared function expressions *TODO*. diff --git a/doc/tutorial.md b/doc/tutorial.md index 804cf39d640..1ef17c71166 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -903,19 +903,6 @@ argument to every element of a vector, producing a new vector. Even when a closure takes no parameters, you must still write the bars for the parameter list, as in `{|| ...}`. -## Binding - -Partial application is done using the `bind` keyword in Rust. - -~~~~ -let findx = bind str::find_char(_, 'x'); -~~~~ - -Binding a function produces a boxed closure (`fn@` type) in which some -of the arguments to the bound function have already been provided. -`findx` will be a function taking a single string argument, and -returning the position where the letter `x` occurs. - ## Iteration Functions taking closures provide a good way to define non-trivial diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index dced049e7e1..a8fea66b192 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -328,8 +328,8 @@ fn load_crate(filename: str) -> option<crate> { mut deps: [] }; let v = visit::mk_simple_visitor(@{ - visit_view_item: bind goto_view_item(e, _), - visit_item: bind goto_item(e, _), + visit_view_item: {|a|goto_view_item(e, a)}, + visit_item: {|a|goto_item(e, a)}, with *visit::default_simple_visitor() }); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 3ccf8fdf341..5afe663f23b 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -325,7 +325,7 @@ fn compose_and_run_compiler( let abs_ab = path::connect(config.aux_base, rel_ab); let aux_args = make_compile_args(config, props, ["--lib"] + extra_link_args, - bind make_lib_name(_, _, testfile), abs_ab); + {|a,b|make_lib_name(a, b, testfile)}, abs_ab); let auxres = compose_and_run(config, abs_ab, aux_args, [], config.compile_lib_path, option::none); if auxres.status != 0 { diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 00e1edbdf77..95abb6636a8 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -139,8 +139,8 @@ fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff { let exprs = @mut []; let tys = @mut []; let v = visit::mk_simple_visitor(@{ - visit_expr: bind stash_expr_if(safe_to_steal_expr, exprs, _, tm), - visit_ty: bind stash_ty_if(safe_to_steal_ty, tys, _, tm) + visit_expr: {|a|stash_expr_if(safe_to_steal_expr, exprs, a, tm)}, + visit_ty: {|a|stash_ty_if(safe_to_steal_ty, tys, a, tm)} with *visit::default_simple_visitor() }); visit::visit_crate(crate, (), v); @@ -188,8 +188,8 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint, } } let afp = - @{fold_expr: fold::wrap(bind fold_expr_rep(j, i, - newexpr.node, _, _, tm)) + @{fold_expr: fold::wrap({|a,b| + fold_expr_rep(j, i, newexpr.node, a, b, tm)}) with *fold::default_ast_fold()}; let af = fold::make_fold(afp); let crate2: @ast::crate = @af.fold_crate(crate); @@ -211,7 +211,7 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::ty, } else { fold::noop_fold_ty(original, fld) } } let afp = - @{fold_ty: fold::wrap(bind fold_ty_rep(j, i, newty.node, _, _, tm)) + @{fold_ty: fold::wrap({|a,b|fold_ty_rep(j, i, newty.node, a, b, tm)}) with *fold::default_ast_fold()}; let af = fold::make_fold(afp); let crate2: @ast::crate = @af.fold_crate(crate); @@ -235,7 +235,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap, filename: str, cx: context) { let stolen = steal(crate, cx.mode); let extra_exprs = vec::filter(common_exprs(), - bind safe_to_use_expr(_, cx.mode)); + {|a|safe_to_use_expr(a, cx.mode)}); check_variants_T(crate, codemap, filename, "expr", extra_exprs + stolen.exprs, pprust::expr_to_str, replace_expr_in_crate, cx); @@ -268,13 +268,13 @@ fn check_variants_T<T: copy>( // testing the string for stability is easier and ok for now. let handler = diagnostic::mk_handler(none); let str3 = - @as_str(bind pprust::print_crate( + @as_str({|a|pprust::print_crate( codemap, diagnostic::mk_span_handler(handler, codemap), crate2, filename, - io::str_reader(""), _, - pprust::no_ann())); + io::str_reader(""), a, + pprust::no_ann())}); alt cx.mode { tm_converge { check_roundtrip_convergence(str3, 1u); @@ -421,12 +421,12 @@ fn parse_and_print(code: @str) -> str { let crate = parse::parse_crate_from_source_str( filename, code, [], sess); io::with_str_reader(*code) { |rdr| - as_str(bind pprust::print_crate(sess.cm, + as_str({|a|pprust::print_crate(sess.cm, sess.span_diagnostic, crate, filename, - rdr, _, - pprust::no_ann())) + rdr, a, + pprust::no_ann())}) } } @@ -439,7 +439,7 @@ fn has_raw_pointers(c: ast::crate) -> bool { } } let v = - visit::mk_simple_visitor(@{visit_ty: bind visit_ty(has_rp, _) + visit::mk_simple_visitor(@{visit_ty: {|a|visit_ty(has_rp, a)} with *visit::default_simple_visitor()}); visit::visit_crate(c, (), v); ret *has_rp; @@ -565,12 +565,12 @@ fn check_variants(files: [str], cx: context) { s, [], sess); io::with_str_reader(*s) { |rdr| #error("%s", - as_str(bind pprust::print_crate(sess.cm, + as_str({|a|pprust::print_crate(sess.cm, sess.span_diagnostic, crate, file, - rdr, _, - pprust::no_ann()))); + rdr, a, + pprust::no_ann())})); } check_variants_of_ast(*crate, sess.cm, file, cx); } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 7836d05c818..7c2a9737f04 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -177,11 +177,11 @@ fn peek<T: send>(p: port<T>) -> bool { peek_(***p) } #[doc(hidden)] fn recv_chan<T: send>(ch: comm::chan<T>) -> T { - as_raw_port(ch, recv_(_)) + as_raw_port(ch, {|x|recv_(x)}) } fn peek_chan<T: send>(ch: comm::chan<T>) -> bool { - as_raw_port(ch, peek_(_)) + as_raw_port(ch, {|x|peek_(x)}) } #[doc = "Receive on a raw port pointer"] diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index c24a0291177..1ae69046715 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -174,7 +174,7 @@ mod ct { let curr: [flag] = [f]; ret {flags: curr + rest, next: j}; } - let more = bind more_(_, s, i, lim); + let more = {|x|more_(x, s, i, lim)}; let f = s[i]; ret if f == '-' as u8 { more(flag_left_justify) diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 322a23ed53e..1be4d12d23e 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -185,7 +185,7 @@ Converts the bitvector to a vector of uint with the same length. Each uint in the resulting vector has either value 0u or 1u. "] fn to_vec(v: bitv) -> [uint] { - let sub = bind init_to_vec(v, _); + let sub = {|x|init_to_vec(v, x)}; ret vec::from_fn::<uint>(v.nbits, sub); } diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index d60d0c8c84e..57fff2cdcbd 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -136,7 +136,7 @@ mod tests { assert mem as int != 0; ret unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, - bind free(mem)) }; + {||free(mem)}) }; } #[test] diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 4cef3245661..1e9b2224a63 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -292,7 +292,7 @@ mod tests { two(17, 42)); #debug("*** test parameterized: taggypar<int>"); - let eq4: eqfn<taggypar<int>> = bind taggypareq::<int>(_, _); + let eq4: eqfn<taggypar<int>> = {|x,y|taggypareq::<int>(x, y)}; test_parameterized::<taggypar<int>>(eq4, onepar::<int>(1), twopar::<int>(1, 2), threepar::<int>(1, 2, 3), diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 6a87a586299..01b413054fb 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -162,7 +162,7 @@ fn run_tests_console(opts: test_opts, mut ignored: 0u, mut failures: []}; - run_tests(opts, tests, bind callback(_, st)); + run_tests(opts, tests, {|x|callback(x, st)}); assert (st.passed + st.failed + st.ignored == st.total); let success = st.failed == 0u; @@ -349,7 +349,7 @@ fn filter_tests(opts: test_opts, } else { ret option::none; } } - let filter = bind filter_fn(_, filter_str); + let filter = {|x|filter_fn(x, filter_str)}; vec::filter_map(filtered, filter) }; @@ -367,7 +367,7 @@ fn filter_tests(opts: test_opts, } else { ret option::none; } }; - vec::filter_map(filtered, bind filter(_)) + vec::filter_map(filtered, {|x|filter(x)}) }; // Sort the tests alphabetically @@ -376,7 +376,7 @@ fn filter_tests(opts: test_opts, fn lteq(t1: test_desc, t2: test_desc) -> bool { str::le(t1.name, t2.name) } - sort::merge_sort(bind lteq(_, _), filtered) + sort::merge_sort({|x,y|lteq(x, y)}, filtered) }; ret filtered; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index b1ca3d5c50d..6cf98f93fe3 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -125,7 +125,7 @@ mod tests { fn t(n: @mut int, &&k: int, &&_v: ()) { assert (*n == k); *n += 1; } - traverse(m, bind t(n, _, _)); + traverse(m, {|x,y|t(n, x, y)}); } #[test] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a356e716a9a..98cf35efdc8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -300,7 +300,6 @@ enum expr_ { expr_rec([field], option<@expr>), expr_call(@expr, [@expr], bool), // True iff last argument is a block expr_tup([@expr]), - expr_bind(@expr, [option<@expr>]), expr_binary(binop, @expr, @expr), expr_unary(unop, @expr), expr_lit(@lit), 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("<core-macros>", 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<T>(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<matchable>, 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 { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 7ddbfb52e94..0589e48489c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -87,7 +87,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { alt mi.node { meta_word(id) { meta_word(fld.fold_ident(id)) } meta_list(id, mis) { - let fold_meta_item = bind fold_meta_item_(_, fld); + let fold_meta_item = {|x|fold_meta_item_(x, fld)}; meta_list(/* FIXME: bad */ copy id, vec::map(mis, fold_meta_item)) } @@ -130,7 +130,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { } fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { - ret {inputs: vec::map(decl.inputs, bind fold_arg_(_, fld)), + ret {inputs: vec::map(decl.inputs, {|x| fold_arg_(x, fld)}), output: fld.fold_ty(decl.output), purity: decl.purity, cf: decl.cf, @@ -147,16 +147,16 @@ fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param { {ident: /* FIXME: bad */ copy tp.ident, id: fld.new_id(tp.id), - bounds: @vec::map(*tp.bounds, fold_ty_param_bound(_, fld))} + bounds: @vec::map(*tp.bounds, {|x|fold_ty_param_bound(x, fld)})} } fn fold_ty_params(tps: [ty_param], fld: ast_fold) -> [ty_param] { - vec::map(tps, fold_ty_param(_, fld)) + vec::map(tps, {|x|fold_ty_param(x, fld)}) } fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { - let fold_meta_item = bind fold_meta_item_(_, fld); - let fold_attribute = bind fold_attribute_(_, fld); + let fold_meta_item = {|x|fold_meta_item_(x, fld)}; + let fold_attribute = {|x|fold_attribute_(x, fld)}; ret {directives: vec::map(c.directives, fld.fold_crate_directive), module: fld.fold_mod(c.module), @@ -186,8 +186,8 @@ fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item { - let fold_arg = bind fold_arg_(_, fld); - let fold_attribute = bind fold_attribute_(_, fld); + let fold_arg = {|x|fold_arg_(x, fld)}; + let fold_attribute = {|x|fold_attribute_(x, fld)}; ret @{ident: fld.fold_ident(ni.ident), attrs: vec::map(ni.attrs, fold_attribute), @@ -209,7 +209,7 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item { } fn noop_fold_item(&&i: @item, fld: ast_fold) -> @item { - let fold_attribute = bind fold_attribute_(_, fld); + let fold_attribute = {|x|fold_attribute_(x, fld)}; ret @{ident: fld.fold_ident(i.ident), attrs: vec::map(i.attrs, fold_attribute), @@ -381,9 +381,9 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr: fld.fold_expr(field.node.expr)}, span: fld.new_span(field.span)}; } - let fold_field = bind fold_field_(_, fld); + let fold_field = {|x|fold_field_(x, fld)}; - let fold_mac = bind fold_mac_(_, fld); + let fold_mac = {|x|fold_mac_(x, fld)}; ret alt e { expr_new(p, i, v) { @@ -406,10 +406,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_call(fld.fold_expr(f), fld.map_exprs(fld.fold_expr, args), blk) } - expr_bind(f, args) { - let opt_map_se = bind option::map(_, fld.fold_expr); - expr_bind(fld.fold_expr(f), vec::map(args, opt_map_se)) - } expr_binary(binop, lhs, rhs) { expr_binary(binop, fld.fold_expr(lhs), fld.fold_expr(rhs)) } @@ -483,7 +479,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { } fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { - let fold_mac = bind fold_mac_(_, fld); + let fold_mac = {|x|fold_mac_(x, fld)}; fn fold_mt(mt: mt, fld: ast_fold) -> mt { {ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl} } @@ -536,10 +532,10 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg { ret {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)}; } - let fold_variant_arg = bind fold_variant_arg_(_, fld); + let fold_variant_arg = {|x|fold_variant_arg_(x, fld)}; let args = vec::map(v.args, fold_variant_arg); - let fold_attribute = bind fold_attribute_(_, fld); + let fold_attribute = {|x|fold_attribute_(x, fld)}; let attrs = vec::map(v.attrs, fold_attribute); let de = alt v.disr_expr { diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index b483e1eb9e4..4ebdd0dd5b5 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -17,8 +17,9 @@ import attr::parser_attr; import common::parser_common; import ast::node_id; import util::interner; -import lexer::{string_reader_as_reader, tt_reader_as_reader, - reader, string_reader, tt_reader}; +// FIXME: resolve badness +import lexer::*;//{string_reader_as_reader, tt_reader_as_reader, + //reader, string_reader, tt_reader}; import diagnostic::{span_handler, mk_span_handler, mk_handler, emitter}; type parse_sess = @{ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 45badde0016..146c3ab3de9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -829,14 +829,6 @@ class parser { let ex_ext = self.parse_syntax_ext(); hi = ex_ext.span.hi; ex = ex_ext.node; - } else if self.eat_keyword("bind") { - let e = self.parse_expr_res(RESTRICT_NO_CALL_EXPRS); - let es = self.parse_unspanned_seq( - token::LPAREN, token::RPAREN, - seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_expr_or_hole()}); - hi = self.span.hi; - ex = expr_bind(e, es); } else if self.eat_keyword("fail") { if can_begin_expr(self.token) { let e = self.parse_expr(); @@ -1008,19 +1000,13 @@ class parser { alt copy self.token { // expr(...) token::LPAREN if self.permits_call() { - let es_opt = self.parse_unspanned_seq( + let es = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_expr_or_hole()}); + {|p| p.parse_expr()}); hi = self.span.hi; - let nd = - if vec::any(es_opt, {|e| option::is_none(e) }) { - expr_bind(self.to_expr(e), es_opt) - } else { - let es = vec::map(es_opt) {|e| option::get(e) }; - expr_call(self.to_expr(e), es, false) - }; + let nd = expr_call(self.to_expr(e), es, false); e = self.mk_pexpr(lo, hi, nd); } @@ -1370,13 +1356,6 @@ class parser { ret self.parse_expr_res(UNRESTRICTED); } - fn parse_expr_or_hole() -> option<@expr> { - alt self.token { - token::UNDERSCORE { self.bump(); ret none; } - _ { ret some(self.parse_expr()); } - } - } - fn parse_expr_res(r: restriction) -> @expr { let old = self.restriction; self.restriction = r; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index ec14778dc02..39327f1efad 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -250,7 +250,6 @@ fn contextual_keyword_table() -> hashmap<str, ()> { let words = str_hash(); let keys = [ "as", - "bind", "else", "implements", "move", diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e0e30dc72fc..6bd9e79b727 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -102,7 +102,7 @@ fn typarams_to_str(tps: [ast::ty_param]) -> str { } fn path_to_str(&&p: @ast::path) -> str { - ret to_str(p, bind print_path(_, _, false)); + ret to_str(p, {|a,b|print_path(a, b, false)}); } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, @@ -840,7 +840,7 @@ fn print_mac(s: ps, m: ast::mac) { some(@{node: ast::expr_vec(_, _), _}) { } _ { word(s.s, " "); } } - option::iter(arg, bind print_expr(s, _)); + option::iter(arg, {|a|print_expr(s, a)}); // FIXME: extension 'body' (#2339) } ast::mac_embed_type(ty) { @@ -938,24 +938,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_expr(s, option::get(blk)); } } - ast::expr_bind(func, args) { - fn print_opt(s: ps, expr: option<@ast::expr>) { - alt expr { - some(expr) { print_expr(s, expr); } - _ { word(s.s, "_"); } - } - } - - // "bind" keyword is only needed if there are no "_" arguments. - if !vec::any(args) {|arg| option::is_none(arg) } { - word_nbsp(s, "bind"); - } - - print_expr(s, func); - popen(s); - commasep(s, inconsistent, args, print_opt); - pclose(s); - } ast::expr_binary(op, lhs, rhs) { let prec = operator_prec(op); print_op_maybe_parens(s, lhs, prec); @@ -1780,7 +1762,7 @@ fn ast_ty_fn_constr_to_str(&&c: @ast::constr) -> str { } fn ast_fn_constr_to_str(decl: ast::fn_decl, &&c: @ast::constr) -> str { - let arg_to_str = bind fn_arg_idx_to_str(decl, _); + let arg_to_str = {|a|fn_arg_idx_to_str(decl, a)}; ret path_to_str(c.node.path) + constr_args_to_str(arg_to_str, c.node.args); } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4a68850674d..3b5b73d78de 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -65,22 +65,22 @@ type visitor<E> = visit_class_item: fn@(@class_member, E, vt<E>)}; fn default_visitor<E>() -> visitor<E> { - ret @{visit_mod: bind visit_mod::<E>(_, _, _, _, _), - visit_view_item: bind visit_view_item::<E>(_, _, _), - visit_native_item: bind visit_native_item::<E>(_, _, _), - visit_item: bind visit_item::<E>(_, _, _), - visit_local: bind visit_local::<E>(_, _, _), - visit_block: bind visit_block::<E>(_, _, _), - visit_stmt: bind visit_stmt::<E>(_, _, _), - visit_arm: bind visit_arm::<E>(_, _, _), - visit_pat: bind visit_pat::<E>(_, _, _), - visit_decl: bind visit_decl::<E>(_, _, _), - visit_expr: bind visit_expr::<E>(_, _, _), - visit_ty: bind skip_ty::<E>(_, _, _), - visit_ty_params: bind visit_ty_params::<E>(_, _, _), - visit_constr: bind visit_constr::<E>(_, _, _, _, _), - visit_fn: bind visit_fn::<E>(_, _, _, _, _, _, _), - visit_class_item: bind visit_class_item::<E>(_,_,_)}; + ret @{visit_mod: {|a,b,c,d,e|visit_mod::<E>(a, b, c, d, e)}, + visit_view_item: {|a,b,c|visit_view_item::<E>(a, b, c)}, + visit_native_item: {|a,b,c|visit_native_item::<E>(a, b, c)}, + visit_item: {|a,b,c|visit_item::<E>(a, b, c)}, + visit_local: {|a,b,c|visit_local::<E>(a, b, c)}, + visit_block: {|a,b,c|visit_block::<E>(a, b, c)}, + visit_stmt: {|a,b,c|visit_stmt::<E>(a, b, c)}, + visit_arm: {|a,b,c|visit_arm::<E>(a, b, c)}, + visit_pat: {|a,b,c|visit_pat::<E>(a, b, c)}, + visit_decl: {|a,b,c|visit_decl::<E>(a, b, c)}, + visit_expr: {|a,b,c|visit_expr::<E>(a, b, c)}, + visit_ty: {|a,b,c|skip_ty::<E>(a, b, c)}, + visit_ty_params: {|a,b,c|visit_ty_params::<E>(a, b, c)}, + visit_constr: {|a,b,c,d,e|visit_constr::<E>(a, b, c, d, e)}, + visit_fn: {|a,b,c,d,e,f,g|visit_fn::<E>(a, b, c, d, e, f, g)}, + visit_class_item: {|a,b,c|visit_class_item::<E>(a, b, c)}}; } fn visit_crate<E>(c: crate, e: E, v: vt<E>) { @@ -377,10 +377,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { visit_exprs(args, e, v); v.visit_expr(callee, e, v); } - expr_bind(callee, args) { - v.visit_expr(callee, e, v); - for args.each {|eo| visit_expr_opt(eo, e, v); } - } expr_binary(_, a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); } expr_addr_of(_, x) | expr_unary(_, x) | expr_loop_body(x) | expr_do_body(x) | @@ -559,9 +555,9 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_fn(fk, decl, body, sp, id, e, v); } let visit_ty = if v.visit_ty == simple_ignore_ty { - bind skip_ty(_, _, _) + {|a,b,c| skip_ty(a, b, c)} } else { - bind v_ty(v.visit_ty, _, _, _) + {|a,b,c| v_ty(v.visit_ty, a, b, c)} }; fn v_class_item(f: fn@(@class_member), cm: @class_member, &&e: (), @@ -569,24 +565,33 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(cm); visit_class_item(cm, e, v); } - ret mk_vt(@{visit_mod: bind v_mod(v.visit_mod, _, _, _, _, _), - visit_view_item: bind v_view_item(v.visit_view_item, _, _, _), + ret mk_vt(@{visit_mod: {|a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e)}, + visit_view_item: {|a,b,c| + v_view_item(v.visit_view_item, a, b, c) + }, visit_native_item: - bind v_native_item(v.visit_native_item, _, _, _), - visit_item: bind v_item(v.visit_item, _, _, _), - visit_local: bind v_local(v.visit_local, _, _, _), - visit_block: bind v_block(v.visit_block, _, _, _), - visit_stmt: bind v_stmt(v.visit_stmt, _, _, _), - visit_arm: bind v_arm(v.visit_arm, _, _, _), - visit_pat: bind v_pat(v.visit_pat, _, _, _), - visit_decl: bind v_decl(v.visit_decl, _, _, _), - visit_expr: bind v_expr(v.visit_expr, _, _, _), + {|a,b,c|v_native_item(v.visit_native_item, a, b, c)}, + visit_item: {|a,b,c|v_item(v.visit_item, a, b, c)}, + visit_local: {|a,b,c|v_local(v.visit_local, a, b, c)}, + visit_block: {|a,b,c|v_block(v.visit_block, a, b, c)}, + visit_stmt: {|a,b,c|v_stmt(v.visit_stmt, a, b, c)}, + visit_arm: {|a,b,c|v_arm(v.visit_arm, a, b, c)}, + visit_pat: {|a,b,c|v_pat(v.visit_pat, a, b, c)}, + visit_decl: {|a,b,c|v_decl(v.visit_decl, a, b, c)}, + visit_expr: {|a,b,c|v_expr(v.visit_expr, a, b, c)}, visit_ty: visit_ty, - visit_ty_params: bind v_ty_params(v.visit_ty_params, _, _, _), - visit_constr: bind v_constr(v.visit_constr, _, _, _, _, _), - visit_fn: bind v_fn(v.visit_fn, _, _, _, _, _, _, _), - visit_class_item: bind v_class_item(v.visit_class_item, _, _, - _) + visit_ty_params: {|a,b,c| + v_ty_params(v.visit_ty_params, a, b, c) + }, + visit_constr: {|a,b,c,d,e| + v_constr(v.visit_constr, a, b, c, d, e) + }, + visit_fn: {|a,b,c,d,e,f,g| + v_fn(v.visit_fn, a, b, c, d, e, f, g) + }, + visit_class_item: {|a,b,c| + v_class_item(v.visit_class_item, a, b, c) + } }); } diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index 06376c18cb0..e37d4270215 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -94,7 +94,10 @@ fn get_rpaths_relative_to_output(os: session::os, cwd: path::path, output: path::path, libs: [path::path]) -> [str] { - vec::map(libs, bind get_rpath_relative_to_output(os, cwd, output, _)) + vec::map(libs, {|a| + check not_win32(os); + get_rpath_relative_to_output(os, cwd, output, a) + }) } fn get_rpath_relative_to_output(os: session::os, @@ -149,7 +152,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { } fn get_absolute_rpaths(cwd: path::path, libs: [path::path]) -> [str] { - vec::map(libs, bind get_absolute_rpath(cwd, _)) + vec::map(libs, {|a|get_absolute_rpath(cwd, a)}) } fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> str { diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index 3925f005de8..e6a61a1d078 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -43,8 +43,8 @@ fn declare_upcalls(targ_cfg: @session::config, fn nothrow(f: ValueRef) -> ValueRef { base::set_no_unwind(f); f } - let d = bind decl(llmod, "upcall_", _, _, _); - let dv = bind decl(llmod, "upcall_", _, _, T_void()); + let d = {|a,b,c|decl(llmod, "upcall_", a, b, c)}; + let dv = {|a,b|decl(llmod, "upcall_", a, b, T_void())}; let int_t = T_int(targ_cfg); let size_t = T_size_t(targ_cfg); diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index b5950037a43..2cd9c392ef4 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -132,7 +132,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, -> {crate: @ast::crate, tcx: option<ty::ctxt>} { let time_passes = sess.time_passes(); let mut crate = time(time_passes, "parsing", - bind parse_input(sess, cfg, input)); + {||parse_input(sess, cfg, input)}); if upto == cu_parse { ret {crate: crate, tcx: none}; } sess.building_library = session::building_library( @@ -140,75 +140,87 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, crate = time(time_passes, "configuration", - bind front::config::strip_unconfigured_items(crate)); + {|copy crate|front::config::strip_unconfigured_items(crate)}); crate = time(time_passes, "maybe building test harness", - bind front::test::modify_for_testing(sess, crate)); + {|copy crate|front::test::modify_for_testing(sess, crate)}); crate = time(time_passes, "expansion", - bind syntax::ext::expand::expand_crate( - sess.parse_sess, sess.opts.cfg, crate)); + {|copy crate|syntax::ext::expand::expand_crate( + sess.parse_sess, sess.opts.cfg, crate)}); if upto == cu_expand { ret {crate: crate, tcx: none}; } crate = - time(time_passes, "intrinsic injection", - bind front::intrinsic_inject::inject_intrinsic(sess, crate)); + time(time_passes, "intrinsic injection", {|copy crate| + front::intrinsic_inject::inject_intrinsic(sess, crate) + }); crate = - time(time_passes, "core injection", - bind front::core_inject::maybe_inject_libcore_ref(sess, crate)); + time(time_passes, "core injection", {|copy crate| + front::core_inject::maybe_inject_libcore_ref(sess, crate) + }); - time(time_passes, "building warning settings table", - bind lint::build_settings_crate(sess, crate)); + time(time_passes, "building warning settings table", {|copy crate| + lint::build_settings_crate(sess, crate) + }); let ast_map = - time(time_passes, "ast indexing", - bind syntax::ast_map::map_crate(sess.diagnostic(), *crate)); - time(time_passes, "external crate/lib resolution", - bind creader::read_crates( - sess.diagnostic(), *crate, sess.cstore, - sess.filesearch, - session::sess_os_to_meta_os(sess.targ_cfg.os), - sess.opts.static)); + time(time_passes, "ast indexing", {|copy crate| + syntax::ast_map::map_crate(sess.diagnostic(), *crate) + }); + time(time_passes, "external crate/lib resolution", {|copy crate| + creader::read_crates( + sess.diagnostic(), *crate, sess.cstore, + sess.filesearch, + session::sess_os_to_meta_os(sess.targ_cfg.os), + sess.opts.static) + }); let {def_map, exp_map, impl_map} = - time(time_passes, "resolution", - bind resolve::resolve_crate(sess, ast_map, crate)); + time(time_passes, "resolution", {|copy crate| + resolve::resolve_crate(sess, ast_map, crate) + }); let freevars = - time(time_passes, "freevar finding", - bind freevars::annotate_freevars(def_map, crate)); + time(time_passes, "freevar finding", {|copy crate| + freevars::annotate_freevars(def_map, crate) + }); let region_map = - time(time_passes, "region resolution", - bind middle::region::resolve_crate(sess, def_map, crate)); + time(time_passes, "region resolution", {|copy crate| + middle::region::resolve_crate(sess, def_map, crate) + }); let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars, region_map); let (method_map, vtable_map) = - time(time_passes, "typechecking", - bind typeck::check_crate(ty_cx, impl_map, crate)); - time(time_passes, "const checking", - bind middle::check_const::check_crate(sess, crate, ast_map, def_map, - method_map, ty_cx)); + time(time_passes, "typechecking", {|copy crate| + typeck::check_crate(ty_cx, impl_map, crate) + }); + time(time_passes, "const checking", {|copy crate| + middle::check_const::check_crate( + sess, crate, ast_map, def_map, method_map, ty_cx) + }); if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; } time(time_passes, "block-use checking", - bind middle::block_use::check_crate(ty_cx, crate)); + {|copy crate|middle::block_use::check_crate(ty_cx, crate)}); time(time_passes, "loop checking", - bind middle::check_loop::check_crate(ty_cx, crate)); + {|copy crate|middle::check_loop::check_crate(ty_cx, crate)}); time(time_passes, "alt checking", - bind middle::check_alt::check_crate(ty_cx, crate)); + {|copy crate|middle::check_alt::check_crate(ty_cx, crate)}); let last_use_map = - time(time_passes, "liveness checking", - bind middle::liveness::check_crate(ty_cx, method_map, crate)); + time(time_passes, "liveness checking", {|copy crate| + middle::liveness::check_crate(ty_cx, method_map, crate) + }); time(time_passes, "typestate checking", - bind middle::tstate::ck::check_crate(ty_cx, crate)); + {|copy crate|middle::tstate::ck::check_crate(ty_cx, crate)}); let (root_map, mutbl_map) = time( time_passes, "borrow checking", - bind middle::borrowck::check_crate(ty_cx, method_map, - last_use_map, crate)); - time(time_passes, "kind checking", - bind kind::check_crate(ty_cx, method_map, last_use_map, crate)); + {|copy crate|middle::borrowck::check_crate(ty_cx, method_map, + last_use_map, crate)}); + time(time_passes, "kind checking", {|copy crate| + kind::check_crate(ty_cx, method_map, last_use_map, crate) + }); time(time_passes, "lint checking", - bind lint::check_crate(ty_cx, crate)); + {|copy crate|lint::check_crate(ty_cx, crate)}); if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; } let outputs = option::get(outputs); @@ -220,11 +232,11 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, let (llmod, link_meta) = time(time_passes, "translation", - bind trans::base::trans_crate( + {|copy crate|trans::base::trans_crate( sess, crate, ty_cx, outputs.obj_filename, - exp_map, maps)); + exp_map, maps)}); time(time_passes, "LLVM passes", - bind link::write::run_passes(sess, llmod, outputs.obj_filename)); + {||link::write::run_passes(sess, llmod, outputs.obj_filename)}); let stop_after_codegen = sess.opts.output_type != link::output_type_exe || @@ -233,8 +245,8 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; } time(time_passes, "linking", - bind link::link_binary(sess, outputs.obj_filename, - outputs.out_filename, link_meta)); + {||link::link_binary(sess, outputs.obj_filename, + outputs.out_filename, link_meta)}); ret {crate: crate, tcx: some(ty_cx)}; } @@ -303,7 +315,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, alt ppm { ppm_typed { ann = {pre: ann_paren_for_expr, - post: bind ann_typed_post(option::get(tcx), _)}; + post: {|a|ann_typed_post(option::get(tcx), a)}}; } ppm_identified | ppm_expanded_identified { ann = {pre: ann_paren_for_expr, post: ann_identified_post}; diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 5e88df1de5e..bc88609d274 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -169,7 +169,7 @@ fn run_compiler(args: [str], demitter: diagnostic::emitter) { let pretty = option::map(getopts::opt_default(match, "pretty", "normal"), - bind parse_pretty(sess, _)); + {|a|parse_pretty(sess, a)}); alt pretty { some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; } none::<pp_mode> {/* continue */ } diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 3a9dfff1ae2..57c1f587f8c 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -24,9 +24,9 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred) let ctxt = @{in_cfg: in_cfg}; let precursor = - @{fold_mod: bind fold_mod(ctxt, _, _), - fold_block: fold::wrap(bind fold_block(ctxt, _, _)), - fold_native_mod: bind fold_native_mod(ctxt, _, _) + @{fold_mod: {|a,b|fold_mod(ctxt, a, b)}, + fold_block: fold::wrap({|a,b|fold_block(ctxt, a, b)}), + fold_native_mod: {|a,b|fold_native_mod(ctxt, a, b)} with *fold::default_ast_fold()}; let fold = fold::make_fold(precursor); @@ -41,7 +41,7 @@ fn filter_item(cx: ctxt, &&item: @ast::item) -> fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { - let filter = bind filter_item(cx, _); + let filter = {|a|filter_item(cx, a)}; let filtered_items = vec::filter_map(m.items, filter); ret {view_items: vec::map(m.view_items, fld.fold_view_item), items: vec::map(filtered_items, fld.fold_item)}; @@ -56,7 +56,7 @@ fn filter_native_item(cx: ctxt, &&item: @ast::native_item) -> fn fold_native_mod(cx: ctxt, nm: ast::native_mod, fld: fold::ast_fold) -> ast::native_mod { - let filter = bind filter_native_item(cx, _); + let filter = {|a|filter_native_item(cx, a)}; let filtered_items = vec::filter_map(nm.items, filter); ret {view_items: vec::map(nm.view_items, fld.fold_view_item), items: filtered_items}; @@ -81,7 +81,7 @@ fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) -> fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { - let filter = bind filter_stmt(cx, _); + let filter = {|a|filter_stmt(cx, a)}; let filtered_stmts = vec::filter_map(b.stmts, filter); ret {view_items: b.view_items, stmts: vec::map(filtered_stmts, fld.fold_stmt), diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 44b9356896b..473d25841b8 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -44,9 +44,9 @@ fn generate_test_harness(sess: session::session, testfns: dvec()}; let precursor = - @{fold_crate: fold::wrap(bind fold_crate(cx, _, _)), - fold_item: bind fold_item(cx, _, _), - fold_mod: bind fold_mod(cx, _, _) with *fold::default_ast_fold()}; + @{fold_crate: fold::wrap({|a,b|fold_crate(cx, a, b)}), + fold_item: {|a,b|fold_item(cx, a, b)}, + fold_mod: {|a,b|fold_mod(cx, a, b)} with *fold::default_ast_fold()}; let fold = fold::make_fold(precursor); let res = @fold.fold_crate(*crate); diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index fbb6a18edcd..97ccb1d3f24 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -31,8 +31,8 @@ fn read_crates(diag: span_handler, crate: ast::crate, mut next_crate_num: 1}; let v = visit::mk_simple_visitor(@{visit_view_item: - bind visit_view_item(e, _), - visit_item: bind visit_item(e, _) + {|a|visit_view_item(e, a)}, + visit_item: {|a|visit_item(e, a)} with *visit::default_simple_visitor()}); visit::visit_crate(crate, (), v); dump_crates(e.crate_cache); diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 9ae0fa9842f..e8e367656c1 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -77,7 +77,7 @@ fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> { fn eq_item(bytes: [u8], item_id: int) -> bool { ret io::u64_from_be_bytes(bytes, 0u, 4u) as int == item_id; } - let eqer = bind eq_item(_, item_id); + let eqer = {|a|eq_item(a, item_id)}; let found = lookup_hash(items, eqer, hash_node_id(item_id)); if vec::len(found) == 0u { ret option::none::<ebml::doc>; @@ -213,7 +213,7 @@ fn resolve_path(path: [ast::ident], data: @[u8]) -> [ast::def_id] { let s = ast_util::path_name_i(path); let md = ebml::doc(data); let paths = ebml::get_doc(md, tag_paths); - let eqer = bind eq_item(_, s); + let eqer = {|a|eq_item(a, s)}; let mut result: [ast::def_id] = []; #debug("resolve_path: looking up %s", s); for lookup_hash(paths, eqer, hash_path(s)).each {|doc| diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 9ad1ef1a4e1..e8fb1a3596e 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -271,7 +271,7 @@ fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt, let ty_str_ctxt = @{diag: ecx.diag, ds: def_to_str, tcx: ecx.tcx, - reachable: reachable(ecx, _), + reachable: {|a|reachable(ecx, a)}, abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; for params.each {|param| ebml_w.start_tag(tag_items_data_item_ty_param_bounds); @@ -292,7 +292,7 @@ fn write_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) { @{diag: ecx.diag, ds: def_to_str, tcx: ecx.tcx, - reachable: reachable(ecx, _), + reachable: {|a|reachable(ecx, a)}, abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); } @@ -551,7 +551,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, index: @mut [entry<int>]) { *index += [{val: item.id, pos: ebml_w.writer.tell()}]; } - let add_to_index = bind add_to_index_(item, copy ebml_w, index); + let add_to_index = {|copy ebml_w|add_to_index_(item, ebml_w, index)}; alt item.node { item_const(_, _) { diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index c6e70c6db07..f7c4628e51c 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -37,7 +37,7 @@ fn next_byte(st: @pstate) -> u8 { fn parse_ident(st: @pstate, last: char) -> ast::ident { fn is_last(b: char, c: char) -> bool { ret c == b; } - ret parse_ident_(st, bind is_last(last, _)); + ret parse_ident_(st, {|a|is_last(last, a)}); } fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 99542973c17..b275ebcb3ae 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -445,8 +445,8 @@ fn decode_ast(par_doc: ebml::doc) -> ast::inlined_item { fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) -> ast::inlined_item { let fld = fold::make_fold(@{ - new_id: xcx.tr_id(_), - new_span: xcx.tr_span(_) + new_id: {|a|xcx.tr_id(a)}, + new_span: {|a|xcx.tr_span(a)} with *fold::default_ast_fold() }); @@ -697,7 +697,7 @@ impl helpers for @e::encode_ctxt { @{diag: self.tcx.sess.diagnostic(), ds: e::def_to_str, tcx: self.tcx, - reachable: encoder::reachable(self, _), + reachable: {|a|encoder::reachable(self, a)}, abbrevs: tyencode::ac_use_abbrevs(self.type_abbrevs)} } } @@ -903,7 +903,7 @@ impl decoder for ebml::ebml_deserializer { tydecode::parse_ty_data( self.parent.data, xcx.dcx.cdata.cnum, self.pos, xcx.dcx.tcx, - xcx.tr_def_id(_)) + {|a|xcx.tr_def_id(a)}) } fn read_tys(xcx: extended_decode_ctxt) -> [ty::t] { @@ -913,7 +913,7 @@ impl decoder for ebml::ebml_deserializer { fn read_bounds(xcx: extended_decode_ctxt) -> @[ty::param_bound] { tydecode::parse_bounds_data( self.parent.data, self.pos, xcx.dcx.cdata.cnum, xcx.dcx.tcx, - xcx.tr_def_id(_)) + {|a|xcx.tr_def_id(a)}) } fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt) diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index b8ec0f9c2f1..cdfb2a08c68 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -170,7 +170,7 @@ impl public_methods for borrowck_ctxt { self.cat_def(expr.id, expr.span, expr_ty, def) } - ast::expr_addr_of(*) | ast::expr_call(*) | ast::expr_bind(*) | + ast::expr_addr_of(*) | ast::expr_call(*) | ast::expr_swap(*) | ast::expr_move(*) | ast::expr_assign(*) | ast::expr_assign_op(*) | ast::expr_fn(*) | ast::expr_fn_block(*) | ast::expr_assert(*) | ast::expr_check(*) | ast::expr_ret(*) | diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index ee95a8571ff..20bbce07d75 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -13,8 +13,8 @@ import std::map::hashmap; fn check_crate(tcx: ty::ctxt, crate: @crate) { visit::visit_crate(*crate, (), visit::mk_vt(@{ - visit_expr: bind check_expr(tcx, _, _, _), - visit_local: bind check_local(tcx, _, _, _) + visit_expr: {|a,b,c|check_expr(tcx, a, b, c)}, + visit_local: {|a,b,c|check_local(tcx, a, b, c)} with *visit::default_visitor::<()>() })); tcx.sess.abort_if_errors(); diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index af4bf8ca910..9abeda8dded 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -8,9 +8,11 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, def_map: resolve::def_map, method_map: typeck::method_map, tcx: ty::ctxt) { visit::visit_crate(*crate, false, visit::mk_vt(@{ - visit_item: check_item(sess, ast_map, def_map, _, _, _), + visit_item: {|a,b,c|check_item(sess, ast_map, def_map, a, b, c)}, visit_pat: check_pat, - visit_expr: bind check_expr(sess, def_map, method_map, tcx, _, _, _) + visit_expr: {|a,b,c| + check_expr(sess, def_map, method_map, tcx, a, b, c) + } with *visit::default_visitor() })); sess.abort_if_errors(); diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 4bec0e35e7e..2f9e8472022 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -240,9 +240,6 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { expr_tup(exprs) | expr_vec(exprs, _) { for exprs.each {|expr| maybe_copy(cx, expr); } } - expr_bind(_, args) { - for args.each {|a| alt a { some(ex) { maybe_copy(cx, ex); } _ {} } } - } expr_call(f, args, _) { let mut i = 0u; for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each {|arg_t| diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 152623bc6be..cc8b0383e36 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -468,7 +468,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { // otherwise, live nodes are not required: expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) | expr_rec(*) | expr_call(*) | expr_tup(*) | - expr_bind(*) | expr_new(*) | expr_log(*) | expr_binary(*) | + expr_new(*) | expr_log(*) | expr_binary(*) | expr_assert(*) | expr_check(*) | expr_addr_of(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_fail(*) | @@ -1081,16 +1081,6 @@ class liveness { self.propagate_through_exprs(exprs, succ) } - expr_bind(f, args) { - let succ = args.foldr(succ) { |arg, succ| - alt arg { - none {succ} - some(e) {self.propagate_through_expr(e, succ)} - } - }; - self.propagate_through_expr(f, succ) - } - expr_binary(op, l, r) if ast_util::lazy_binop(op) { let r_succ = self.propagate_through_expr(r, succ); @@ -1464,7 +1454,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) { expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) | expr_rec(*) | expr_tup(*) | - expr_bind(*) | expr_new(*) | expr_log(*) | expr_binary(*) | + expr_new(*) | expr_log(*) | expr_binary(*) | expr_assert(*) | expr_check(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_fail(*) | diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index fb9ae118a4a..fd0ecaa4fd5 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -328,8 +328,8 @@ fn map_crate(e: @env, c: @ast::crate) { // First, find all the modules, and index the names that they contain let v_map_mod = - @{visit_view_item: bind index_vi(e, _, _, _), - visit_item: bind index_i(e, _, _, _), + @{visit_view_item: {|a,b,c|index_vi(e, a, b, c)}, + visit_item: {|a,b,c|index_i(e, a, b, c)}, visit_block: visit_block_with_scope with *visit::default_visitor::<scopes>()}; visit::visit_crate(*c, top_scope(), visit::mk_vt(v_map_mod)); @@ -345,9 +345,9 @@ fn map_crate(e: @env, c: @ast::crate) { // Next, assemble the links for globbed imports and exports. let v_link_glob = - @{visit_view_item: bind link_glob(e, _, _, _), + @{visit_view_item: {|a,b,c|link_glob(e, a, b, c)}, visit_block: visit_block_with_scope, - visit_item: bind visit_item_with_scope(e, _, _, _) + visit_item: {|a,b,c|visit_item_with_scope(e, a, b, c)} with *visit::default_visitor::<scopes>()}; visit::visit_crate(*c, top_scope(), visit::mk_vt(v_link_glob)); @@ -414,17 +414,19 @@ fn resolve_names(e: @env, c: @ast::crate) { e.used_imports.track = true; let v = @{visit_native_item: visit_native_item_with_scope, - visit_item: bind walk_item(e, _, _, _), + visit_item: {|a,b,c|walk_item(e, a, b, c)}, visit_block: visit_block_with_scope, visit_decl: visit_decl_with_scope, visit_arm: visit_arm_with_scope, - visit_local: bind visit_local_with_scope(e, _, _, _), - visit_pat: bind walk_pat(e, _, _, _), - visit_expr: bind walk_expr(e, _, _, _), - visit_ty: bind walk_ty(e, _, _, _), - visit_ty_params: bind walk_tps(e, _, _, _), - visit_constr: bind walk_constr(e, _, _, _, _, _), - visit_fn: bind visit_fn_with_scope(e, _, _, _, _, _, _, _) + visit_local: {|a,b,c|visit_local_with_scope(e, a, b, c)}, + visit_pat: {|a,b,c|walk_pat(e, a, b, c)}, + visit_expr: {|a,b,c|walk_expr(e, a, b ,c)}, + visit_ty: {|a,b,c|walk_ty(e, a, b, c)}, + visit_ty_params: {|a,b,c|walk_tps(e, a, b, c)}, + visit_constr: {|a,b,c,d,f|walk_constr(e, a, b, c, d, f)}, + visit_fn: {|a,b,c,d,f,g,h| + visit_fn_with_scope(e, a, b, c, d, f, g, h) + } with *visit::default_visitor()}; visit::visit_crate(*c, top_scope(), visit::mk_vt(v)); e.used_imports.track = false; @@ -1713,11 +1715,12 @@ fn check_for_collisions(e: @env, c: ast::crate) { }; // Other scopes have to be checked the hard way. let v = - @{visit_item: bind check_item(e, _, _, _), - visit_block: bind check_block(e, _, _, _), - visit_arm: bind check_arm(e, _, _, _), - visit_expr: bind check_expr(e, _, _, _), - visit_ty: bind check_ty(e, _, _, _) with *visit::default_visitor()}; + @{visit_item: {|a,b,c|check_item(e, a, b, c)}, + visit_block: {|a,b,c|check_block(e, a, b, c)}, + visit_arm: {|a,b,c|check_arm(e, a, b, c)}, + visit_expr: {|a,b,c|check_expr(e, a, b, c)}, + visit_ty: {|a,b,c|check_ty(e, a, b, c)} + with *visit::default_visitor()}; visit::visit_crate(c, (), visit::mk_vt(v)); } @@ -2157,9 +2160,9 @@ type iscopes = @list<@[@_impl]>; fn resolve_impls(e: @env, c: @ast::crate) { visit::visit_crate(*c, @nil, visit::mk_vt(@{ - visit_block: bind visit_block_with_impl_scope(e, _, _, _), - visit_mod: bind visit_mod_with_impl_scope(e, _, _, _, _, _), - visit_expr: bind resolve_impl_in_expr(e, _, _, _) + visit_block: {|a,b,c|visit_block_with_impl_scope(e, a, b, c)}, + visit_mod: {|a,b,c,d,f|visit_mod_with_impl_scope(e, a, b, c, d, f)}, + visit_expr: {|a,b,c|resolve_impl_in_expr(e, a, b, c)} with *visit::default_visitor() })); } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 183f78ad2ac..f3f53804c20 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -663,7 +663,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm], *done = some(fail_cx.llbb); ret fail_cx.llbb; } - some(bind mk_fail(scope_cx, expr.span, fail_cx)) + some({||mk_fail(scope_cx, expr.span, fail_cx)}) } ast::alt_exhaustive { none } }; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index c532e51c584..44bb515393e 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -920,7 +920,7 @@ enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, } fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, op: ast::binop) -> result { - let f = bind compare_scalar_values(cx, lhs, rhs, _, op); + let f = {|a|compare_scalar_values(cx, lhs, rhs, a, op)}; alt ty::get(t).struct { ty::ty_nil { ret rslt(cx, f(nil_type)); } @@ -950,7 +950,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, cx.tcx().sess.bug("compare_scalar_values: must be a\ comparison operator"); } - let die = bind die_(cx); + let die = fn@() -> ! { die_(cx) }; alt nt { nil_type { // We don't need to do actual comparisons for nil. @@ -1609,7 +1609,8 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, fn cast_shift_expr_rhs(cx: block, op: ast::binop, lhs: ValueRef, rhs: ValueRef) -> ValueRef { cast_shift_rhs(op, lhs, rhs, - bind Trunc(cx, _, _), bind ZExt(cx, _, _)) + {|a,b|Trunc(cx, a, b)}, + {|a,b|ZExt(cx, a, b)}) } fn cast_shift_const_rhs(op: ast::binop, @@ -2343,7 +2344,9 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) none { // Not seen yet alt csearch::maybe_get_item_ast( ccx.tcx, fn_id, - bind astencode::decode_inlined_item(_, _, ccx.maps, _, _)) { + {|a,b,c,d| + astencode::decode_inlined_item(a, b, ccx.maps, c, d) + }) { csearch::not_found { ccx.external.insert(fn_id, none); @@ -3664,10 +3667,6 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ast::expr_do_body(blk) { ret trans_expr(bcx, blk, dest); } - ast::expr_bind(f, args) { - ret closure::trans_bind( - bcx, f, args, e.id, dest); - } ast::expr_copy(a) { if !expr_is_lval(bcx, a) { ret trans_expr(bcx, a, dest); @@ -5351,7 +5350,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { fn trans_constants(ccx: @crate_ctxt, crate: @ast::crate) { visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ - visit_item: bind trans_constant(ccx, _) + visit_item: {|a|trans_constant(ccx, a)} with *visit::default_simple_visitor() })); } @@ -5495,14 +5494,14 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) -> encoder::encode_parms { let encode_inlined_item = - bind astencode::encode_inlined_item(_, _, _, _, cx.maps); + {|a,b,c,d|astencode::encode_inlined_item(a, b, c, d, cx.maps)}; ret { diag: cx.sess.diagnostic(), tcx: cx.tcx, reachable: cx.reachable, reexports: reexports(cx), - impl_map: impl_map(cx, _), + impl_map: {|a|impl_map(cx, a)}, item_symbols: cx.item_symbols, discrim_symbols: cx.discrim_symbols, link_meta: cx.link_meta, diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 868826d975b..fd66b34c816 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -426,14 +426,6 @@ fn trans_expr_fn(bcx: block, ret bcx; } -fn trans_bind(cx: block, f: @ast::expr, args: [option<@ast::expr>], - id: ast::node_id, dest: dest) -> block { - let _icx = cx.insn_ctxt("closure::trans_bind"); - let f_res = trans_callee(cx, f); - ret trans_bind_1(cx, expr_ty(cx, f), f_res, args, - node_id_type(cx, id), dest); -} - fn trans_bind_1(cx: block, outgoing_fty: ty::t, f_res: lval_maybe_callee, args: [option<@ast::expr>], pair_ty: ty::t, diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 6474fa716b4..d3f75d3c07d 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -232,7 +232,7 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) { ty_to_str(cx.ccx().tcx, ty)]; let cleanup_type = cleanup_type(cx.tcx(), ty); in_scope_cx(cx) {|info| - info.cleanups += [clean(bind base::drop_ty(_, val, ty), + info.cleanups += [clean({|a|base::drop_ty(a, val, ty)}, cleanup_type)]; scope_clean_changed(info); } @@ -252,7 +252,7 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { } } in_scope_cx(cx) {|info| - info.cleanups += [clean_temp(val, bind do_drop(_, val, ty), + info.cleanups += [clean_temp(val, {|a|do_drop(a, val, ty)}, cleanup_type)]; scope_clean_changed(info); } @@ -264,14 +264,14 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { ty_to_str(cx.ccx().tcx, ty)]; let cleanup_type = cleanup_type(cx.tcx(), ty); in_scope_cx(cx) {|info| - info.cleanups += [clean_temp(val, bind base::drop_ty(_, val, ty), + info.cleanups += [clean_temp(val, {|a|base::drop_ty(a, val, ty)}, cleanup_type)]; scope_clean_changed(info); } } fn add_clean_free(cx: block, ptr: ValueRef, shared: bool) { - let free_fn = if shared { bind base::trans_unique_free(_, ptr) } - else { bind base::trans_free(_, ptr) }; + let free_fn = if shared { {|a|base::trans_unique_free(a, ptr)} } + else { {|a|base::trans_free(a, ptr)} }; in_scope_cx(cx) {|info| info.cleanups += [clean_temp(ptr, free_fn, normal_exit_and_unwind)]; diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 6b453b9d9dc..7f87c6f74e2 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -223,7 +223,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { expr_while(_, _) | expr_fail(_) | expr_break | expr_cont | expr_unary(_, _) | expr_lit(_) | expr_assert(_) | expr_check(_, _) | expr_if_check(_, _, _) | expr_mac(_) | expr_addr_of(_, _) | - expr_ret(_) | expr_loop(_) | expr_bind(_, _) | + expr_ret(_) | expr_loop(_) | expr_loop_body(_) | expr_do_body(_) {} } } diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index 0db63a4ac26..be38692c49e 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -27,11 +27,11 @@ fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut [node_id]) { fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]) { let collect_ids = - visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs), - visit_block: bind collect_ids_block(_, rs), - visit_stmt: bind collect_ids_stmt(_, rs), - visit_local: - bind collect_ids_local(tcx, _, rs) + visit::mk_simple_visitor(@{visit_expr: {|a|collect_ids_expr(a, rs)}, + visit_block: {|a|collect_ids_block(a, rs)}, + visit_stmt: {|a|collect_ids_stmt(a, rs)}, + visit_local: {|a| + collect_ids_local(tcx, a, rs)} with *visit::default_simple_visitor()}); collect_ids.visit_block(body, (), collect_ids); } @@ -59,7 +59,7 @@ fn annotate_in_fn(ccx: crate_ctxt, _fk: visit::fn_kind, _decl: fn_decl, fn annotate_crate(ccx: crate_ctxt, crate: crate) { let do_ann = visit::mk_simple_visitor( - @{visit_fn: bind annotate_in_fn(ccx, _, _, _, _, _) + @{visit_fn: {|a,b,c,d,e|annotate_in_fn(ccx, a, b, c, d, e)} with *visit::default_simple_visitor()}); visit::visit_crate(crate, (), do_ann); } diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index acc11572fe2..1ccb19cd53f 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -551,7 +551,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { } fn exprs_to_constr_args(tcx: ty::ctxt, args: [@expr]) -> [@constr_arg_use] { - let f = bind expr_to_constr_arg(tcx, _); + let f = {|a|expr_to_constr_arg(tcx, a)}; let mut rslt: [@constr_arg_use] = []; for args.each {|e| rslt += [f(e)]; } rslt diff --git a/src/rustc/middle/tstate/bitvectors.rs b/src/rustc/middle/tstate/bitvectors.rs index c3a38ac35eb..4524684bc60 100644 --- a/src/rustc/middle/tstate/bitvectors.rs +++ b/src/rustc/middle/tstate/bitvectors.rs @@ -138,7 +138,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) { visit_stmt: relax_precond_stmt, visit_item: fn@(_i: @item, _cx: relax_ctxt, _vt: visit::vt<relax_ctxt>) { }, - visit_fn: bind do_nothing(_, _, _, _, _, _, _) + visit_fn: do_nothing with *visitor}; let v1 = visit::mk_vt(visitor); v1.visit_block(b, cx, v1); diff --git a/src/rustc/middle/tstate/ck.rs b/src/rustc/middle/tstate/ck.rs index 64936ec37e5..5283c3b6f05 100644 --- a/src/rustc/middle/tstate/ck.rs +++ b/src/rustc/middle/tstate/ck.rs @@ -80,7 +80,9 @@ fn check_states_against_conditions(fcx: fn_ctxt, let visitor = visit::mk_vt( @{visit_stmt: check_states_stmt, visit_expr: check_states_expr, - visit_fn: bind do_nothing::<fn_ctxt>(_, _, _, _, _, _, _) + visit_fn: {|a,b,c,d,e,f,g| + do_nothing::<fn_ctxt>(a, b, c, d, e, f, g) + } with *visit::default_visitor::<fn_ctxt>()}); visit::visit_fn(fk, f_decl, f_body, sp, id, fcx, visitor); } diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index a6ce1642bab..33a5b1ab0b0 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -43,7 +43,7 @@ fn find_locals(tcx: ty::ctxt, let visitor = visit::default_visitor::<ctxt>(); let visitor = @{visit_expr: collect_pred, - visit_fn: bind do_nothing(_, _, _, _, _, _, _) + visit_fn: do_nothing with *visitor}; visit::visit_fn(fk, f_decl, f_body, sp, id, cx, visit::mk_vt(visitor)); @@ -147,9 +147,11 @@ fn mk_fn_info(ccx: crate_ctxt, to bit number) */ fn mk_f_to_fn_info(ccx: crate_ctxt, c: @crate) { let visitor = - visit::mk_simple_visitor(@{visit_fn: - bind mk_fn_info(ccx, _, _, _, _, _) - with *visit::default_simple_visitor()}); + visit::mk_simple_visitor(@{ + visit_fn: {|a,b,c,d,e| + mk_fn_info(ccx, a, b, c, d, e) + } + with *visit::default_simple_visitor()}); visit::visit_crate(*c, (), visitor); } // diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 110989a6a79..e1d0bf332c0 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -81,7 +81,7 @@ fn find_pre_post_exprs(fcx: fn_ctxt, args: [@expr], id: node_id) { fn get_pp(ccx: crate_ctxt, &&e: @expr) -> pre_and_post { ret expr_pp(ccx, e); } - let pps = vec::map(args, bind get_pp(fcx.ccx, _)); + let pps = vec::map(args, {|a|get_pp(fcx.ccx, a)}); set_pre_and_post(fcx.ccx, id, seq_preconds(fcx, pps), seq_postconds(fcx, vec::map(pps, get_post))); @@ -414,7 +414,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { let e_pp = {precondition: empty_prestate(num_local_vars), postcondition: false_postcond(num_local_vars)}; - let g = bind combine_pp(antec_pp, fcx, _, _); + let g = {|a,b|combine_pp(antec_pp, fcx, a, b)}; let alts_overall_pp = vec::foldl(e_pp, alt_pps, g); set_pre_and_post(fcx.ccx, e.id, alts_overall_pp.precondition, @@ -449,22 +449,6 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_if_check(p, conseq, maybe_alt) { join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check); } - expr_bind(operator, maybe_args) { - let mut args = []; - let mut cmodes = callee_modes(fcx, operator.id); - let mut modes = []; - let mut i = 0; - for maybe_args.each {|expr_opt| - alt expr_opt { - none {/* no-op */ } - some(expr) { modes += [cmodes[i]]; args += [expr]; } - } - i += 1; - } - args += [operator]; /* ??? order of eval? */ - forget_args_moved_in(fcx, e, modes, args); - find_pre_post_exprs(fcx, args, e.id); - } expr_break { clear_pp(expr_pp(fcx.ccx, e)); } expr_cont { clear_pp(expr_pp(fcx.ccx, e)); } expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); } @@ -572,7 +556,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) { } for b.node.stmts.each {|s| do_one_(fcx, s); } fn do_inner_(fcx: fn_ctxt, &&e: @expr) { find_pre_post_expr(fcx, e); } - let do_inner = bind do_inner_(fcx, _); + let do_inner = {|a|do_inner_(fcx, a)}; option::map::<@expr, ()>(b.node.expr, do_inner); let mut pps: [pre_and_post] = []; diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index dfc511122a6..2948d097ab6 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -305,21 +305,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { operands, controlflow_expr(fcx.ccx, operator)); } - expr_bind(operator, maybe_args) { - let mut args = []; - let callee_ops = callee_arg_init_ops(fcx, operator.id); - let mut ops = []; - let mut i = 0; - for maybe_args.each {|a_opt| - alt a_opt { - none {/* no-op */ } - some(a) { ops += [callee_ops[i]]; args += [a]; } - } - i += 1; - } - ret find_pre_post_state_call(fcx, pres, operator, e.id, ops, args, - return_val); - } expr_path(_) { ret pure_exp(fcx.ccx, e.id, pres); } expr_log(_, lvl, ex) { ret find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure); diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index b1672ef31bc..de12fcb389a 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -134,7 +134,7 @@ impl methods for isr_alist { fn check_item_types(ccx: @crate_ctxt, crate: @ast::crate) { let visit = visit::mk_simple_visitor(@{ - visit_item: bind check_item(ccx, _) + visit_item: {|a|check_item(ccx, a)} with *visit::default_simple_visitor() }); visit::visit_crate(*crate, (), visit); @@ -1396,63 +1396,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; fcx.write_ty(id, typ); } - ast::expr_bind(f, args) { - // Call the generic checker. - bot = check_expr(fcx, f, none); - - let {fty, bot: ccob_bot} = { - let fn_ty = fcx.expr_ty(f); - check_call_or_bind(fcx, expr.span, expr.id, fn_ty, args) - }; - bot |= ccob_bot; - - // TODO: Perform substitutions on the return type. - - // Pull the argument and return types out. - let mut proto, arg_tys, rt, cf, constrs; - alt structure_of(fcx, expr.span, fty) { - // FIXME: - // probably need to munge the constrs to drop constraints - // for any bound args (contingent on #2588 not getting accepted) - ty::ty_fn(f) { - proto = f.proto; - arg_tys = f.inputs; - rt = f.output; - cf = f.ret_style; - constrs = f.constraints; - } - _ { fail "LHS of bind expr didn't have a function type?!"; } - } - - let proto = alt proto { - ast::proto_bare | ast::proto_box | ast::proto_uniq { - ast::proto_box - } - ast::proto_any | ast::proto_block { - tcx.sess.span_err(expr.span, - #fmt["cannot bind %s closures", - proto_to_str(proto)]); - proto // dummy value so compilation can proceed - } - }; - - // For each blank argument, add the type of that argument - // to the resulting function type. - let mut out_args = []; - let mut i = 0u; - while i < vec::len(args) { - alt args[i] { - some(_) {/* no-op */ } - none { out_args += [arg_tys[i]]; } - } - i += 1u; - } - - let ft = ty::mk_fn(tcx, {purity: ast::impure_fn, proto: proto, - inputs: out_args, output: rt, - ret_style: cf, constraints: constrs}); - fcx.write_ty(id, ft); - } ast::expr_call(f, args, _) { bot = check_call(fcx, expr.span, expr.id, f, args); } diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index e56e99aa543..bb9bc0a6653 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -198,7 +198,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { ret str::eq(*name, *f.ident); } for fields.each {|f| - alt vec::find(ex_fields, bind matches(f.ident, _)) { + alt vec::find(ex_fields, {|a|matches(f.ident, a)}) { some(field) { check_pat(pcx, f.pat, field.mt.ty); } diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 81e1e3057de..490656eccbe 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -53,8 +53,8 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { } visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ - visit_item: bind convert(ccx, _), - visit_native_item: bind convert_native(ccx, _) + visit_item: {|a|convert(ccx, a)}, + visit_native_item: {|a|convert_native(ccx, a)} with *visit::default_simple_visitor() })); } diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 845bd8b1fb4..ec599e72c4c 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -39,7 +39,7 @@ fn block_expr_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { let rs = @mut false; let visit_expr = {|flag: @mut bool, e: @ast::expr| *flag |= p(e.node)}; let v = - visit::mk_simple_visitor(@{visit_expr: bind visit_expr(rs, _) + visit::mk_simple_visitor(@{visit_expr: {|a|visit_expr(rs, a)} with *visit::default_simple_visitor()}); visit::visit_block(b, (), v); ret *rs; diff --git a/src/rustdoc/prune_unexported_pass.rs b/src/rustdoc/prune_unexported_pass.rs index 0c4614adf1d..d581ead494a 100644 --- a/src/rustdoc/prune_unexported_pass.rs +++ b/src/rustdoc/prune_unexported_pass.rs @@ -62,7 +62,9 @@ fn exported_items_from_mod( srv: astsrv::srv, doc: doc::moddoc ) -> [doc::itemtag] { - exported_items_from(srv, doc, bind is_exported_from_mod(_, doc.id(), _)) + exported_items_from(srv, doc, {|a,b| + is_exported_from_mod(a, doc.id(), b) + }) } fn exported_items_from( diff --git a/src/rustdoc/reexport_pass.rs b/src/rustdoc/reexport_pass.rs index ea58eea76cb..b79d8e88f50 100644 --- a/src/rustdoc/reexport_pass.rs +++ b/src/rustdoc/reexport_pass.rs @@ -68,13 +68,13 @@ fn from_assoc_list<K:copy, V:copy>( fn from_def_assoc_list<V:copy>( list: [(ast::def_id, V)] ) -> map::hashmap<ast::def_id, V> { - from_assoc_list(list, bind ast_util::new_def_hash()) + from_assoc_list(list, ast_util::new_def_hash) } fn from_str_assoc_list<V:copy>( list: [(str, V)] ) -> map::hashmap<str, V> { - from_assoc_list(list, bind map::str_hash()) + from_assoc_list(list, map::str_hash) } fn build_reexport_def_set(srv: astsrv::srv) -> def_set { @@ -256,7 +256,7 @@ fn for_each_reexported_impl( f: fn@(ast::node_id, resolve::_impl) ) { let visitor = @{ - visit_mod: bind visit_mod(ctxt, f, _, _, _) + visit_mod: {|a,b,c|visit_mod(ctxt, f, a, b, c)} with *visit::default_simple_visitor() }; let visitor = visit::mk_simple_visitor(visitor); diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index dee7ef70d81..3973905c807 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -77,7 +77,7 @@ fn solve_grid(g: grid_t) { if color != 0u8 { bitv::set(colors, color as uint, false); } } - let it = bind drop_color(g, avail, _, _); + let it = {|a,b|drop_color(g, avail, a, b)}; for u8::range(0u8, 9u8) { |idx| it(idx, col); /* check same column fields */ diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 71023b8207b..f43f27f425f 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -129,7 +129,7 @@ mod map_reduce { send(c, emit_val(val)); } - map(input, bind emit(intermediates, ctrl, _, _)); + map(input, {|a,b|emit(intermediates, ctrl, a, b)}); fn finish<K: copy send, V: copy send>(_k: K, v: chan<reduce_proto<V>>) { @@ -148,8 +148,8 @@ mod map_reduce { send(out, chan(p)); - let ref_count = 0; - let is_done = false; + let mut ref_count = 0; + let mut is_done = false; fn get<V: copy send>(p: port<reduce_proto<V>>, &ref_count: int, &is_done: bool) @@ -171,7 +171,7 @@ mod map_reduce { ret none; } - reduce(key, bind get(p, ref_count, is_done)); + reduce(key, {||get(p, ref_count, is_done)}); } fn map_reduce<K1: copy send, K2: copy send, V: copy send>( diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index 2cce73209bf..12fd0943b4c 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -91,7 +91,7 @@ mod map_reduce { send(c, emit_val(val)); } - map(input, bind emit(intermediates, ctrl, _, _)); + map(input, {|a,b|emit(intermediates, ctrl, a, b)}); for intermediates.each_value {|v| send(v, release); } @@ -125,7 +125,7 @@ mod map_reduce { ret none; } - reduce(key, bind get(p, state)); + reduce(key, {||get(p, state)}); } fn map_reduce(-inputs: [str]) { diff --git a/src/test/compile-fail/auto-deref-bind.rs b/src/test/compile-fail/auto-deref-bind.rs deleted file mode 100644 index b218ddd122a..00000000000 --- a/src/test/compile-fail/auto-deref-bind.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern: mismatched types - -fn add1(i: int) -> int { ret i + 1; } -fn main() { let f = @add1; let g = bind f(5); } diff --git a/src/test/compile-fail/bind-stack-closure.rs b/src/test/compile-fail/bind-stack-closure.rs deleted file mode 100644 index 6a08b9b56c0..00000000000 --- a/src/test/compile-fail/bind-stack-closure.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn foo(x: fn()) { - bind x(); //! ERROR cannot bind fn closures -} - -fn bar(x: fn&()) { - bind x(); //! ERROR cannot bind fn& closures -} - -fn main() { -} diff --git a/src/test/compile-fail/crust-no-bind.rs b/src/test/compile-fail/crust-no-bind.rs deleted file mode 100644 index 66ba4e4dad9..00000000000 --- a/src/test/compile-fail/crust-no-bind.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:expected function or native function but found *u8 -crust fn f() { -} - -fn main() { - let x = bind f(); -} \ No newline at end of file diff --git a/src/test/compile-fail/fn-bare-bind.rs b/src/test/compile-fail/fn-bare-bind.rs deleted file mode 100644 index a9d2f38f617..00000000000 --- a/src/test/compile-fail/fn-bare-bind.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn f() { -} - -fn main() { - // Can't produce a bare function by binding - let g: native fn() = bind f(); - //!^ ERROR mismatched types: expected `native fn()` but found `fn@()` -} diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/liveness-uninit-after-item.rs index 3d8e77040cd..678a063284e 100644 --- a/src/test/compile-fail/liveness-uninit-after-item.rs +++ b/src/test/compile-fail/liveness-uninit-after-item.rs @@ -1,6 +1,6 @@ fn main() { let bar; fn baz(_x: int) { } - bind baz(bar); //! ERROR use of possibly uninitialized variable: `bar` + baz(bar); //! ERROR use of possibly uninitialized variable: `bar` } diff --git a/src/test/compile-fail/tstate-unsat-after-item.rs b/src/test/compile-fail/tstate-unsat-after-item.rs index b82df3a8657..03fc1d326f6 100644 --- a/src/test/compile-fail/tstate-unsat-after-item.rs +++ b/src/test/compile-fail/tstate-unsat-after-item.rs @@ -4,6 +4,6 @@ fn even(i: int) : is_even(i) -> int { i } fn main() { let x = 4; fn baz(_x: int) { } - bind baz(even(x)); //! ERROR unsatisfied precondition + baz(even(x)); //! ERROR unsatisfied precondition } diff --git a/src/test/compile-fail/unsafe-fn-used-in-bind.rs b/src/test/compile-fail/unsafe-fn-used-in-bind.rs deleted file mode 100644 index 0e9a93390ec..00000000000 --- a/src/test/compile-fail/unsafe-fn-used-in-bind.rs +++ /dev/null @@ -1,9 +0,0 @@ -// -*- rust -*- - -unsafe fn f(x: int, y: int) -> int { ret x + y; } - -fn main() { - let x = bind f(3, _); - //!^ ERROR access to unsafe function requires unsafe function or block - let y = x(4); -} diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs index 216ae054947..1a1bfdd7d49 100644 --- a/src/test/run-fail/unwind-closure.rs +++ b/src/test/run-fail/unwind-closure.rs @@ -5,6 +5,7 @@ fn f(a: @int) { } fn main() { - let g = bind f(@0); + let b = @0; + let g = {|move b|f(b)}; g(); } \ No newline at end of file diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 75d5fc8b357..deb87b813d1 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -81,55 +81,55 @@ fn main() { @plus(@val(22u), @val(5u))), "plus(@minus(@val(3u), @val(10u)), \ @plus(@val(22u), @val(5u)))", - serialize_expr(_, _), - deserialize_expr(_), - serialize_expr(_, _)); + serialize_expr, + deserialize_expr, + serialize_expr); test_ser_and_deser({lo: 0u, hi: 5u, node: 22u}, "{lo: 0u, hi: 5u, node: 22u}", - serialize_spanned_uint(_, _), - deserialize_spanned_uint(_), - serialize_spanned_uint(_, _)); + serialize_spanned_uint, + deserialize_spanned_uint, + serialize_spanned_uint); test_ser_and_deser(an_enum({v: [1u, 2u, 3u]}), "an_enum({v: [1u, 2u, 3u]})", - serialize_an_enum(_, _), - deserialize_an_enum(_), - serialize_an_enum(_, _)); + serialize_an_enum, + deserialize_an_enum, + serialize_an_enum); test_ser_and_deser({x: 3u, y: 5u}, "{x: 3u, y: 5u}", - serialize_point(_, _), - deserialize_point(_), - serialize_point(_, _)); + serialize_point, + deserialize_point, + serialize_point); test_ser_and_deser([1u, 2u, 3u], "[1u, 2u, 3u]", - serialize_uint_vec(_, _), - deserialize_uint_vec(_), - serialize_uint_vec(_, _)); + serialize_uint_vec, + deserialize_uint_vec, + serialize_uint_vec); test_ser_and_deser(top(22u), "top(22u)", - serialize_uint_quark(_, _), - deserialize_uint_quark(_), - serialize_uint_quark(_, _)); + serialize_uint_quark, + deserialize_uint_quark, + serialize_uint_quark); test_ser_and_deser(bottom(222u), "bottom(222u)", - serialize_uint_quark(_, _), - deserialize_uint_quark(_), - serialize_uint_quark(_, _)); + serialize_uint_quark, + deserialize_uint_quark, + serialize_uint_quark); test_ser_and_deser(a, "a", - serialize_c_like(_, _), - deserialize_c_like(_), - serialize_c_like(_, _)); + serialize_c_like, + deserialize_c_like, + serialize_c_like); test_ser_and_deser(b, "b", - serialize_c_like(_, _), - deserialize_c_like(_), - serialize_c_like(_, _)); + serialize_c_like, + deserialize_c_like, + serialize_c_like); } \ No newline at end of file diff --git a/src/test/run-pass/bind-exterior.rs b/src/test/run-pass/bind-exterior.rs deleted file mode 100644 index 67784fa12d0..00000000000 --- a/src/test/run-pass/bind-exterior.rs +++ /dev/null @@ -1,5 +0,0 @@ - - -fn foo(a: @int, b: @int) -> int { ret *a + *b; } - -fn main() { let f1 = bind foo(@10, @12); assert (f1() == 22); } diff --git a/src/test/run-pass/bind-generic.rs b/src/test/run-pass/bind-generic.rs deleted file mode 100644 index 579b304f839..00000000000 --- a/src/test/run-pass/bind-generic.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn wrapper3<T: copy>(i: T, j: int) { - log(debug, i); - log(debug, j); - // This is a regression test that the spawn3 thunk to wrapper3 - // correctly finds the value of j - assert j == 123456789; -} - -fn spawn3<T: copy>(i: T, j: int) { - let wrapped = bind wrapper3(i, j); - wrapped(); -} - -fn main() { - spawn3(127u8, 123456789); -} \ No newline at end of file diff --git a/src/test/run-pass/bind-interior.rs b/src/test/run-pass/bind-interior.rs deleted file mode 100644 index 980a1e568f6..00000000000 --- a/src/test/run-pass/bind-interior.rs +++ /dev/null @@ -1,11 +0,0 @@ - - - -// -*- rust -*- -fn f(n: int) -> int { ret n; } - -fn main() { - let g: fn@() -> int = bind f(10); - let i: int = g(); - assert (i == 10); -} diff --git a/src/test/run-pass/bind-methods.rs b/src/test/run-pass/bind-methods.rs deleted file mode 100644 index 2eb20ed0e9d..00000000000 --- a/src/test/run-pass/bind-methods.rs +++ /dev/null @@ -1,20 +0,0 @@ -iface foo { - fn foo() -> int; - fn bar(p: int) -> int; -} -impl of foo for int { - fn foo() -> int { self } - fn bar(p: int) -> int { p * self.foo() } -} -impl <T: foo> of foo for [T] { - fn foo() -> int { vec::foldl(0, self, {|a, b| a + b.foo()}) } - fn bar(p: int) -> int { p + self.len() as int } -} - -fn main() { - let x = [1, 2, 3]; - let y = x.foo, z = [4, 5, 6].foo; - assert y() + z() == 21; - let a = x.bar, b = bind [4, 5, 6].bar(_); - assert a(1) + b(2) + z() == 24; -} diff --git a/src/test/run-pass/bind-native-fn.rs b/src/test/run-pass/bind-native-fn.rs deleted file mode 100644 index 93e54db6aa2..00000000000 --- a/src/test/run-pass/bind-native-fn.rs +++ /dev/null @@ -1,21 +0,0 @@ -// From #1174: -// xfail-fast - -use std; -import str; -import libc::*; - -#[nolink] -native mod libc { - fn write(fd: core::libc::c_int, buf: *u8, nbyte: core::libc::size_t); -} - -fn main() { - let s = "hello world\n"; - let b = str::bytes(s); - let l = str::len(s) as core::libc::size_t; - let b8 = unsafe { vec::unsafe::to_ptr(b) }; - libc::write(0i32, b8, l); - let a = bind libc::write(0i32, _, _); - a(b8, l); -} diff --git a/src/test/run-pass/bind-native.rs b/src/test/run-pass/bind-native.rs deleted file mode 100644 index 1b9e05d4fe6..00000000000 --- a/src/test/run-pass/bind-native.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* -Can we bind native things? -*/ - -#[abi = "cdecl"] -native mod rustrt { - fn rand_new() -> *libc::c_void; -} - -fn main() { bind rustrt::rand_new(); } diff --git a/src/test/run-pass/bind-parameterized-args-2.rs b/src/test/run-pass/bind-parameterized-args-2.rs deleted file mode 100644 index 997bc2b1799..00000000000 --- a/src/test/run-pass/bind-parameterized-args-2.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - fn echo<T>(c: int, x: fn@(T)) { #error("wee"); } - - let y = echo(42, _); - - y(fn@(&&i: str) { }); -} diff --git a/src/test/run-pass/bind-parameterized-args.rs b/src/test/run-pass/bind-parameterized-args.rs deleted file mode 100644 index a990ecc4da1..00000000000 --- a/src/test/run-pass/bind-parameterized-args.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - fn echo<T>(c: int, x: [T]) { } - - let y: fn@([int]) = echo(42, _); - - y([1]); -} diff --git a/src/test/run-pass/bind-thunk.rs b/src/test/run-pass/bind-thunk.rs deleted file mode 100644 index 52bae30b8ff..00000000000 --- a/src/test/run-pass/bind-thunk.rs +++ /dev/null @@ -1,11 +0,0 @@ - - - -// -*- rust -*- -fn f() -> int { ret 42; } - -fn main() { - let g: fn@() -> int = bind f(); - let i: int = g(); - assert (i == 42); -} diff --git a/src/test/run-pass/bind-trivial.rs b/src/test/run-pass/bind-trivial.rs deleted file mode 100644 index 205809a2b69..00000000000 --- a/src/test/run-pass/bind-trivial.rs +++ /dev/null @@ -1,11 +0,0 @@ - - - -// -*- rust -*- -fn f(n: int) -> int { ret n; } - -fn main() { - let g: fn@(int) -> int = f(_); - let i: int = g(42); - assert (i == 42); -} diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index 0b6413fc3ec..70e6c432c91 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -2,6 +2,6 @@ fn force(f: fn() -> int) -> int { ret f(); } fn main() { fn f() -> int { ret 7; } assert (force(f) == 7); - let g = bind force(f); + let g = {||force(f)}; assert (g() == 7); } diff --git a/src/test/run-pass/cycle-collection2.rs b/src/test/run-pass/cycle-collection2.rs index 406e73f545c..4a050761538 100644 --- a/src/test/run-pass/cycle-collection2.rs +++ b/src/test/run-pass/cycle-collection2.rs @@ -4,7 +4,7 @@ fn nop() { } fn nop_foo(_x : @foo) { } fn main() { - let w = @{ mut z: bind nop() }; - let x = bind nop_foo(w); + let w = @{ mut z: {||nop()} }; + let x = {||nop_foo(w)}; w.z = x; } \ No newline at end of file diff --git a/src/test/run-pass/cycle-collection4.rs b/src/test/run-pass/cycle-collection4.rs index 833fb3aafc5..ccbcdf6037b 100644 --- a/src/test/run-pass/cycle-collection4.rs +++ b/src/test/run-pass/cycle-collection4.rs @@ -4,7 +4,7 @@ fn nop() { } fn nop_foo(_y: [int], _x : @foo) { } fn main() { - let w = @{ mut z: bind nop() }; - let x = bind nop_foo([], w); + let w = @{ mut z: {||nop()} }; + let x = {||nop_foo([], w)}; w.z = x; } \ No newline at end of file diff --git a/src/test/run-pass/cycle-collection5.rs b/src/test/run-pass/cycle-collection5.rs index e64bdd16bf4..b75e559aae2 100644 --- a/src/test/run-pass/cycle-collection5.rs +++ b/src/test/run-pass/cycle-collection5.rs @@ -6,7 +6,7 @@ fn nop_foo(_y: @int, _x : @foo) { } fn o() -> @int { @10 } fn main() { - let w = @{ mut z: bind nop() }; - let x = bind nop_foo(o(), w); + let w = @{ mut z: {||nop()} }; + let x = {||nop_foo(o(), w)}; w.z = x; } \ No newline at end of file diff --git a/src/test/run-pass/drop-bind-thunk-args.rs b/src/test/run-pass/drop-bind-thunk-args.rs deleted file mode 100644 index e75320c1e75..00000000000 --- a/src/test/run-pass/drop-bind-thunk-args.rs +++ /dev/null @@ -1,5 +0,0 @@ - - -fn f(x: @int) { } - -fn main() { let x = @10; let ff = f(_); ff(x); ff(x); } diff --git a/src/test/run-pass/drop-parametric-closure-with-bound-box.rs b/src/test/run-pass/drop-parametric-closure-with-bound-box.rs deleted file mode 100644 index 39785d10bbf..00000000000 --- a/src/test/run-pass/drop-parametric-closure-with-bound-box.rs +++ /dev/null @@ -1,5 +0,0 @@ - - -fn f<T>(i: @uint, t: T) { } - -fn main() { let x = f::<char>(@0xdeafbeefu, _); } diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index 63201e5c796..1a3e6edd151 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -5,6 +5,6 @@ fn wrapper3(i: chan) { } fn main() { - let wrapped = bind wrapper3(chan_t); + let wrapped = {||wrapper3(chan_t)}; wrapped(); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index bdaa676954b..aa90fb785ec 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -11,8 +11,7 @@ fn test_generic<T>(expected: @T, eq: compare<T>) { fn test_box() { fn compare_box(b1: @bool, b2: @bool) -> bool { ret *b1 == *b2; } - let eq = compare_box(_, _); - test_generic::<bool>(@true, eq); + test_generic::<bool>(@true, compare_box); } fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index de1143464c8..78383513cd4 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -11,8 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_vec() { fn compare_box(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } - let eq = compare_box(_, _); - test_generic::<@int>(@1, eq); + test_generic::<@int>(@1, compare_box); } fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index 55e33263776..d7d639bcbcb 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -10,8 +10,7 @@ fn test_generic<T: copy>(expected: ~T, eq: compare<T>) { fn test_box() { fn compare_box(b1: ~bool, b2: ~bool) -> bool { ret *b1 == *b2; } - let eq = compare_box(_, _); - test_generic::<bool>(~true, eq); + test_generic::<bool>(~true, compare_box); } fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index 9dc580ed3b0..a1923e2dd8c 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -11,8 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_vec() { fn compare_box(&&v1: ~int, &&v2: ~int) -> bool { ret v1 == v2; } - let eq = compare_box(_, _); - test_generic::<~int>(~1, eq); + test_generic::<~int>(~1, compare_box); } fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 84324a00db7..57d519b62cb 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -11,16 +11,14 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_bool() { fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } - let eq = compare_bool(_, _); - test_generic::<bool>(true, eq); + test_generic::<bool>(true, compare_bool); } fn test_rec() { type t = {a: int, b: int}; fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } - let eq = compare_rec(_, _); - test_generic::<t>({a: 1, b: 2}, eq); + test_generic::<t>({a: 1, b: 2}, compare_rec); } fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 432c1438be6..f4be90bfe34 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -15,8 +15,7 @@ fn test_box() { log(debug, *b2); ret *b1 == *b2; } - let eq = compare_box(_, _); - test_generic::<bool>(@true, eq); + test_generic::<bool>(@true, compare_box); } fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index d099875a462..8d8fc5020d5 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -11,8 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_vec() { fn compare_vec(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } - let eq = compare_vec(_, _); - test_generic::<@int>(@1, eq); + test_generic::<@int>(@1, compare_vec); } fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 5647eab3dfe..c7953536546 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -14,8 +14,7 @@ fn test_box() { log(debug, *b2); ret *b1 == *b2; } - let eq = compare_box(_, _); - test_generic::<bool>(~true, eq); + test_generic::<bool>(~true, compare_box); } fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 903d93eb3c0..7b210b66f1f 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -11,8 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_vec() { fn compare_vec(&&v1: ~int, &&v2: ~int) -> bool { ret v1 == v2; } - let eq = compare_vec(_, _); - test_generic::<~int>(~1, eq); + test_generic::<~int>(~1, compare_vec); } fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index f9b8a43d344..d5a329189b5 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -13,16 +13,14 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { fn test_bool() { fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } - let eq = compare_bool(_, _); - test_generic::<bool>(true, eq); + test_generic::<bool>(true, compare_bool); } fn test_rec() { type t = {a: int, b: int}; fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } - let eq = compare_rec(_, _); - test_generic::<t>({a: 1, b: 2}, eq); + test_generic::<t>({a: 1, b: 2}, compare_rec); } fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index e69f022c291..0eea4a8ee34 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -11,8 +11,7 @@ fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) { fn test_box() { fn compare_box(b1: @bool, b2: @bool) -> bool { ret *b1 == *b2; } - let eq = compare_box(_, _); - test_generic::<bool>(@true, @false, eq); + test_generic::<bool>(@true, @false, compare_box); } fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index 68b8e0173b1..e4379e22e80 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -11,8 +11,7 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) { fn test_vec() { fn compare_box(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } - let eq = compare_box(_, _); - test_generic::<@int>(@1, @2, eq); + test_generic::<@int>(@1, @2, compare_box); } fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 3152f9eb801..cb44a03af2d 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -13,16 +13,14 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) { fn test_bool() { fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } - let eq = compare_bool(_, _); - test_generic::<bool>(true, false, eq); + test_generic::<bool>(true, false, compare_bool); } fn test_rec() { type t = {a: int, b: int}; fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } - let eq = compare_rec(_, _); - test_generic::<t>({a: 1, b: 2}, {a: 2, b: 3}, eq); + test_generic::<t>({a: 1, b: 2}, {a: 2, b: 3}, compare_rec); } fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index 319f24a7b02..a9d0e3e077d 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -1,9 +1,9 @@ fn fix_help<A, B>(f: native fn(fn@(A) -> B, A) -> B, x: A) -> B { - ret f(fix_help(f, _), x); + ret f({|a|fix_help(f, a)}, x); } fn fix<A, B>(f: native fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { - ret fix_help(f, _); + ret {|a|fix_help(f, a)}; } fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index a15b2fbbd53..75315243a74 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -1,9 +1,9 @@ fn fix_help<A, B: send>(f: native fn(fn@(A) -> B, A) -> B, x: A) -> B { - ret f(fix_help(f, _), x); + ret f({|a|fix_help(f, a)}, x); } fn fix<A, B: send>(f: native fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { - ret fix_help(f, _); + ret {|a|fix_help(f, a)}; } fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { diff --git a/src/test/run-pass/fn-bare-bind-generic.rs b/src/test/run-pass/fn-bare-bind-generic.rs deleted file mode 100644 index 58b28df63ae..00000000000 --- a/src/test/run-pass/fn-bare-bind-generic.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn f<T>(i: T, j: T, k: T) { - assert i == j; - assert j != k; -} - -fn main() { - // Binding a bare function turns it into a shared closure - let g: fn@() = bind f(10, 10, 20); - g(); -} \ No newline at end of file diff --git a/src/test/run-pass/fn-bare-bind.rs b/src/test/run-pass/fn-bare-bind.rs deleted file mode 100644 index 064e6430f8a..00000000000 --- a/src/test/run-pass/fn-bare-bind.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn f(i: int) { - assert i == 10; -} - -fn main() { - // Binding a bare function turns it into a shared closure - let g: fn@() = bind f(10); - g(); -} \ No newline at end of file diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 2f28b7c4192..408bd665534 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -7,7 +7,5 @@ fn main() { let a: int = direct(3); // direct let b: int = ho(direct); // indirect unbound - let c: int = ho(direct(_)); // indirect bound assert (a == b); - assert (b == c); } diff --git a/src/test/run-pass/generic-bind-2.rs b/src/test/run-pass/generic-bind-2.rs deleted file mode 100644 index eeb9cf25f8f..00000000000 --- a/src/test/run-pass/generic-bind-2.rs +++ /dev/null @@ -1,10 +0,0 @@ - - -fn id<T: copy>(t: T) -> T { ret t; } - -fn main() { - let t = {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7}; - assert (t.f == 6); - let f0 = bind id(t); - assert (f0().f == 6); -} diff --git a/src/test/run-pass/generic-bind.rs b/src/test/run-pass/generic-bind.rs deleted file mode 100644 index 5a9795d7ec6..00000000000 --- a/src/test/run-pass/generic-bind.rs +++ /dev/null @@ -1,17 +0,0 @@ - - -fn id<T: copy>(t: T) -> T { ret t; } - -fn main() { - let t = {_0: 1, _1: 2, _2: 3, _3: 4, _4: 5, _5: 6, _6: 7}; - assert (t._5 == 6); - let f1 = - id::<{_0: int, - _1: int, - _2: int, - _3: int, - _4: int, - _5: int, - _6: int}>(_); - assert (f1(t)._5 == 6); -} diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 197fda5c2f4..9d8e7ec116e 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -59,7 +59,7 @@ mod map_reduce { } } - map(input, emit(intermediates, ctrl, _, _)); + map(input, {|a,b|emit(intermediates, ctrl, a, b)}); send(ctrl, mapper_done); } diff --git a/src/test/run-pass/issue-1899.rs b/src/test/run-pass/issue-1899.rs deleted file mode 100644 index 77cf0b7e089..00000000000 --- a/src/test/run-pass/issue-1899.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() -{ - let _b = [bind (fn~() { })()]; -} diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 34ad5a1ce3d..151361660f5 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -37,11 +37,11 @@ fn range(lo: uint, hi: uint, it: fn(uint)) { } fn main() { - let range = bind range(0u, 1000u, _); - let filt = bind filter( + let range = {|a|range(0u, 1000u, a)}; + let filt = {|a|filter( range, {|&&n: uint| n % 3u != 0u && n % 5u != 0u }, - _); + a)}; let sum = foldl(filt, 0u) {|accum, &&n: uint| accum + n }; io::println(#fmt("%u", sum)); diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 1f0e2d830e5..06202bc1c0b 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -1,4 +1,4 @@ -fn quux<T: copy>(x: T) -> T { let f = id::<T>(_); ret f(x); } +fn quux<T: copy>(x: T) -> T { let f = id::<T>; ret f(x); } fn id<T: copy>(x: T) -> T { ret x; } diff --git a/src/test/run-pass/issue-898.rs b/src/test/run-pass/issue-898.rs deleted file mode 100644 index 7b6f3033ab4..00000000000 --- a/src/test/run-pass/issue-898.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn even(&&e: int) -> bool { - e % 2 == 0 -} - -fn log_if<T>(c: native fn(T)->bool, e: T) { - if c(e) { log(debug, e); } -} - -fn main() { - (log_if(even, _))(2); -} diff --git a/src/test/run-pass/rebind-fn.rs b/src/test/run-pass/rebind-fn.rs deleted file mode 100644 index 49cc7ef6d5a..00000000000 --- a/src/test/run-pass/rebind-fn.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn add(i: int, j: int) -> int { ret i + j; } -fn binder(n: int) -> fn@() -> int { let f = add(n, _); ret bind f(2); } -fn main() { - binder(5); - let f = binder(1); - assert (f() == 3); - assert (binder(8)() == 10); -} diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index 157a7aca6ea..99131811ae1 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -18,7 +18,7 @@ fn pure_foldl<T: copy, U: copy>(ls: @list<T>, u: U, f: fn(T, U) -> U) -> U { // fn from a pure fn pure fn pure_length<T: copy>(ls: @list<T>) -> uint { fn count<T>(_t: T, &&u: uint) -> uint { u + 1u } - unchecked{ pure_foldl(ls, 0u, count(_, _)) } + unchecked{ pure_foldl(ls, 0u, count) } } pure fn nonempty_list<T: copy>(ls: @list<T>) -> bool { pure_length(ls) > 0u } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 0b4e90ae1df..e8758237bb7 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -10,7 +10,7 @@ fn funny() { fn what() { fn the(x: @mut bool) { ret while !*x { *x = true; }; } let i = @mut false; - let dont = bind the(i); + let dont = {||the(i)}; dont(); assert (*i); } |
