diff --git a/doc/keywords.txt b/doc/keywords.txt index c01bc2c8ee49..eb559f0d5f9f 100644 --- a/doc/keywords.txt +++ b/doc/keywords.txt @@ -7,7 +7,7 @@ do else export f32 f64 fail false float fn for i16 i32 i64 i8 if import in int -lambda let log +let log mod mutable native note obj diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index ae65c284fc2b..fae174ad1139 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -234,7 +234,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { ret parse_ty_rust_fn(st, conv, ast::proto_send); } 'F' { - ret parse_ty_rust_fn(st, conv, ast::proto_shared(ast::sugar_normal)); + ret parse_ty_rust_fn(st, conv, ast::proto_shared); } 'f' { ret parse_ty_rust_fn(st, conv, ast::proto_bare); diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index f5c4c91d0ac6..2260ea632065 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -203,7 +203,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { fn enc_proto(w: io::writer, proto: proto) { alt proto { proto_send. { w.write_char('s'); } - proto_shared(_) { w.write_char('F'); } + proto_shared. { w.write_char('F'); } proto_block. { w.write_char('B'); } proto_bare. { w.write_char('f'); } } diff --git a/src/comp/middle/capture.rs b/src/comp/middle/capture.rs index 0dd1956ff418..c34450fa5285 100644 --- a/src/comp/middle/capture.rs +++ b/src/comp/middle/capture.rs @@ -34,7 +34,7 @@ fn check_capture_clause(tcx: ty::ctxt, let freevars = freevars::get_freevars(tcx, fn_expr_id); let seen_defs = map::new_int_hash(); - let check_capture_item = lambda(&&cap_item: @ast::capture_item) { + let check_capture_item = fn@(&&cap_item: @ast::capture_item) { let cap_def = tcx.def_map.get(cap_item.id); if !vec::any(*freevars, {|fv| fv.def == cap_def}) { tcx.sess.span_warn( @@ -52,7 +52,7 @@ fn check_capture_clause(tcx: ty::ctxt, } }; - let check_not_upvar = lambda(&&cap_item: @ast::capture_item) { + let check_not_upvar = fn@(&&cap_item: @ast::capture_item) { alt tcx.def_map.get(cap_item.id) { ast::def_upvar(_, _, _) { tcx.sess.span_err( @@ -64,7 +64,7 @@ fn check_capture_clause(tcx: ty::ctxt, } }; - let check_block_captures = lambda(v: [@ast::capture_item]) { + let check_block_captures = fn@(v: [@ast::capture_item]) { if check vec::is_not_empty(v) { let cap_item0 = vec::head(v); tcx.sess.span_err( @@ -78,7 +78,7 @@ fn check_capture_clause(tcx: ty::ctxt, check_block_captures(cap_clause.copies); check_block_captures(cap_clause.moves); } - ast::proto_bare. | ast::proto_shared(_) | ast::proto_send. { + ast::proto_bare. | ast::proto_shared. | ast::proto_send. { vec::iter(cap_clause.copies, check_capture_item); vec::iter(cap_clause.moves, check_capture_item); vec::iter(cap_clause.moves, check_not_upvar); @@ -113,7 +113,7 @@ fn compute_capture_vars(tcx: ty::ctxt, let implicit_mode = alt fn_proto { ast::proto_block. { cap_ref } - ast::proto_bare. | ast::proto_shared(_) | ast::proto_send. { cap_copy } + ast::proto_bare. | ast::proto_shared. | ast::proto_send. { cap_copy } }; vec::iter(*freevars) { |fvar| diff --git a/src/comp/middle/freevars.rs b/src/comp/middle/freevars.rs index 46ceb4257ff3..e1d481ca5c5a 100644 --- a/src/comp/middle/freevars.rs +++ b/src/comp/middle/freevars.rs @@ -37,7 +37,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt) { } let walk_expr = - lambda (expr: @ast::expr, &&depth: int, v: visit::vt) { + fn@ (expr: @ast::expr, &&depth: int, v: visit::vt) { alt expr.node { ast::expr_fn(proto, decl, _, captures) { if proto != ast::proto_bare { @@ -89,7 +89,7 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) -> freevar_map { let freevars = new_int_hash(); - let walk_fn = lambda (_fk: visit::fn_kind, _decl: ast::fn_decl, + let walk_fn = fn@ (_fk: visit::fn_kind, _decl: ast::fn_decl, blk: ast::blk, _sp: span, nid: ast::node_id) { let vars = collect_freevars(def_map, blk); freevars.insert(nid, vars); diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 2e3060b2c2b8..85ea75a95ec3 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -61,7 +61,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, let fty = ty::node_id_to_monotype(cx.tcx, id); alt ty::ty_fn_proto(cx.tcx, fty) { proto_send. { b(check_send); } - proto_shared(_) { b(check_copy); } + proto_shared. { b(check_copy); } proto_block. { /* no check needed */ } proto_bare. { b(check_none); } } @@ -106,7 +106,7 @@ fn check_fn_cap_clause(cx: ctx, }); //log("freevar_ids", freevar_ids); with_appropriate_checker(cx, id) { |checker| - let check_var = lambda(&&cap_item: @capture_item) { + let check_var = fn@(&&cap_item: @capture_item) { let cap_def = cx.tcx.def_map.get(cap_item.id); let cap_def_id = ast_util::def_id_of_def(cap_def).node; if !vec::member(cap_def_id, freevar_ids) { diff --git a/src/comp/middle/trans_closure.rs b/src/comp/middle/trans_closure.rs index dd343e14b4f7..5cbd72c4bef2 100644 --- a/src/comp/middle/trans_closure.rs +++ b/src/comp/middle/trans_closure.rs @@ -208,7 +208,7 @@ fn allocate_cbox(bcx: @block_ctxt, let ccx = bcx_ccx(bcx); - let alloc_in_heap = lambda(bcx: @block_ctxt, + let alloc_in_heap = fn@(bcx: @block_ctxt, xchgheap: bool, &temp_cleanups: [ValueRef]) -> (@block_ctxt, ValueRef) { @@ -520,7 +520,7 @@ fn trans_expr_fn(bcx: @block_ctxt, let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); register_fn(ccx, sp, sub_cx.path, "anon fn", [], id); - let trans_closure_env = lambda(ck: ty::closure_kind) -> ValueRef { + let trans_closure_env = fn@(ck: ty::closure_kind) -> ValueRef { let cap_vars = capture::compute_capture_vars( ccx.tcx, id, proto, cap_clause); let {llbox, cboxptr_ty, bcx} = build_closure(bcx, cap_vars, ck); @@ -532,7 +532,7 @@ fn trans_expr_fn(bcx: @block_ctxt, let closure = alt proto { ast::proto_block. { trans_closure_env(ty::closure_block) } - ast::proto_shared(_) { trans_closure_env(ty::closure_shared) } + ast::proto_shared. { trans_closure_env(ty::closure_shared) } ast::proto_send. { trans_closure_env(ty::closure_send) } ast::proto_bare. { let closure = C_null(T_opaque_cbox_ptr(ccx)); @@ -660,7 +660,7 @@ fn make_fn_glue( let bcx = cx; let tcx = bcx_tcx(cx); - let fn_env = lambda(ck: ty::closure_kind) -> @block_ctxt { + let fn_env = fn@(ck: ty::closure_kind) -> @block_ctxt { let box_cell_v = GEPi(cx, v, [0, abi::fn_field_box]); let box_ptr_v = Load(cx, box_cell_v); make_null_test(cx, box_ptr_v) {|bcx| @@ -675,7 +675,7 @@ fn make_fn_glue( ty::ty_fn({proto: ast::proto_send., _}) { fn_env(ty::closure_send) } - ty::ty_fn({proto: ast::proto_shared(_), _}) { + ty::ty_fn({proto: ast::proto_shared., _}) { fn_env(ty::closure_shared) } _ { fail "make_fn_glue invoked on non-function type" } diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 89d18ca2c2d6..e4d00120aacb 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -348,7 +348,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_fn(_, _, _, cap_clause) { find_pre_post_expr_fn_upvars(fcx, e); - let use_cap_item = lambda(&&cap_item: @capture_item) { + let use_cap_item = fn@(&&cap_item: @capture_item) { let d = local_node_id_to_local_def_id(fcx, cap_item.id); option::may(d, { |id| use_var(fcx, id) }); }; diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 84db898d21ef..f1a1858267aa 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1020,7 +1020,7 @@ pure fn kind_can_be_sent(k: kind) -> bool { fn proto_kind(p: proto) -> kind { alt p { ast::proto_block. { kind_noncopyable } - ast::proto_shared(_) { kind_copyable } + ast::proto_shared. { kind_copyable } ast::proto_send. { kind_sendable } ast::proto_bare. { kind_sendable } } @@ -1563,7 +1563,7 @@ fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto { ty::ty_fn(f) { ret f.proto; } ty::ty_native_fn(_, _) { // FIXME: This should probably be proto_bare - ret ast::proto_shared(ast::sugar_normal); + ret ast::proto_shared; } _ { cx.sess.bug("ty_fn_proto() called on non-fn type"); } } @@ -1947,8 +1947,7 @@ mod unify { (_, ast::proto_block.) { true } (ast::proto_bare., _) { true } - // Equal prototypes (modulo sugar) are always subprotos: - (ast::proto_shared(_), ast::proto_shared(_)) { true } + // Equal prototypes are always subprotos: (_, _) { p_sub == p_sup } }; } diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index ee97ce4a15f6..c55d26ce81cc 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -553,7 +553,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj, let t_field = ast_ty_to_ty(tcx, mode, f.ty); t_inputs += [{mode: ast::by_copy, ty: t_field}]; } - let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared(ast::sugar_normal), + let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared, inputs: t_inputs, output: t_obj.ty, ret_style: ast::return_val, constraints: []}); let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn}; @@ -697,7 +697,7 @@ mod collect { } // FIXME: this will be different for constrained types ty::mk_fn(cx.tcx, - {proto: ast::proto_shared(ast::sugar_normal), + {proto: ast::proto_shared, inputs: args, output: tag_ty, ret_style: ast::return_val, constraints: []}) }; @@ -799,13 +799,13 @@ mod collect { let t_res = ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty, params); let t_ctor = ty::mk_fn(cx.tcx, { - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, inputs: [{mode: ast::by_copy with t_arg}], output: t_res, ret_style: ast::return_val, constraints: [] }); let t_dtor = ty::mk_fn(cx.tcx, { - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, inputs: [t_arg], output: ty::mk_nil(cx.tcx), ret_style: ast::return_val, constraints: [] }); @@ -1172,9 +1172,9 @@ fn gather_locals(ccx: @crate_ctxt, }; let tcx = ccx.tcx; - let next_var_id = lambda () -> int { let rv = *nvi; *nvi += 1; ret rv; }; + let next_var_id = fn@ () -> int { let rv = *nvi; *nvi += 1; ret rv; }; let assign = - lambda (nid: ast::node_id, ty_opt: option::t) { + fn@ (nid: ast::node_id, ty_opt: option::t) { let var_id = next_var_id(); locals.insert(nid, var_id); alt ty_opt { @@ -1206,7 +1206,7 @@ fn gather_locals(ccx: @crate_ctxt, // Add explicitly-declared locals. let visit_local = - lambda (local: @ast::local, &&e: (), v: visit::vt<()>) { + fn@ (local: @ast::local, &&e: (), v: visit::vt<()>) { let local_ty = ast_ty_to_ty_crate_infer(ccx, local.node.ty); assign(local.node.id, local_ty); visit::visit_local(local, e, v); @@ -1214,7 +1214,7 @@ fn gather_locals(ccx: @crate_ctxt, // Add pattern bindings. let visit_pat = - lambda (p: @ast::pat, &&e: (), v: visit::vt<()>) { + fn@ (p: @ast::pat, &&e: (), v: visit::vt<()>) { alt p.node { ast::pat_bind(_, _) { assign(p.id, none); } _ {/* no-op */ } @@ -1726,7 +1726,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, // of arguments when we typecheck the functions. This isn't really the // right way to do this. let check_args = - lambda (check_blocks: bool) -> bool { + fn@ (check_blocks: bool) -> bool { let i = 0u; let bot = false; for a_opt: option::t<@ast::expr> in args { @@ -2179,7 +2179,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, fn lower_bound_proto(proto: ast::proto) -> ast::proto { // FIXME: This is right for bare fns, possibly not others alt proto { - ast::proto_bare. { ast::proto_shared(ast::sugar_normal) } + ast::proto_bare. { ast::proto_shared } _ { proto } } } @@ -2632,7 +2632,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) { let fcx: @fn_ctxt = @{ret_ty: rty, purity: ast::pure_fn, - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, var_bindings: ty::unify::mk_var_bindings(), locals: new_int_hash::(), next_var_id: @mutable 0, diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index c5e9a13616fd..1acbabd65f98 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -110,15 +110,10 @@ tag pat_ { tag mutability { mut; imm; maybe_mut; } -tag proto_sugar { - sugar_normal; - sugar_sexy; -} - tag proto { proto_bare; proto_send; - proto_shared(proto_sugar); + proto_shared; proto_block; } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 2b45115f5b99..2eeb5cbf136e 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -168,7 +168,7 @@ fn bad_expr_word_table() -> hashmap { let words = new_str_hash(); for word in ["mod", "if", "else", "while", "do", "alt", "for", "break", "cont", "ret", "be", "fail", "type", "resource", "check", - "assert", "claim", "native", "fn", "lambda", "pure", + "assert", "claim", "native", "fn", "fn@", "pure", "unsafe", "block", "import", "export", "let", "const", "log", "tag", "obj", "copy", "sendfn", "impl", "iface"] { words.insert(word, ()); @@ -514,8 +514,8 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { t = parse_ty_fn(proto, p); } else if eat_word(p, "block") { t = parse_ty_fn(ast::proto_block, p); - } else if eat_word(p, "lambda") { - t = parse_ty_fn(ast::proto_shared(ast::sugar_sexy), p); + } else if eat_word(p, "fn@") { + t = parse_ty_fn(ast::proto_shared, p); } else if eat_word(p, "sendfn") { t = parse_ty_fn(ast::proto_send, p); } else if eat_word(p, "obj") { @@ -821,8 +821,8 @@ fn parse_bottom_expr(p: parser) -> pexpr { ret pexpr(parse_fn_expr(p, proto)); } else if eat_word(p, "block") { ret pexpr(parse_fn_expr(p, ast::proto_block)); - } else if eat_word(p, "lambda") { - ret pexpr(parse_fn_expr(p, ast::proto_shared(ast::sugar_sexy))); + } else if eat_word(p, "fn@") { + ret pexpr(parse_fn_expr(p, ast::proto_shared)); } else if eat_word(p, "sendfn") { ret pexpr(parse_fn_expr(p, ast::proto_send)); } else if eat_word(p, "unchecked") { @@ -2117,7 +2117,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item { fn parse_fn_ty_proto(p: parser) -> ast::proto { if p.peek() == token::AT { p.bump(); - ast::proto_shared(ast::sugar_normal) + ast::proto_shared } else { ast::proto_bare } diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index b4a47a8db385..fc0a67dee235 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1685,8 +1685,7 @@ fn proto_to_str(p: ast::proto) -> str { ast::proto_bare. { "fn" } ast::proto_block. { "block" } ast::proto_send. { "sendfn" } - ast::proto_shared(ast::sugar_normal.) { "fn@" } - ast::proto_shared(ast::sugar_sexy.) { "lambda" } + ast::proto_shared. { "fn@" } }; } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index 7fec9e97e06c..1c38095d519e 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -19,7 +19,7 @@ tag fn_kind { fk_item_fn(ident, [ty_param]); //< an item declared with fn() fk_method(ident, [ty_param]); fk_res(ident, [ty_param]); - fk_anon(proto); //< an anonymous function like lambda(...) + fk_anon(proto); //< an anonymous function like fn@(...) fk_fn_block; //< a block {||...} } diff --git a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs index d5a0042d107a..a7348b26fa20 100644 --- a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs +++ b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs @@ -1,10 +1,10 @@ // error-pattern: copying a noncopyable value -fn to_lambda1(f: lambda(uint) -> uint) -> lambda(uint) -> uint { +fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint { ret f; } -fn to_lambda2(b: block(uint) -> uint) -> lambda(uint) -> uint { +fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { ret to_lambda1({|x| b(x)}); } diff --git a/src/test/compile-fail/cap-clause-illegal-cap.rs b/src/test/compile-fail/cap-clause-illegal-cap.rs index e2f60dbb6ab1..6f4972fdf66e 100644 --- a/src/test/compile-fail/cap-clause-illegal-cap.rs +++ b/src/test/compile-fail/cap-clause-illegal-cap.rs @@ -1,9 +1,9 @@ // error-pattern: copying a noncopyable value -fn to_lambda2(b: block(uint) -> uint) -> lambda(uint) -> uint { +fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { // test case where copy clause specifies a value that is not used - // in lambda body, but value is illegal to copy: - ret lambda[copy b](u: uint) -> uint { 22u }; + // in fn@ body, but value is illegal to copy: + ret fn@[copy b](u: uint) -> uint { 22u }; } fn main() { diff --git a/src/test/compile-fail/fn-expr-type-state.rs b/src/test/compile-fail/fn-expr-type-state.rs index 5eb7541a5203..cd7800b3780f 100644 --- a/src/test/compile-fail/fn-expr-type-state.rs +++ b/src/test/compile-fail/fn-expr-type-state.rs @@ -1,7 +1,7 @@ // error-pattern:Unsatisfied precondition fn main() { - // Typestate should work even in a lambda. we should reject this program. + // Typestate should work even in a fn@. we should reject this program. let f = fn () -> int { let i: int; ret i; }; log(error, f()); } diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs index 0a733687aa33..2117eeefe8bc 100644 --- a/src/test/compile-fail/lambda-mutate-nested.rs +++ b/src/test/compile-fail/lambda-mutate-nested.rs @@ -1,11 +1,11 @@ // error-pattern:assigning to upvar -// Make sure that nesting a block within a lambda doesn't let us -// mutate upvars from a lambda. +// Make sure that nesting a block within a fn@ doesn't let us +// mutate upvars from a fn@. fn f2(x: block()) { x(); } fn main() { let i = 0; - let ctr = lambda () -> int { f2({|| i = i + 1; }); ret i; }; + let ctr = fn@ () -> int { f2({|| i = i + 1; }); ret i; }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/lambda-mutate.rs b/src/test/compile-fail/lambda-mutate.rs index 6ba1cfc5401e..0c6d8b1e7c53 100644 --- a/src/test/compile-fail/lambda-mutate.rs +++ b/src/test/compile-fail/lambda-mutate.rs @@ -1,8 +1,8 @@ // error-pattern:assigning to upvar -// Make sure we can't write to upvars from lambdas +// Make sure we can't write to upvars from fn@s fn main() { let i = 0; - let ctr = lambda () -> int { i = i + 1; ret i; }; + let ctr = fn@ () -> int { i = i + 1; ret i; }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/sendfn-is-not-a-lambda.rs b/src/test/compile-fail/sendfn-is-not-a-lambda.rs index 0eb787761f31..1be97b946547 100644 --- a/src/test/compile-fail/sendfn-is-not-a-lambda.rs +++ b/src/test/compile-fail/sendfn-is-not-a-lambda.rs @@ -1,6 +1,6 @@ -// error-pattern: mismatched types: expected `lambda(++uint) -> uint` +// error-pattern: mismatched types: expected `fn@(++uint) -> uint` -fn test(f: lambda(uint) -> uint) -> uint { +fn test(f: fn@(uint) -> uint) -> uint { ret f(22u); } diff --git a/src/test/pretty/cap-clause.rs b/src/test/pretty/cap-clause.rs index cbe19a4cd1ec..eeaa7853c3e5 100644 --- a/src/test/pretty/cap-clause.rs +++ b/src/test/pretty/cap-clause.rs @@ -4,9 +4,9 @@ fn main() { let x = 1; let y = 2; let z = 3; - let l1 = lambda[copy x]() -> int { x + y }; - let l2 = lambda[copy x; move y]() -> int { x + y }; - let l3 = lambda[move z]() -> int { z }; + let l1 = fn@[copy x]() -> int { x + y }; + let l2 = fn@[copy x; move y]() -> int { x + y }; + let l3 = fn@[move z]() -> int { z }; let x = 1; let y = 2; diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 6980cc16bd15..b9dcabcabbfd 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -8,7 +8,7 @@ fn main() { macerate(*tasties); } (carrots, { |food| let mush = food + cheese; - lambda() { + let _ = fn@() { let chew = mush + cheese; fail "so yummy" } (); diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index caef692060e6..87067c502188 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -4,7 +4,7 @@ fn asSendfn( f : sendfn()->uint ) -> uint { ret f(); } -fn asLambda( f : lambda()->uint ) -> uint { +fn asLambda( f : fn@()->uint ) -> uint { ret f(); } diff --git a/src/test/run-pass/block-arg-used-as-lambda.rs b/src/test/run-pass/block-arg-used-as-lambda.rs index 6780e3692f59..18e8513b0903 100644 --- a/src/test/run-pass/block-arg-used-as-lambda.rs +++ b/src/test/run-pass/block-arg-used-as-lambda.rs @@ -1,9 +1,9 @@ -fn to_lambda(f: lambda(uint) -> uint) -> lambda(uint) -> uint { +fn to_lambda(f: fn@(uint) -> uint) -> fn@(uint) -> uint { ret f; } fn main() { - let x: lambda(uint) -> uint = to_lambda({ |x| x * 2u }); + let x: fn@(uint) -> uint = to_lambda({ |x| x * 2u }); let y = to_lambda(x); let x_r = x(22u); diff --git a/src/test/run-pass/cap-clause-move.rs b/src/test/run-pass/cap-clause-move.rs index a8cca1490faa..b484a16b06d4 100644 --- a/src/test/run-pass/cap-clause-move.rs +++ b/src/test/run-pass/cap-clause-move.rs @@ -2,8 +2,8 @@ fn main() { let x = ~1; let y = ptr::addr_of(*x) as uint; - let lam_copy = lambda[copy x]() -> uint { ptr::addr_of(*x) as uint }; - let lam_move = lambda[move x]() -> uint { ptr::addr_of(*x) as uint }; + let lam_copy = fn@[copy x]() -> uint { ptr::addr_of(*x) as uint }; + let lam_move = fn@[move x]() -> uint { ptr::addr_of(*x) as uint }; assert lam_copy() != y; assert lam_move() == y; diff --git a/src/test/run-pass/fn-type-infer.rs b/src/test/run-pass/fn-type-infer.rs index d9b6ac60ba3b..8367cbd58a7d 100644 --- a/src/test/run-pass/fn-type-infer.rs +++ b/src/test/run-pass/fn-type-infer.rs @@ -1,4 +1,4 @@ fn main() { - // We should be able to type infer inside of lambdas. + // We should be able to type infer inside of fn@s. let f = fn () { let i = 10; }; } diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 87dc1e6d89be..d526c00a9981 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -1,7 +1,7 @@ // This should typecheck even though the type of e is not fully -// resolved when we finish typechecking the lambda. +// resolved when we finish typechecking the fn@. fn main() { let e = @{mutable refs: [], n: 0}; - let f = lambda () { log(error, e.n); }; + let f = fn@ () { log(error, e.n); }; e.refs += [1]; } diff --git a/src/test/run-pass/lambda-no-leak.rs b/src/test/run-pass/lambda-no-leak.rs index 0eeb306d4fda..171650a42689 100644 --- a/src/test/run-pass/lambda-no-leak.rs +++ b/src/test/run-pass/lambda-no-leak.rs @@ -1,7 +1,7 @@ -// Make sure we don't leak lambdas in silly ways. +// Make sure we don't leak fn@s in silly ways. fn force(f: fn@()) { f() } fn main() { let x = 7; - lambda () { log(error, x); }; - force(lambda () { log(error, x); }); + let _ = fn@ () { log(error, x); }; + force(fn@ () { log(error, x); }); } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index aaef6e8e366d..6ac7404c3ceb 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -1,9 +1,9 @@ // Make sure #1399 stays fixed -fn foo() -> lambda() -> int { +fn foo() -> fn@() -> int { let k = ~22; let _u = {a: k}; - ret lambda[move k]() -> int { 22 }; + ret fn@[move k]() -> int { 22 }; } fn main() { diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 1399839a1ed0..b238dab30266 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -1,7 +1,7 @@ // Make sure #1399 stays fixed fn main() { - fn invoke(f: lambda()) { f(); } + fn invoke(f: fn@()) { f(); } let k = ~22; let _u = {a: k}; invoke {||log(error, k);}