Skip to content

Commit 1f0b3d2

Browse files
committed
treat fn*() as fn&()
This is not my ideal way of going about things. I'd prefer not to have expressions typed as fn*(), for example, but I couldn't get that to work together with inferring the modes of arguments and other corner cases.
1 parent d54cc1c commit 1f0b3d2

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/comp/middle/shape.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
432432
ty::ty_fn({proto: ast::proto_uniq, _}) {
433433
s += [shape_uniq_fn];
434434
}
435-
ty::ty_fn({proto: ast::proto_block, _}) {
435+
ty::ty_fn({proto: ast::proto_block, _}) |
436+
ty::ty_fn({proto: ast::proto_any, _}) {
436437
s += [shape_stack_fn];
437438
}
438439
ty::ty_fn({proto: ast::proto_bare, _}) {

src/comp/middle/trans_closure.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ fn trans_expr_fn(bcx: @block_ctxt,
528528
};
529529

530530
let closure = alt proto {
531-
ast::proto_any { fail "proto_any cannot appear in an expr"; }
532-
ast::proto_block { trans_closure_env(ty::ck_block) }
531+
ast::proto_any | ast::proto_block { trans_closure_env(ty::ck_block) }
533532
ast::proto_box { trans_closure_env(ty::ck_box) }
534533
ast::proto_uniq { trans_closure_env(ty::ck_uniq) }
535534
ast::proto_bare {

src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
146146
for word in ["mod", "if", "else", "while", "do", "alt", "for", "break",
147147
"cont", "ret", "be", "fail", "type", "resource", "check",
148148
"assert", "claim", "native", "fn", "pure",
149-
"unsafe", "block", "import", "export", "let", "const",
150-
"log", "copy", "sendfn", "impl", "iface", "enum"] {
149+
"unsafe", "import", "export", "let", "const",
150+
"log", "copy", "impl", "iface", "enum"] {
151151
words.insert(word, ());
152152
}
153153
words
@@ -493,9 +493,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
493493
_ { /* fallthrough */ }
494494
}
495495
t = parse_ty_fn(proto, p);
496-
} else if eat_word(p, "block") {
497-
//p.warn("block is deprecated, use fn& or fn");
498-
t = parse_ty_fn(ast::proto_block, p);
499496
} else if eat_word(p, "native") {
500497
expect_word(p, "fn");
501498
t = parse_ty_fn(ast::proto_bare, p);
@@ -802,9 +799,6 @@ fn parse_bottom_expr(p: parser) -> pexpr {
802799
_ { /* fallthrough */ }
803800
}
804801
ret pexpr(parse_fn_expr(p, proto));
805-
} else if eat_word(p, "block") {
806-
p.warn("block is deprecated, use fn& or fn");
807-
ret pexpr(parse_fn_expr(p, ast::proto_block));
808802
} else if eat_word(p, "unchecked") {
809803
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
810804
} else if eat_word(p, "unsafe") {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn call_any(f: fn*() -> uint) -> uint {
2+
ret f();
3+
}
4+
5+
fn main() {
6+
let x_r = call_any {|| 22u };
7+
assert x_r == 22u;
8+
}

0 commit comments

Comments
 (0)