diff --git a/src/libcore/task.rs b/src/libcore/task.rs index a4d6f63dbd6..5f31b5090f0 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -879,7 +879,7 @@ fn test_avoid_copying_the_body_spawn() { #[test] fn test_avoid_copying_the_body_spawn_listener() { avoid_copying_the_body {|f| - spawn_listener(fn~[move f](_po: comm::port) { + spawn_listener(fn~(move f, _po: comm::port) { f(); }); } @@ -899,7 +899,7 @@ fn test_avoid_copying_the_body_run() { fn test_avoid_copying_the_body_run_listener() { avoid_copying_the_body {|f| let buildr = builder(); - run_listener(buildr, fn~[move f](_po: comm::port) { + run_listener(buildr, fn~(move f, _po: comm::port) { f(); }); } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 23c6a3714c3..ae76cbafef7 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -59,7 +59,7 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), res_rel_file(cx, sp, file), parse::parser::SOURCE_FILE); - ret parse::parser::parse_expr(p) + ret p.parse_expr(); } fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e0029b2a222..20452cd8724 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -16,8 +16,6 @@ import dvec::{dvec, extensions}; export file_type; export parser; -export parse_expr; -export parse_pat; // FIXME: #ast expects to find this here but it's actually defined in `parse` // Fixing this will be easier when we have export decls on individual items -- @@ -26,12 +24,6 @@ export parse_pat; import parse_from_source_str; export parse_from_source_str; -// TODO: remove these once we go around a snapshot cycle. -// These are here for the old way that #ast (qquote.rs) worked -fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() } -fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() } - - enum restriction { UNRESTRICTED, RESTRICT_STMT_EXPR, @@ -1231,8 +1223,6 @@ class parser { fn parse_fn_expr(proto: proto) -> @expr { let lo = self.last_span.lo; - let cc_old = self.parse_old_skool_capture_clause(); - // if we want to allow fn expression argument types to be inferred in // the future, just have to change parse_arg to parse_fn_block_arg. let (decl, capture_clause) = @@ -1241,8 +1231,7 @@ class parser { let body = self.parse_block(); ret self.mk_expr(lo, body.span.hi, - expr_fn(proto, decl, body, - @(*capture_clause + cc_old))); + expr_fn(proto, decl, body, capture_clause)); } fn parse_fn_block_expr() -> @expr { @@ -1731,55 +1720,6 @@ class parser { } else { [] } } - // FIXME Remove after snapshot - fn parse_old_skool_capture_clause() -> [capture_item] { - fn expect_opt_trailing_semi(p: parser) { - if !p.eat(token::SEMI) { - if p.token != token::RBRACKET { - p.fatal("expecting ; or ]"); - } - } - } - - fn eat_ident_list(p: parser, is_move: bool) -> [capture_item] { - let mut res = []; - loop { - alt p.token { - token::IDENT(_, _) { - let id = p.get_id(); - let sp = mk_sp(p.span.lo, p.span.hi); - let ident = p.parse_ident(); - res += [@{id:id, is_move: is_move, name:ident, span:sp}]; - if !p.eat(token::COMMA) { - ret res; - } - } - - _ { ret res; } - } - }; - } - - let mut cap_items = []; - - if self.eat(token::LBRACKET) { - while !self.eat(token::RBRACKET) { - if self.eat_keyword("copy") { - cap_items += eat_ident_list(self, false); - expect_opt_trailing_semi(self); - } else if self.eat_keyword("move") { - cap_items += eat_ident_list(self, true); - expect_opt_trailing_semi(self); - } else { - let s: str = "expecting send, copy, or move clause"; - self.fatal(s); - } - } - } - - ret cap_items; - } - fn parse_fn_decl(purity: purity, parse_arg_fn: fn(parser) -> arg_or_capture_item) -> (fn_decl, capture_clause) { diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 235a1c18ca5..7d8b5e1f7d5 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -97,7 +97,7 @@ fn exec( ) -> T { let po = comm::port(); let ch = comm::chan(po); - let msg = handle_request(fn~[move f](ctxt: ctxt) { + let msg = handle_request(fn~(move f, ctxt: ctxt) { comm::send(ch, f(ctxt)) }); comm::send(srv.ch, msg); diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-1895.rs index 3be9fa65b83..21938a9594a 100644 --- a/src/test/run-pass/issue-1895.rs +++ b/src/test/run-pass/issue-1895.rs @@ -1,6 +1,6 @@ fn main() { let x = 1; - let y = fn@[move x]() -> int { + let y = fn@(move x) -> int { x }(); } diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index ce4d5dcf21a..6272b20163c 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -15,7 +15,7 @@ fn test05() { log(error, *three + n); // will copy x into the closure assert(*three == 3); }; - task::spawn(fn~[move fn_to_send]() { + task::spawn(fn~(move fn_to_send) { test05_start(fn_to_send); }); } diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index 1758faaac50..cf98be6effb 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -8,7 +8,7 @@ fn main() { let y = ~2; let y_in_parent = ptr::addr_of(*y) as uint; - task::spawn(fn~[copy ch, y; move x]() { + task::spawn(fn~(copy ch, copy y, move x) { let x_in_child = ptr::addr_of(*x) as uint; comm::send(ch, x_in_child); diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index d6fa0e533d5..8e81e5277bf 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -1,5 +1,5 @@ fn main() { let x = ~1; - let lam_move = fn@[move x]() { }; + let lam_move = fn@(move x) { }; lam_move(); }