]> git.lizzy.rs Git - rust.git/commitdiff
Rename fn*() to fn() as originally planned.
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 19 Jan 2012 02:10:51 +0000 (18:10 -0800)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 19 Jan 2012 15:11:50 +0000 (07:11 -0800)
src/comp/syntax/parse/parser.rs
src/comp/syntax/print/pprust.rs
src/test/compile-fail/block-coerce-no-2.rs
src/test/compile-fail/block-coerce-no.rs
src/test/pretty/fn-types.rs [new file with mode: 0644]
src/test/run-pass/block-arg-used-as-any.rs

index ee947772ab251336a7fb6d88bb879ce86e5f8958..a5980465048f478d9315a4d60425d0b9d2b99ae4 100644 (file)
@@ -146,8 +146,8 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
     for word in ["mod", "if", "else", "while", "do", "alt", "for", "break",
                  "cont", "ret", "be", "fail", "type", "resource", "check",
                  "assert", "claim", "native", "fn", "pure",
-                 "unsafe", "import", "export", "let", "const",
-                 "log", "copy", "impl", "iface", "enum"] {
+                 "unsafe", "block", "import", "export", "let", "const",
+                 "log", "copy", "sendfn", "impl", "iface", "enum"] {
         words.insert(word, ());
     }
     words
@@ -493,6 +493,9 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
           _ { /* fallthrough */ }
         }
         t = parse_ty_fn(proto, p);
+    } else if eat_word(p, "block") {
+        //p.warn("block is deprecated, use fn& or fn");
+        t = parse_ty_fn(ast::proto_block, p);
     } else if eat_word(p, "native") {
         expect_word(p, "fn");
         t = parse_ty_fn(ast::proto_bare, p);
@@ -799,6 +802,9 @@ fn parse_bottom_expr(p: parser) -> pexpr {
           _ { /* fallthrough */ }
         }
         ret pexpr(parse_fn_expr(p, proto));
+    } else if eat_word(p, "block") {
+        p.warn("block is deprecated, use fn& or fn");
+        ret pexpr(parse_fn_expr(p, ast::proto_block));
     } else if eat_word(p, "unchecked") {
         ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
     } else if eat_word(p, "unsafe") {
@@ -2109,12 +2115,8 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
         p.bump();
         ast::proto_block
       }
-      token::BINOP(token::STAR) {
-        p.bump(); // temporary: fn* for any closure
-        ast::proto_any
-      }
       _ {
-        ast::proto_bare
+        ast::proto_any
       }
     }
 }
index f4aa5646d0b7b89012c4152eacc5d4a63ba33d96..d666e0e3fabb29e34ce5943409ad4ec22fff298b 100644 (file)
@@ -1643,7 +1643,7 @@ fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
 fn proto_to_str(p: ast::proto) -> str {
     ret alt p {
       ast::proto_bare { "native fn" }
-      ast::proto_any { "fn*" }
+      ast::proto_any { "fn" }
       ast::proto_block { "fn&" }
       ast::proto_uniq { "fn~" }
       ast::proto_box { "fn@" }
index 926e39529eaae57a5495f1d806def2f14c3866eb..0ef325aadd3ab39e4f585eb7401136b20bf56d4d 100644 (file)
@@ -1,14 +1,13 @@
-// error-pattern: mismatched types
-
 // Make sure that fn-to-block coercion isn't incorrectly lifted over
 // other tycons.
 
 fn main() {
-    fn f(f: fn(fn(fn()))) {
+    fn f(f: native fn(native fn(native fn()))) {
     }
 
-    fn g(f: fn(block())) {
+    fn g(f: native fn(fn())) {
     }
 
     f(g);
+    //!^ ERROR mismatched types: expected `native fn(native fn(native fn()))`
 }
index 2985d98a34aac4ee553b39c6fde992d9f2cd30a6..42c893a2064216d0c80f255138bf7089db2abd06 100644 (file)
@@ -1,16 +1,16 @@
-// error-pattern: mismatched types
-
 // Make sure that fn-to-block coercion isn't incorrectly lifted over
 // other tycons.
 
-fn coerce(b: block()) -> fn() {
-    fn lol(f: fn(block()) -> fn(), g: block()) -> fn() { ret f(g); }
-    fn fn_id(f: fn()) -> fn() { ret f }
+fn coerce(b: fn()) -> native fn() {
+    fn lol(f: native fn(block()) -> native fn(),
+           g: fn()) -> native fn() { ret f(g); }
+    fn fn_id(f: native fn()) -> native fn() { ret f }
     ret lol(fn_id, b);
+    //!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()`
 }
 
-
 fn main() {
     let i = 8;
-    let f = coerce(block () { log(error, i); });
-    f(); }
+    let f = coerce({|| log(error, i); });
+    f();
+}
diff --git a/src/test/pretty/fn-types.rs b/src/test/pretty/fn-types.rs
new file mode 100644 (file)
index 0000000..f0e4807
--- /dev/null
@@ -0,0 +1,8 @@
+// pp-exact
+
+fn from_native_fn(x: native fn()) { }
+fn from_closure(x: fn()) { }
+fn from_stack_closure(x: fn&()) { }
+fn from_box_closure(x: fn@()) { }
+fn from_unique_closure(x: fn~()) { }
+fn main() { }
index 3612875f2d3f767aed9b03744cab797732b82082..a13e03d94ce5a5398ba611c8c4eb5c331777eb97 100644 (file)
@@ -1,4 +1,4 @@
-fn call_any(f: fn*() -> uint) -> uint {
+fn call_any(f: fn() -> uint) -> uint {
     ret f();
 }