Skip to content

Commit 47a534c

Browse files
committed
make blocks fn& and fn stand for "any closure"
1 parent 3f3bfee commit 47a534c

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/comp/middle/ty.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export variant_info;
182182
export walk_ty;
183183
export occurs_check_fails;
184184
export closure_kind;
185+
export ck_any;
185186
export ck_block;
186187
export ck_box;
187188
export ck_uniq;
@@ -235,6 +236,7 @@ type raw_t = {struct: sty,
235236
type t = uint;
236237

237238
tag closure_kind {
239+
ck_any;
238240
ck_block;
239241
ck_box;
240242
ck_uniq;

src/comp/syntax/ast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ tag pat_ {
110110
tag mutability { mut; imm; maybe_mut; }
111111

112112
tag proto {
113-
proto_bare; // fn
113+
proto_bare; // native fn
114+
proto_any; // fn
114115
proto_uniq; // fn~
115116
proto_box; // fn@
116-
proto_block; // block
117+
proto_block; // fn&
117118
}
118119

119120
tag binop {

src/comp/syntax/parse/parser.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
481481
} else if eat_word(p, "fn") {
482482
let proto = parse_fn_ty_proto(p);
483483
alt proto {
484-
ast::proto_bare. { p.warn("fn is deprecated, use native fn"); }
484+
ast::proto_bare. { p.fatal("fn is deprecated, use native fn"); }
485485
_ { /* fallthrough */ }
486486
}
487487
t = parse_ty_fn(proto, p);
@@ -490,12 +490,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
490490
} else if eat_word(p, "native") {
491491
expect_word(p, "fn");
492492
t = parse_ty_fn(ast::proto_bare, p);
493-
} else if eat_word(p, "lambda") {
494-
p.warn("lambda is deprecated, use fn@");
495-
t = parse_ty_fn(ast::proto_box, p);
496-
} else if eat_word(p, "sendfn") {
497-
p.warn("sendfn is deprecated, use fn~");
498-
t = parse_ty_fn(ast::proto_uniq, p);
499493
} else if p.token == token::MOD_SEP || is_ident(p.token) {
500494
let path = parse_path(p);
501495
t = ast::ty_path(path, p.get_id());
@@ -800,12 +794,6 @@ fn parse_bottom_expr(p: parser) -> pexpr {
800794
ret pexpr(parse_fn_expr(p, proto));
801795
} else if eat_word(p, "block") {
802796
ret pexpr(parse_fn_expr(p, ast::proto_block));
803-
} else if eat_word(p, "lambda") {
804-
//(breaks prettyprinting!) p.warn("lambda is deprecated, use fn@");
805-
ret pexpr(parse_fn_expr(p, ast::proto_box));
806-
} else if eat_word(p, "sendfn") {
807-
//(breaks prettyprinting!) p.warn("sendfn is deprecated, use fn~");
808-
ret pexpr(parse_fn_expr(p, ast::proto_uniq));
809797
} else if eat_word(p, "unchecked") {
810798
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
811799
} else if eat_word(p, "unsafe") {
@@ -2067,14 +2055,29 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
20672055
}
20682056

20692057
fn parse_fn_ty_proto(p: parser) -> ast::proto {
2058+
<<<<<<< HEAD
20702059
if p.token == token::AT {
20712060
p.bump();
20722061
ast::proto_box
20732062
} else if p.token == token::TILDE {
2063+
=======
2064+
alt p.peek() {
2065+
token::AT. {
2066+
p.bump();
2067+
ast::proto_box
2068+
}
2069+
token::TILDE. {
2070+
>>>>>>> make blocks fn& and fn stand for "any closure"
20742071
p.bump();
20752072
ast::proto_uniq
2076-
} else {
2073+
}
2074+
token::BINOP(token::AND.) {
2075+
p.bump();
2076+
ast::proto_block
2077+
}
2078+
_ {
20772079
ast::proto_bare
2080+
}
20782081
}
20792082
}
20802083

0 commit comments

Comments
 (0)