diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-01-12 11:39:23 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-01-13 06:36:31 -0800 |
| commit | 47a534c197444f3af04994350dfdf83bd97316bb (patch) | |
| tree | bcc6f68b5eb7ba248294221ff2ce68506b81b14e | |
| parent | 3f3bfeec27c3457de30929d7dbf914a5b350808c (diff) | |
| download | rust-47a534c197444f3af04994350dfdf83bd97316bb.tar.gz rust-47a534c197444f3af04994350dfdf83bd97316bb.zip | |
make blocks fn& and fn stand for "any closure"
| -rw-r--r-- | src/comp/middle/ty.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ast.rs | 5 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 31 |
3 files changed, 22 insertions, 16 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index ab651b1094a..80d701120f1 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -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; diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 25d6cda1b71..c48c92c4e7e 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -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 { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 3a7f85b56c4..32840c730af 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -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 + } } } |
