diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 2e2bf37da77..425b43f7ce6 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -88,7 +88,7 @@ fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str) ret {crate: crate, src: src}; } -fn time<@T>(do_it: bool, what: str, thunk: fn() -> T) -> T { +fn time<@T>(do_it: bool, what: str, thunk: fn@() -> T) -> T { if !do_it { ret thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index 8d2ce55a279..e9e4b0aed34 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -12,7 +12,7 @@ import front::attr; export modify_for_testing; -type node_id_gen = fn() -> ast::node_id; +type node_id_gen = fn@() -> ast::node_id; type test = {span: span, path: [ast::ident], ignore: bool}; @@ -369,7 +369,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { il: ast::il_normal, cf: ast::return_val, constraints: []}; - let proto = ast::proto_fn; + let proto = ast::proto_bare; let test_main_call_expr = mk_test_main_call(cx); diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs index 8d3f8f5d824..fe97845a448 100644 --- a/src/comp/metadata/decoder.rs +++ b/src/comp/metadata/decoder.rs @@ -28,9 +28,9 @@ export external_resolver; // def_id for an item defined in another crate, somebody needs to figure out // what crate that's in and give us a def_id that makes sense for the current // build. -type external_resolver = fn(ast::def_id) -> ast::def_id; +type external_resolver = fn@(ast::def_id) -> ast::def_id; -fn lookup_hash(d: ebml::doc, eq_fn: fn([u8]) -> bool, hash: uint) -> +fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]) -> bool, hash: uint) -> [ebml::doc] { let index = ebml::get_doc(d, tag_index); let table = ebml::get_doc(index, tag_index_table); diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index 2e6a83c153d..4d56d5ae6ad 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -16,7 +16,7 @@ export parse_ty_data; // data buffer. Whatever format you choose should not contain pipe characters. // Callback to translate defs to strs or back: -type str_def = fn(str) -> ast::def_id; +type str_def = fn@(str) -> ast::def_id; type pstate = {data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt}; @@ -34,7 +34,7 @@ fn parse_ident(st: @pstate, sd: str_def, last: char) -> ast::ident { ret parse_ident_(st, sd, bind is_last(last, _)); } -fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn(char) -> bool) -> +fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn@(char) -> bool) -> ast::ident { let rslt = ""; while !is_last(peek(st) as char) { diff --git a/src/comp/middle/freevars.rs b/src/comp/middle/freevars.rs index 5a6ed3283e7..ea6d57e351b 100644 --- a/src/comp/middle/freevars.rs +++ b/src/comp/middle/freevars.rs @@ -24,7 +24,7 @@ type freevar_map = hashmap; // Since we want to be able to collect upvars in some arbitrary piece // of the AST, we take a walker function that we invoke with a visitor // in order to start the search. -fn collect_freevars(def_map: resolve::def_map, walker: fn(visit::vt)) -> +fn collect_freevars(def_map: resolve::def_map, walker: fn@(visit::vt)) -> freevar_info { let seen = new_int_hash(); let refs = @mutable []; diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 750a29da9f1..96b70568bf5 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -595,6 +595,7 @@ fn lookup_in_scope_strict(e: env, sc: scopes, sp: span, name: ident, fn scope_is_fn(sc: scope) -> bool { ret alt sc { scope_fn(_, ast::proto_iter., _) | scope_fn(_, ast::proto_fn., _) | + scope_fn(_, ast::proto_bare., _) | scope_native_item(_) { true } diff --git a/src/comp/middle/trans_alt.rs b/src/comp/middle/trans_alt.rs index be1de76f5b5..814a287bbc6 100644 --- a/src/comp/middle/trans_alt.rs +++ b/src/comp/middle/trans_alt.rs @@ -109,7 +109,7 @@ fn matches_always(p: @ast::pat) -> bool { }; } -type enter_pat = fn(@ast::pat) -> option::t<[@ast::pat]>; +type enter_pat = fn@(@ast::pat) -> option::t<[@ast::pat]>; fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match { let result = []; @@ -314,7 +314,7 @@ fn any_tup_pat(m: match, col: uint) -> bool { } type exit_node = {bound: bind_map, from: BasicBlockRef, to: BasicBlockRef}; -type mk_fail = fn() -> BasicBlockRef; +type mk_fail = fn@() -> BasicBlockRef; fn pick_col(m: match) -> uint { let scores = vec::init_elt_mut(0u, vec::len(m[0].pats)); diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index 3b0043e1660..651ac61277e 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -259,8 +259,8 @@ type fn_ctxt = lcx: @local_ctxt}; tag cleanup { - clean(fn(@block_ctxt) -> @block_ctxt); - clean_temp(ValueRef, fn(@block_ctxt) -> @block_ctxt); + clean(fn@(@block_ctxt) -> @block_ctxt); + clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt); } fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) { diff --git a/src/comp/middle/tstate/bitvectors.rs b/src/comp/middle/tstate/bitvectors.rs index 63d220ddbd2..9a0b1059bf2 100644 --- a/src/comp/middle/tstate/bitvectors.rs +++ b/src/comp/middle/tstate/bitvectors.rs @@ -151,7 +151,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) { }, - visit_fn: do_nothing + visit_fn: bind do_nothing(_, _, _, _, _, _, _) with *visitor}; let v1 = visit::mk_vt(visitor); v1.visit_block(b, cx, v1); diff --git a/src/comp/middle/tstate/ck.rs b/src/comp/middle/tstate/ck.rs index 45dc8d87d2b..2d1167bcc2d 100644 --- a/src/comp/middle/tstate/ck.rs +++ b/src/comp/middle/tstate/ck.rs @@ -111,7 +111,8 @@ fn check_states_against_conditions(fcx: fn_ctxt, f: _fn, tps: [ast::ty_param], visitor = @{visit_stmt: check_states_stmt, visit_expr: check_states_expr, - visit_fn: do_nothing with *visitor}; + visit_fn: bind do_nothing(_, _, _, _, _, _, _) + with *visitor}; visit::visit_fn(f, tps, sp, i, id, fcx, visit::mk_vt(visitor)); /* Check that the return value is initialized */ diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index 5b192e3a406..64c8a6c9174 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -54,7 +54,8 @@ fn find_locals(tcx: ty::ctxt, f: _fn, tps: [ty_param], sp: span, i: fn_ident, visitor = @{visit_local: collect_local, visit_expr: collect_pred, - visit_fn: do_nothing with *visitor}; + visit_fn: bind do_nothing(_, _, _, _, _, _, _) + with *visitor}; visit::visit_fn(f, tps, sp, i, id, cx, visit::mk_vt(visitor)); ret cx; } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 84532e718e5..512b648fe0c 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -603,7 +603,7 @@ fn cname(cx: ctxt, typ: t) -> option::t { // Type folds -type ty_walk = fn(t); +type ty_walk = fn@(t); fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) { alt struct(cx, ty) { @@ -655,9 +655,9 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) { } tag fold_mode { - fm_var(fn(int) -> t); - fm_param(fn(uint, ast::kind) -> t); - fm_general(fn(t) -> t); + fm_var(fn@(int) -> t); + fm_param(fn@(uint, ast::kind) -> t); + fm_general(fn@(t) -> t); } fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t { @@ -2712,13 +2712,14 @@ fn type_err_to_str(err: ty::type_err) -> str { // Converts type parameters in a type to type variables and returns the // resulting type along with a list of type variable IDs. -fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn() -> int, typ: t, +fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn@() -> int, typ: t, ty_param_count: uint) -> {ids: [int], ty: t} { let param_var_ids: @mutable [int] = @mutable []; let i = 0u; while i < ty_param_count { *param_var_ids += [next_ty_var()]; i += 1u; } fn binder(sp: span, cx: ctxt, param_var_ids: @mutable [int], - _next_ty_var: fn() -> int, index: uint, _kind: ast::kind) -> t { + _next_ty_var: fn@() -> int, index: uint, + _kind: ast::kind) -> t { if index < vec::len(*param_var_ids) { ret mk_var(cx, param_var_ids[index]); } else { diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index a017a684bb0..6bb9529042a 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -53,7 +53,7 @@ type fn_ctxt = // Used for ast_ty_to_ty() below. -type ty_getter = fn(ast::def_id) -> ty::ty_param_kinds_and_ty; +type ty_getter = fn@(ast::def_id) -> ty::ty_param_kinds_and_ty; fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> int { alt fcx.locals.find(id) { @@ -516,8 +516,8 @@ mod collect { ret k; } - fn ty_of_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t, - ty_of_arg: fn(ast::arg) -> arg, decl: ast::fn_decl, + fn ty_of_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t, + ty_of_arg: fn@(ast::arg) -> arg, decl: ast::fn_decl, proto: ast::proto, ty_params: [ast::ty_param], def_id: option::t) -> ty::ty_param_kinds_and_ty { @@ -536,8 +536,8 @@ mod collect { alt def_id { some(did) { cx.tcx.tcache.insert(did, tpt); } _ { } } ret tpt; } - fn ty_of_native_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t, - ty_of_arg: fn(ast::arg) -> arg, + fn ty_of_native_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t, + ty_of_arg: fn@(ast::arg) -> arg, decl: ast::fn_decl, abi: ast::native_abi, ty_params: [ast::ty_param], def_id: ast::def_id) -> ty::ty_param_kinds_and_ty { @@ -1227,8 +1227,10 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id, let visit = @{visit_local: visit_local, visit_pat: visit_pat, - visit_fn: visit_fn, - visit_item: visit_item with *visit::default_visitor()}; + visit_fn: bind visit_fn(_, _, _, _, _, _, _), + visit_item: bind visit_item(_, _, _) + with *visit::default_visitor()}; + visit::visit_block(f.body, (), visit::mk_vt(visit)); ret {var_bindings: vb, locals: locals, @@ -2787,7 +2789,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool { fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) { let main_t = ty::node_id_to_monotype(tcx, main_id); alt ty::struct(tcx, main_t) { - ty::ty_fn(ast::proto_fn., args, rs, ast::return_val., constrs) { + ty::ty_fn(ast::proto_bare., args, rs, ast::return_val., constrs) { let ok = vec::len(constrs) == 0u; ok &= ty::type_is_nil(tcx, rs); let num_args = vec::len(args); diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index 3f020a8aeb2..fb3b7caa3ca 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -6,10 +6,10 @@ import std::map::new_str_hash; import codemap; type syntax_expander = - fn(ext_ctxt, span, @ast::expr, option::t) -> @ast::expr; + fn@(ext_ctxt, span, @ast::expr, option::t) -> @ast::expr; type macro_def = {ident: str, ext: syntax_extension}; type macro_definer = - fn(ext_ctxt, span, @ast::expr, option::t) -> macro_def; + fn@(ext_ctxt, span, @ast::expr, option::t) -> macro_def; tag syntax_extension { normal(syntax_expander); diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs index 53b06824320..81a50d2f0b7 100644 --- a/src/comp/syntax/ext/expand.rs +++ b/src/comp/syntax/ext/expand.rs @@ -11,7 +11,7 @@ import syntax::ext::base::*; fn expand_expr(exts: hashmap, cx: ext_ctxt, e: expr_, - fld: ast_fold, orig: fn(expr_, ast_fold) -> expr_) -> expr_ { + fld: ast_fold, orig: fn@(expr_, ast_fold) -> expr_) -> expr_ { ret alt e { expr_mac(mac) { alt mac.node { diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 656ee3663af..d7b4214f2d0 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -72,7 +72,7 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! { // we'll want to return something indicating amount of progress and location // of failure instead of `none`. type match_result = option::t>; -type selector = fn(matchable) -> match_result; +type selector = fn@(matchable) -> match_result; fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) -> {pre: [@expr], rep: option::t<@expr>, post: [@expr]} { @@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) -> } } -fn option_flatten_map(f: fn(T) -> option::t, v: [T]) -> +fn option_flatten_map(f: fn@(T) -> option::t, v: [T]) -> option::t<[U]> { let res = []; for elem: T in v { @@ -263,7 +263,7 @@ iter free_vars(b: bindings, e: @expr) -> ident { /* handle sequences (anywhere in the AST) of exprs, either real or ...ed */ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], - recur: fn(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] { + recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] { alt elts_to_ell(cx, exprs) { {pre: pre, rep: repeat_me_maybe, post: post} { let res = vec::map(recur, pre); @@ -351,7 +351,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], e: ast::expr_, fld: ast_fold, - orig: fn(ast::expr_, ast_fold) -> ast::expr_) -> + orig: fn@(ast::expr_, ast_fold) -> ast::expr_) -> ast::expr_ { ret alt e { expr_path(p) { @@ -378,7 +378,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], t: ast::ty_, fld: ast_fold, - orig: fn(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ { + orig: fn@(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ { ret alt t { ast::ty_path(pth, _) { alt path_to_ident(pth) { @@ -402,7 +402,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint], blk: blk_, fld: ast_fold, - orig: fn(blk_, ast_fold) -> blk_) -> blk_ { + orig: fn@(blk_, ast_fold) -> blk_) -> blk_ { ret alt block_to_ident(blk) { some(id) { alt follow_for_trans(cx, b.find(id), idx_path) { diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 4a81ca1da0e..4e384efd5b2 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -20,58 +20,59 @@ type ast_fold = @mutable a_f; type ast_fold_precursor = //unlike the others, item_ is non-trivial - {fold_crate: fn(crate_, ast_fold) -> crate_, - fold_crate_directive: fn(crate_directive_, ast_fold) -> crate_directive_, - fold_view_item: fn(view_item_, ast_fold) -> view_item_, - fold_native_item: fn(&&@native_item, ast_fold) -> @native_item, - fold_item: fn(&&@item, ast_fold) -> @item, - fold_item_underscore: fn(item_, ast_fold) -> item_, - fold_method: fn(method_, ast_fold) -> method_, - fold_block: fn(blk_, ast_fold) -> blk_, - fold_stmt: fn(stmt_, ast_fold) -> stmt_, - fold_arm: fn(arm, ast_fold) -> arm, - fold_pat: fn(pat_, ast_fold) -> pat_, - fold_decl: fn(decl_, ast_fold) -> decl_, - fold_expr: fn(expr_, ast_fold) -> expr_, - fold_ty: fn(ty_, ast_fold) -> ty_, - fold_constr: fn(ast::constr_, ast_fold) -> constr_, - fold_fn: fn(_fn, ast_fold) -> _fn, - fold_mod: fn(_mod, ast_fold) -> _mod, - fold_native_mod: fn(native_mod, ast_fold) -> native_mod, - fold_variant: fn(variant_, ast_fold) -> variant_, - fold_ident: fn(&&ident, ast_fold) -> ident, - fold_path: fn(path_, ast_fold) -> path_, - fold_local: fn(local_, ast_fold) -> local_, - map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr], - new_id: fn(node_id) -> node_id, - new_span: fn(span) -> span}; + {fold_crate: fn@(crate_, ast_fold) -> crate_, + fold_crate_directive: fn@(crate_directive_, + ast_fold) -> crate_directive_, + fold_view_item: fn@(view_item_, ast_fold) -> view_item_, + fold_native_item: fn@(&&@native_item, ast_fold) -> @native_item, + fold_item: fn@(&&@item, ast_fold) -> @item, + fold_item_underscore: fn@(item_, ast_fold) -> item_, + fold_method: fn@(method_, ast_fold) -> method_, + fold_block: fn@(blk_, ast_fold) -> blk_, + fold_stmt: fn@(stmt_, ast_fold) -> stmt_, + fold_arm: fn@(arm, ast_fold) -> arm, + fold_pat: fn@(pat_, ast_fold) -> pat_, + fold_decl: fn@(decl_, ast_fold) -> decl_, + fold_expr: fn@(expr_, ast_fold) -> expr_, + fold_ty: fn@(ty_, ast_fold) -> ty_, + fold_constr: fn@(ast::constr_, ast_fold) -> constr_, + fold_fn: fn@(_fn, ast_fold) -> _fn, + fold_mod: fn@(_mod, ast_fold) -> _mod, + fold_native_mod: fn@(native_mod, ast_fold) -> native_mod, + fold_variant: fn@(variant_, ast_fold) -> variant_, + fold_ident: fn@(&&ident, ast_fold) -> ident, + fold_path: fn@(path_, ast_fold) -> path_, + fold_local: fn@(local_, ast_fold) -> local_, + map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr], + new_id: fn@(node_id) -> node_id, + new_span: fn@(span) -> span}; type a_f = - {fold_crate: fn(crate) -> crate, - fold_crate_directive: fn(&&@crate_directive) -> @crate_directive, - fold_view_item: fn(&&@view_item) -> @view_item, - fold_native_item: fn(&&@native_item) -> @native_item, - fold_item: fn(&&@item) -> @item, - fold_item_underscore: fn(item_) -> item_, - fold_method: fn(&&@method) -> @method, - fold_block: fn(blk) -> blk, - fold_stmt: fn(&&@stmt) -> @stmt, - fold_arm: fn(arm) -> arm, - fold_pat: fn(&&@pat) -> @pat, - fold_decl: fn(&&@decl) -> @decl, - fold_expr: fn(&&@expr) -> @expr, - fold_ty: fn(&&@ty) -> @ty, - fold_constr: fn(&&@constr) -> @constr, - fold_fn: fn(_fn) -> _fn, - fold_mod: fn(_mod) -> _mod, - fold_native_mod: fn(native_mod) -> native_mod, - fold_variant: fn(variant) -> variant, - fold_ident: fn(&&ident) -> ident, - fold_path: fn(path) -> path, - fold_local: fn(&&@local) -> @local, - map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr], - new_id: fn(node_id) -> node_id, - new_span: fn(span) -> span}; + {fold_crate: fn@(crate) -> crate, + fold_crate_directive: fn@(&&@crate_directive) -> @crate_directive, + fold_view_item: fn@(&&@view_item) -> @view_item, + fold_native_item: fn@(&&@native_item) -> @native_item, + fold_item: fn@(&&@item) -> @item, + fold_item_underscore: fn@(item_) -> item_, + fold_method: fn@(&&@method) -> @method, + fold_block: fn@(blk) -> blk, + fold_stmt: fn@(&&@stmt) -> @stmt, + fold_arm: fn@(arm) -> arm, + fold_pat: fn@(&&@pat) -> @pat, + fold_decl: fn@(&&@decl) -> @decl, + fold_expr: fn@(&&@expr) -> @expr, + fold_ty: fn@(&&@ty) -> @ty, + fold_constr: fn@(&&@constr) -> @constr, + fold_fn: fn@(_fn) -> _fn, + fold_mod: fn@(_mod) -> _mod, + fold_native_mod: fn@(native_mod) -> native_mod, + fold_variant: fn@(variant) -> variant, + fold_ident: fn@(&&ident) -> ident, + fold_path: fn@(path) -> path, + fold_local: fn@(&&@local) -> @local, + map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr], + new_id: fn@(node_id) -> node_id, + new_span: fn@(span) -> span}; //fn nf_dummy(&T node) -> T { fail; } @@ -119,7 +120,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { span: mi.span}; } //used in noop_fold_item and noop_fold_crate -fn fold_attribute_(at: attribute, fmi: fn(&&@meta_item) -> @meta_item) -> +fn fold_attribute_(at: attribute, fmi: fn@(&&@meta_item) -> @meta_item) -> attribute { ret {node: {style: at.node.style, value: *fmi(@at.node.value)}, span: at.span}; @@ -495,7 +496,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { /* temporarily eta-expand because of a compiler bug with using `fn` as a value */ -fn noop_map_exprs(f: fn(&&@expr) -> @expr, es: [@expr]) -> [@expr] { +fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: [@expr]) -> [@expr] { ret vec::map(f, es); } @@ -568,32 +569,34 @@ resource foldres(f: ast_fold) { } fn make_fold(afp: ast_fold_precursor) -> @foldres { + // FIXME: Have to bind all the bare functions into shared functions + // because @mutable is invariant with respect to its contents let result: ast_fold = - @mutable {fold_crate: nf_crate_dummy, - fold_crate_directive: nf_crate_directive_dummy, - fold_view_item: nf_view_item_dummy, - fold_native_item: nf_native_item_dummy, - fold_item: nf_item_dummy, - fold_item_underscore: nf_item_underscore_dummy, - fold_method: nf_method_dummy, - fold_block: nf_blk_dummy, - fold_stmt: nf_stmt_dummy, - fold_arm: nf_arm_dummy, - fold_pat: nf_pat_dummy, - fold_decl: nf_decl_dummy, - fold_expr: nf_expr_dummy, - fold_ty: nf_ty_dummy, - fold_constr: nf_constr_dummy, - fold_fn: nf_fn_dummy, - fold_mod: nf_mod_dummy, - fold_native_mod: nf_native_mod_dummy, - fold_variant: nf_variant_dummy, - fold_ident: nf_ident_dummy, - fold_path: nf_path_dummy, - fold_local: nf_local_dummy, - map_exprs: noop_map_exprs, - new_id: noop_id, - new_span: noop_span}; + @mutable {fold_crate: bind nf_crate_dummy(_), + fold_crate_directive: bind nf_crate_directive_dummy(_), + fold_view_item: bind nf_view_item_dummy(_), + fold_native_item: bind nf_native_item_dummy(_), + fold_item: bind nf_item_dummy(_), + fold_item_underscore: bind nf_item_underscore_dummy(_), + fold_method: bind nf_method_dummy(_), + fold_block: bind nf_blk_dummy(_), + fold_stmt: bind nf_stmt_dummy(_), + fold_arm: bind nf_arm_dummy(_), + fold_pat: bind nf_pat_dummy(_), + fold_decl: bind nf_decl_dummy(_), + fold_expr: bind nf_expr_dummy(_), + fold_ty: bind nf_ty_dummy(_), + fold_constr: bind nf_constr_dummy(_), + fold_fn: bind nf_fn_dummy(_), + fold_mod: bind nf_mod_dummy(_), + fold_native_mod: bind nf_native_mod_dummy(_), + fold_variant: bind nf_variant_dummy(_), + fold_ident: bind nf_ident_dummy(_), + fold_path: bind nf_path_dummy(_), + fold_local: bind nf_local_dummy(_), + map_exprs: bind noop_map_exprs(_, _), + new_id: bind noop_id(_), + new_span: bind noop_span(_)}; /* naturally, a macro to write these would be nice */ fn f_crate(afp: ast_fold_precursor, f: ast_fold, c: crate) -> crate { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index e661d24873b..3846e9dc03b 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -390,7 +390,8 @@ fn parse_constr_in_type(p: parser) -> @ast::ty_constr { } -fn parse_constrs(pser: fn(parser) -> @ast::constr_general, p: parser) -> +fn parse_constrs(pser: fn@(parser) -> @ast::constr_general, + p: parser) -> [@ast::constr_general] { let constrs: [@ast::constr_general] = []; while true { @@ -602,7 +603,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg { } fn parse_seq_to_before_gt<@T>(sep: option::t, - f: fn(parser) -> T, + f: fn@(parser) -> T, p: parser) -> [T] { let first = true; let v = []; @@ -618,7 +619,7 @@ fn parse_seq_to_before_gt<@T>(sep: option::t, ret v; } -fn parse_seq_to_gt<@T>(sep: option::t, f: fn(parser) -> T, +fn parse_seq_to_gt<@T>(sep: option::t, f: fn@(parser) -> T, p: parser) -> [T] { let v = parse_seq_to_before_gt(sep, f, p); expect_gt(p); @@ -626,7 +627,7 @@ fn parse_seq_to_gt<@T>(sep: option::t, f: fn(parser) -> T, ret v; } -fn parse_seq_lt_gt<@T>(sep: option::t, f: fn(parser) -> T, +fn parse_seq_lt_gt<@T>(sep: option::t, f: fn@(parser) -> T, p: parser) -> spanned<[T]> { let lo = p.get_lo_pos(); expect(p, token::LT); @@ -645,7 +646,7 @@ fn parse_seq_to_end<@T>(ket: token::token, sep: option::t, fn parse_seq_to_before_end<@T>(ket: token::token, sep: option::t, - f: fn(parser) -> T, p: parser) -> [T] { + f: fn@(parser) -> T, p: parser) -> [T] { let first: bool = true; let v: [T] = []; while p.peek() != ket { @@ -660,7 +661,7 @@ fn parse_seq_to_before_end<@T>(ket: token::token, fn parse_seq<@T>(bra: token::token, ket: token::token, - sep: option::t, f: fn(parser) -> T, p: parser) + sep: option::t, f: fn@(parser) -> T, p: parser) -> spanned<[T]> { let lo = p.get_lo_pos(); expect(p, bra); @@ -2141,7 +2142,7 @@ fn parse_fn_item_proto(p: parser) -> ast::proto { p.bump(); ast::proto_fn } else { - ast::proto_fn + ast::proto_bare } } @@ -2153,7 +2154,7 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto { p.bump(); ast::proto_fn } else { - ast::proto_fn + ast::proto_bare } } @@ -2165,7 +2166,7 @@ fn parse_fn_anon_proto(p: parser) -> ast::proto { p.bump(); ast::proto_fn } else { - ast::proto_fn + ast::proto_bare } } @@ -2198,7 +2199,8 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> { } else if is_word(p, "unsafe") && p.look_ahead(1u) != token::LBRACE { p.bump(); expect_word(p, "fn"); - ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, ast::proto_fn, + let proto = parse_fn_item_proto(p); + ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, proto, attrs, ast::il_normal)); } else if eat_word(p, "iter") { ret some(parse_item_fn_or_iter(p, ast::impure_fn, ast::proto_iter, diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index b806df75128..008cbac0218 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -18,7 +18,7 @@ tag ann_node { node_expr(ps, @ast::expr); node_pat(ps, @ast::pat); } -type pp_ann = {pre: fn(ann_node), post: fn(ann_node)}; +type pp_ann = {pre: fn@(ann_node), post: fn@(ann_node)}; fn no_ann() -> pp_ann { fn ignore(_node: ann_node) { } @@ -352,7 +352,7 @@ fn print_native_item(s: ps, item: @ast::native_item) { ast::native_item_fn(lname, decl, typarams) { - print_fn(s, decl, ast::proto_fn, item.ident, typarams, + print_fn(s, decl, ast::proto_bare, item.ident, typarams, decl.constraints); alt lname { none. { } @@ -1557,7 +1557,7 @@ fn escape_str(st: str, to_escape: char) -> str { ret out; } -fn to_str(t: T, f: fn(ps, T)) -> str { +fn to_str(t: T, f: fn@(ps, T)) -> str { let writer = io::string_writer(); let s = rust_printer(writer.get_writer()); f(s, t); @@ -1578,7 +1578,7 @@ fn next_comment(s: ps) -> option::t { // Removing the aliases from the type of f in the next two functions // triggers memory corruption, but I haven't isolated the bug yet. FIXME -fn constr_args_to_str(f: fn(T) -> str, args: [@ast::sp_constr_arg]) -> +fn constr_args_to_str(f: fn@(T) -> str, args: [@ast::sp_constr_arg]) -> str { let comma = false; let s = "("; @@ -1590,7 +1590,7 @@ fn constr_args_to_str(f: fn(T) -> str, args: [@ast::sp_constr_arg]) -> ret s; } -fn constr_arg_to_str(f: fn(T) -> str, c: ast::constr_arg_general_) -> +fn constr_arg_to_str(f: fn@(T) -> str, c: ast::constr_arg_general_) -> str { alt c { ast::carg_base. { ret "*"; } @@ -1643,11 +1643,11 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str { fn proto_to_str(p: ast::proto) -> str { ret alt p { - ast::proto_fn. { "fn" } + ast::proto_fn. { "fn@" } ast::proto_iter. { "iter" } ast::proto_block. { "block" } ast::proto_closure. { "lambda" } - ast::proto_bare. { "fn#" } + ast::proto_bare. { "fn" } }; } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index f234c2fb221..98d6026ed84 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -18,20 +18,20 @@ tag vt { mk_vt(visitor); } type visitor = // takes the components so that one function can be // generic over constr and ty_constr - @{visit_mod: fn(_mod, span, E, vt), - visit_view_item: fn(@view_item, E, vt), - visit_native_item: fn(@native_item, E, vt), - visit_item: fn(@item, E, vt), - visit_local: fn(@local, E, vt), - visit_block: fn(ast::blk, E, vt), - visit_stmt: fn(@stmt, E, vt), - visit_arm: fn(arm, E, vt), - visit_pat: fn(@pat, E, vt), - visit_decl: fn(@decl, E, vt), - visit_expr: fn(@expr, E, vt), - visit_ty: fn(@ty, E, vt), - visit_constr: fn(path, span, node_id, E, vt), - visit_fn: fn(_fn, [ty_param], span, fn_ident, node_id, E, vt)}; + @{visit_mod: fn@(_mod, span, E, vt), + visit_view_item: fn@(@view_item, E, vt), + visit_native_item: fn@(@native_item, E, vt), + visit_item: fn@(@item, E, vt), + visit_local: fn@(@local, E, vt), + visit_block: fn@(ast::blk, E, vt), + visit_stmt: fn@(@stmt, E, vt), + visit_arm: fn@(arm, E, vt), + visit_pat: fn@(@pat, E, vt), + visit_decl: fn@(@decl, E, vt), + visit_expr: fn@(@expr, E, vt), + visit_ty: fn@(@ty, E, vt), + visit_constr: fn@(path, span, node_id, E, vt), + visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id, E, vt)}; fn default_visitor() -> visitor { ret @{visit_mod: bind visit_mod::(_, _, _, _), @@ -341,97 +341,97 @@ fn visit_arm(a: arm, e: E, v: vt) { type simple_visitor = // takes the components so that one function can be // generic over constr and ty_constr - @{visit_mod: fn(_mod, span), - visit_view_item: fn(@view_item), - visit_native_item: fn(@native_item), - visit_item: fn(@item), - visit_local: fn(@local), - visit_block: fn(ast::blk), - visit_stmt: fn(@stmt), - visit_arm: fn(arm), - visit_pat: fn(@pat), - visit_decl: fn(@decl), - visit_expr: fn(@expr), - visit_ty: fn(@ty), - visit_constr: fn(path, span, node_id), - visit_fn: fn(_fn, [ty_param], span, fn_ident, node_id)}; + @{visit_mod: fn@(_mod, span), + visit_view_item: fn@(@view_item), + visit_native_item: fn@(@native_item), + visit_item: fn@(@item), + visit_local: fn@(@local), + visit_block: fn@(ast::blk), + visit_stmt: fn@(@stmt), + visit_arm: fn@(arm), + visit_pat: fn@(@pat), + visit_decl: fn@(@decl), + visit_expr: fn@(@expr), + visit_ty: fn@(@ty), + visit_constr: fn@(path, span, node_id), + visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id)}; fn default_simple_visitor() -> simple_visitor { - ret @{visit_mod: fn (_m: _mod, _sp: span) { }, - visit_view_item: fn (_vi: @view_item) { }, - visit_native_item: fn (_ni: @native_item) { }, - visit_item: fn (_i: @item) { }, - visit_local: fn (_l: @local) { }, - visit_block: fn (_b: ast::blk) { }, - visit_stmt: fn (_s: @stmt) { }, - visit_arm: fn (_a: arm) { }, - visit_pat: fn (_p: @pat) { }, - visit_decl: fn (_d: @decl) { }, - visit_expr: fn (_e: @expr) { }, - visit_ty: fn (_t: @ty) { }, - visit_constr: fn (_p: path, _sp: span, _id: node_id) { }, + ret @{visit_mod: fn(_m: _mod, _sp: span) { }, + visit_view_item: fn(_vi: @view_item) { }, + visit_native_item: fn(_ni: @native_item) { }, + visit_item: fn(_i: @item) { }, + visit_local: fn(_l: @local) { }, + visit_block: fn(_b: ast::blk) { }, + visit_stmt: fn(_s: @stmt) { }, + visit_arm: fn(_a: arm) { }, + visit_pat: fn(_p: @pat) { }, + visit_decl: fn(_d: @decl) { }, + visit_expr: fn(_e: @expr) { }, + visit_ty: fn(_t: @ty) { }, + visit_constr: fn(_p: path, _sp: span, _id: node_id) { }, visit_fn: - fn (_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident, + fn(_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident, _id: node_id) { }}; } fn mk_simple_visitor(v: simple_visitor) -> vt<()> { - fn v_mod(f: fn(_mod, span), m: _mod, sp: span, &&e: (), v: vt<()>) { + fn v_mod(f: fn@(_mod, span), m: _mod, sp: span, &&e: (), v: vt<()>) { f(m, sp); visit_mod(m, sp, e, v); } - fn v_view_item(f: fn(@view_item), vi: @view_item, &&e: (), v: vt<()>) { + fn v_view_item(f: fn@(@view_item), vi: @view_item, &&e: (), v: vt<()>) { f(vi); visit_view_item(vi, e, v); } - fn v_native_item(f: fn(@native_item), ni: @native_item, &&e: (), + fn v_native_item(f: fn@(@native_item), ni: @native_item, &&e: (), v: vt<()>) { f(ni); visit_native_item(ni, e, v); } - fn v_item(f: fn(@item), i: @item, &&e: (), v: vt<()>) { + fn v_item(f: fn@(@item), i: @item, &&e: (), v: vt<()>) { f(i); visit_item(i, e, v); } - fn v_local(f: fn(@local), l: @local, &&e: (), v: vt<()>) { + fn v_local(f: fn@(@local), l: @local, &&e: (), v: vt<()>) { f(l); visit_local(l, e, v); } - fn v_block(f: fn(ast::blk), bl: ast::blk, &&e: (), v: vt<()>) { + fn v_block(f: fn@(ast::blk), bl: ast::blk, &&e: (), v: vt<()>) { f(bl); visit_block(bl, e, v); } - fn v_stmt(f: fn(@stmt), st: @stmt, &&e: (), v: vt<()>) { + fn v_stmt(f: fn@(@stmt), st: @stmt, &&e: (), v: vt<()>) { f(st); visit_stmt(st, e, v); } - fn v_arm(f: fn(arm), a: arm, &&e: (), v: vt<()>) { + fn v_arm(f: fn@(arm), a: arm, &&e: (), v: vt<()>) { f(a); visit_arm(a, e, v); } - fn v_pat(f: fn(@pat), p: @pat, &&e: (), v: vt<()>) { + fn v_pat(f: fn@(@pat), p: @pat, &&e: (), v: vt<()>) { f(p); visit_pat(p, e, v); } - fn v_decl(f: fn(@decl), d: @decl, &&e: (), v: vt<()>) { + fn v_decl(f: fn@(@decl), d: @decl, &&e: (), v: vt<()>) { f(d); visit_decl(d, e, v); } - fn v_expr(f: fn(@expr), ex: @expr, &&e: (), v: vt<()>) { + fn v_expr(f: fn@(@expr), ex: @expr, &&e: (), v: vt<()>) { f(ex); visit_expr(ex, e, v); } - fn v_ty(f: fn(@ty), ty: @ty, &&e: (), v: vt<()>) { + fn v_ty(f: fn@(@ty), ty: @ty, &&e: (), v: vt<()>) { f(ty); visit_ty(ty, e, v); } - fn v_constr(f: fn(path, span, node_id), pt: path, sp: span, id: node_id, + fn v_constr(f: fn@(path, span, node_id), pt: path, sp: span, id: node_id, &&e: (), v: vt<()>) { f(pt, sp, id); visit_constr(pt, sp, id, e, v); } - fn v_fn(f: fn(_fn, [ty_param], span, fn_ident, node_id), ff: _fn, + fn v_fn(f: fn@(_fn, [ty_param], span, fn_ident, node_id), ff: _fn, tps: [ty_param], sp: span, ident: fn_ident, id: node_id, &&e: (), v: vt<()>) { f(ff, tps, sp, ident, id); diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index da550f1735b..7a45cc40bae 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -128,8 +128,8 @@ fn test_opts(config: config) -> test::test_opts { } type tests_and_conv_fn = { - tests: [test::test_desc], - to_task: fn(fn()) -> test::joinable + tests: [test::test_desc], + to_task: fn@(fn@()) -> test::joinable }; fn make_tests(cx: cx) -> tests_and_conv_fn { @@ -167,7 +167,7 @@ fn is_test(config: config, testfile: str) -> bool { } fn make_test(cx: cx, testfile: str, configport: port<[u8]>) -> - test::test_desc { + test::test_desc { {name: make_test_name(cx.config, testfile), fn: make_test_closure(testfile, chan(configport)), ignore: header::is_test_ignored(cx.config, testfile)} @@ -178,7 +178,7 @@ fn make_test_name(config: config, testfile: str) -> str { } fn make_test_closure(testfile: str, - configchan: chan<[u8]>) -> test::test_fn { + configchan: chan<[u8]>) -> test::test_fn { bind send_config(testfile, configchan) } @@ -186,7 +186,7 @@ fn send_config(testfile: str, configchan: chan<[u8]>) { send(configchan, str::bytes(testfile)); } -fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn()) -> +fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn@()) -> test::joinable { testfn(); let testfile = recv(configport); diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 099968a23ea..4083029c4f5 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -154,13 +154,13 @@ fn worker(p: port) { // Only windows needs to set the library path #[cfg(target_os = "win32")] -fn maybe_with_lib_path<@T>(path: str, f: fn() -> T) -> T { +fn maybe_with_lib_path<@T>(path: str, f: fn@() -> T) -> T { with_lib_path(path, f) } #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] -fn maybe_with_lib_path<@T>(_path: str, f: fn() -> T) -> T { +fn maybe_with_lib_path<@T>(_path: str, f: fn@() -> T) -> T { f() } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 06a327c507f..2697f8bbc98 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -232,7 +232,7 @@ fn exec_compiled_test(cx: cx, props: test_props, testfile: str) -> procres { } fn compose_and_run(cx: cx, testfile: str, - make_args: fn(config, str) -> procargs, lib_path: str, + make_args: fn@(config, str) -> procargs, lib_path: str, input: option::t) -> procres { let procargs = make_args(cx.config, testfile); ret program_output(cx, testfile, lib_path, procargs.prog, procargs.args, diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index acd77e64753..d8e8d43e591 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -216,7 +216,7 @@ iter under(n: uint) -> uint { fn devnull() -> io::writer { std::io::string_writer().get_writer() } -fn as_str(f: fn(io::writer)) -> str { +fn as_str(f: fn@(io::writer)) -> str { let w = std::io::string_writer(); f(w.get_writer()); ret w.get_str(); diff --git a/src/lib/extfmt.rs b/src/lib/extfmt.rs index 6337be01f70..3f43707cc1b 100644 --- a/src/lib/extfmt.rs +++ b/src/lib/extfmt.rs @@ -67,7 +67,7 @@ mod ct { // A fragment of the output sequence tag piece { piece_string(str); piece_conv(conv); } - type error_fn = fn(str) -> ! ; + type error_fn = fn@(str) -> ! ; fn parse_fmt_string(s: str, error: error_fn) -> [piece] { let pieces: [piece] = []; diff --git a/src/lib/list.rs b/src/lib/list.rs index 58f976110d9..d327d15db7c 100644 --- a/src/lib/list.rs +++ b/src/lib/list.rs @@ -50,7 +50,7 @@ fn has<@T>(ls_: list, elt: T) -> bool { fn length<@T>(ls: list) -> uint { fn count(_t: T, &&u: uint) -> uint { ret u + 1u; } - ret foldl(ls, 0u, count); + ret foldl(ls, 0u, bind count(_, _)); } fn cdr<@T>(ls: list) -> list { diff --git a/src/lib/map.rs b/src/lib/map.rs index c63183b1893..3445f4b6c82 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -1,9 +1,9 @@ /** * Hashmap implementation. */ -type hashfn = fn(K) -> uint; +type hashfn = fn@(K) -> uint; -type eqfn = fn(K, K) -> bool; +type eqfn = fn@(K, K) -> bool; type hashmap = obj { diff --git a/src/lib/task.rs b/src/lib/task.rs index 8808f0c8d02..903e4b34a81 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -136,7 +136,7 @@ fn spawn_inner2<~T>(-data: T, f: fn#(T), // FIXME: This is the old spawn function that spawns a shared closure. // It is a hack and needs to be rewritten. -fn unsafe_spawn_inner(-thunk: fn(), +fn unsafe_spawn_inner(-thunk: fn@(), notify: option>) -> task_id unsafe { let id = rustrt::new_task(); diff --git a/src/lib/test.rs b/src/lib/test.rs index 17d34ed4c1f..0df3667ea4a 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -100,7 +100,7 @@ type joinable = (task, comm::port); // In cases where test functions are closures it is not ok to just dump them // into a task and run them, so this transformation gives the caller a chance // to create the test task. -type test_to_task<@T> = fn(test_fn) -> joinable; +type test_to_task<@T> = fn@(test_fn) -> joinable; // A simple console test runner fn run_tests_console(opts: test_opts, @@ -215,7 +215,7 @@ tag testevent<@T> { fn run_tests<@T>(opts: test_opts, tests: [test_desc], to_task: test_to_task, - callback: fn(testevent)) { + callback: fn@(testevent)) { let filtered_tests = filter_tests(opts, tests); @@ -286,7 +286,7 @@ fn filter_tests<@T>(opts: test_opts, } else { ret option::none; } }; - vec::filter_map(filter, filtered) + vec::filter_map(bind filter(_), filtered) }; // Sort the tests alphabetically @@ -295,13 +295,13 @@ fn filter_tests<@T>(opts: test_opts, fn lteq<@T>(t1: test_desc, t2: test_desc) -> bool { str::lteq(t1.name, t2.name) } - sort::merge_sort(lteq, filtered) + sort::merge_sort(bind lteq(_, _), filtered) }; ret filtered; } -type test_future<@T> = {test: test_desc, wait: fn() -> test_result}; +type test_future<@T> = {test: test_desc, wait: fn@() -> test_result}; fn run_test<@T>(test: test_desc, to_task: test_to_task) -> test_future { diff --git a/src/lib/treemap.rs b/src/lib/treemap.rs index 593a1664920..c9817c2d730 100644 --- a/src/lib/treemap.rs +++ b/src/lib/treemap.rs @@ -52,7 +52,7 @@ fn find<@K, @V>(m: treemap, k: K) -> option { } // Performs an in-order traversal -fn traverse<@K, @V>(m: treemap, f: fn(K, V)) { +fn traverse<@K, @V>(m: treemap, f: fn@(K, V)) { alt *m { empty. { } node(k, v, _, _) { diff --git a/src/lib/vec.rs b/src/lib/vec.rs index f329e40cb98..e5b1e33ac8a 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -20,7 +20,7 @@ fn reserve<@T>(&v: [mutable? T], n: uint) { pure fn len(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } } -type init_op = fn(uint) -> T; +type init_op = fn@(uint) -> T; fn init_fn<@T>(op: init_op, n_elts: uint) -> [T] { let v = []; diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index 5316941355f..f7c49d6432f 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -51,11 +51,11 @@ mod map_reduce { export reducer; export map_reduce; - type putter = fn(str, int); + type putter = fn@(str, int); type mapper = fn(str, putter); - type getter = fn() -> option; + type getter = fn@() -> option; type reducer = fn(str, getter); diff --git a/src/test/compile-fail/fn-bare-bind.rs b/src/test/compile-fail/fn-bare-bind.rs index c8f4960e741..05ead1b2836 100644 --- a/src/test/compile-fail/fn-bare-bind.rs +++ b/src/test/compile-fail/fn-bare-bind.rs @@ -1,4 +1,4 @@ -// error-pattern:mismatched types: expected fn#() but found fn() +// error-pattern:mismatched types: expected fn() but found fn@() fn# f() { } diff --git a/src/test/compile-fail/unsafe-alias.rs b/src/test/compile-fail/unsafe-alias.rs index 7038f6bdbb1..3e5233460b7 100644 --- a/src/test/compile-fail/unsafe-alias.rs +++ b/src/test/compile-fail/unsafe-alias.rs @@ -1,6 +1,6 @@ // error-pattern:may alias with argument -fn foo(x: {mutable x: int}, f: fn()) { log x; } +fn foo(x: {mutable x: int}, f: fn@()) { log x; } fn whoknows(x: @mutable {mutable x: int}) { *x = {mutable x: 10}; } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 29a8527e6f3..19f5f13e5a6 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -1,3 +1,7 @@ +// FIXME: Autobind doesn't work for bare functions currently +// because it would have to convert them to shared closures +// xfail-test + fn f<@T>(x: [T]) -> T { ret x[0]; } fn g(act: fn([int]) -> int) -> int { ret act([1, 2, 3]); } diff --git a/src/test/run-pass/bind-interior.rs b/src/test/run-pass/bind-interior.rs index 639077a72c0..980a1e568f6 100644 --- a/src/test/run-pass/bind-interior.rs +++ b/src/test/run-pass/bind-interior.rs @@ -5,7 +5,7 @@ fn f(n: int) -> int { ret n; } fn main() { - let g: fn() -> int = bind f(10); + let g: fn@() -> int = bind f(10); let i: int = g(); assert (i == 10); } diff --git a/src/test/run-pass/bind-parameterized-args.rs b/src/test/run-pass/bind-parameterized-args.rs index d1feb5ac91d..e0a21fba2a5 100644 --- a/src/test/run-pass/bind-parameterized-args.rs +++ b/src/test/run-pass/bind-parameterized-args.rs @@ -1,7 +1,7 @@ fn main() { fn echo(c: int, x: [T]) { } - let y: fn([int]) = bind echo(42, _); + let y: fn@([int]) = bind echo(42, _); y([1]); } diff --git a/src/test/run-pass/bind-thunk.rs b/src/test/run-pass/bind-thunk.rs index a85c7fc9679..52bae30b8ff 100644 --- a/src/test/run-pass/bind-thunk.rs +++ b/src/test/run-pass/bind-thunk.rs @@ -5,7 +5,7 @@ fn f() -> int { ret 42; } fn main() { - let g: fn() -> int = bind f(); + 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 index 20b217c1046..8ae7e4cf200 100644 --- a/src/test/run-pass/bind-trivial.rs +++ b/src/test/run-pass/bind-trivial.rs @@ -5,7 +5,7 @@ fn f(n: int) -> int { ret n; } fn main() { - let g: fn(int) -> int = bind f(_); + let g: fn@(int) -> int = bind f(_); let i: int = g(42); assert (i == 42); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index ce11b0a990e..0c58d9d6727 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(@T, @T) -> bool; +type compare = fn@(@T, @T) -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = alt true { true { expected } }; diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index 631e3301a93..556e00adc54 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = alt true { true { expected } }; diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index f604df830a3..6548c98b469 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -1,7 +1,7 @@ // -*- rust -*- -type compare = fn(~T, ~T) -> bool; +type compare = fn@(~T, ~T) -> bool; fn test_generic<@T>(expected: ~T, eq: compare) { let actual: ~T = alt true { true { expected } }; diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index 734c33a3bd4..f56070a6444 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = alt true { true { expected } }; diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 528ac23fc30..b2d686db43d 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = alt true { true { expected } }; diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 28e5de3a830..2e689b5f07d 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(@T, @T) -> bool; +type compare = fn@(@T, @T) -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index b44f3d4f783..63526729f5e 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 0c49dac3c33..6415558fb1e 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -1,7 +1,7 @@ // -*- rust -*- -type compare = fn(~T, ~T) -> bool; +type compare = fn@(~T, ~T) -> bool; fn test_generic<@T>(expected: ~T, eq: compare) { let actual: ~T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 5f3e29aba6e..6a1716493f4 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 03773bdb19d..147ae500b7c 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -4,7 +4,7 @@ // -*- rust -*- // Tests for standalone blocks as expressions with dynamic type sizes -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index 4b23d1a6e3f..f7869b093b9 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(@T, @T) -> bool; +type compare = fn@(@T, @T) -> bool; fn test_generic(expected: @T, not_expected: @T, eq: compare) { let actual: @T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index ff97e564577..42b57a7c193 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -2,7 +2,7 @@ // -*- rust -*- -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index b9512657c4c..4ccef87fb8c 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -4,7 +4,7 @@ // -*- rust -*- // Tests for if as expressions with dynamic type sizes -type compare = fn(T, T) -> bool; +type compare = fn@(T, T) -> bool; fn test_generic<@T>(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index f177efb7b50..531c59fffbc 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -1,12 +1,12 @@ -fn fix_help(f: fn(fn(A) -> B, A) -> B, x: A) -> B { +fn fix_help(f: fn(fn@(A) -> B, A) -> B, x: A) -> B { ret f(bind fix_help(f, _), x); } -fn fix(f: fn(fn(A) -> B, A) -> B) -> fn(A) -> B { +fn fix(f: fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { ret bind fix_help(f, _); } -fn fact_(f: fn(&&int) -> int, &&n: int) -> int { +fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { // fun fact 0 = 1 ret if n == 0 { 1 } else { n * f(n - 1) }; } diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 7937b6b6f95..aaee23ff35b 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -1,12 +1,12 @@ -fn fix_help(f: fn(fn(A) -> B, A) -> B, x: A) -> B { +fn fix_help(f: fn(fn@(A) -> B, A) -> B, x: A) -> B { ret f(bind fix_help(f, _), x); } -fn fix(f: fn(fn(A) -> B, A) -> B) -> fn(A) -> B { +fn fix(f: fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { ret bind fix_help(f, _); } -fn fact_(f: fn(&&int) -> int, &&n: int) -> int { +fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { // fun fact 0 = 1 ret if n == 0 { 1 } else { n * f(n - 1) }; } diff --git a/src/test/run-pass/fn-bare-bind-generic.rs b/src/test/run-pass/fn-bare-bind-generic.rs index e5b97745c9c..3e5935427f0 100644 --- a/src/test/run-pass/fn-bare-bind-generic.rs +++ b/src/test/run-pass/fn-bare-bind-generic.rs @@ -5,6 +5,6 @@ fn# f(i: T, j: T, k: T) { fn main() { // Binding a bare function turns it into a shared closure - let g: fn() = bind f(10, 10, 20); + 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 index de3db272beb..ec6747cd255 100644 --- a/src/test/run-pass/fn-bare-bind.rs +++ b/src/test/run-pass/fn-bare-bind.rs @@ -4,6 +4,6 @@ fn# f(i: int) { fn main() { // Binding a bare function turns it into a shared closure - let g: fn() = bind f(10); + 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 0469e804948..c11e64c234f 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -1,5 +1,5 @@ // -*- rust -*- -fn ho(f: fn(int) -> int) -> int { let n: int = f(3); ret n; } +fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); ret n; } fn direct(x: int) -> int { ret x + 1; } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index ade075d856d..9f4c4bb17d2 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -26,7 +26,7 @@ mod map_reduce { export mapper; export map_reduce; - type putter = fn(str, str); + type putter = fn@(str, str); type mapper = fn(str, putter); diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 27bbc2506b0..abae3c5dcb2 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -1,4 +1,4 @@ -fn quux<@T>(x: T) -> T { let f = id::; ret f(x); } +fn quux<@T>(x: T) -> T { let f = bind id::(_); ret f(x); } fn id<@T>(x: T) -> T { ret x; } diff --git a/src/test/run-pass/lambda-no-leak.rs b/src/test/run-pass/lambda-no-leak.rs index 7807ec6c571..3c5e1d825ab 100644 --- a/src/test/run-pass/lambda-no-leak.rs +++ b/src/test/run-pass/lambda-no-leak.rs @@ -1,5 +1,5 @@ // Make sure we don't leak lambdas in silly ways. -fn force(f: fn()) { f() } +fn force(f: fn@()) { f() } fn main() { let x = 7; lambda () { log_err x; }; diff --git a/src/test/run-pass/rebind-fn.rs b/src/test/run-pass/rebind-fn.rs index 62d3ca16d11..c651bb50af8 100644 --- a/src/test/run-pass/rebind-fn.rs +++ b/src/test/run-pass/rebind-fn.rs @@ -1,5 +1,5 @@ fn add(i: int, j: int) -> int { ret i + j; } -fn binder(n: int) -> fn() -> int { let f = bind add(n, _); ret bind f(2); } +fn binder(n: int) -> fn@() -> int { let f = bind add(n, _); ret bind f(2); } fn main() { binder(5); let f = binder(1); diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index b1412fc3963..8f4791399ea 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -13,7 +13,7 @@ fn pure_foldl<@T, @U>(ls: list, u: U, f: block(T, U) -> U) -> U { // fn from a pure fn pure fn pure_length<@T>(ls: list) -> uint { fn count(_t: T, &&u: uint) -> uint { u + 1u } - unchecked{ pure_foldl(ls, 0u, count) } + unchecked{ pure_foldl(ls, 0u, bind count(_, _)) } } pure fn nonempty_list<@T>(ls: list) -> bool { pure_length(ls) > 0u } diff --git a/src/test/stdtest/deque.rs b/src/test/stdtest/deque.rs index 1f4f2d7790e..d532d975535 100644 --- a/src/test/stdtest/deque.rs +++ b/src/test/stdtest/deque.rs @@ -79,7 +79,7 @@ fn test_boxes(a: @int, b: @int, c: @int, d: @int) { assert (deq.get(3) == d); } -type eqfn = fn(T, T) -> bool; +type eqfn = fn@(T, T) -> bool; fn test_parameterized<@T>(e: eqfn, a: T, b: T, c: T, d: T) { let deq: deque::t = deque::create::(); @@ -178,7 +178,7 @@ fn test() { two(17, 42)); log "*** test parameterized: taggypar"; - let eq4: eqfn> = taggypareq::; + let eq4: eqfn> = bind taggypareq::(_, _); test_parameterized::>(eq4, onepar::(1), twopar::(1, 2), threepar::(1, 2, 3), diff --git a/src/test/stdtest/map.rs b/src/test/stdtest/map.rs index 18f64bf6899..45d1a535e02 100644 --- a/src/test/stdtest/map.rs +++ b/src/test/stdtest/map.rs @@ -12,7 +12,7 @@ import std::option; fn test_simple() { log "*** starting test_simple"; fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } - let hasher_uint: map::hashfn = util::id; + let hasher_uint: map::hashfn = bind util::id(_); let eqer_uint: map::eqfn = eq_uint; let hasher_str: map::hashfn = str::hash; let eqer_str: map::eqfn = str::eq; @@ -85,7 +85,7 @@ fn test_growth() { let num_to_insert: uint = 64u; fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } log "uint -> uint"; - let hasher_uint: map::hashfn = util::id; + let hasher_uint: map::hashfn = bind util::id(_); let eqer_uint: map::eqfn = eq_uint; let hm_uu: map::hashmap = map::mk_hashmap::(hasher_uint, eqer_uint);