Skip to content

Commit 29ad3bd

Browse files
committed
Make fn denote a bare function. Convert fn to fn@ as needed
1 parent f324704 commit 29ad3bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+263
-248
lines changed

src/comp/driver/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str)
8888
ret {crate: crate, src: src};
8989
}
9090

91-
fn time<@T>(do_it: bool, what: str, thunk: fn() -> T) -> T {
91+
fn time<@T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
9292
if !do_it { ret thunk(); }
9393
let start = std::time::precise_time_s();
9494
let rv = thunk();

src/comp/front/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import front::attr;
1212

1313
export modify_for_testing;
1414

15-
type node_id_gen = fn() -> ast::node_id;
15+
type node_id_gen = fn@() -> ast::node_id;
1616

1717
type test = {span: span, path: [ast::ident], ignore: bool};
1818

@@ -369,7 +369,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
369369
il: ast::il_normal,
370370
cf: ast::return_val,
371371
constraints: []};
372-
let proto = ast::proto_fn;
372+
let proto = ast::proto_bare;
373373

374374
let test_main_call_expr = mk_test_main_call(cx);
375375

src/comp/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export external_resolver;
2828
// def_id for an item defined in another crate, somebody needs to figure out
2929
// what crate that's in and give us a def_id that makes sense for the current
3030
// build.
31-
type external_resolver = fn(ast::def_id) -> ast::def_id;
31+
type external_resolver = fn@(ast::def_id) -> ast::def_id;
3232

33-
fn lookup_hash(d: ebml::doc, eq_fn: fn([u8]) -> bool, hash: uint) ->
33+
fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]) -> bool, hash: uint) ->
3434
[ebml::doc] {
3535
let index = ebml::get_doc(d, tag_index);
3636
let table = ebml::get_doc(index, tag_index_table);

src/comp/metadata/tydecode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export parse_ty_data;
1616
// data buffer. Whatever format you choose should not contain pipe characters.
1717

1818
// Callback to translate defs to strs or back:
19-
type str_def = fn(str) -> ast::def_id;
19+
type str_def = fn@(str) -> ast::def_id;
2020

2121
type pstate =
2222
{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 {
3434
ret parse_ident_(st, sd, bind is_last(last, _));
3535
}
3636

37-
fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn(char) -> bool) ->
37+
fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn@(char) -> bool) ->
3838
ast::ident {
3939
let rslt = "";
4040
while !is_last(peek(st) as char) {

src/comp/middle/freevars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type freevar_map = hashmap<ast::node_id, freevar_info>;
2424
// Since we want to be able to collect upvars in some arbitrary piece
2525
// of the AST, we take a walker function that we invoke with a visitor
2626
// in order to start the search.
27-
fn collect_freevars(def_map: resolve::def_map, walker: fn(visit::vt<int>)) ->
27+
fn collect_freevars(def_map: resolve::def_map, walker: fn@(visit::vt<int>)) ->
2828
freevar_info {
2929
let seen = new_int_hash();
3030
let refs = @mutable [];

src/comp/middle/resolve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ fn lookup_in_scope_strict(e: env, sc: scopes, sp: span, name: ident,
595595
fn scope_is_fn(sc: scope) -> bool {
596596
ret alt sc {
597597
scope_fn(_, ast::proto_iter., _) | scope_fn(_, ast::proto_fn., _) |
598+
scope_fn(_, ast::proto_bare., _) |
598599
scope_native_item(_) {
599600
true
600601
}

src/comp/middle/trans_alt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn matches_always(p: @ast::pat) -> bool {
109109
};
110110
}
111111

112-
type enter_pat = fn(@ast::pat) -> option::t<[@ast::pat]>;
112+
type enter_pat = fn@(@ast::pat) -> option::t<[@ast::pat]>;
113113

114114
fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match {
115115
let result = [];
@@ -314,7 +314,7 @@ fn any_tup_pat(m: match, col: uint) -> bool {
314314
}
315315

316316
type exit_node = {bound: bind_map, from: BasicBlockRef, to: BasicBlockRef};
317-
type mk_fail = fn() -> BasicBlockRef;
317+
type mk_fail = fn@() -> BasicBlockRef;
318318

319319
fn pick_col(m: match) -> uint {
320320
let scores = vec::init_elt_mut(0u, vec::len(m[0].pats));

src/comp/middle/trans_common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ type fn_ctxt =
259259
lcx: @local_ctxt};
260260

261261
tag cleanup {
262-
clean(fn(@block_ctxt) -> @block_ctxt);
263-
clean_temp(ValueRef, fn(@block_ctxt) -> @block_ctxt);
262+
clean(fn@(@block_ctxt) -> @block_ctxt);
263+
clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt);
264264
}
265265

266266
fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) {

src/comp/middle/tstate/bitvectors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) {
151151
visit_stmt: relax_precond_stmt,
152152
visit_item:
153153
fn (_i: @item, _cx: relax_ctxt, _vt: visit::vt<relax_ctxt>) { },
154-
visit_fn: do_nothing
154+
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
155155
with *visitor};
156156
let v1 = visit::mk_vt(visitor);
157157
v1.visit_block(b, cx, v1);

src/comp/middle/tstate/ck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ fn check_states_against_conditions(fcx: fn_ctxt, f: _fn, tps: [ast::ty_param],
111111
visitor =
112112
@{visit_stmt: check_states_stmt,
113113
visit_expr: check_states_expr,
114-
visit_fn: do_nothing with *visitor};
114+
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
115+
with *visitor};
115116
visit::visit_fn(f, tps, sp, i, id, fcx, visit::mk_vt(visitor));
116117

117118
/* Check that the return value is initialized */

src/comp/middle/tstate/collect_locals.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ fn find_locals(tcx: ty::ctxt, f: _fn, tps: [ty_param], sp: span, i: fn_ident,
5454
visitor =
5555
@{visit_local: collect_local,
5656
visit_expr: collect_pred,
57-
visit_fn: do_nothing with *visitor};
57+
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
58+
with *visitor};
5859
visit::visit_fn(f, tps, sp, i, id, cx, visit::mk_vt(visitor));
5960
ret cx;
6061
}

src/comp/middle/ty.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ fn cname(cx: ctxt, typ: t) -> option::t<str> {
603603

604604

605605
// Type folds
606-
type ty_walk = fn(t);
606+
type ty_walk = fn@(t);
607607

608608
fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
609609
alt struct(cx, ty) {
@@ -655,9 +655,9 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
655655
}
656656

657657
tag fold_mode {
658-
fm_var(fn(int) -> t);
659-
fm_param(fn(uint, ast::kind) -> t);
660-
fm_general(fn(t) -> t);
658+
fm_var(fn@(int) -> t);
659+
fm_param(fn@(uint, ast::kind) -> t);
660+
fm_general(fn@(t) -> t);
661661
}
662662

663663
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 {
27122712

27132713
// Converts type parameters in a type to type variables and returns the
27142714
// resulting type along with a list of type variable IDs.
2715-
fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn() -> int, typ: t,
2715+
fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn@() -> int, typ: t,
27162716
ty_param_count: uint) -> {ids: [int], ty: t} {
27172717
let param_var_ids: @mutable [int] = @mutable [];
27182718
let i = 0u;
27192719
while i < ty_param_count { *param_var_ids += [next_ty_var()]; i += 1u; }
27202720
fn binder(sp: span, cx: ctxt, param_var_ids: @mutable [int],
2721-
_next_ty_var: fn() -> int, index: uint, _kind: ast::kind) -> t {
2721+
_next_ty_var: fn@() -> int, index: uint,
2722+
_kind: ast::kind) -> t {
27222723
if index < vec::len(*param_var_ids) {
27232724
ret mk_var(cx, param_var_ids[index]);
27242725
} else {

src/comp/middle/typeck.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type fn_ctxt =
5353

5454

5555
// Used for ast_ty_to_ty() below.
56-
type ty_getter = fn(ast::def_id) -> ty::ty_param_kinds_and_ty;
56+
type ty_getter = fn@(ast::def_id) -> ty::ty_param_kinds_and_ty;
5757

5858
fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> int {
5959
alt fcx.locals.find(id) {
@@ -516,8 +516,8 @@ mod collect {
516516
ret k;
517517
}
518518

519-
fn ty_of_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t,
520-
ty_of_arg: fn(ast::arg) -> arg, decl: ast::fn_decl,
519+
fn ty_of_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t,
520+
ty_of_arg: fn@(ast::arg) -> arg, decl: ast::fn_decl,
521521
proto: ast::proto, ty_params: [ast::ty_param],
522522
def_id: option::t<ast::def_id>) ->
523523
ty::ty_param_kinds_and_ty {
@@ -536,8 +536,8 @@ mod collect {
536536
alt def_id { some(did) { cx.tcx.tcache.insert(did, tpt); } _ { } }
537537
ret tpt;
538538
}
539-
fn ty_of_native_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t,
540-
ty_of_arg: fn(ast::arg) -> arg,
539+
fn ty_of_native_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t,
540+
ty_of_arg: fn@(ast::arg) -> arg,
541541
decl: ast::fn_decl, abi: ast::native_abi,
542542
ty_params: [ast::ty_param], def_id: ast::def_id)
543543
-> ty::ty_param_kinds_and_ty {
@@ -1227,8 +1227,10 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
12271227
let visit =
12281228
@{visit_local: visit_local,
12291229
visit_pat: visit_pat,
1230-
visit_fn: visit_fn,
1231-
visit_item: visit_item with *visit::default_visitor()};
1230+
visit_fn: bind visit_fn(_, _, _, _, _, _, _),
1231+
visit_item: bind visit_item(_, _, _)
1232+
with *visit::default_visitor()};
1233+
12321234
visit::visit_block(f.body, (), visit::mk_vt(visit));
12331235
ret {var_bindings: vb,
12341236
locals: locals,
@@ -2787,7 +2789,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
27872789
fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
27882790
let main_t = ty::node_id_to_monotype(tcx, main_id);
27892791
alt ty::struct(tcx, main_t) {
2790-
ty::ty_fn(ast::proto_fn., args, rs, ast::return_val., constrs) {
2792+
ty::ty_fn(ast::proto_bare., args, rs, ast::return_val., constrs) {
27912793
let ok = vec::len(constrs) == 0u;
27922794
ok &= ty::type_is_nil(tcx, rs);
27932795
let num_args = vec::len(args);

src/comp/syntax/ext/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import std::map::new_str_hash;
66
import codemap;
77

88
type syntax_expander =
9-
fn(ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
9+
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
1010
type macro_def = {ident: str, ext: syntax_extension};
1111
type macro_definer =
12-
fn(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
12+
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
1313

1414
tag syntax_extension {
1515
normal(syntax_expander);

src/comp/syntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import syntax::ext::base::*;
1111

1212

1313
fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, e: expr_,
14-
fld: ast_fold, orig: fn(expr_, ast_fold) -> expr_) -> expr_ {
14+
fld: ast_fold, orig: fn@(expr_, ast_fold) -> expr_) -> expr_ {
1515
ret alt e {
1616
expr_mac(mac) {
1717
alt mac.node {

src/comp/syntax/ext/simplext.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! {
7272
// we'll want to return something indicating amount of progress and location
7373
// of failure instead of `none`.
7474
type match_result = option::t<arb_depth<matchable>>;
75-
type selector = fn(matchable) -> match_result;
75+
type selector = fn@(matchable) -> match_result;
7676

7777
fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
7878
{pre: [@expr], rep: option::t<@expr>, post: [@expr]} {
@@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
104104
}
105105
}
106106

107-
fn option_flatten_map<T, @U>(f: fn(T) -> option::t<U>, v: [T]) ->
107+
fn option_flatten_map<T, @U>(f: fn@(T) -> option::t<U>, v: [T]) ->
108108
option::t<[U]> {
109109
let res = [];
110110
for elem: T in v {
@@ -263,7 +263,7 @@ iter free_vars(b: bindings, e: @expr) -> ident {
263263

264264
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
265265
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
266-
recur: fn(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
266+
recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
267267
alt elts_to_ell(cx, exprs) {
268268
{pre: pre, rep: repeat_me_maybe, post: post} {
269269
let res = vec::map(recur, pre);
@@ -351,7 +351,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
351351

352352
fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
353353
e: ast::expr_, fld: ast_fold,
354-
orig: fn(ast::expr_, ast_fold) -> ast::expr_) ->
354+
orig: fn@(ast::expr_, ast_fold) -> ast::expr_) ->
355355
ast::expr_ {
356356
ret alt e {
357357
expr_path(p) {
@@ -378,7 +378,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
378378

379379
fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
380380
t: ast::ty_, fld: ast_fold,
381-
orig: fn(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
381+
orig: fn@(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
382382
ret alt t {
383383
ast::ty_path(pth, _) {
384384
alt path_to_ident(pth) {
@@ -402,7 +402,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
402402

403403
fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
404404
blk: blk_, fld: ast_fold,
405-
orig: fn(blk_, ast_fold) -> blk_) -> blk_ {
405+
orig: fn@(blk_, ast_fold) -> blk_) -> blk_ {
406406
ret alt block_to_ident(blk) {
407407
some(id) {
408408
alt follow_for_trans(cx, b.find(id), idx_path) {

0 commit comments

Comments
 (0)