Skip to content

Commit 882bea5

Browse files
committed
Rename fn*() to fn() as originally planned.
1 parent 1f0b3d2 commit 882bea5

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 9 additions & 7 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", "import", "export", "let", "const",
150-
"log", "copy", "impl", "iface", "enum"] {
149+
"unsafe", "block", "import", "export", "let", "const",
150+
"log", "copy", "sendfn", "impl", "iface", "enum"] {
151151
words.insert(word, ());
152152
}
153153
words
@@ -493,6 +493,9 @@ 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);
496499
} else if eat_word(p, "native") {
497500
expect_word(p, "fn");
498501
t = parse_ty_fn(ast::proto_bare, p);
@@ -799,6 +802,9 @@ fn parse_bottom_expr(p: parser) -> pexpr {
799802
_ { /* fallthrough */ }
800803
}
801804
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));
802808
} else if eat_word(p, "unchecked") {
803809
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
804810
} else if eat_word(p, "unsafe") {
@@ -2109,12 +2115,8 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
21092115
p.bump();
21102116
ast::proto_block
21112117
}
2112-
token::BINOP(token::STAR) {
2113-
p.bump(); // temporary: fn* for any closure
2114-
ast::proto_any
2115-
}
21162118
_ {
2117-
ast::proto_bare
2119+
ast::proto_any
21182120
}
21192121
}
21202122
}

src/comp/syntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
16431643
fn proto_to_str(p: ast::proto) -> str {
16441644
ret alt p {
16451645
ast::proto_bare { "native fn" }
1646-
ast::proto_any { "fn*" }
1646+
ast::proto_any { "fn" }
16471647
ast::proto_block { "fn&" }
16481648
ast::proto_uniq { "fn~" }
16491649
ast::proto_box { "fn@" }
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// error-pattern: mismatched types
2-
31
// Make sure that fn-to-block coercion isn't incorrectly lifted over
42
// other tycons.
53

64
fn main() {
7-
fn f(f: fn(fn(fn()))) {
5+
fn f(f: native fn(native fn(native fn()))) {
86
}
97

10-
fn g(f: fn(block())) {
8+
fn g(f: native fn(fn())) {
119
}
1210

1311
f(g);
12+
//!^ ERROR mismatched types: expected `native fn(native fn(native fn()))`
1413
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// error-pattern: mismatched types
2-
31
// Make sure that fn-to-block coercion isn't incorrectly lifted over
42
// other tycons.
53

6-
fn coerce(b: block()) -> fn() {
7-
fn lol(f: fn(block()) -> fn(), g: block()) -> fn() { ret f(g); }
8-
fn fn_id(f: fn()) -> fn() { ret f }
4+
fn coerce(b: fn()) -> native fn() {
5+
fn lol(f: native fn(block()) -> native fn(),
6+
g: fn()) -> native fn() { ret f(g); }
7+
fn fn_id(f: native fn()) -> native fn() { ret f }
98
ret lol(fn_id, b);
9+
//!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()`
1010
}
1111

12-
1312
fn main() {
1413
let i = 8;
15-
let f = coerce(block () { log(error, i); });
16-
f(); }
14+
let f = coerce({|| log(error, i); });
15+
f();
16+
}

src/test/pretty/fn-types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// pp-exact
2+
3+
fn from_native_fn(x: native fn()) { }
4+
fn from_closure(x: fn()) { }
5+
fn from_stack_closure(x: fn&()) { }
6+
fn from_box_closure(x: fn@()) { }
7+
fn from_unique_closure(x: fn~()) { }
8+
fn main() { }

src/test/run-pass/block-arg-used-as-any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn call_any(f: fn*() -> uint) -> uint {
1+
fn call_any(f: fn() -> uint) -> uint {
22
ret f();
33
}
44

0 commit comments

Comments
 (0)