diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index e7890e9e926b..537c420aa71c 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -483,7 +483,7 @@ fn create_index(index: [entry], hash_fn: fn@(T) -> uint) -> fn encode_index(ebml_w: ebml::writer, buckets: [@[entry]], write_fn: block(io::writer, T)) { - let writer = io::new_writer(ebml_w.writer); + let writer = ebml_w.writer; ebml::start_tag(ebml_w, tag_index); let bucket_locs: [uint] = []; ebml::start_tag(ebml_w, tag_index_buckets); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 6c5fd6b03542..d1289488b36c 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -304,7 +304,7 @@ fn print_type(s: ps, &&ty: @ast::ty) { pclose(s); } ast::ty_fn(proto, d) { - print_ty_fn(s, proto, d, none, none); + print_ty_fn(s, some(proto), d, none, none); } ast::ty_path(path, _) { print_path(s, path, false); } ast::ty_type. { word(s.s, "type"); } @@ -485,7 +485,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) { hardbreak_if_not_bol(s); cbox(s, indent_unit); maybe_print_comment(s, m.span.lo); - print_ty_fn(s, ast::proto_bare, m.decl, some(m.ident), some(m.tps)); + print_ty_fn(s, none, m.decl, some(m.ident), some(m.tps)); word(s.s, ";"); end(s); } @@ -1320,11 +1320,11 @@ fn print_mt(s: ps, mt: ast::mt) { print_type(s, mt.ty); } -fn print_ty_fn(s: ps, proto: ast::proto, +fn print_ty_fn(s: ps, opt_proto: option, decl: ast::fn_decl, id: option::t, tps: option::t<[ast::ty_param]>) { ibox(s, indent_unit); - word(s.s, proto_to_str(proto)); + word(s.s, opt_proto_to_str(opt_proto)); alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } } alt tps { some(tps) { print_type_params(s, tps); } _ { } } zerobreak(s.s); @@ -1602,6 +1602,13 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str { ret s; } +fn opt_proto_to_str(opt_p: option) -> str { + alt opt_p { + none. { "fn" } + some(p) { proto_to_str(p) } + } +} + fn proto_to_str(p: ast::proto) -> str { ret alt p { ast::proto_bare. { "native fn" } diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 261259d98867..afb64da8b6f3 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -116,7 +116,7 @@ Returns: A handle to the new task */ -fn spawn(+f: sendfn()) -> task { +fn spawn(+f: fn~()) -> task { spawn_inner(f, none) } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 7b9157f2afe1..ef3c9a244bc4 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -313,24 +313,24 @@ type test_future = {test: test_desc, wait: fn@() -> test_result}; fn run_test(test: test_desc, to_task: test_to_task) -> test_future { if test.ignore { - ret {test: test, wait: fn () -> test_result { tr_ignored }}; + ret {test: test, wait: fn@() -> test_result { tr_ignored }}; } let test_task = to_task(test.fn); ret {test: test, - wait: - bind fn (test_task: joinable, should_fail: bool) -> test_result { - alt task::join(test_task) { - task::tr_success. { - if should_fail { tr_failed } - else { tr_ok } - } - task::tr_failure. { - if should_fail { tr_ok } - else { tr_failed } - } - } - }(test_task, test.should_fail)}; + wait: fn@() -> test_result { + alt task::join(test_task) { + task::tr_success. { + if test.should_fail { tr_failed } + else { tr_ok } + } + task::tr_failure. { + if test.should_fail { tr_ok } + else { tr_failed } + } + } + } + }; } // We need to run our tests in another task in order to trap test failures. diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index a920f73e0522..eb421ae9b085 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -45,11 +45,11 @@ mod map_reduce { type putter = fn@(str, int); - type mapper = fn(str, putter); + type mapper = fn@(str, putter); type getter = fn@() -> option; - type reducer = fn(str, getter); + type reducer = fn@(str, getter); tag ctrl_proto { find_reducer(str, chan>); diff --git a/src/test/compile-fail/fn-bare-bind.rs b/src/test/compile-fail/fn-bare-bind.rs index c15147f36f83..a9d2f38f6170 100644 --- a/src/test/compile-fail/fn-bare-bind.rs +++ b/src/test/compile-fail/fn-bare-bind.rs @@ -1,9 +1,8 @@ -// error-pattern:mismatched types: expected `fn()` but found `fn@()` - fn f() { } fn main() { // Can't produce a bare function by binding - let g: fn() = bind f(); + let g: native fn() = bind f(); + //!^ ERROR mismatched types: expected `native fn()` but found `fn@()` } diff --git a/src/test/compile-fail/fn-compare-mismatch.rs b/src/test/compile-fail/fn-compare-mismatch.rs index e13ec6396c1b..a3b3e502ea46 100644 --- a/src/test/compile-fail/fn-compare-mismatch.rs +++ b/src/test/compile-fail/fn-compare-mismatch.rs @@ -1,7 +1,6 @@ -// error-pattern:expected `fn()` but found `fn(++int)` - fn main() { fn f() { } fn g(i: int) { } let x = f == g; + //!^ ERROR expected `native fn()` but found `native fn(++int)` } diff --git a/src/test/compile-fail/main-wrong-type-2.rs b/src/test/compile-fail/main-wrong-type-2.rs index cf78f2eff74b..b5ba3e2a7f80 100644 --- a/src/test/compile-fail/main-wrong-type-2.rs +++ b/src/test/compile-fail/main-wrong-type-2.rs @@ -1,2 +1,3 @@ -// error-pattern:wrong type in main function: found `fn() -> char` -fn main() -> char { } +fn main() -> char { +//!^ ERROR wrong type in main function: found `native fn() -> char` +} diff --git a/src/test/compile-fail/main-wrong-type.rs b/src/test/compile-fail/main-wrong-type.rs index 854a6a2299de..34f35e51e52a 100644 --- a/src/test/compile-fail/main-wrong-type.rs +++ b/src/test/compile-fail/main-wrong-type.rs @@ -1,2 +1,3 @@ -// error-pattern:wrong type in main function: found `fn(&&{x: int,y: int})` -fn main(foo: {x: int, y: int}) { } +fn main(foo: {x: int, y: int}) { +//!^ ERROR wrong type in main function: found `native fn(&&{x: int,y: int})` +} diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index f70e6bf727c5..b2b1d4ed85dd 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -4,7 +4,7 @@ fn main() { let cheese = "roquefort"; let carrots = @"crunchy"; - fn (tasties: @str, macerate: block(str)) { + fn@(tasties: @str, macerate: block(str)) { macerate(*tasties); } (carrots, { |food| let mush = food + cheese; diff --git a/src/test/run-pass/bind-parameterized-args-2.rs b/src/test/run-pass/bind-parameterized-args-2.rs index d88558ef421e..af308c71064a 100644 --- a/src/test/run-pass/bind-parameterized-args-2.rs +++ b/src/test/run-pass/bind-parameterized-args-2.rs @@ -1,7 +1,7 @@ fn main() { - fn echo(c: int, x: native fn(T)) { #error("wee"); } + fn echo(c: int, x: fn@(T)) { #error("wee"); } let y = bind echo(42, _); - y(fn(&&i: str) { }); + y(fn@(&&i: str) { }); } diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index 14271ade9e80..9e1e5127a245 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -23,7 +23,7 @@ fn test05_start(&&f: fn~(&&float, &&str) -> pair) { assert q.b == "Ho"; } -fn spawn(f: fn(fn~(A,B)->pair)) { +fn spawn(f: native fn(fn~(A,B)->pair)) { let arg = fn~(a: A, b: B) -> pair { ret make_generic_record(a, b); };