about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/comp/syntax/parse/parser.rs13
-rw-r--r--src/test/run-pass/uniq-cc-generic.rs6
-rw-r--r--src/test/run-pass/uniq-cc.rs4
3 files changed, 17 insertions, 6 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 13396d68227..4e5620efed6 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -2166,13 +2166,24 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
     }
 }
 
+fn fn_expr_lookahead(tok: token::token) -> bool {
+    alt tok {
+      token::LPAREN. | token::AT. | token::TILDE. | token::BINOP(_) {
+        true
+      }
+      _ {
+        false
+      }
+    }
+}
+
 fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
     if eat_word(p, "const") {
         ret some(parse_item_const(p, attrs));
     } else if eat_word(p, "inline") {
         expect_word(p, "fn");
         ret some(parse_item_fn(p, ast::impure_fn, attrs));
-    } else if is_word(p, "fn") && p.look_ahead(1u) != token::LPAREN {
+    } else if is_word(p, "fn") && !fn_expr_lookahead(p.look_ahead(1u)) {
         p.bump();
         ret some(parse_item_fn(p, ast::impure_fn, attrs));
     } else if eat_word(p, "pure") {
diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs
index 46d02c45161..2a439245697 100644
--- a/src/test/run-pass/uniq-cc-generic.rs
+++ b/src/test/run-pass/uniq-cc-generic.rs
@@ -5,11 +5,11 @@ tag maybe_pointy {
 
 type pointy = {
     mutable a : maybe_pointy,
-    d : sendfn() -> uint,
+    d : fn~() -> uint,
 };
 
-fn make_uniq_closure<A:send>(a: A) -> sendfn() -> uint {
-    sendfn() -> uint { ptr::addr_of(a) as uint }
+fn make_uniq_closure<A:send>(a: A) -> fn~() -> uint {
+    fn~() -> uint { ptr::addr_of(a) as uint }
 }
 
 fn empty_pointy() -> @pointy {
diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs
index a2d798fbb7c..b0f634ee98c 100644
--- a/src/test/run-pass/uniq-cc.rs
+++ b/src/test/run-pass/uniq-cc.rs
@@ -6,14 +6,14 @@ tag maybe_pointy {
 type pointy = {
     mutable a : maybe_pointy,
     c : ~int,
-    d : sendfn()->(),
+    d : fn~()->(),
 };
 
 fn empty_pointy() -> @pointy {
     ret @{
         mutable a : none,
         c : ~22,
-        d : sendfn()->(){},
+        d : fn~()->(){},
     }
 }