make blocks fn& and fn stand for "any closure"

This commit is contained in:
Niko Matsakis 2012-01-12 11:39:23 -08:00
parent 3f3bfeec27
commit 47a534c197
3 changed files with 22 additions and 16 deletions

View file

@ -182,6 +182,7 @@ export variant_info;
export walk_ty;
export occurs_check_fails;
export closure_kind;
export ck_any;
export ck_block;
export ck_box;
export ck_uniq;
@ -235,6 +236,7 @@ type raw_t = {struct: sty,
type t = uint;
tag closure_kind {
ck_any;
ck_block;
ck_box;
ck_uniq;

View file

@ -110,10 +110,11 @@ tag pat_ {
tag mutability { mut; imm; maybe_mut; }
tag proto {
proto_bare; // fn
proto_bare; // native fn
proto_any; // fn
proto_uniq; // fn~
proto_box; // fn@
proto_block; // block
proto_block; // fn&
}
tag binop {

View file

@ -481,7 +481,7 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
} else if eat_word(p, "fn") {
let proto = parse_fn_ty_proto(p);
alt proto {
ast::proto_bare. { p.warn("fn is deprecated, use native fn"); }
ast::proto_bare. { p.fatal("fn is deprecated, use native fn"); }
_ { /* fallthrough */ }
}
t = parse_ty_fn(proto, p);
@ -490,12 +490,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
} else if eat_word(p, "native") {
expect_word(p, "fn");
t = parse_ty_fn(ast::proto_bare, p);
} else if eat_word(p, "lambda") {
p.warn("lambda is deprecated, use fn@");
t = parse_ty_fn(ast::proto_box, p);
} else if eat_word(p, "sendfn") {
p.warn("sendfn is deprecated, use fn~");
t = parse_ty_fn(ast::proto_uniq, p);
} else if p.token == token::MOD_SEP || is_ident(p.token) {
let path = parse_path(p);
t = ast::ty_path(path, p.get_id());
@ -800,12 +794,6 @@ fn parse_bottom_expr(p: parser) -> pexpr {
ret pexpr(parse_fn_expr(p, proto));
} else if eat_word(p, "block") {
ret pexpr(parse_fn_expr(p, ast::proto_block));
} else if eat_word(p, "lambda") {
//(breaks prettyprinting!) p.warn("lambda is deprecated, use fn@");
ret pexpr(parse_fn_expr(p, ast::proto_box));
} else if eat_word(p, "sendfn") {
//(breaks prettyprinting!) p.warn("sendfn is deprecated, use fn~");
ret pexpr(parse_fn_expr(p, ast::proto_uniq));
} else if eat_word(p, "unchecked") {
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
} else if eat_word(p, "unsafe") {
@ -2067,14 +2055,29 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
}
fn parse_fn_ty_proto(p: parser) -> ast::proto {
<<<<<<< HEAD
if p.token == token::AT {
p.bump();
ast::proto_box
} else if p.token == token::TILDE {
=======
alt p.peek() {
token::AT. {
p.bump();
ast::proto_box
}
token::TILDE. {
>>>>>>> make blocks fn& and fn stand for "any closure"
p.bump();
ast::proto_uniq
} else {
}
token::BINOP(token::AND.) {
p.bump();
ast::proto_block
}
_ {
ast::proto_bare
}
}
}