From 20490167b0d01baa4d976d26787f9d19576b359b Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Nov 2013 16:34:19 -0800 Subject: [PATCH 1/3] test: Remove most uses of `&fn()` from the tests. --- src/test/auxiliary/cci_impl_lib.rs | 4 +-- src/test/auxiliary/cci_iter_lib.rs | 2 +- src/test/auxiliary/cci_no_inline_lib.rs | 2 +- src/test/bench/core-map.rs | 2 +- src/test/bench/core-set.rs | 25 +++++++------ src/test/bench/core-std.rs | 2 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 3 +- src/test/bench/shootout-k-nucleotide.rs | 2 +- .../compile-fail/access-mode-in-closures.rs | 2 +- src/test/compile-fail/block-coerce-no-2.rs | 2 +- src/test/compile-fail/block-coerce-no.rs | 6 ++-- .../compile-fail/borrowck-assign-comp-idx.rs | 2 +- .../compile-fail/borrowck-autoref-3261.rs | 2 +- .../borrowck-insert-during-each.rs | 2 +- .../compile-fail/borrowck-lend-flow-if.rs | 2 +- .../compile-fail/borrowck-lend-flow-loop.rs | 4 +-- src/test/compile-fail/borrowck-lend-flow.rs | 2 +- .../borrowck-loan-blocks-move-cc.rs | 2 +- .../borrowck-loan-blocks-mut-uniq.rs | 2 +- src/test/compile-fail/borrowck-loan-rcvr.rs | 4 +-- .../compile-fail/borrowck-loan-vec-content.rs | 2 +- .../borrowck-move-in-irrefut-pat.rs | 2 +- .../closure-bounds-not-builtin.rs | 2 +- ...ure-bounds-static-cant-capture-borrowed.rs | 2 +- .../compile-fail/closure-bounds-subtype.rs | 8 ++--- src/test/compile-fail/closure-that-fails.rs | 2 +- src/test/compile-fail/do2.rs | 2 +- .../compile-fail/extern-wrong-value-type.rs | 2 +- src/test/compile-fail/fn-variance-1.rs | 2 +- .../compile-fail/immut-function-arguments.rs | 2 +- src/test/compile-fail/issue-2074.rs | 4 +-- src/test/compile-fail/issue-2149.rs | 4 +-- src/test/compile-fail/issue-5216.rs | 4 +-- src/test/compile-fail/issue-5239-1.rs | 2 +- src/test/compile-fail/issue-6762.rs | 11 +++--- src/test/compile-fail/issue-7573.rs | 2 +- src/test/compile-fail/kindck-freeze.rs | 2 +- .../compile-fail/lint-unused-mut-variables.rs | 2 +- src/test/compile-fail/lint-unused-unsafe.rs | 2 +- src/test/compile-fail/liveness-block-unint.rs | 2 +- .../liveness-closure-require-ret.rs | 2 +- .../liveness-init-in-called-fn-expr.rs | 2 +- .../compile-fail/liveness-init-in-fn-expr.rs | 2 +- src/test/compile-fail/missing-do.rs | 2 +- .../moves-based-on-type-block-bad.rs | 2 +- ...ased-on-type-no-recursive-stack-closure.rs | 2 +- .../compile-fail/omitted-arg-wrong-types.rs | 2 +- ...once-cant-move-out-of-non-once-on-stack.rs | 2 +- src/test/compile-fail/once-fn-subtyping.rs | 4 +-- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- .../regionck-closure-lifetimes.rs | 4 +-- .../compile-fail/regions-creating-enums.rs | 2 +- .../compile-fail/regions-escape-bound-fn-2.rs | 2 +- .../compile-fail/regions-escape-bound-fn.rs | 2 +- .../regions-escape-via-trait-or-not.rs | 2 +- src/test/compile-fail/regions-fn-bound.rs | 16 ++++----- src/test/compile-fail/regions-fn-subtyping.rs | 36 +++++++++---------- src/test/compile-fail/regions-fns.rs | 2 +- .../regions-free-region-ordering-callee.rs | 2 +- .../regions-free-region-ordering-caller.rs | 2 +- .../regions-infer-borrow-scope-within-loop.rs | 2 +- src/test/compile-fail/regions-infer-call-3.rs | 2 +- .../compile-fail/regions-name-undeclared.rs | 12 +++---- src/test/compile-fail/regions-nested-fns-2.rs | 2 +- src/test/compile-fail/regions-nested-fns.rs | 4 +-- .../compile-fail/regions-ref-in-fn-arg.rs | 2 +- .../compile-fail/regions-ret-borrowed-1.rs | 2 +- src/test/compile-fail/regions-ret-borrowed.rs | 2 +- .../compile-fail/type-arg-out-of-scope.rs | 2 +- .../lexical-scope-in-stack-closure.rs | 2 +- src/test/run-fail/unwind-iter.rs | 2 +- src/test/run-fail/unwind-iter2.rs | 2 +- src/test/run-fail/unwind-lambda.rs | 4 +-- src/test/run-pass-fulldeps/qquote.rs | 2 +- src/test/run-pass/argument-passing.rs | 2 +- src/test/run-pass/assignability-trait.rs | 6 ++-- src/test/run-pass/autobind.rs | 4 +-- src/test/run-pass/block-arg-call-as.rs | 4 +-- .../block-arg-can-be-followed-by-block-arg.rs | 2 +- src/test/run-pass/block-arg-used-as-any.rs | 2 +- src/test/run-pass/block-explicit-types.rs | 2 +- src/test/run-pass/block-fn-coerce.rs | 2 +- src/test/run-pass/block-iter-1.rs | 2 +- src/test/run-pass/block-iter-2.rs | 2 +- .../borrowck-borrow-from-expr-block.rs | 2 +- src/test/run-pass/borrowck-mut-uniq.rs | 2 +- .../borrowck-preserve-box-in-field.rs | 2 +- .../run-pass/borrowck-preserve-box-in-uniq.rs | 2 +- src/test/run-pass/borrowck-preserve-box.rs | 2 +- .../run-pass/borrowck-preserve-expl-deref.rs | 2 +- src/test/run-pass/closure-inference.rs | 2 +- src/test/run-pass/do-empty-args.rs | 2 +- src/test/run-pass/do-no-args.rs | 4 +-- src/test/run-pass/do-pure.rs | 2 +- src/test/run-pass/do-stack.rs | 2 +- src/test/run-pass/do1.rs | 2 +- src/test/run-pass/do2.rs | 2 +- src/test/run-pass/do3.rs | 2 +- src/test/run-pass/fn-bare-coerce-to-block.rs | 2 +- src/test/run-pass/fn-pattern-expected-type.rs | 2 +- src/test/run-pass/fn-type-infer.rs | 2 +- src/test/run-pass/foreach-nested.rs | 2 +- src/test/run-pass/foreach-put-structured.rs | 2 +- .../run-pass/foreach-simple-outer-slot.rs | 2 +- src/test/run-pass/fun-call-variants.rs | 2 +- src/test/run-pass/generic-static-methods.rs | 4 +-- src/test/run-pass/issue-1458.rs | 4 +-- src/test/run-pass/issue-2185.rs | 30 ++++++++-------- src/test/run-pass/issue-2190-2.rs | 6 ++-- src/test/run-pass/issue-2487-a.rs | 2 +- src/test/run-pass/issue-3429.rs | 2 +- src/test/run-pass/issue-3796.rs | 2 +- src/test/run-pass/issue-3874.rs | 2 +- src/test/run-pass/issue-3904.rs | 2 +- src/test/run-pass/issue-5239-2.rs | 2 +- src/test/run-pass/issue-6153.rs | 2 +- src/test/run-pass/issue-868.rs | 2 +- src/test/run-pass/iter-range.rs | 2 +- src/test/run-pass/lambda-infer-unresolved.rs | 4 +-- src/test/run-pass/last-use-in-block.rs | 6 ++-- src/test/run-pass/last-use-is-capture.rs | 2 +- src/test/run-pass/match-phi.rs | 2 +- src/test/run-pass/monad.rs | 8 ++--- src/test/run-pass/move-nullary-fn.rs | 4 +-- src/test/run-pass/mut-function-arguments.rs | 2 +- src/test/run-pass/newlambdas.rs | 4 +-- src/test/run-pass/non-legacy-modes.rs | 2 +- src/test/run-pass/purity-infer.rs | 2 +- src/test/run-pass/reflect-visit-data.rs | 6 ++-- src/test/run-pass/regions-fn-subtyping-2.rs | 4 +-- src/test/run-pass/regions-fn-subtyping.rs | 8 ++--- src/test/run-pass/regions-infer-call-2.rs | 2 +- src/test/run-pass/regions-params.rs | 2 +- src/test/run-pass/sendfn-is-a-block.rs | 2 +- src/test/run-pass/static-impl.rs | 12 +++---- src/test/run-pass/task-killjoin-rsrc.rs | 2 +- src/test/run-pass/tempfile.rs | 2 +- src/test/run-pass/trait-bounds-in-arc.rs | 8 ++--- src/test/run-pass/trait-generic.rs | 4 +-- src/test/run-pass/type-params-in-for-each.rs | 2 +- src/test/run-pass/unnamed_argument_mode.rs | 2 +- src/test/run-pass/unused-move-capture.rs | 2 +- src/test/run-pass/variadic-ffi.rs | 2 +- src/test/run-pass/vec-matching-fold.rs | 4 +-- 145 files changed, 249 insertions(+), 256 deletions(-) diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index aebe9382f64a7..f038acf67a82e 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -11,12 +11,12 @@ #[link(name="cci_impl_lib", vers="0.0")]; trait uint_helpers { - fn to(&self, v: uint, f: &fn(uint)); + fn to(&self, v: uint, f: |uint|); } impl uint_helpers for uint { #[inline] - fn to(&self, v: uint, f: &fn(uint)) { + fn to(&self, v: uint, f: |uint|) { let mut i = *self; while i < v { f(i); diff --git a/src/test/auxiliary/cci_iter_lib.rs b/src/test/auxiliary/cci_iter_lib.rs index a264c7d238f52..e08a2f7fcbbec 100644 --- a/src/test/auxiliary/cci_iter_lib.rs +++ b/src/test/auxiliary/cci_iter_lib.rs @@ -11,7 +11,7 @@ #[link(name="cci_iter_lib", vers="0.0")]; #[inline] -pub fn iter(v: &[T], f: &fn(&T)) { +pub fn iter(v: &[T], f: |&T|) { let mut i = 0u; let n = v.len(); while i < n { diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index fbdb7806b5e67..99d13e91752ab 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -11,7 +11,7 @@ #[link(name="cci_no_inline_lib", vers="0.0")]; // same as cci_iter_lib, more-or-less, but not marked inline -pub fn iter(v: ~[uint], f: &fn(uint)) { +pub fn iter(v: ~[uint], f: |uint|) { let mut i = 0u; let n = v.len(); while i < n { diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 37efa5768af7c..3cfe615b9c019 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -19,7 +19,7 @@ use std::trie::TrieMap; use std::uint; use std::vec; -fn timed(label: &str, f: &fn()) { +fn timed(label: &str, f: ||) { let start = time::precise_time_s(); f(); let end = time::precise_time_s(); diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index 9f65dc1e5555b..f9a3618d2abb6 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -27,7 +27,7 @@ struct Results { delete_strings: f64 } -fn timed(result: &mut f64, op: &fn()) { +fn timed(result: &mut f64, op: ||) { let start = extra::time::precise_time_s(); op(); let end = extra::time::precise_time_s(); @@ -36,13 +36,12 @@ fn timed(result: &mut f64, op: &fn()) { impl Results { pub fn bench_int, - R: rand::Rng>( - &mut self, - rng: &mut R, - num_keys: uint, - rand_cap: uint, - f: &fn() -> T) { - { + R: rand::Rng>( + &mut self, + rng: &mut R, + num_keys: uint, + rand_cap: uint, + f: || -> T) { { let mut set = f(); do timed(&mut self.sequential_ints) { for i in range(0u, num_keys) { @@ -79,11 +78,11 @@ impl Results { } pub fn bench_str, - R:rand::Rng>( - &mut self, - rng: &mut R, - num_keys: uint, - f: &fn() -> T) { + R:rand::Rng>( + &mut self, + rng: &mut R, + num_keys: uint, + f: || -> T) { { let mut set = f(); do timed(&mut self.sequential_strings) { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 4f1e267257538..c7036f8d9db31 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -40,7 +40,7 @@ fn main() { bench!(argv, is_utf8_multibyte); } -fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) { +fn maybe_run_test(argv: &[~str], name: ~str, test: ||) { let mut run_test = false; if os::getenv("RUST_BENCH").is_some() { diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 5cc8e161f5ffd..69d2a0021934d 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -104,8 +104,7 @@ fn update_freq(mm: &mut HashMap<~[u8], uint>, key: &[u8]) { // given a ~[u8], for each window call a function // i.e., for "hello" and windows of size four, // run it("hell") and it("ello"), then return "llo" -fn windows_with_carry(bb: &[u8], nn: uint, - it: &fn(window: &[u8])) -> ~[u8] { +fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> ~[u8] { let mut ii = 0u; let len = bb.len(); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index f2ba0d40ebc69..f8ac5154e7b0d 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -154,7 +154,7 @@ impl Table { } } - fn each(&self, f: &fn(entry: &Entry) -> bool) { + fn each(&self, f: |entry: &Entry| -> bool) { for self.items.each |item| { match *item { None => {} diff --git a/src/test/compile-fail/access-mode-in-closures.rs b/src/test/compile-fail/access-mode-in-closures.rs index 61fb754f7619f..ef853f57ef5e1 100644 --- a/src/test/compile-fail/access-mode-in-closures.rs +++ b/src/test/compile-fail/access-mode-in-closures.rs @@ -11,7 +11,7 @@ struct sty(~[int]); -fn unpack(_unpack: &fn(v: &sty) -> ~[int]) {} +fn unpack(_unpack: |v: &sty| -> ~[int]) {} fn main() { let _foo = unpack(|s| { diff --git a/src/test/compile-fail/block-coerce-no-2.rs b/src/test/compile-fail/block-coerce-no-2.rs index 3e38ce9ab358b..52359bed59c90 100644 --- a/src/test/compile-fail/block-coerce-no-2.rs +++ b/src/test/compile-fail/block-coerce-no-2.rs @@ -15,7 +15,7 @@ fn main() { fn f(f: extern fn(extern fn(extern fn()))) { } - fn g(f: extern fn(&fn())) { + fn g(f: extern fn(||)) { } f(g); diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 71afba18bb1ff..d07c3feb19423 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -11,9 +11,9 @@ // Make sure that fn-to-block coercion isn't incorrectly lifted over // other tycons. -fn coerce(b: &fn()) -> extern fn() { - fn lol(f: extern fn(v: &fn()) -> extern fn(), - g: &fn()) -> extern fn() { return f(g); } +fn coerce(b: ||) -> extern fn() { + fn lol(f: extern fn(v: ||) -> extern fn(), + g: ||) -> extern fn() { return f(g); } fn fn_id(f: extern fn()) -> extern fn() { return f } return lol(fn_id, b); //~^ ERROR mismatched types diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 81e16b6b615ed..55ef70ad8520f 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -24,7 +24,7 @@ fn a() { info!("{}", *q); } -fn borrow(_x: &[int], _f: &fn()) {} +fn borrow(_x: &[int], _f: ||) {} fn b() { // here we alias the mutable vector into an imm slice and try to diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 4bbd1b0decf57..f834642eb3cc5 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -11,7 +11,7 @@ struct X(Either<(uint,uint),extern fn()>); impl X { - pub fn with(&self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) { + pub fn with(&self, blk: |x: &Either<(uint,uint),extern fn()>|) { blk(&**self) } } diff --git a/src/test/compile-fail/borrowck-insert-during-each.rs b/src/test/compile-fail/borrowck-insert-during-each.rs index e507f0e9e5b92..358305aee08fb 100644 --- a/src/test/compile-fail/borrowck-insert-during-each.rs +++ b/src/test/compile-fail/borrowck-insert-during-each.rs @@ -15,7 +15,7 @@ struct Foo { } impl Foo { - pub fn foo(&mut self, fun: &fn(&int)) { + pub fn foo(&mut self, fun: |&int|) { for f in self.n.iter() { fun(f); } diff --git a/src/test/compile-fail/borrowck-lend-flow-if.rs b/src/test/compile-fail/borrowck-lend-flow-if.rs index 563f63b98be05..80b8770397fb2 100644 --- a/src/test/compile-fail/borrowck-lend-flow-if.rs +++ b/src/test/compile-fail/borrowck-lend-flow-if.rs @@ -17,7 +17,7 @@ fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} fn cond() -> bool { fail!() } -fn for_func(_f: &fn() -> bool) { fail!() } +fn for_func(_f: || -> bool) { fail!() } fn produce() -> T { fail!(); } fn inc(v: &mut ~int) { diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 9286340f6c9f5..14994c0245da9 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -111,7 +111,7 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) { } } -fn loop_break_pops_scopes<'r>(_v: &'r mut [uint], f: &fn(&'r mut uint) -> bool) { +fn loop_break_pops_scopes<'r>(_v: &'r mut [uint], f: |&'r mut uint| -> bool) { // Here we check that when you break out of an inner loop, the // borrows that go out of scope as you exit the inner loop are // removed from the bitset. @@ -127,7 +127,7 @@ fn loop_break_pops_scopes<'r>(_v: &'r mut [uint], f: &fn(&'r mut uint) -> bool) } } -fn loop_loop_pops_scopes<'r>(_v: &'r mut [uint], f: &fn(&'r mut uint) -> bool) { +fn loop_loop_pops_scopes<'r>(_v: &'r mut [uint], f: |&'r mut uint| -> bool) { // Similar to `loop_break_pops_scopes` but for the `loop` keyword while cond() { diff --git a/src/test/compile-fail/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck-lend-flow.rs index ea840a28b4e6a..5e4e5bb1e73f1 100644 --- a/src/test/compile-fail/borrowck-lend-flow.rs +++ b/src/test/compile-fail/borrowck-lend-flow.rs @@ -17,7 +17,7 @@ fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} fn cond() -> bool { fail!() } -fn for_func(_f: &fn() -> bool) { fail!() } +fn for_func(_f: || -> bool) { fail!() } fn produce() -> T { fail!(); } fn inc(v: &mut ~int) { diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index 0284f234d9a5a..7a226b8b67c0b 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -10,7 +10,7 @@ use std::task; -fn borrow(v: &int, f: &fn(x: &int)) { +fn borrow(v: &int, f: |x: &int|) { f(v); } diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index ae8779eafcc70..417330b6864a7 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(v: &int, f: &fn(x: &int)) { +fn borrow(v: &int, f: |x: &int|) { f(v); } diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index 27a66557434b0..e04eaa4d7af6a 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -12,14 +12,14 @@ struct point { x: int, y: int } trait methods { fn impurem(&self); - fn blockm(&self, f: &fn()); + fn blockm(&self, f: ||); } impl methods for point { fn impurem(&self) { } - fn blockm(&self, f: &fn()) { f() } + fn blockm(&self, f: ||) { f() } } fn a() { diff --git a/src/test/compile-fail/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck-loan-vec-content.rs index 8a4a2cdedb230..0617d19919114 100644 --- a/src/test/compile-fail/borrowck-loan-vec-content.rs +++ b/src/test/compile-fail/borrowck-loan-vec-content.rs @@ -12,7 +12,7 @@ // (locally rooted) mutable, unique vector, and that we then prevent // modifications to the contents. -fn takes_imm_elt(_v: &int, f: &fn()) { +fn takes_imm_elt(_v: &int, f: ||) { f(); } diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs index 628ccd1a5d782..7615036300f6f 100644 --- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs +++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs @@ -1,4 +1,4 @@ -fn with(f: &fn(&~str)) {} +fn with(f: |&~str|) {} fn arg_item(&_x: &~str) {} //~^ ERROR cannot move out of dereference of & pointer diff --git a/src/test/compile-fail/closure-bounds-not-builtin.rs b/src/test/compile-fail/closure-bounds-not-builtin.rs index fbf1acb60665b..4afab8db5468b 100644 --- a/src/test/compile-fail/closure-bounds-not-builtin.rs +++ b/src/test/compile-fail/closure-bounds-not-builtin.rs @@ -1,7 +1,7 @@ trait Foo {} -fn take(f: &fn:Foo()) { +fn take(f: ||:Foo) { //~^ ERROR only the builtin traits can be used as closure or object bounds } diff --git a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs index cac1244a56092..8fb64ee6dacec 100644 --- a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs +++ b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn bar(blk: &fn:'static()) { +fn bar(blk: ||:'static) { } fn foo(x: &()) { diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index f04da0575b954..77281b26554b1 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -1,15 +1,15 @@ -fn take_any(_: &fn:()) { +fn take_any(_: ||:) { } -fn take_const_owned(_: &fn:Freeze+Send()) { +fn take_const_owned(_: ||:Freeze+Send) { } -fn give_any(f: &fn:()) { +fn give_any(f: ||:) { take_any(f); } -fn give_owned(f: &fn:Send()) { +fn give_owned(f: ||:Send) { take_any(f); take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Send` } diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index aad0e8bcbb6dd..fc8e2d4d853f1 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -1,4 +1,4 @@ -fn foo(f: &fn() -> !) {} +fn foo(f: || -> !) {} fn main() { // Type inference didn't use to be able to handle this: diff --git a/src/test/compile-fail/do2.rs b/src/test/compile-fail/do2.rs index 1bffdaa682cdc..ffb779da354f8 100644 --- a/src/test/compile-fail/do2.rs +++ b/src/test/compile-fail/do2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: &fn(int) -> bool) -> bool { f(10i) } +fn f(f: |int| -> bool) -> bool { f(10i) } fn main() { assert!(do f() |i| { i == 10i } == 10i); diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index 069c5a77c6c33..6b01b83db21fd 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -14,5 +14,5 @@ extern fn f() { fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK - let _x: &fn() = f; //~ ERROR mismatched types + let _x: || = f; //~ ERROR mismatched types } diff --git a/src/test/compile-fail/fn-variance-1.rs b/src/test/compile-fail/fn-variance-1.rs index dd14d89a380c1..a4ebfef1774c6 100644 --- a/src/test/compile-fail/fn-variance-1.rs +++ b/src/test/compile-fail/fn-variance-1.rs @@ -13,7 +13,7 @@ fn takes_mut(x: @mut int) { } fn takes_imm(x: @int) { } -fn apply(t: T, f: &fn(T)) { +fn apply(t: T, f: |T|) { f(t) } diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs index 66b5bd172cace..663a50e9e553e 100644 --- a/src/test/compile-fail/immut-function-arguments.rs +++ b/src/test/compile-fail/immut-function-arguments.rs @@ -13,7 +13,7 @@ fn f(y: ~int) { } fn g() { - let _frob: &fn(~int) = |q| { *q = 2; }; //~ ERROR cannot assign + let _frob: |~int| = |q| { *q = 2; }; //~ ERROR cannot assign } diff --git a/src/test/compile-fail/issue-2074.rs b/src/test/compile-fail/issue-2074.rs index 7815fca16c69b..3b8c552db2bd2 100644 --- a/src/test/compile-fail/issue-2074.rs +++ b/src/test/compile-fail/issue-2074.rs @@ -10,11 +10,11 @@ // xfail-test fn main() { - let one: &fn() -> uint = || { + let one: || -> uint = || { enum r { a }; a as uint }; - let two = &fn() -> uint = || { + let two = || -> uint = || { enum r { a }; a as uint }; diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 3da01c6fb0139..8d2bdd2d2eb36 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -9,11 +9,11 @@ // except according to those terms. trait vec_monad { - fn bind(&self, f: &fn(A) -> ~[B]); + fn bind(&self, f: |A| -> ~[B]); } impl vec_monad for ~[A] { - fn bind(&self, f: &fn(A) -> ~[B]) { + fn bind(&self, f: |A| -> ~[B]) { let mut r = fail!(); for elt in self.iter() { r = r + f(*elt); } //~^ ERROR the type of this value must be known diff --git a/src/test/compile-fail/issue-5216.rs b/src/test/compile-fail/issue-5216.rs index 8205a6dae6470..ec9ec9565c406 100644 --- a/src/test/compile-fail/issue-5216.rs +++ b/src/test/compile-fail/issue-5216.rs @@ -9,12 +9,12 @@ // except according to those terms. fn f() { } -struct S(&fn()); //~ ERROR missing lifetime specifier +struct S(||); //~ ERROR missing lifetime specifier pub static C: S = S(f); fn g() { } -type T = &fn(); //~ ERROR missing lifetime specifier +type T = ||; //~ ERROR missing lifetime specifier pub static D: T = g; fn main() {} diff --git a/src/test/compile-fail/issue-5239-1.rs b/src/test/compile-fail/issue-5239-1.rs index 97317ec762ad1..a316e3df042e0 100644 --- a/src/test/compile-fail/issue-5239-1.rs +++ b/src/test/compile-fail/issue-5239-1.rs @@ -11,5 +11,5 @@ // Regression test for issue #5239 fn main() { - let x: &fn(int) -> int = |ref x| { x += 1; }; //~ ERROR binary operation + cannot be applied to type `&int` + let x: |int| -> int = |ref x| { x += 1; }; //~ ERROR binary operation + cannot be applied to type `&int` } diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6762.rs index 14dcc4ea8a3a8..22bb660a08066 100644 --- a/src/test/compile-fail/issue-6762.rs +++ b/src/test/compile-fail/issue-6762.rs @@ -4,20 +4,17 @@ // transferring ownership of the owned box before invoking the stack // closure results in a crash. -fn twice(x: ~uint) -> uint -{ +fn twice(x: ~uint) -> uint { *x * 2 } -fn invoke(f : &fn() -> uint) -{ +fn invoke(f: || -> uint) { f(); } -fn main() -{ +fn main() { let x : ~uint = ~9; - let sq : &fn() -> uint = || { *x * *x }; + let sq : || -> uint = || { *x * *x }; twice(x); invoke(sq); diff --git a/src/test/compile-fail/issue-7573.rs b/src/test/compile-fail/issue-7573.rs index 9dc29e59f904a..4ab0ac6386e4c 100644 --- a/src/test/compile-fail/issue-7573.rs +++ b/src/test/compile-fail/issue-7573.rs @@ -35,7 +35,7 @@ pub fn remove_package_from_database() { } -pub fn list_database(f: &fn(&PkgId)) { +pub fn list_database(f: |&PkgId|) { let stuff = ["foo", "bar"]; for l in stuff.iter() { diff --git a/src/test/compile-fail/kindck-freeze.rs b/src/test/compile-fail/kindck-freeze.rs index c83892e2a3b31..474c1b1d3cfa4 100644 --- a/src/test/compile-fail/kindck-freeze.rs +++ b/src/test/compile-fail/kindck-freeze.rs @@ -45,7 +45,7 @@ fn test<'a,T,U:Freeze>(_: &'a int) { assert_freeze::<&'a mut Dummy:Freeze>(); //~ ERROR does not fulfill `Freeze` // closures are like an `&mut` object - assert_freeze::<&fn()>(); //~ ERROR does not fulfill `Freeze` + assert_freeze::<||>(); //~ ERROR does not fulfill `Freeze` // unsafe ptrs are ok unless they point at unfreezeable things assert_freeze::<*int>(); diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index 3abacdba18340..d73f0e6ab1e68 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -55,7 +55,7 @@ fn main() { let mut _allowed = 1; } -fn callback(f: &fn()) {} +fn callback(f: ||) {} // make sure the lint attribute can be turned off #[allow(unused_mut)] diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index 50cc9ceb94e91..253459be85a82 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -18,7 +18,7 @@ mod foo { } } -fn callback(_f: &fn() -> T) -> T { fail!() } +fn callback(_f: || -> T) -> T { fail!() } unsafe fn unsf() {} fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block diff --git a/src/test/compile-fail/liveness-block-unint.rs b/src/test/compile-fail/liveness-block-unint.rs index 98b6cabb6ffac..c46b9013a068d 100644 --- a/src/test/compile-fail/liveness-block-unint.rs +++ b/src/test/compile-fail/liveness-block-unint.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: &fn()) { f(); } +fn force(f: ||) { f(); } fn main() { let x: int; force(|| { diff --git a/src/test/compile-fail/liveness-closure-require-ret.rs b/src/test/compile-fail/liveness-closure-require-ret.rs index 8f9941e668895..9d46202d64e21 100644 --- a/src/test/compile-fail/liveness-closure-require-ret.rs +++ b/src/test/compile-fail/liveness-closure-require-ret.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: &fn() -> int) -> int { f() } +fn force(f: || -> int) -> int { f() } fn main() { info!("{:?}", force(|| {})); } //~ ERROR mismatched types diff --git a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs index 7054cb0d901ce..d759a5738bd22 100644 --- a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let j: &fn() -> int = || { + let j: || -> int = || { let i: int; i //~ ERROR use of possibly uninitialized variable: `i` }; diff --git a/src/test/compile-fail/liveness-init-in-fn-expr.rs b/src/test/compile-fail/liveness-init-in-fn-expr.rs index 1381631388449..f6bb2f5428370 100644 --- a/src/test/compile-fail/liveness-init-in-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-fn-expr.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let f: &fn() -> int = || { + let f: || -> int = || { let i: int; i //~ ERROR use of possibly uninitialized variable: `i` }; diff --git a/src/test/compile-fail/missing-do.rs b/src/test/compile-fail/missing-do.rs index e6a7698d0f075..5448766c30a72 100644 --- a/src/test/compile-fail/missing-do.rs +++ b/src/test/compile-fail/missing-do.rs @@ -10,7 +10,7 @@ // Regression test for issue #2783 -fn foo(f: &fn()) { f() } +fn foo(f: ||) { f() } fn main() { ~"" || 42; //~ ERROR binary operation || cannot be applied to type diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 11c4d078208ee..355305b6c630c 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -8,7 +8,7 @@ enum E { Baz } -fn f(s: &S, g: &fn(&S)) { +fn f(s: &S, g: |&S|) { g(s) } diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index 2762140be3793..db8effb1de3df 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -36,7 +36,7 @@ fn innocent_looking_victim() { } } -fn conspirator(f: &fn(&R, bool)) { +fn conspirator(f: |&R, bool|) { let r = R {c: f}; f(&r, false) //~ ERROR use of moved value } diff --git a/src/test/compile-fail/omitted-arg-wrong-types.rs b/src/test/compile-fail/omitted-arg-wrong-types.rs index a44c113269b98..f43ff0421a9a7 100644 --- a/src/test/compile-fail/omitted-arg-wrong-types.rs +++ b/src/test/compile-fail/omitted-arg-wrong-types.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test - #2093 -fn let_in(x: T, f: &fn(T)) {} +fn let_in(x: T, f: |T|) {} fn main() { let_in(3u, |i| { assert!(i == 3); }); diff --git a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs index aedeb92df787c..4927acde48d87 100644 --- a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs +++ b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs @@ -15,7 +15,7 @@ extern mod extra; use extra::arc; use std::util; -fn foo(blk: &fn()) { +fn foo(blk: ||) { blk(); blk(); } diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs index 5f7393fdf8b8c..503b4d3e77b97 100644 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ b/src/test/compile-fail/once-fn-subtyping.rs @@ -11,7 +11,7 @@ #[feature(once_fns)]; fn main() { let f: &once fn() = ||(); - let g: &fn() = f; //~ ERROR mismatched types - let h: &fn() = ||(); + let g: || = f; //~ ERROR mismatched types + let h: || = ||(); let i: &once fn() = h; // ok } diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index 0112c0adea298..f55fcfc204b2f 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -62,6 +62,6 @@ fn main() { check_pp(expr3, pprust::print_expr, "2 - 23 + 7"); } -fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { +fn check_pp(expr: T, f: |pprust::ps, T|, expect: str) { fail!(); } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 57355885e2f46..262abc045a411 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -57,6 +57,6 @@ fn main() { check_pp(*stmt, pprust::print_stmt, ""); } -fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { +fn check_pp(expr: T, f: |pprust::ps, T|, expect: str) { fail!(); } diff --git a/src/test/compile-fail/regionck-closure-lifetimes.rs b/src/test/compile-fail/regionck-closure-lifetimes.rs index c9a3e044d9c47..f66b17d68c76f 100644 --- a/src/test/compile-fail/regionck-closure-lifetimes.rs +++ b/src/test/compile-fail/regionck-closure-lifetimes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn env<'a>(_: &'a uint, blk: &fn(p: &'a fn())) { +fn env<'a>(_: &'a uint, blk: |p: 'a |||) { // Test that the closure here cannot be assigned // the lifetime `'a`, which outlives the current // block. @@ -21,7 +21,7 @@ fn env<'a>(_: &'a uint, blk: &fn(p: &'a fn())) { blk(|| *statep = 1); //~ ERROR cannot infer an appropriate lifetime } -fn no_env_no_for<'a>(_: &'a uint, blk: &fn(p: &'a fn())) { +fn no_env_no_for<'a>(_: &'a uint, blk: |p: 'a |||) { // Test that a closure with no free variables CAN // outlive the block in which it is created. // diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs index c2d8427d5eb39..0a370425c4165 100644 --- a/src/test/compile-fail/regions-creating-enums.rs +++ b/src/test/compile-fail/regions-creating-enums.rs @@ -27,7 +27,7 @@ fn compute(x: &ast) -> uint { } } -fn map_nums(x: &ast, f: &fn(uint) -> uint) -> &ast { +fn map_nums(x: &ast, f: |uint| -> uint) -> &ast { match *x { num(x) => { return &num(f(x)); //~ ERROR borrowed value does not live long enough diff --git a/src/test/compile-fail/regions-escape-bound-fn-2.rs b/src/test/compile-fail/regions-escape-bound-fn-2.rs index 305aa68528493..d2551ec4fedb4 100644 --- a/src/test/compile-fail/regions-escape-bound-fn-2.rs +++ b/src/test/compile-fail/regions-escape-bound-fn-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with_int(f: &fn(x: &int)) { +fn with_int(f: |x: &int|) { let x = 3; f(&x); } diff --git a/src/test/compile-fail/regions-escape-bound-fn.rs b/src/test/compile-fail/regions-escape-bound-fn.rs index 5ac5e334be23d..eb72b4b0c5321 100644 --- a/src/test/compile-fail/regions-escape-bound-fn.rs +++ b/src/test/compile-fail/regions-escape-bound-fn.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with_int(f: &fn(x: &int)) { +fn with_int(f: |x: &int|) { let x = 3; f(&x); } diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs index 5b6dc1b2f4fb4..32ec59d97413b 100644 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs @@ -18,7 +18,7 @@ impl<'self> deref for &'self int { } } -fn with(f: &fn(x: &int) -> R) -> int { +fn with(f: |x: &int| -> R) -> int { f(&3).get() } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index add53d3d9b0b9..09801d37ee92c 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -11,8 +11,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> &fn(T) { fail!(); } -fn subtype(x: &fn(T)) { fail!(); } +fn of() -> |T| { fail!(); } +fn subtype(x: |T|) { fail!(); } fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters @@ -21,14 +21,14 @@ fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // iff T1 <: T2. // should be the default: - subtype::<&'static fn()>(of::<&fn()>()); - subtype::<&fn()>(of::<&'static fn()>()); + subtype::<'static ||>(of::<||>()); + subtype::<||>(of::<'static ||>()); // - subtype::<&'x fn()>(of::<&fn()>()); //~ ERROR mismatched types - subtype::<&'x fn()>(of::<&'y fn()>()); //~ ERROR mismatched types + subtype::<'x ||>(of::<||>()); //~ ERROR mismatched types + subtype::<'x ||>(of::<'y ||>()); //~ ERROR mismatched types - subtype::<&'x fn()>(of::<&'static fn()>()); //~ ERROR mismatched types - subtype::<&'static fn()>(of::<&'x fn()>()); + subtype::<'x ||>(of::<'static ||>()); //~ ERROR mismatched types + subtype::<'static ||>(of::<'x ||>()); } diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index cad73daa46b15..0cbd37a3b9a5e 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> &fn(T) { fail!(); } -fn subtype(x: &fn(T)) { fail!(); } +fn of() -> |T| { fail!(); } +fn subtype(x: |T|) { fail!(); } fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters @@ -17,29 +17,29 @@ fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) { // subtype::(of::()) will typecheck // iff T1 <: T2. - subtype::<&fn<'a>(&'a T)>( - of::<&fn<'a>(&'a T)>()); + subtype::< <'a>|&'a T|>( + of::< <'a>|&'a T|>()); - subtype::<&fn<'a>(&'a T)>( - of::<&fn<'b>(&'b T)>()); + subtype::< <'a>|&'a T|>( + of::< <'b>|&'b T|>()); - subtype::<&fn<'b>(&'b T)>( - of::<&fn(&'x T)>()); + subtype::< <'b>|&'b T|>( + of::<|&'x T|>()); - subtype::<&fn(&'x T)>( - of::<&fn<'b>(&'b T)>()); //~ ERROR mismatched types + subtype::<|&'x T|>( + of::< <'b>|&'b T|>()); //~ ERROR mismatched types - subtype::<&fn<'a,'b>(&'a T, &'b T)>( - of::<&fn<'a>(&'a T, &'a T)>()); + subtype::< <'a,'b>|&'a T, &'b T|>( + of::< <'a>|&'a T, &'a T|>()); - subtype::<&fn<'a>(&'a T, &'a T)>( - of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types + subtype::< <'a>|&'a T, &'a T|>( + of::< <'a,'b>|&'a T, &'b T|>()); //~ ERROR mismatched types - subtype::<&fn<'a,'b>(&'a T, &'b T)>( - of::<&fn(&'x T, &'y T)>()); + subtype::< <'a,'b>|&'a T, &'b T|>( + of::<|&'x T, &'y T|>()); - subtype::<&fn(&'x T, &'y T)>( - of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types + subtype::<|&'x T, &'y T|>( + of::< <'a,'b>|&'a T, &'b T|>()); //~ ERROR mismatched types } fn main() {} diff --git a/src/test/compile-fail/regions-fns.rs b/src/test/compile-fail/regions-fns.rs index 715261d816a4e..854584ec535e6 100644 --- a/src/test/compile-fail/regions-fns.rs +++ b/src/test/compile-fail/regions-fns.rs @@ -12,7 +12,7 @@ // we reported errors in this case: fn not_ok<'b>(a: &uint, b: &'b uint) { - let mut g: &fn(x: &uint) = |x: &'b uint| {}; + let mut g: |x: &uint| = |x: &'b uint| {}; //~^ ERROR mismatched types g(a); } diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index fb31e477ba279..94c617b218266 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -30,7 +30,7 @@ fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint { fail!(); } -fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: &fn(&'a &'b uint)) { +fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: |&'a &'b uint|) { let z: Option<&'a &'b uint> = None; } diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs index 58fa437a6a365..808e850907f28 100644 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ b/src/test/compile-fail/regions-free-region-ordering-caller.rs @@ -26,7 +26,7 @@ fn call3<'a, 'b>(a: &'a uint, b: &'b uint) { } fn call4<'a, 'b>(a: &'a uint, b: &'b uint) { - let z: Option<&fn(&'a &'b uint)> = None; + let z: Option<|&'a &'b uint|> = None; //~^ ERROR pointer has a longer lifetime than the data it references } diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index e0764d3929133..26b0f2b66c387 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -12,7 +12,7 @@ fn borrow<'r, T>(x: &'r T) -> &'r T {x} -fn foo(cond: &fn() -> bool, box: &fn() -> @int) { +fn foo(cond: || -> bool, box: || -> @int) { let mut y: ∫ loop { let x = box(); diff --git a/src/test/compile-fail/regions-infer-call-3.rs b/src/test/compile-fail/regions-infer-call-3.rs index 585b56d5a420b..8002f8bcc50d2 100644 --- a/src/test/compile-fail/regions-infer-call-3.rs +++ b/src/test/compile-fail/regions-infer-call-3.rs @@ -10,7 +10,7 @@ fn select<'r>(x: &'r int, y: &'r int) -> &'r int { x } -fn with(f: &fn(x: &int) -> T) -> T { +fn with(f: |x: &int| -> T) -> T { f(&20) } diff --git a/src/test/compile-fail/regions-name-undeclared.rs b/src/test/compile-fail/regions-name-undeclared.rs index abff33e051491..ba3d7bd29f4ac 100644 --- a/src/test/compile-fail/regions-name-undeclared.rs +++ b/src/test/compile-fail/regions-name-undeclared.rs @@ -43,16 +43,16 @@ fn bar<'a>(x: &'a int) { // &'a CAN be declared on functions and used then: fn g<'a>(a: &'a int) { } // OK - fn h(a: &fn<'a>(&'a int)) { } // OK + fn h(a: <'a>|&'a int|) { } // OK } // Test nesting of lifetimes in fn type declarations fn fn_types(a: &'a int, //~ ERROR undeclared lifetime - b: &fn<'a>(a: &'a int, - b: &'b int, //~ ERROR undeclared lifetime - c: &fn<'b>(a: &'a int, - b: &'b int), - d: &'b int), //~ ERROR undeclared lifetime + b: <'a>|a: &'a int, + b: &'b int, //~ ERROR undeclared lifetime + c: <'b>|a: &'a int, + b: &'b int|, + d: &'b int|, //~ ERROR undeclared lifetime c: &'a int) //~ ERROR undeclared lifetime { } diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs index fe995052c52e4..8e9a7546541d0 100644 --- a/src/test/compile-fail/regions-nested-fns-2.rs +++ b/src/test/compile-fail/regions-nested-fns-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn ignore(_f: &fn<'z>(&'z int) -> &'z int) {} +fn ignore(_f: <'z>|&'z int| -> &'z int) {} fn nested() { let y = 3; diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index 244e9cc06a1ac..11610f422a0c8 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -14,13 +14,13 @@ fn nested<'x>(x: &'x int) { let y = 3; let mut ay = &y; //~ ERROR cannot infer an appropriate lifetime - ignore::<&fn<'z>(&'z int)>(|z| { + ignore::< <'z>|&'z int|>(|z| { ay = x; ay = &y; ay = z; }); - ignore::<&fn<'z>(&'z int) -> &'z int>(|z| { + ignore::< <'z>|&'z int| -> &'z int>(|z| { if false { return x; } //~ ERROR mismatched types //~^ ERROR cannot infer an appropriate lifetime if false { return ay; } diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs index 4848262750720..9574f05fa5852 100644 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ b/src/test/compile-fail/regions-ref-in-fn-arg.rs @@ -2,7 +2,7 @@ fn arg_item(~ref x: ~int) -> &'static int { x //~^ ERROR borrowed value does not live long enough } -fn with(f: &fn(~int) -> R) -> R { f(~3) } +fn with(f: |~int| -> R) -> R { f(~3) } fn arg_closure() -> &'static int { with(|~ref x| x) //~ ERROR borrowed value does not live long enough diff --git a/src/test/compile-fail/regions-ret-borrowed-1.rs b/src/test/compile-fail/regions-ret-borrowed-1.rs index ee6ed3b0d76f6..7eb5fa3c60be6 100644 --- a/src/test/compile-fail/regions-ret-borrowed-1.rs +++ b/src/test/compile-fail/regions-ret-borrowed-1.rs @@ -12,7 +12,7 @@ // some point regions-ret-borrowed reported an error but this file did // not, due to special hardcoding around the anonymous region. -fn with(f: &fn<'a>(x: &'a int) -> R) -> R { +fn with(f: <'a>|x: &'a int| -> R) -> R { f(&3) } diff --git a/src/test/compile-fail/regions-ret-borrowed.rs b/src/test/compile-fail/regions-ret-borrowed.rs index c2e48053260cf..2f6f2f44cda58 100644 --- a/src/test/compile-fail/regions-ret-borrowed.rs +++ b/src/test/compile-fail/regions-ret-borrowed.rs @@ -15,7 +15,7 @@ // used to successfully compile because we failed to account for the // fact that fn(x: &int) rebound the region &. -fn with(f: &fn(x: &int) -> R) -> R { +fn with(f: |x: &int| -> R) -> R { f(&3) } diff --git a/src/test/compile-fail/type-arg-out-of-scope.rs b/src/test/compile-fail/type-arg-out-of-scope.rs index 07dc677c04763..240b1aa06d472 100644 --- a/src/test/compile-fail/type-arg-out-of-scope.rs +++ b/src/test/compile-fail/type-arg-out-of-scope.rs @@ -10,6 +10,6 @@ // error-pattern:attempt to use a type argument out of scope fn foo(x: T) { - fn bar(f: &fn(T) -> T) { } + fn bar(f: |T| -> T) { } } fn main() { foo(1); } diff --git a/src/test/debug-info/lexical-scope-in-stack-closure.rs b/src/test/debug-info/lexical-scope-in-stack-closure.rs index 238ad3c519d13..f052448c146a6 100644 --- a/src/test/debug-info/lexical-scope-in-stack-closure.rs +++ b/src/test/debug-info/lexical-scope-in-stack-closure.rs @@ -51,7 +51,7 @@ fn main() { zzz(); sentinel(); - let stack_closure: &fn(int) = |x| { + let stack_closure: |int| = |x| { zzz(); sentinel(); diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 51c6cb3adf318..1f5e455564e34 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -13,7 +13,7 @@ #[allow(unreachable_code)]; #[allow(unused_variable)]; -fn x(it: &fn(int)) { +fn x(it: |int|) { fail!(); it(0); } diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index 17936df6959f2..d0726d2544ca6 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn x(it: &fn(int)) { +fn x(it: |int|) { let _a = @0; it(1); } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 4b95afc0ee28b..bd415e9eac3e7 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -16,13 +16,13 @@ fn main() { let cheese = ~"roquefort"; let carrots = @~"crunchy"; - let result: &'static fn(@~str, &fn(~str)) = (|tasties, macerate| { + let result: &'static fn(@~str, |~str|) = (|tasties, macerate| { macerate((*tasties).clone()); }); result(carrots, |food| { let mush = food + cheese; let cheese = cheese.clone(); - let f: &fn() = || { + let f: || = || { let _chew = mush + cheese; fail!("so yummy") }; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index c7c8e3a19a6cd..0fcd49790e072 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -74,7 +74,7 @@ fn main() { } fn check_pp(cx: fake_ext_ctxt, - expr: T, f: &fn(pprust::ps, T), expect: ~str) { + expr: T, f: |pprust::ps, T|, expect: ~str) { let s = do io::with_str_writer |wr| { let pp = pprust::rust_printer(wr, cx.parse_sess().interner); f(pp, expr); diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 6d6ae3da62fef..7f43642463e1e 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -21,7 +21,7 @@ fn f1(a: &mut X, b: &mut int, c: int) -> int { return r; } -fn f2(a: int, f: &fn(int)) -> int { f(1); return a; } +fn f2(a: int, f: |int|) -> int { f(1); return a; } pub fn main() { let mut a = X {x: 1}; diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 5269f7dab5aad..1da5023dce023 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -13,17 +13,17 @@ // it. trait iterable { - fn iterate(&self, blk: &fn(x: &A) -> bool) -> bool; + fn iterate(&self, blk: |x: &A| -> bool) -> bool; } impl<'self,A> iterable for &'self [A] { - fn iterate(&self, f: &fn(x: &A) -> bool) -> bool { + fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } impl iterable for ~[A] { - fn iterate(&self, f: &fn(x: &A) -> bool) -> bool { + fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 440ad723a12ce..c0ceb50a2c4be 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -10,10 +10,10 @@ fn f(x: ~[T]) -> T { return x[0]; } -fn g(act: &fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } +fn g(act: |~[int]| -> int) -> int { return act(~[1, 2, 3]); } pub fn main() { assert_eq!(g(f), 1); - let f1: &fn(~[~str]) -> ~str = f; + let f1: |~[~str]| -> ~str = f; assert_eq!(f1(~[~"x", ~"y", ~"z"]), ~"x"); } diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index 5aa28258792e6..70307e1ff0465 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -10,11 +10,11 @@ extern mod extra; -fn asSendfn( f : proc()->uint ) -> uint { +fn asSendfn(f: proc() -> uint) -> uint { return f(); } -fn asBlock( f : &fn()->uint ) -> uint { +fn asBlock(f: || -> uint) -> uint { return f(); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index ed8641eaf85f9..0d82e294caf22 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - fn f(i: &fn() -> uint) -> uint { i() } + fn f(i: || -> uint) -> uint { i() } let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0]; let z = do do v.iter().fold(f) |x, _y| { x } { 22u }; assert_eq!(z, 22u); diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index 7ee9d9e5b5489..f05eb8e30b17c 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn call_any(f: &fn() -> uint) -> uint { +fn call_any(f: || -> uint) -> uint { return f(); } diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index 379fced1d334b..82e563ae41ced 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - fn as_buf(s: ~str, f: &fn(~str) -> T) -> T { f(s) } + fn as_buf(s: ~str, f: |~str| -> T) -> T { f(s) } as_buf(~"foo", |foo: ~str| -> () error!("{}", foo) ); } diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index 19e1fd4099b74..bbb30e9578e9e 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: &fn() -> int) -> int { return f(); } +fn force(f: || -> int) -> int { return f(); } pub fn main() { fn f() -> int { return 7; } assert_eq!(force(f), 7); diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index a977eb40992bb..821f4b17a79b1 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -10,7 +10,7 @@ // xfail-fast -fn iter_vec(v: ~[T], f: &fn(&T)) { for x in v.iter() { f(x); } } +fn iter_vec(v: ~[T], f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7]; diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index e5ea54c2a3eb3..ddaf7f233cf01 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -10,7 +10,7 @@ // xfail-fast -fn iter_vec(v: ~[T], f: &fn(&T)) { for x in v.iter() { f(x); } } +fn iter_vec(v: ~[T], f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { let v = ~[1, 2, 3, 4, 5]; diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index bc3078f88eabb..dae10ed6d3917 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -13,7 +13,7 @@ use std::borrow; use std::ptr; -fn borrow(x: &int, f: &fn(x: &int)) { +fn borrow(x: &int, f: |x: &int|) { f(x) } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 9057ebf7983f1..7b4c4247a353b 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -20,7 +20,7 @@ fn add_int(x: &mut Ints, v: int) { util::swap(&mut values, &mut x.values); } -fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) -> bool { +fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool { let l = x.values.len(); range(0u, l).advance(|i| f(&x.values[i])) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index 214753c009cda..bc8eeb5cd4178 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -12,7 +12,7 @@ use std::ptr; -fn borrow(x: &int, f: &fn(x: &int)) { +fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 239dd4c6dc43c..3ff30192efed8 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -12,7 +12,7 @@ use std::ptr; -fn borrow(x: &int, f: &fn(x: &int)) { +fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index 8a97e8f1b5caf..e83621d6bb280 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -12,7 +12,7 @@ use std::ptr; -fn borrow(x: &int, f: &fn(x: &int)) { +fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index a0010d3619091..6041fa977f5c3 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -12,7 +12,7 @@ use std::ptr; -fn borrow(x: &int, f: &fn(x: &int)) { +fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; diff --git a/src/test/run-pass/closure-inference.rs b/src/test/run-pass/closure-inference.rs index 167fbdf3fc052..b6943b4570018 100644 --- a/src/test/run-pass/closure-inference.rs +++ b/src/test/run-pass/closure-inference.rs @@ -12,7 +12,7 @@ fn foo(i: int) -> int { i + 1 } -fn apply(f: &fn(A) -> A, v: A) -> A { f(v) } +fn apply(f: |A| -> A, v: A) -> A { f(v) } pub fn main() { let f = {|i| foo(i)}; diff --git a/src/test/run-pass/do-empty-args.rs b/src/test/run-pass/do-empty-args.rs index 485d59da7d4b2..0078294eb89d5 100644 --- a/src/test/run-pass/do-empty-args.rs +++ b/src/test/run-pass/do-empty-args.rs @@ -11,7 +11,7 @@ // no-reformat // Testing various forms of `do` with empty arg lists -fn f(_f: &fn() -> bool) -> bool { +fn f(_f: || -> bool) -> bool { true } diff --git a/src/test/run-pass/do-no-args.rs b/src/test/run-pass/do-no-args.rs index 1f725ffb3576a..eb6a4a3db5421 100644 --- a/src/test/run-pass/do-no-args.rs +++ b/src/test/run-pass/do-no-args.rs @@ -10,9 +10,9 @@ // Testing that we can drop the || in do exprs -fn f(_f: &fn() -> bool) -> bool { true } +fn f(_f: || -> bool) -> bool { true } -fn d(_f: &fn()) { } +fn d(_f: ||) { } pub fn main() { do d { } diff --git a/src/test/run-pass/do-pure.rs b/src/test/run-pass/do-pure.rs index 8a0509c177432..85bb84c6061ac 100644 --- a/src/test/run-pass/do-pure.rs +++ b/src/test/run-pass/do-pure.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(_f: &fn()) { +fn f(_f: ||) { } fn g() { diff --git a/src/test/run-pass/do-stack.rs b/src/test/run-pass/do-stack.rs index 0444b269cb34f..fddf3b15c78da 100644 --- a/src/test/run-pass/do-stack.rs +++ b/src/test/run-pass/do-stack.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: &fn(int)) { f(10) } +fn f(f: |int|) { f(10) } pub fn main() { do f() |i| { assert!(i == 10) } diff --git a/src/test/run-pass/do1.rs b/src/test/run-pass/do1.rs index 0444b269cb34f..fddf3b15c78da 100644 --- a/src/test/run-pass/do1.rs +++ b/src/test/run-pass/do1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: &fn(int)) { f(10) } +fn f(f: |int|) { f(10) } pub fn main() { do f() |i| { assert!(i == 10) } diff --git a/src/test/run-pass/do2.rs b/src/test/run-pass/do2.rs index 9feededc9800b..1bfb10a9f7568 100644 --- a/src/test/run-pass/do2.rs +++ b/src/test/run-pass/do2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: &fn(int) -> int) -> int { f(10) } +fn f(f: |int| -> int) -> int { f(10) } pub fn main() { assert_eq!(do f() |i| { i }, 10); diff --git a/src/test/run-pass/do3.rs b/src/test/run-pass/do3.rs index eeb983b455792..c08842a45ce77 100644 --- a/src/test/run-pass/do3.rs +++ b/src/test/run-pass/do3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: &fn(int) -> int) -> int { f(10) } +fn f(f: |int| -> int) -> int { f(10) } pub fn main() { assert_eq!(do f |i| { i }, 10); diff --git a/src/test/run-pass/fn-bare-coerce-to-block.rs b/src/test/run-pass/fn-bare-coerce-to-block.rs index db7604d11484d..1231a49dcd31b 100644 --- a/src/test/run-pass/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/fn-bare-coerce-to-block.rs @@ -10,7 +10,7 @@ fn bare() {} -fn likes_block(f: &fn()) { f() } +fn likes_block(f: ||) { f() } pub fn main() { likes_block(bare); diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index 450e2a70aab9b..fb75abc6ea093 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let f: &fn((int,int)) = |(x, y)| { + let f: |(int,int)| = |(x, y)| { assert_eq!(x, 1); assert_eq!(y, 2); }; diff --git a/src/test/run-pass/fn-type-infer.rs b/src/test/run-pass/fn-type-infer.rs index 09e7ababa6cb6..cf783ca141c0a 100644 --- a/src/test/run-pass/fn-type-infer.rs +++ b/src/test/run-pass/fn-type-infer.rs @@ -11,7 +11,7 @@ #[allow(unused_variable)]; pub fn main() { - // We should be able to type infer inside of &fns. + // We should be able to type infer inside of ||s. let _f = || { let i = 10; }; diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 36c086093cff0..1f63bd68d34f7 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -11,7 +11,7 @@ -fn two(it: &fn(int)) { it(0); it(1); } +fn two(it: |int|) { it(0); it(1); } pub fn main() { let mut a: ~[int] = ~[-1, -1, -1, -1]; diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 2b57cc033f9f6..91468841e0923 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -10,7 +10,7 @@ -fn pairs(it: &fn((int, int))) { +fn pairs(it: |(int, int)|) { let mut i: int = 0; let mut j: int = 0; while i < 10 { it((i, j)); i += 1; j += i; } diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index f38ac1ed38b4a..34b131893269a 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -19,7 +19,7 @@ pub fn main() { assert_eq!(sum, 45); } -fn first_ten(it: &fn(int)) { +fn first_ten(it: |int|) { let mut i: int = 0; while i < 10 { info!("first_ten"); it(i); i = i + 1; } } diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 0edfe174680e6..479f4f8387fb4 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn ho(f: &fn(int) -> int) -> int { let n: int = f(3); return n; } +fn ho(f: |int| -> int) -> int { let n: int = f(3); return n; } fn direct(x: int) -> int { return x + 1; } diff --git a/src/test/run-pass/generic-static-methods.rs b/src/test/run-pass/generic-static-methods.rs index 2e281812d138f..5832c565d7f4c 100644 --- a/src/test/run-pass/generic-static-methods.rs +++ b/src/test/run-pass/generic-static-methods.rs @@ -9,11 +9,11 @@ // except according to those terms. trait vec_utils { - fn map_(x: &Self, f: &fn(&T) -> U) -> ~[U]; + fn map_(x: &Self, f: |&T| -> U) -> ~[U]; } impl vec_utils for ~[T] { - fn map_(x: &~[T], f: &fn(&T) -> U) -> ~[U] { + fn map_(x: &~[T], f: |&T| -> U) -> ~[U] { let mut r = ~[]; for elt in x.iter() { r.push(f(elt)); diff --git a/src/test/run-pass/issue-1458.rs b/src/test/run-pass/issue-1458.rs index e22f38287ad5d..ce5c932f8da2e 100644 --- a/src/test/run-pass/issue-1458.rs +++ b/src/test/run-pass/issue-1458.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn plus_one(f: &fn() -> int) -> int { +fn plus_one(f: || -> int) -> int { return f() + 1; } -fn ret_plus_one() -> extern fn(&fn() -> int) -> int { +fn ret_plus_one() -> extern fn(|| -> int) -> int { return plus_one; } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index fdf88f414ecfc..afe7656b7a343 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -18,12 +18,12 @@ // // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait -// issue-2185.rs:24 impl iterable for &'static fn(&fn(uint)) { -// issue-2185.rs:25 fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) } +// issue-2185.rs:24 impl iterable for &'static fn(|uint|) { +// issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) } // issue-2185.rs:26 } // issue-2185.rs:20:0: 22:1 note: note conflicting implementation here -// issue-2185.rs:20 impl iterable for &'static fn(&fn(A)) { -// issue-2185.rs:21 fn iter(&self, blk: &fn(A)) { self(blk); } +// issue-2185.rs:20 impl iterable for 'static ||A|| { +// issue-2185.rs:21 fn iter(&self, blk: |A|) { self(blk); } // issue-2185.rs:22 } // // … so it looks like it's just not possible to implement both the generic iterable and iterable for the type iterable. Is it okay if I just remove this test? @@ -39,26 +39,24 @@ // warrant still having a test, so I inlined the old definitions. trait iterable { - fn iter(&self, blk: &fn(A)); + fn iter(&self, blk: |A|); } -impl iterable for &'static fn(&fn(A)) { - fn iter(&self, blk: &fn(A)) { self(blk); } +impl iterable for 'static ||A|| { + fn iter(&self, blk: |A|) { self(blk); } } -impl iterable for &'static fn(&fn(uint)) { - fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) } +impl iterable for 'static ||uint|| { + fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) } } -fn filter>(self: IA, - prd: &'static fn(A) -> bool, - blk: &fn(A)) { +fn filter>(self: IA, prd: 'static |A| -> bool, blk: |A|) { do self.iter |a| { if prd(a) { blk(a) } } } -fn foldl>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { +fn foldl>(self: IA, b0: B, blk: |B, A| -> B) -> B { let mut b = b0; do self.iter |a| { b = blk(b, a); @@ -66,7 +64,7 @@ fn foldl>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { b } -fn range(lo: uint, hi: uint, it: &fn(uint)) { +fn range(lo: uint, hi: uint, it: |uint|) { let mut i = lo; while i < hi { it(i); @@ -75,8 +73,8 @@ fn range(lo: uint, hi: uint, it: &fn(uint)) { } pub fn main() { - let range: &'static fn(&fn(uint)) = |a| range(0u, 1000u, a); - let filt: &'static fn(&fn(v: uint)) = |a| filter( + let range: 'static ||uint|| = |a| range(0u, 1000u, a); + let filt: 'static ||v: uint|| = |a| filter( range, |&&n: uint| n % 3u != 0u && n % 5u != 0u, a); diff --git a/src/test/run-pass/issue-2190-2.rs b/src/test/run-pass/issue-2190-2.rs index d5ee712d412bc..571944e5300b8 100644 --- a/src/test/run-pass/issue-2190-2.rs +++ b/src/test/run-pass/issue-2190-2.rs @@ -10,19 +10,19 @@ // xfail-test FIXME #2190 mod a { - fn foo(f: &fn()) { f() } + fn foo(f: ||) { f() } fn bar() {} pub fn main() { foo(||bar()); } } mod b { - fn foo(f: Option<&fn()>) { f.iter(|x|x()) } + fn foo(f: Option<||>) { f.iter(|x|x()) } fn bar() {} pub fn main() { foo(Some(bar)); } } mod c { - fn foo(f: Option<&fn()>) { f.iter(|x|x()) } + fn foo(f: Option<||>) { f.iter(|x|x()) } fn bar() {} pub fn main() { foo(Some(||bar())); } } diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index c12325e6ff52e..110bceced82a1 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -31,7 +31,7 @@ fn socket() -> socket { } } -fn closure(f: &fn()) { f() } +fn closure(f: ||) { f() } fn setsockopt_bytes(_sock: int) { } diff --git a/src/test/run-pass/issue-3429.rs b/src/test/run-pass/issue-3429.rs index fc493485b794e..cce90f8a2cd29 100644 --- a/src/test/run-pass/issue-3429.rs +++ b/src/test/run-pass/issue-3429.rs @@ -10,6 +10,6 @@ pub fn main() { let x = 1; - let y: &fn() -> int = || x; + let y: || -> int = || x; let _z = y(); } diff --git a/src/test/run-pass/issue-3796.rs b/src/test/run-pass/issue-3796.rs index 5f4409391396a..a7c6f86b45357 100644 --- a/src/test/run-pass/issue-3796.rs +++ b/src/test/run-pass/issue-3796.rs @@ -12,7 +12,7 @@ #[deny(dead_assignment)]; fn main() { let mut x = 1; - let f: &fn() -> int = || { x + 20 }; + let f: || -> int = || { x + 20 }; assert_eq!(f(), 21); x += 1; assert_eq!(f(), 22); diff --git a/src/test/run-pass/issue-3874.rs b/src/test/run-pass/issue-3874.rs index ea1242ae21613..40725311f313c 100644 --- a/src/test/run-pass/issue-3874.rs +++ b/src/test/run-pass/issue-3874.rs @@ -10,7 +10,7 @@ enum PureCounter { PureCounter(uint) } -fn each(thing: PureCounter, blk: &fn(v: &uint)) { +fn each(thing: PureCounter, blk: |v: &uint|) { let PureCounter(ref x) = thing; blk(x); } diff --git a/src/test/run-pass/issue-3904.rs b/src/test/run-pass/issue-3904.rs index 6b678ffdb1c4a..4a9b58067b056 100644 --- a/src/test/run-pass/issue-3904.rs +++ b/src/test/run-pass/issue-3904.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -type ErrPrinter = &fn(&str, &str); +type ErrPrinter = |&str, &str|; fn example_err(prog: &str, arg: &str) { println!("{}: {}", prog, arg) diff --git a/src/test/run-pass/issue-5239-2.rs b/src/test/run-pass/issue-5239-2.rs index ba70fac0e4e8f..eabc1cfeb595f 100644 --- a/src/test/run-pass/issue-5239-2.rs +++ b/src/test/run-pass/issue-5239-2.rs @@ -11,7 +11,7 @@ // Regression test for issue #5239 pub fn main() { - let _f: &fn(int) -> int = |ref x: int| { *x }; + let _f: |int| -> int = |ref x: int| { *x }; let foo = 10; assert!(_f(foo) == 10); } diff --git a/src/test/run-pass/issue-6153.rs b/src/test/run-pass/issue-6153.rs index 668d6f3ae45e3..f7d0316880a4d 100644 --- a/src/test/run-pass/issue-6153.rs +++ b/src/test/run-pass/issue-6153.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn swap(f: &fn(~[int]) -> ~[int]) -> ~[int] { +fn swap(f: |~[int]| -> ~[int]) -> ~[int] { let x = ~[1, 2, 3]; f(x) } diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs index 2a82f559d547c..12dcc4ecd2c3a 100644 --- a/src/test/run-pass/issue-868.rs +++ b/src/test/run-pass/issue-868.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(g: &fn() -> T) -> T { g() } +fn f(g: || -> T) -> T { g() } pub fn main() { let _x = f( | | { 10 }); diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index 5ada4aa8c7583..c44b7389666f9 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -10,7 +10,7 @@ -fn range_(a: int, b: int, it: &fn(int)) { +fn range_(a: int, b: int, it: |int|) { assert!((a < b)); let mut i: int = a; while i < b { it(i); i += 1; } diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index e615cfae6add0..b6ee2d10fb33f 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -9,13 +9,13 @@ // except according to those terms. // This should typecheck even though the type of e is not fully -// resolved when we finish typechecking the &fn. +// resolved when we finish typechecking the ||. struct Refs { refs: ~[int], n: int } pub fn main() { let e = @mut Refs{refs: ~[], n: 0}; - let _f: &fn() = || error!("{}", e.n); + let _f: || = || error!("{}", e.n); e.refs.push(1); } diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index e2dbf7d29db19..8117c5657e989 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -10,7 +10,7 @@ // Issue #1818 -fn lp(s: ~str, f: &fn(~str) -> T) -> T { +fn lp(s: ~str, f: |~str| -> T) -> T { while false { let r = f(s); return (r); @@ -18,8 +18,8 @@ fn lp(s: ~str, f: &fn(~str) -> T) -> T { fail!(); } -fn apply(s: ~str, f: &fn(~str) -> T) -> T { - fn g(s: ~str, f: &fn(~str) -> T) -> T {f(s)} +fn apply(s: ~str, f: |~str| -> T) -> T { + fn g(s: ~str, f: |~str| -> T) -> T {f(s)} g(s, |v| { let r = f(v); r }) } diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 5c349a095513e..c34e65b2b4213 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -13,7 +13,7 @@ struct A { a: ~int } pub fn main() { - fn invoke(f: &fn()) { f(); } + fn invoke(f: ||) { f(); } let k = ~22; let _u = A {a: k.clone()}; invoke(|| error!("{:?}", k.clone()) ) diff --git a/src/test/run-pass/match-phi.rs b/src/test/run-pass/match-phi.rs index c25f573e73bce..fc851e444e86b 100644 --- a/src/test/run-pass/match-phi.rs +++ b/src/test/run-pass/match-phi.rs @@ -13,7 +13,7 @@ enum thing { a, b, c, } -fn foo(it: &fn(int)) { it(10); } +fn foo(it: |int|) { it(10); } pub fn main() { let mut x = true; diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 8baf15c8493be..891ee4812c1b8 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -11,11 +11,11 @@ // xfail-fast trait vec_monad { - fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B]; + fn bind(&self, f: |&A| -> ~[B]) -> ~[B]; } impl vec_monad for ~[A] { - fn bind(&self, f: &fn(&A) -> ~[B]) -> ~[B] { + fn bind(&self, f: |&A| -> ~[B]) -> ~[B] { let mut r = ~[]; for elt in self.iter() { r.push_all_move(f(elt)); @@ -25,11 +25,11 @@ impl vec_monad for ~[A] { } trait option_monad { - fn bind(&self, f: &fn(&A) -> Option) -> Option; + fn bind(&self, f: |&A| -> Option) -> Option; } impl option_monad for Option { - fn bind(&self, f: &fn(&A) -> Option) -> Option { + fn bind(&self, f: |&A| -> Option) -> Option { match *self { Some(ref a) => { f(a) } None => { None } diff --git a/src/test/run-pass/move-nullary-fn.rs b/src/test/run-pass/move-nullary-fn.rs index 87281c2fd2253..4b613e9beaab2 100644 --- a/src/test/run-pass/move-nullary-fn.rs +++ b/src/test/run-pass/move-nullary-fn.rs @@ -9,9 +9,9 @@ // except according to those terms. // Issue #922 -fn f2(_thing: &fn()) { } +fn f2(_thing: ||) { } -fn f(thing: &fn()) { +fn f(thing: ||) { f2(thing); } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index 0fa89ba0f049d..5801ccebb0fcd 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -14,7 +14,7 @@ fn f(mut y: ~int) { } fn g() { - let frob: &fn(~int) = |mut q| { *q = 2; assert!(*q == 2); }; + let frob: |~int| = |mut q| { *q = 2; assert!(*q == 2); }; let w = ~37; frob(w); diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index d9d0daa7138cd..1835514c0d1fe 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -10,9 +10,9 @@ // Tests for the new |args| expr lambda syntax -fn f(i: int, f: &fn(int) -> int) -> int { f(i) } +fn f(i: int, f: |int| -> int) -> int { f(i) } -fn g(_g: &fn()) { } +fn g(_g: ||) { } pub fn main() { assert_eq!(f(10, |a| a), 10); diff --git a/src/test/run-pass/non-legacy-modes.rs b/src/test/run-pass/non-legacy-modes.rs index 642686e06e5dd..8262432db607f 100644 --- a/src/test/run-pass/non-legacy-modes.rs +++ b/src/test/run-pass/non-legacy-modes.rs @@ -12,7 +12,7 @@ struct X { repr: int } -fn apply(x: T, f: &fn(T)) { +fn apply(x: T, f: |T|) { f(x); } diff --git a/src/test/run-pass/purity-infer.rs b/src/test/run-pass/purity-infer.rs index debde77b21128..bbb312842ce14 100644 --- a/src/test/run-pass/purity-infer.rs +++ b/src/test/run-pass/purity-infer.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn something(f: &fn()) { f(); } +fn something(f: ||) { f(); } pub fn main() { something(|| error!("hi!") ); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 42614f7653928..96081d30275fb 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -22,7 +22,7 @@ use std::unstable::raw::Vec; /// Trait for visitor that wishes to reflect on data. trait movable_ptr { - fn move_ptr(&mut self, adjustment: &fn(*c_void) -> *c_void); + fn move_ptr(&mut self, adjustment: |*c_void| -> *c_void); } /// Helper function for alignment calculation. @@ -471,7 +471,7 @@ struct Stuff { } impl my_visitor { - pub fn get(&mut self, f: &fn(T)) { + pub fn get(&mut self, f: |T|) { unsafe { f((*(self.ptr1 as *T)).clone()); } @@ -490,7 +490,7 @@ impl my_visitor { struct Inner { inner: V } impl movable_ptr for my_visitor { - fn move_ptr(&mut self, adjustment: &fn(*c_void) -> *c_void) { + fn move_ptr(&mut self, adjustment: |*c_void| -> *c_void) { self.ptr1 = adjustment(self.ptr1); self.ptr2 = adjustment(self.ptr2); } diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index ef8d9970c2b47..9d2a959eae1c7 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -13,13 +13,13 @@ // Here, `f` is a function that takes a pointer `x` and a function // `g`, where `g` requires its argument `y` to be in the same region // that `x` is in. -fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) { +fn has_same_region(f: <'a>|x: &'a int, g: |y: &'a int||) { // `f` should be the type that `wants_same_region` wants, but // right now the compiler complains that it isn't. wants_same_region(f); } -fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { +fn wants_same_region(_f: <'b>|x: &'b int, g: |y: &'b int||) { } pub fn main() { diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index 06c8aca474164..14e56bd618117 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -14,21 +14,21 @@ #[allow(unused_variable)]; // Should pass region checking. -fn ok(f: &fn(x: &uint)) { +fn ok(f: |x: &uint|) { // Here, g is a function that can accept a uint pointer with // lifetime r, and f is a function that can accept a uint pointer // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: &fn<'r>(y: &'r uint) = |x| { }; + let mut g: <'r>|y: &'r uint| = |x| { }; g = f; } // This version is the same as above, except that here, g's type is // inferred. -fn ok_inferred(f: &fn(x: &uint)) { - let mut g: &fn<'r>(x: &'r uint) = |_| {}; +fn ok_inferred(f: |x: &uint|) { + let mut g: <'r>|x: &'r uint| = |_| {}; g = f; } diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index 42be3b5b97553..061f27972871f 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -10,7 +10,7 @@ fn takes_two(x: &int, y: &int) -> int { *x + *y } -fn with(f: &fn(x: &int) -> T) -> T { +fn with(f: |x: &int| -> T) -> T { f(&20) } diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index ea32cf866a0cd..5fe92f527d05b 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -12,7 +12,7 @@ fn region_identity<'r>(x: &'r uint) -> &'r uint { x } -fn apply(t: T, f: &fn(T) -> T) -> T { f(t) } +fn apply(t: T, f: |T| -> T) -> T { f(t) } fn parameterized(x: &uint) -> uint { let z = apply(x, ({|y| diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index f7808f7f8ac8b..1b80d7648a6df 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -10,7 +10,7 @@ // xfail-fast -fn test(f: &fn(uint) -> uint) -> uint { +fn test(f: |uint| -> uint) -> uint { return f(22u); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 651b3342d5833..28aab18cf6cfc 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -26,12 +26,12 @@ mod b { trait uint_utils { fn str(&self) -> ~str; - fn multi(&self, f: &fn(uint)); + fn multi(&self, f: |uint|); } impl uint_utils for uint { fn str(&self) -> ~str { self.to_str() } - fn multi(&self, f: &fn(uint)) { + fn multi(&self, f: |uint|) { let mut c = 0u; while c < *self { f(c); c += 1u; } } @@ -39,14 +39,14 @@ impl uint_utils for uint { trait vec_utils { fn length_(&self, ) -> uint; - fn iter_(&self, f: &fn(&T)); - fn map_(&self, f: &fn(&T) -> U) -> ~[U]; + fn iter_(&self, f: |&T|); + fn map_(&self, f: |&T| -> U) -> ~[U]; } impl vec_utils for ~[T] { fn length_(&self) -> uint { self.len() } - fn iter_(&self, f: &fn(&T)) { for x in self.iter() { f(x); } } - fn map_(&self, f: &fn(&T) -> U) -> ~[U] { + fn iter_(&self, f: |&T|) { for x in self.iter() { f(x); } } + fn map_(&self, f: |&T| -> U) -> ~[U] { let mut r = ~[]; for elt in self.iter() { r.push(f(elt)); diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 395d6b0b51ad2..94e402bfa9021 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -45,7 +45,7 @@ fn notify(ch: Chan, v: @mut bool) -> notify { } fn joinable(f: proc()) -> Port { - fn wrapper(c: Chan, f: &fn()) { + fn wrapper(c: Chan, f: ||) { let b = @mut false; error!("wrapper: task=%? allocated v=%x", 0, diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index a10753451400a..cee2079251a28 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -136,7 +136,7 @@ pub fn test_rmdir_recursive_ok() { assert!(!root.join("bar").join("blat").exists()); } -fn in_tmpdir(f: &fn()) { +fn in_tmpdir(f: ||) { let tmpdir = TempDir::new("test").expect("can't make tmpdir"); assert!(os::change_dir(tmpdir.path())); diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index a4510ef70e1b2..7b331c4356807 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -22,7 +22,7 @@ use std::task; use std::cell; trait Pet { - fn name(&self, blk: &fn(&str)); + fn name(&self, blk: |&str|); fn num_legs(&self) -> uint; fn of_good_pedigree(&self) -> bool; } @@ -44,19 +44,19 @@ struct Goldfyshe { } impl Pet for Catte { - fn name(&self, blk: &fn(&str)) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { - fn name(&self, blk: &fn(&str)) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { - fn name(&self, blk: &fn(&str)) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name) } fn num_legs(&self) -> uint { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index f448bcb4ab5d2..90f87d832ff89 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -24,10 +24,10 @@ impl to_str for () { } trait map { - fn map(&self, f: &fn(&T) -> U) -> ~[U]; + fn map(&self, f: |&T| -> U) -> ~[U]; } impl map for ~[T] { - fn map(&self, f: &fn(&T) -> U) -> ~[U] { + fn map(&self, f: |&T| -> U) -> ~[U] { let mut r = ~[]; // FIXME: #7355 generates bad code with VecIterator for i in range(0u, self.len()) { diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index a5a9075af7b24..042b5e96bbc08 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -13,7 +13,7 @@ struct S { b: uint, } -fn range_(lo: uint, hi: uint, it: &fn(uint)) { +fn range_(lo: uint, hi: uint, it: |uint|) { let mut lo_ = lo; while lo_ < hi { it(lo_); lo_ += 1u; } } diff --git a/src/test/run-pass/unnamed_argument_mode.rs b/src/test/run-pass/unnamed_argument_mode.rs index c52658542f05b..948824834df84 100644 --- a/src/test/run-pass/unnamed_argument_mode.rs +++ b/src/test/run-pass/unnamed_argument_mode.rs @@ -3,7 +3,7 @@ fn good(_a: &int) { // unnamed argument &int is now parse x: &int -fn called(_f: &fn(&int)) { +fn called(_f: |&int|) { } pub fn main() { diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index 662121a09931f..ceb91d557f6ae 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -10,6 +10,6 @@ pub fn main() { let _x = ~1; - let lam_move: &fn() = || {}; + let lam_move: || = || {}; lam_move(); } diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs index d82e2890ae8d3..06026d58f6005 100644 --- a/src/test/run-pass/variadic-ffi.rs +++ b/src/test/run-pass/variadic-ffi.rs @@ -15,7 +15,7 @@ extern { fn sprintf(s: *mut c_char, format: *c_char, ...) -> c_int; } -unsafe fn check(expected: &str, f: &fn(*mut c_char) -> T) { +unsafe fn check(expected: &str, f: |*mut c_char| -> T) { let mut x = [0i8, ..50]; f(&mut x[0] as *mut c_char); let res = CString::new(&x[0], false); diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 22f1ccb8bbb05..75c48da8d812d 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -1,6 +1,6 @@ fn foldl(values: &[T], initial: U, - function: &fn(partial: U, element: &T) -> U) + function: |partial: U, element: &T| -> U) -> U { match values { [ref head, ..tail] => @@ -11,7 +11,7 @@ fn foldl(values: &[T], fn foldr(values: &[T], initial: U, - function: &fn(element: &T, partial: U) -> U) + function: |element: &T, partial: U| -> U) -> U { match values { [..head, ref tail] => From 5d57c24a72822f9d0f26d17039fe084b580c7d93 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Nov 2013 17:36:32 -0800 Subject: [PATCH 2/3] librustc: Remove remaining uses of `&fn()` in favor of `||`. --- doc/po/ja/rust.md.po | 18 ++++----- doc/po/ja/tutorial.md.po | 28 +++++++------- doc/po/rust.md.pot | 18 ++++----- doc/po/tutorial.md.pot | 18 ++++----- doc/rust.md | 18 ++++----- doc/tutorial.md | 18 ++++----- src/libextra/sort.rs | 2 +- src/librustc/front/config.rs | 2 +- src/librustc/metadata/decoder.rs | 14 +++---- src/librustc/metadata/encoder.rs | 8 ++-- src/librustc/metadata/filesearch.rs | 2 +- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/middle/trans/_match.rs | 2 +- src/librustc/middle/trans/base.rs | 3 +- src/librustc/middle/trans/glue.rs | 3 +- src/librustc/middle/trans/tvec.rs | 3 +- src/librustc/middle/ty_fold.rs | 13 +++---- .../middle/typeck/check/regionmanip.rs | 2 +- src/librustc/middle/typeck/infer/lattice.rs | 4 +- src/librustc/util/common.rs | 4 +- src/librustdoc/html/format.rs | 4 +- src/librustdoc/html/render.rs | 6 +-- src/librustpkg/installed_packages.rs | 2 +- src/librustpkg/package_source.rs | 2 +- src/librustpkg/path_util.rs | 2 +- src/librustpkg/sha1.rs | 8 ++-- src/librustpkg/util.rs | 4 +- src/librustpkg/workspace.rs | 5 ++- src/libstd/cleanup.rs | 2 +- src/libstd/condition.rs | 4 +- src/libstd/iter.rs | 38 +++++++++---------- src/libstd/rand/distributions/mod.rs | 14 ++++--- src/libstd/str.rs | 2 +- src/libstd/to_bytes.rs | 2 +- src/libstd/unstable/finally.rs | 4 +- src/libstd/vec.rs | 20 +++++----- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/deriving/generic.rs | 11 +++--- src/libsyntax/ext/deriving/mod.rs | 22 +++++------ src/test/auxiliary/iss.rs | 2 +- src/test/bench/shootout-meteor.rs | 4 +- src/test/compile-fail/issue-4335.rs | 4 +- src/test/compile-fail/issue-4523.rs | 2 +- ...ased-on-type-no-recursive-stack-closure.rs | 2 +- src/test/compile-fail/regions-freevar.rs | 2 +- .../regions-infer-at-fn-not-param.rs | 6 +-- ...ns-infer-invariance-due-to-mutability-3.rs | 2 +- ...ns-infer-invariance-due-to-mutability-4.rs | 2 +- .../compile-fail/regions-infer-not-param.rs | 4 +- .../compile-fail/regions-steal-closure.rs | 4 +- src/test/run-fail/unwind-lambda.rs | 2 +- src/test/run-pass/const-fn-val.rs | 2 +- src/test/run-pass/const-vec-of-fns.rs | 2 +- src/test/run-pass/expr-block-fn.rs | 2 +- src/test/run-pass/expr-block-generic-box1.rs | 2 +- src/test/run-pass/expr-block-generic-box2.rs | 2 +- .../run-pass/expr-block-generic-unique1.rs | 2 +- .../run-pass/expr-block-generic-unique2.rs | 2 +- src/test/run-pass/expr-block-generic.rs | 2 +- src/test/run-pass/expr-if-generic-box1.rs | 2 +- src/test/run-pass/expr-if-generic-box2.rs | 2 +- src/test/run-pass/expr-if-generic.rs | 2 +- src/test/run-pass/expr-match-generic-box1.rs | 2 +- src/test/run-pass/expr-match-generic-box2.rs | 2 +- .../run-pass/expr-match-generic-unique1.rs | 2 +- .../run-pass/expr-match-generic-unique2.rs | 2 +- src/test/run-pass/fn-coerce-field.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 +- src/test/run-pass/issue-1516.rs | 2 +- src/test/run-pass/issue-2185.rs | 2 +- src/test/run-pass/issue-3052.rs | 2 +- src/test/run-pass/last-use-in-cap-clause.rs | 4 +- src/test/run-pass/regions-copy-closure.rs | 4 +- src/test/run-pass/regions-dependent-autofn.rs | 4 +- src/test/run-pass/regions-static-closure.rs | 4 +- 75 files changed, 219 insertions(+), 209 deletions(-) diff --git a/doc/po/ja/rust.md.po b/doc/po/ja/rust.md.po index 42237b9d6cca3..86c6070bccb01 100644 --- a/doc/po/ja/rust.md.po +++ b/doc/po/ja/rust.md.po @@ -1817,10 +1817,10 @@ msgstr "" #, no-wrap msgid "" "~~~~ {.xfail-test}\n" -"fn iter(seq: &[T], f: &fn(T)) {\n" +"fn iter(seq: &[T], f: |T|) {\n" " for elt in seq.iter() { f(elt); }\n" "}\n" -"fn map(seq: &[T], f: &fn(T) -> U) -> ~[U] {\n" +"fn map(seq: &[T], f: |T| -> U) -> ~[U] {\n" " let mut acc = ~[];\n" " for elt in seq.iter() { acc.push(f(elt)); }\n" " acc\n" @@ -2404,7 +2404,7 @@ msgid "" "trait Seq {\n" " fn len(&self) -> uint;\n" " fn elt_at(&self, n: uint) -> T;\n" -" fn iter(&self, &fn(T));\n" +" fn iter(&self, |T|);\n" "}\n" "~~~~\n" msgstr "" @@ -4243,7 +4243,7 @@ msgid "" "[function definitions](#functions) do not. The exact type of capture " "depends on the [function type](#function-types) inferred for the lambda " "expression. In the simplest and least-expensive form (analogous to a " -"```&fn() { }``` expression), the lambda expression captures its environment " +"```|| { }``` expression), the lambda expression captures its environment " "by reference, effectively borrowing pointers to all outer variables " "mentioned inside the function. Alternately, the compiler may infer that a " "lambda expression should copy or move values (depending on their type.) " @@ -4262,7 +4262,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn ten_times(f: &fn(int)) {\n" +"fn ten_times(f: |int|) {\n" " let mut i = 0;\n" " while i < 10 {\n" " f(i);\n" @@ -4455,7 +4455,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2339 -msgid "~~~~ # fn f(f: &fn(int)) { } # fn g(i: int) { }" +msgid "~~~~ # fn f(f: |int|) { } # fn g(i: int) { }" msgstr "" #. type: Plain text @@ -4481,7 +4481,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2352 -msgid "~~~~ # fn k(x:int, f: &fn(int)) { } # fn l(i: int) { }" +msgid "~~~~ # fn k(x:int, f: |int|) { } # fn l(i: int) { }" msgstr "" #. type: Plain text @@ -5383,7 +5383,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2849 msgid "" -"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = " +"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = " "bo(5,7); ~~~~~~~~" msgstr "" @@ -5483,7 +5483,7 @@ msgstr "" #, no-wrap msgid "" "~~~~~~~\n" -"fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] {\n" +"fn map(f: |A|) -> B, xs: &[A]) -> ~[B] {\n" " if xs.len() == 0 {\n" " return ~[];\n" " }\n" diff --git a/doc/po/ja/tutorial.md.po b/doc/po/ja/tutorial.md.po index 2b4e6e2c148cb..1d3fc494efac0 100644 --- a/doc/po/ja/tutorial.md.po +++ b/doc/po/ja/tutorial.md.po @@ -3340,10 +3340,10 @@ msgstr "" #. type: Plain text #: doc/tutorial.md:1434 -msgid "~~~~ fn call_closure_with_ten(b: &fn(int)) { b(10); }" +msgid "~~~~ fn call_closure_with_ten(b: |int|) { b(10); }" msgstr "" "~~~~\n" -"fn call_closure_with_ten(b: &fn(int)) { b(10); }" +"fn call_closure_with_ten(b: |int|) { b(10); }" #. type: Plain text #: doc/tutorial.md:1437 @@ -3400,11 +3400,11 @@ msgstr "" #: doc/tutorial.md:1459 msgid "" "There are several forms of closure, each with its own role. The most common, " -"called a _stack closure_, has type `&fn` and can directly access local " +"called a _stack closure_, has type `||` and can directly access local " "variables in the enclosing scope." msgstr "" "クロージャにはいくつかの形態があり、それぞれに独自の役割があります。最も一般" -"的なのはスタッククロージャと呼ばれるもので、 `&fn` という型を持ち、外側のロー" +"的なのはスタッククロージャと呼ばれるもので、 `||` という型を持ち、外側のロー" "カル変数に直接アクセスすることができます。" #. type: Plain text @@ -3531,27 +3531,27 @@ msgstr "## クロージャの互換性" msgid "" "Rust closures have a convenient subtyping property: you can pass any kind of " "closure (as long as the arguments and return types match) to functions that " -"expect a `&fn()`. Thus, when writing a higher-order function that only calls " +"expect a `||`. Thus, when writing a higher-order function that only calls " "its function argument, and does nothing else with it, you should almost " -"always declare the type of that argument as `&fn()`. That way, callers may " +"always declare the type of that argument as `||`. That way, callers may " "pass any kind of closure." msgstr "" "Rust のクロージャは型の派生 (subtyping) という便利な性質を持っています。この" -"性質により、`&fn()` 型を期待する関数には (引数と戻り値の型が一致する限り) 任" +"性質により、`||` 型を期待する関数には (引数と戻り値の型が一致する限り) 任" "意の種類のクロージャを渡すことができます。したがって、引数で渡された関数につ" "いては呼び出すだけで他に何もしない高階関数を書くときには、ほぼすべてのケース" -"で引数の型を `&fn` と宣言するべきです。そうすることで、呼び出し元は任意の種類" +"で引数の型を `||` と宣言するべきです。そうすることで、呼び出し元は任意の種類" "のクロージャを渡すことができるよになります。" #. type: Plain text #: doc/tutorial.md:1527 msgid "" -"~~~~ fn call_twice(f: &fn()) { f(); f(); } let closure = || { \"I'm a " +"~~~~ fn call_twice(f: ||) { f(); f(); } let closure = || { \"I'm a " "closure, and it doesn't matter what type I am\"; }; fn function() { \"I'm a " "normal function\"; } call_twice(closure); call_twice(function); ~~~~" msgstr "" "~~~~\n" -"fn call_twice(f: &fn()) { f(); f(); }\n" +"fn call_twice(f: ||) { f(); f(); }\n" "let closure = || { \"I'm a closure, and it doesn't matter what type I am" "\"; };\n" "fn function() { \"I'm a normal function\"; }\n" @@ -3598,7 +3598,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn each(v: &[int], op: &fn(v: &int)) {\n" +"fn each(v: &[int], op: |v: &int|) {\n" " let mut n = 0;\n" " while n < v.len() {\n" " op(&v[n]);\n" @@ -3622,7 +3622,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"# fn each(v: &[int], op: &fn(v: &int)) { }\n" +"# fn each(v: &[int], op: |v: &int|) { }\n" "# fn do_some_work(i: &int) { }\n" "each([1, 2, 3], |n| {\n" " do_some_work(n);\n" @@ -3644,7 +3644,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"# fn each(v: &[int], op: &fn(v: &int)) { }\n" +"# fn each(v: &[int], op: |v: &int|) { }\n" "# fn do_some_work(i: &int) { }\n" "do each([1, 2, 3]) |n| {\n" " do_some_work(n);\n" @@ -4011,7 +4011,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {\n" +"fn map(vector: &[T], function: |v: &T| -> U) -> ~[U] {\n" " let mut accumulator = ~[];\n" " for element in vector.iter() {\n" " accumulator.push(function(element));\n" diff --git a/doc/po/rust.md.pot b/doc/po/rust.md.pot index 9acefdf821568..1914526cb921f 100644 --- a/doc/po/rust.md.pot +++ b/doc/po/rust.md.pot @@ -1817,10 +1817,10 @@ msgstr "" #, no-wrap msgid "" "~~~~ {.xfail-test}\n" -"fn iter(seq: &[T], f: &fn(T)) {\n" +"fn iter(seq: &[T], f: |T|) {\n" " for elt in seq.iter() { f(elt); }\n" "}\n" -"fn map(seq: &[T], f: &fn(T) -> U) -> ~[U] {\n" +"fn map(seq: &[T], f: |T| -> U) -> ~[U] {\n" " let mut acc = ~[];\n" " for elt in seq.iter() { acc.push(f(elt)); }\n" " acc\n" @@ -2404,7 +2404,7 @@ msgid "" "trait Seq {\n" " fn len(&self) -> uint;\n" " fn elt_at(&self, n: uint) -> T;\n" -" fn iter(&self, &fn(T));\n" +" fn iter(&self, |T|);\n" "}\n" "~~~~\n" msgstr "" @@ -4230,7 +4230,7 @@ msgid "" "[function definitions](#functions) do not. The exact type of capture " "depends on the [function type](#function-types) inferred for the lambda " "expression. In the simplest and least-expensive form (analogous to a " -"```&fn() { }``` expression), the lambda expression captures its environment " +"```|| { }``` expression), the lambda expression captures its environment " "by reference, effectively borrowing pointers to all outer variables " "mentioned inside the function. Alternately, the compiler may infer that a " "lambda expression should copy or move values (depending on their type.) " @@ -4249,7 +4249,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn ten_times(f: &fn(int)) {\n" +"fn ten_times(f: |int|) {\n" " let mut i = 0;\n" " while i < 10 {\n" " f(i);\n" @@ -4442,7 +4442,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2339 -msgid "~~~~ # fn f(f: &fn(int)) { } # fn g(i: int) { }" +msgid "~~~~ # fn f(f: |int|) { } # fn g(i: int) { }" msgstr "" #. type: Plain text @@ -4468,7 +4468,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2352 -msgid "~~~~ # fn k(x:int, f: &fn(int)) { } # fn l(i: int) { }" +msgid "~~~~ # fn k(x:int, f: |int|) { } # fn l(i: int) { }" msgstr "" #. type: Plain text @@ -5370,7 +5370,7 @@ msgstr "" #. type: Plain text #: doc/rust.md:2849 msgid "" -"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = " +"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = " "bo(5,7); ~~~~~~~~" msgstr "" @@ -5470,7 +5470,7 @@ msgstr "" #, no-wrap msgid "" "~~~~~~~\n" -"fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] {\n" +"fn map(f: |A| -> B, xs: &[A]) -> ~[B] {\n" " if xs.len() == 0 {\n" " return ~[];\n" " }\n" diff --git a/doc/po/tutorial.md.pot b/doc/po/tutorial.md.pot index 86937652da93b..4573c0904c85d 100644 --- a/doc/po/tutorial.md.pot +++ b/doc/po/tutorial.md.pot @@ -2558,7 +2558,7 @@ msgstr "" #. type: Plain text #: doc/tutorial.md:1434 -msgid "~~~~ fn call_closure_with_ten(b: &fn(int)) { b(10); }" +msgid "~~~~ fn call_closure_with_ten(b: |int|) { b(10); }" msgstr "" #. type: Plain text @@ -2601,7 +2601,7 @@ msgstr "" #: doc/tutorial.md:1459 msgid "" "There are several forms of closure, each with its own role. The most common, " -"called a _stack closure_, has type `&fn` and can directly access local " +"called a _stack closure_, has type `||` and can directly access local " "variables in the enclosing scope." msgstr "" @@ -2700,16 +2700,16 @@ msgstr "" msgid "" "Rust closures have a convenient subtyping property: you can pass any kind of " "closure (as long as the arguments and return types match) to functions that " -"expect a `&fn()`. Thus, when writing a higher-order function that only calls " +"expect a `||`. Thus, when writing a higher-order function that only calls " "its function argument, and does nothing else with it, you should almost " -"always declare the type of that argument as `&fn()`. That way, callers may " +"always declare the type of that argument as `||`. That way, callers may " "pass any kind of closure." msgstr "" #. type: Plain text #: doc/tutorial.md:1527 msgid "" -"~~~~ fn call_twice(f: &fn()) { f(); f(); } let closure = || { \"I'm a " +"~~~~ fn call_twice(f: ||) { f(); f(); } let closure = || { \"I'm a " "closure, and it doesn't matter what type I am\"; }; fn function() { \"I'm a " "normal function\"; } call_twice(closure); call_twice(function); ~~~~" msgstr "" @@ -2746,7 +2746,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn each(v: &[int], op: &fn(v: &int)) {\n" +"fn each(v: &[int], op: |v: &int|) {\n" " let mut n = 0;\n" " while n < v.len() {\n" " op(&v[n]);\n" @@ -2768,7 +2768,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"# fn each(v: &[int], op: &fn(v: &int)) { }\n" +"# fn each(v: &[int], op: |v: &int|) { }\n" "# fn do_some_work(i: &int) { }\n" "each([1, 2, 3], |n| {\n" " do_some_work(n);\n" @@ -2788,7 +2788,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"# fn each(v: &[int], op: &fn(v: &int)) { }\n" +"# fn each(v: &[int], op: |v: &int|) { }\n" "# fn do_some_work(i: &int) { }\n" "do each([1, 2, 3]) |n| {\n" " do_some_work(n);\n" @@ -3080,7 +3080,7 @@ msgstr "" #, no-wrap msgid "" "~~~~\n" -"fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {\n" +"fn map(vector: &[T], function: |v: &T| -> U) -> ~[U] {\n" " let mut accumulator = ~[];\n" " for element in vector.iter() {\n" " accumulator.push(function(element));\n" diff --git a/doc/rust.md b/doc/rust.md index d876fe02b920e..2025a541c86c4 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -950,10 +950,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following the function name. ~~~~ {.xfail-test} -fn iter(seq: &[T], f: &fn(T)) { +fn iter(seq: &[T], f: |T|) { for elt in seq.iter() { f(elt); } } -fn map(seq: &[T], f: &fn(T) -> U) -> ~[U] { +fn map(seq: &[T], f: |T| -> U) -> ~[U] { let mut acc = ~[]; for elt in seq.iter() { acc.push(f(elt)); } acc @@ -1315,7 +1315,7 @@ These appear after the trait name, using the same syntax used in [generic functi trait Seq { fn len(&self) -> uint; fn elt_at(&self, n: uint) -> T; - fn iter(&self, &fn(T)); + fn iter(&self, |T|); } ~~~~ @@ -2608,7 +2608,7 @@ as an abbreviation for defining and capturing a separate function. Significantly, lambda expressions _capture their environment_, which regular [function definitions](#functions) do not. The exact type of capture depends on the [function type](#function-types) inferred for the lambda expression. -In the simplest and least-expensive form (analogous to a ```&fn() { }``` expression), +In the simplest and least-expensive form (analogous to a ```|| { }``` expression), the lambda expression captures its environment by reference, effectively borrowing pointers to all outer variables mentioned inside the function. Alternately, the compiler may infer that a lambda expression should copy or move values (depending on their type.) @@ -2618,7 +2618,7 @@ In this example, we define a function `ten_times` that takes a higher-order func and call it with a lambda expression as an argument. ~~~~ -fn ten_times(f: &fn(int)) { +fn ten_times(f: |int|) { let mut i = 0; while i < 10 { f(i); @@ -2727,7 +2727,7 @@ If the `expr` is a [field expression](#field-expressions), it is parsed as thoug In this example, both calls to `f` are equivalent: ~~~~ -# fn f(f: &fn(int)) { } +# fn f(f: |int|) { } # fn g(i: int) { } f(|j| g(j)); @@ -2740,7 +2740,7 @@ do f |j| { In this example, both calls to the (binary) function `k` are equivalent: ~~~~ -# fn k(x:int, f: &fn(int)) { } +# fn k(x:int, f: |int|) { } # fn l(i: int) { } k(3, |j| l(j)); @@ -3195,7 +3195,7 @@ fn add(x: int, y: int) -> int { let mut x = add(5,7); -type Binop<'self> = &'self fn(int,int) -> int; +type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = bo(5,7); ~~~~ @@ -3242,7 +3242,7 @@ and the cast expression in `main`. Within the body of an item that has type parameter declarations, the names of its type parameters are types: ~~~~ -fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] { +fn map(f: |A| -> B, xs: &[A]) -> ~[B] { if xs.len() == 0 { return ~[]; } diff --git a/doc/tutorial.md b/doc/tutorial.md index 313d36e38bf7e..2f059f95f978b 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1366,7 +1366,7 @@ Rust also supports _closures_, functions that can access variables in the enclosing scope. ~~~~ -fn call_closure_with_ten(b: &fn(int)) { b(10); } +fn call_closure_with_ten(b: |int|) { b(10); } let captured_var = 20; let closure = |arg| println!("captured_var={}, arg={}", captured_var, arg); @@ -1390,7 +1390,7 @@ let square = |x: int| -> uint { (x * x) as uint }; ~~~~ There are several forms of closure, each with its own role. The most -common, called a _stack closure_, has type `&fn` and can directly +common, called a _stack closure_, has type `||` and can directly access local variables in the enclosing scope. ~~~~ @@ -1420,13 +1420,13 @@ for spawning [tasks][tasks]. Rust closures have a convenient subtyping property: you can pass any kind of closure (as long as the arguments and return types match) to functions -that expect a `&fn()`. Thus, when writing a higher-order function that +that expect a `||`. Thus, when writing a higher-order function that only calls its function argument, and does nothing else with it, you -should almost always declare the type of that argument as `&fn()`. That way, +should almost always declare the type of that argument as `||`. That way, callers may pass any kind of closure. ~~~~ -fn call_twice(f: &fn()) { f(); f(); } +fn call_twice(f: ||) { f(); f(); } let closure = || { "I'm a closure, and it doesn't matter what type I am"; }; fn function() { "I'm a normal function"; } call_twice(closure); @@ -1446,7 +1446,7 @@ Consider this function that iterates over a vector of integers, passing in a pointer to each integer in the vector: ~~~~ -fn each(v: &[int], op: &fn(v: &int)) { +fn each(v: &[int], op: |v: &int|) { let mut n = 0; while n < v.len() { op(&v[n]); @@ -1460,7 +1460,7 @@ argument, we can write it in a way that has a pleasant, block-like structure. ~~~~ -# fn each(v: &[int], op: &fn(v: &int)) { } +# fn each(v: &[int], op: |v: &int|) { } # fn do_some_work(i: &int) { } each([1, 2, 3], |n| { do_some_work(n); @@ -1471,7 +1471,7 @@ This is such a useful pattern that Rust has a special form of function call that can be written more like a built-in control structure: ~~~~ -# fn each(v: &[int], op: &fn(v: &int)) { } +# fn each(v: &[int], op: |v: &int|) { } # fn do_some_work(i: &int) { } do each([1, 2, 3]) |n| { do_some_work(n); @@ -1650,7 +1650,7 @@ vector consisting of the result of applying `function` to each element of `vector`: ~~~~ -fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { +fn map(vector: &[T], function: |v: &T| -> U) -> ~[U] { let mut accumulator = ~[]; for element in vector.iter() { accumulator.push(function(element)); diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index 60c4a75104b60..175eaa2a8db81 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -15,7 +15,7 @@ use std::cmp::{Eq, Ord}; use std::util::swap; use std::vec; -type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool; +type Le<'self, T> = 'self |v1: &T, v2: &T| -> bool; /** * Merge sort. Returns a new vector containing the sorted list. diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 296e8578cbe7c..460f1ff1262ff 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -13,7 +13,7 @@ use syntax::fold::ast_fold; use syntax::{ast, fold, attr}; struct Context<'self> { - in_cfg: &'self fn(attrs: &[ast::Attribute]) -> bool, + in_cfg: 'self |attrs: &[ast::Attribute]| -> bool, } // Support conditional compilation by transforming the AST, stripping out diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index fbe3d7bbe9eea..dd70d29ec5b2d 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -74,7 +74,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) -> ret } -pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> Cmd; +pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd; pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option { fn eq_item(bytes: &[u8], item_id: int) -> bool { @@ -528,7 +528,7 @@ struct EachItemContext<'self> { cdata: Cmd, get_crate_data: GetCrateDataCb<'self>, path_builder: &'self mut ~str, - callback: &'self fn(&str, DefLike, ast::visibility) -> bool, + callback: 'self |&str, DefLike, ast::visibility| -> bool, } impl<'self> EachItemContext<'self> { @@ -901,11 +901,11 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path { item_path(lookup_item(id, cdata.data)) } -pub type decode_inlined_item<'self> = &'self fn( - cdata: @cstore::crate_metadata, - tcx: ty::ctxt, - path: ast_map::path, - par_doc: ebml::Doc) -> Option; +pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata, + tcx: ty::ctxt, + path: ast_map::path, + par_doc: ebml::Doc| + -> Option; pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, id: ast::NodeId, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 340a4241da23b..c22f05d249cde 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -52,10 +52,10 @@ use std::cast; // used by astencode: type abbrev_map = @mut HashMap; -pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext, - ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], - ii: ast::inlined_item); +pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item|; pub struct EncodeParams<'self> { diag: @mut span_handler, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 32beb4bbaf375..7e3a1a0a2c25e 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -23,7 +23,7 @@ pub enum FileMatch { FileMatches, FileDoesntMatch } /// Functions with type `pick` take a parent directory as well as /// a file found in that directory. -pub type pick<'self> = &'self fn(path: &Path) -> FileMatch; +pub type pick<'self> = 'self |path: &Path| -> FileMatch; pub fn pick_file(file: Path, path: &Path) -> Option { if path.filename() == Some(file.as_vec()) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 281998b081146..27bca78b7b725 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -54,7 +54,7 @@ pub enum DefIdSource { RegionParameter, } type conv_did<'self> = - &'self fn(source: DefIdSource, ast::DefId) -> ast::DefId; + 'self |source: DefIdSource, ast::DefId| -> ast::DefId; pub struct PState<'self> { data: &'self [u8], diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 92913983d8659..27d1e887bd32f 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -477,7 +477,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) { } } -type enter_pat<'self> = &'self fn(@ast::Pat) -> Option<~[@ast::Pat]>; +type enter_pat<'self> = 'self |@ast::Pat| -> Option<~[@ast::Pat]>; fn enter_match<'r>(bcx: @mut Block, dm: DefMap, diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 80b3455e9fa76..1acfc1ea8b9b8 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -669,7 +669,8 @@ pub fn compare_scalar_values(cx: @mut Block, } } -pub type val_and_ty_fn<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type val_and_ty_fn<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef { return Load(cx, GEPi(cx, p, idxs)); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 0993d3322f1e6..3eef1267429c7 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -642,7 +642,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { return inf; } -pub type glue_helper<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type glue_helper<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type, name: &str) -> ValueRef { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 93718fc1a2382..82615b1e119a0 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -539,7 +539,8 @@ pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (Val } } -pub type iter_vec_block<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block; +pub type iter_vec_block<'self> = 'self |@mut Block, ValueRef, ty::t| + -> @mut Block; pub fn iter_vec_loop(bcx: @mut Block, data_ptr: ValueRef, diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index dc4fca0176a5f..2f35121dc02ae 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -224,7 +224,7 @@ pub fn super_fold_trait_store(this: &mut T, pub struct BottomUpFolder<'self> { tcx: ty::ctxt, - fldop: &'self fn(ty::t) -> ty::t, + fldop: 'self |ty::t| -> ty::t, } impl<'self> TypeFolder for BottomUpFolder<'self> { @@ -241,14 +241,14 @@ impl<'self> TypeFolder for BottomUpFolder<'self> { pub struct RegionFolder<'self> { tcx: ty::ctxt, - fld_t: &'self fn(ty::t) -> ty::t, - fld_r: &'self fn(ty::Region) -> ty::Region, + fld_t: 'self |ty::t| -> ty::t, + fld_r: 'self |ty::Region| -> ty::Region, } impl<'self> RegionFolder<'self> { pub fn general(tcx: ty::ctxt, - fld_r: &'self fn(ty::Region) -> ty::Region, - fld_t: &'self fn(ty::t) -> ty::t) + fld_r: 'self |ty::Region| -> ty::Region, + fld_t: 'self |ty::t| -> ty::t) -> RegionFolder<'self> { RegionFolder { tcx: tcx, @@ -257,8 +257,7 @@ impl<'self> RegionFolder<'self> { } } - pub fn regions(tcx: ty::ctxt, - fld_r: &'self fn(ty::Region) -> ty::Region) + pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region) -> RegionFolder<'self> { fn noop(t: ty::t) -> ty::t { t } diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index ebdd4b5f48c2f..7bf5eacb3d5c4 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -88,7 +88,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt, struct RegionRelator<'self> { tcx: ty::ctxt, stack: ~[ty::Region], - relate_op: &'self fn(ty::Region, ty::Region), + relate_op: 'self |ty::Region, ty::Region|, } // FIXME(#10151) -- Define more precisely when a region is diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 04bf5fda7258d..dbf11ab68bcae 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -52,7 +52,7 @@ pub trait LatticeValue { } pub type LatticeOp<'self, T> = - &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres; + 'self |cf: &CombineFields, a: &T, b: &T| -> cres; impl LatticeValue for ty::t { fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { @@ -407,7 +407,7 @@ pub fn super_lattice_tys(this: &L, } } -pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres; +pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres; #[deriving(Clone)] pub enum LatticeVarResult { diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index ffbea94c4774b..28fe067293b89 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -61,7 +61,7 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] { } struct LoopQueryVisitor<'self> { - p: &'self fn(&ast::Expr_) -> bool, + p: 'self |&ast::Expr_| -> bool, flag: bool, } @@ -89,7 +89,7 @@ pub fn loop_query(b: &ast::Block, p: |&ast::Expr_| -> bool) -> bool { } struct BlockQueryVisitor<'self> { - p: &'self fn(@ast::Expr) -> bool, + p: 'self |@ast::Expr| -> bool, flag: bool, } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ee2aaee240ec8..b191eb37af1bc 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -148,8 +148,8 @@ fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool, } fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool, - root: &fn(&render::Cache, &[~str]) -> Option<~str>, - info: &fn(&render::Cache) -> Option<(~[~str], &'static str)>) { + root: |&render::Cache, &[~str]| -> Option<~str>, + info: |&render::Cache| -> Option<(~[~str], &'static str)>) { // The generics will get written to both the title and link let mut generics = ~""; let last = path.segments.last(); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 1b514f10af049..03e97ccd78a4c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -335,7 +335,7 @@ fn mkdir(path: &Path) { /// things like ".." to components which preserve the "top down" hierarchy of a /// static HTML tree. // FIXME (#9639): The closure should deal with &[u8] instead of &str -fn clean_srcpath(src: &[u8], f: &fn(&str)) { +fn clean_srcpath(src: &[u8], f: |&str|) { let p = Path::new(src); if p.as_vec() != bytes!(".") { for c in p.str_component_iter().map(|x|x.unwrap()) { @@ -644,7 +644,7 @@ impl<'self> Cache { impl Context { /// Recurse in the directory structure and change the "root path" to make /// sure it always points to the top (relatively) - fn recurse(&mut self, s: ~str, f: &fn(&mut Context) -> T) -> T { + fn recurse(&mut self, s: ~str, f: |&mut Context| -> T) -> T { if s.len() == 0 { fail!("what {:?}", self); } @@ -766,7 +766,7 @@ impl Context { /// all sub-items which need to be rendered. /// /// The rendering driver uses this closure to queue up more work. - fn item(&mut self, item: clean::Item, f: &fn(&mut Context, clean::Item)) { + fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) { fn render(w: io::File, cx: &mut Context, it: &clean::Item, pushname: bool) { // A little unfortunate that this is done like this, but it sure diff --git a/src/librustpkg/installed_packages.rs b/src/librustpkg/installed_packages.rs index 23fa1bdebd55c..ef146ea830955 100644 --- a/src/librustpkg/installed_packages.rs +++ b/src/librustpkg/installed_packages.rs @@ -16,7 +16,7 @@ use std::os; use std::io; use std::io::fs; -pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool { +pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool { let workspaces = rust_path(); for p in workspaces.iter() { let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) }; diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs index 6c5ac603dc44b..d24d921317ccd 100644 --- a/src/librustpkg/package_source.rs +++ b/src/librustpkg/package_source.rs @@ -348,7 +348,7 @@ impl PkgSrc { self.find_crates_with_filter(|_| true); } - pub fn find_crates_with_filter(&mut self, filter: &fn(&str) -> bool) { + pub fn find_crates_with_filter(&mut self, filter: |&str| -> bool) { use conditions::missing_pkg_files::cond; let prefix = self.start_dir.component_iter().len(); diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index 921005fdaab57..31446cc48e946 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -63,7 +63,7 @@ pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool { pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path, // Returns the directory it was actually found in - workspace_to_src_dir: &fn(&Path) -> Path) -> Option { + workspace_to_src_dir: |&Path| -> Path) -> Option { if !workspace.is_dir() { return None; } diff --git a/src/librustpkg/sha1.rs b/src/librustpkg/sha1.rs index d955fd1aa97d0..db31f603d6ee0 100644 --- a/src/librustpkg/sha1.rs +++ b/src/librustpkg/sha1.rs @@ -94,7 +94,7 @@ fn add_bytes_to_bits(bits: T, bytes: T) -> T { trait FixedBuffer { /// Input a vector of bytes. If the buffer becomes full, process it with the provided /// function and then clear the buffer. - fn input(&mut self, input: &[u8], func: &fn(&[u8])); + fn input(&mut self, input: &[u8], func: |&[u8]|); /// Reset the buffer. fn reset(&mut self); @@ -137,7 +137,7 @@ impl FixedBuffer64 { } impl FixedBuffer for FixedBuffer64 { - fn input(&mut self, input: &[u8], func: &fn(&[u8])) { + fn input(&mut self, input: &[u8], func: |&[u8]|) { let mut i = 0; let size = 64; @@ -217,11 +217,11 @@ trait StandardPadding { /// and is guaranteed to have exactly rem remaining bytes when it returns. If there are not at /// least rem bytes available, the buffer will be zero padded, processed, cleared, and then /// filled with zeros again until only rem bytes are remaining. - fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])); + fn standard_padding(&mut self, rem: uint, func: |&[u8]|); } impl StandardPadding for T { - fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])) { + fn standard_padding(&mut self, rem: uint, func: |&[u8]|) { let size = self.size(); self.next(1)[0] = 128; diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 49c497584fd52..f8c5de6f35812 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -425,7 +425,7 @@ struct ViewItemVisitor<'self> { sess: session::Session, exec: &'self mut workcache::Exec, c: &'self ast::Crate, - save: &'self fn(Path), + save: 'self |Path|, deps: &'self mut DepMap } @@ -587,7 +587,7 @@ pub fn find_and_install_dependencies(context: &BuildContext, exec: &mut workcache::Exec, c: &ast::Crate, deps: &mut DepMap, - save: &fn(Path)) { + save: |Path|) { debug!("In find_and_install_dependencies..."); let mut visitor = ViewItemVisitor { context: context, diff --git a/src/librustpkg/workspace.rs b/src/librustpkg/workspace.rs index e65f3ce5bb6ab..22d673333e954 100644 --- a/src/librustpkg/workspace.rs +++ b/src/librustpkg/workspace.rs @@ -18,7 +18,10 @@ use path_util::rust_path; use util::option_to_vec; use package_id::PkgId; -pub fn each_pkg_parent_workspace(cx: &Context, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool { +pub fn each_pkg_parent_workspace(cx: &Context, + pkgid: &PkgId, + action: |&Path| -> bool) + -> bool { // Using the RUST_PATH, find workspaces that contain // this package ID let workspaces = pkg_parent_workspaces(cx, pkgid); diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index a1f8509786562..2f7b27b55e321 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -15,7 +15,7 @@ use ptr; use unstable::intrinsics::TyDesc; use unstable::raw; -type DropGlue<'self> = &'self fn(**TyDesc, *c_void); +type DropGlue<'self> = 'self |**TyDesc, *c_void|; /* * Box annihilation diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index 56d5a8594012f..03994043dcf0c 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -104,7 +104,7 @@ impl Condition { /// // use `trap`'s inside method to register the handler and then run a /// // block of code with the handler registered /// ``` - pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> { + pub fn trap<'a>(&'a self, h: 'a |T| -> U) -> Trap<'a, T, U> { let h: Closure = unsafe { ::cast::transmute(h) }; let prev = local_data::get(self.key, |k| k.map(|x| *x)); let h = @Handler { handle: h, prev: prev }; @@ -181,7 +181,7 @@ impl<'self, T, U> Trap<'self, T, U> { /// }; /// assert_eq!(result, 7); /// ``` - pub fn inside(&self, inner: &'self fn() -> V) -> V { + pub fn inside(&self, inner: 'self || -> V) -> V { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); local_data::set(self.cond.key, self.handler); diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index f736b10cc4fc5..b1958bde60d2a 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -156,7 +156,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn map<'r, B>(self, f: &'r fn(A) -> B) -> Map<'r, A, B, Self> { + fn map<'r, B>(self, f: 'r |A| -> B) -> Map<'r, A, B, Self> { Map{iter: self, f: f} } @@ -173,7 +173,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> Filter<'r, A, Self> { + fn filter<'r>(self, predicate: 'r |&A| -> bool) -> Filter<'r, A, Self> { Filter{iter: self, predicate: predicate} } @@ -190,7 +190,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn filter_map<'r, B>(self, f: &'r fn(A) -> Option) -> FilterMap<'r, A, B, Self> { + fn filter_map<'r, B>(self, f: 'r |A| -> Option) -> FilterMap<'r, A, B, Self> { FilterMap { iter: self, f: f } } @@ -249,7 +249,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhile<'r, A, Self> { + fn skip_while<'r>(self, predicate: 'r |&A| -> bool) -> SkipWhile<'r, A, Self> { SkipWhile{iter: self, flag: false, predicate: predicate} } @@ -267,7 +267,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhile<'r, A, Self> { + fn take_while<'r>(self, predicate: 'r |&A| -> bool) -> TakeWhile<'r, A, Self> { TakeWhile{iter: self, flag: false, predicate: predicate} } @@ -327,7 +327,7 @@ pub trait Iterator { /// assert!(it.next().is_none()); /// ``` #[inline] - fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option) + fn scan<'r, St, B>(self, initial_state: St, f: 'r |&mut St, A| -> Option) -> Scan<'r, A, B, Self, St> { Scan{iter: self, f: f, state: initial_state} } @@ -349,7 +349,7 @@ pub trait Iterator { /// } /// ``` #[inline] - fn flat_map<'r, B, U: Iterator>(self, f: &'r fn(A) -> U) + fn flat_map<'r, B, U: Iterator>(self, f: 'r |A| -> U) -> FlatMap<'r, A, Self, U> { FlatMap{iter: self, f: f, frontiter: None, backiter: None } } @@ -401,7 +401,7 @@ pub trait Iterator { ///println(sum.to_str()); /// ``` #[inline] - fn inspect<'r>(self, f: &'r fn(&A)) -> Inspect<'r, A, Self> { + fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> { Inspect{iter: self, f: f} } @@ -1123,7 +1123,7 @@ RandomAccessIterator<(A, B)> for Zip { /// An iterator which maps the values of `iter` with `f` pub struct Map<'self, A, B, T> { priv iter: T, - priv f: &'self fn(A) -> B + priv f: 'self |A| -> B } impl<'self, A, B, T> Map<'self, A, B, T> { @@ -1172,7 +1172,7 @@ impl<'self, A, B, T: RandomAccessIterator> RandomAccessIterator for Map<'s /// An iterator which filters the elements of `iter` with `predicate` pub struct Filter<'self, A, T> { priv iter: T, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for Filter<'self, A, T> { @@ -1216,7 +1216,7 @@ impl<'self, A, T: DoubleEndedIterator> DoubleEndedIterator for Filter<'sel /// An iterator which uses `f` to both filter and map elements from `iter` pub struct FilterMap<'self, A, B, T> { priv iter: T, - priv f: &'self fn(A) -> Option + priv f: 'self |A| -> Option } impl<'self, A, B, T: Iterator> Iterator for FilterMap<'self, A, B, T> { @@ -1359,7 +1359,7 @@ impl<'self, A, T: Iterator> Peekable { pub struct SkipWhile<'self, A, T> { priv iter: T, priv flag: bool, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for SkipWhile<'self, A, T> { @@ -1397,7 +1397,7 @@ impl<'self, A, T: Iterator> Iterator for SkipWhile<'self, A, T> { pub struct TakeWhile<'self, A, T> { priv iter: T, priv flag: bool, - priv predicate: &'self fn(&A) -> bool + priv predicate: 'self |&A| -> bool } impl<'self, A, T: Iterator> Iterator for TakeWhile<'self, A, T> { @@ -1544,7 +1544,7 @@ impl> RandomAccessIterator for Take { /// An iterator to maintain state while iterating another iterator pub struct Scan<'self, A, B, T, St> { priv iter: T, - priv f: &'self fn(&mut St, A) -> Option, + priv f: 'self |&mut St, A| -> Option, /// The current internal state to be passed to the closure next. state: St @@ -1568,7 +1568,7 @@ impl<'self, A, B, T: Iterator, St> Iterator for Scan<'self, A, B, T, St> { /// pub struct FlatMap<'self, A, T, U> { priv iter: T, - priv f: &'self fn(A) -> U, + priv f: 'self |A| -> U, priv frontiter: Option, priv backiter: Option, } @@ -1699,7 +1699,7 @@ impl Fuse { /// element before yielding it. pub struct Inspect<'self, A, T> { priv iter: T, - priv f: &'self fn(&A) + priv f: 'self |&A| } impl<'self, A, T> Inspect<'self, A, T> { @@ -1751,7 +1751,7 @@ for Inspect<'self, A, T> { /// An iterator which just modifies the contained state throughout iteration. pub struct Unfold<'self, A, St> { - priv f: &'self fn(&mut St) -> Option, + priv f: 'self |&mut St| -> Option, /// Internal state that will be yielded on the next iteration state: St } @@ -1760,8 +1760,8 @@ impl<'self, A, St> Unfold<'self, A, St> { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the iterator #[inline] - pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option) - -> Unfold<'a, A, St> { + pub fn new<'a>(initial_state: St, f: 'a |&mut St| -> Option) + -> Unfold<'a, A, St> { Unfold { f: f, state: initial_state diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index 9697fc22ccd5f..00fc7eceacd3f 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -205,12 +205,14 @@ mod ziggurat_tables; // the perf improvement (25-50%) is definitely worth the extra code // size from force-inlining. #[inline(always)] -fn ziggurat(rng: &mut R, - symmetric: bool, - X: ziggurat_tables::ZigTable, - F: ziggurat_tables::ZigTable, - pdf: &'static fn(f64) -> f64, - zero_case: &'static fn(&mut R, f64) -> f64) -> f64 { +fn ziggurat( + rng: &mut R, + symmetric: bool, + X: ziggurat_tables::ZigTable, + F: ziggurat_tables::ZigTable, + pdf: 'static |f64| -> f64, + zero_case: 'static |&mut R, f64| -> f64) + -> f64 { static SCALE: f64 = (1u64 << 53) as f64; loop { // reimplement the f64 generation as an optimisation suggested diff --git a/src/libstd/str.rs b/src/libstd/str.rs index c567fd0a8b312..692491e02f77e 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -322,7 +322,7 @@ impl CharEq for char { fn only_ascii(&self) -> bool { (*self as uint) < 128 } } -impl<'self> CharEq for &'self fn(char) -> bool { +impl<'self> CharEq for 'self |char| -> bool { #[inline] fn matches(&self, c: char) -> bool { (*self)(c) } diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 8b424c53be0b8..4868b5a086513 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -21,7 +21,7 @@ use option::{None, Option, Some}; use str::{Str, StrSlice}; use vec::{Vector, ImmutableVector}; -pub type Cb<'self> = &'self fn(buf: &[u8]) -> bool; +pub type Cb<'self> = 'self |buf: &[u8]| -> bool; /// /// A trait to implement in order to make a type hashable; diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 78f1c3655ad6e..56d1df2e5549a 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -44,7 +44,7 @@ macro_rules! finally_fn { } } -impl<'self,T> Finally for &'self fn() -> T { +impl<'self,T> Finally for 'self || -> T { fn finally(&self, dtor: ||) -> T { let _d = Finallyalizer { dtor: dtor @@ -57,7 +57,7 @@ impl<'self,T> Finally for &'self fn() -> T { finally_fn!(extern "Rust" fn() -> T) struct Finallyalizer<'self> { - dtor: &'self fn() + dtor: 'self || } #[unsafe_destructor] diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 2bd6a00ed4a0e..bc5708f955f7f 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -222,7 +222,7 @@ pub fn build(size: Option, builder: |push: |v: A||) -> ~[A] { pub struct SplitIterator<'self, T> { priv v: &'self [T], priv n: uint, - priv pred: &'self fn(t: &T) -> bool, + priv pred: 'self |t: &T| -> bool, priv finished: bool } @@ -271,7 +271,7 @@ impl<'self, T> Iterator<&'self [T]> for SplitIterator<'self, T> { pub struct RSplitIterator<'self, T> { priv v: &'self [T], priv n: uint, - priv pred: &'self fn(t: &T) -> bool, + priv pred: 'self |t: &T| -> bool, priv finished: bool } @@ -859,20 +859,20 @@ pub trait ImmutableVector<'self, T> { fn rev_iter(self) -> RevIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. - fn split_iter(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>; + fn split_iter(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`, limited to splitting /// at most `n` times. - fn splitn_iter(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>; + fn splitn_iter(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. This starts at the /// end of the vector and works backwards. - fn rsplit_iter(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>; + fn rsplit_iter(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred` limited to splitting /// at most `n` times. This starts at the end of the vector and /// works backwards. - fn rsplitn_iter(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>; + fn rsplitn_iter(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>; /** * Returns an iterator over all contiguous windows of length @@ -1024,11 +1024,11 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn split_iter(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> { + fn split_iter(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { self.splitn_iter(uint::max_value, pred) } #[inline] - fn splitn_iter(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> { + fn splitn_iter(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { SplitIterator { v: self, n: n, @@ -1037,11 +1037,11 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } } #[inline] - fn rsplit_iter(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> { + fn rsplit_iter(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { self.rsplitn_iter(uint::max_value, pred) } #[inline] - fn rsplitn_iter(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> { + fn rsplitn_iter(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { RSplitIterator { v: self, n: n, diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index a49109911de42..26ac827302b3d 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -669,7 +669,7 @@ pub trait EachViewItem { } struct EachViewItemData<'self> { - callback: &'self fn(&ast::view_item) -> bool, + callback: 'self |&ast::view_item| -> bool, } impl<'self> Visitor<()> for EachViewItemData<'self> { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 23dc38fdc31e5..2f6cfeb24da1f 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -294,7 +294,7 @@ Combine the values of all the fields together. The last argument is all the fields of all the structures, see above for details. */ pub type CombineSubstructureFunc<'self> = - &'self fn(@ExtCtxt, Span, &Substructure) -> @Expr; + 'self |@ExtCtxt, Span, &Substructure| -> @Expr; /** Deal with non-matching enum variants, the arguments are a list @@ -302,10 +302,11 @@ representing each variant: (variant index, ast::variant instance, [variant fields]), and a list of the nonself args of the type */ pub type EnumNonMatchFunc<'self> = - &'self fn(@ExtCtxt, Span, - &[(uint, ast::variant, - ~[(Span, Option, @Expr)])], - &[@Expr]) -> @Expr; + 'self |@ExtCtxt, + Span, + &[(uint, ast::variant, ~[(Span, Option, @Expr)])], + &[@Expr]| + -> @Expr; impl<'self> TraitDef<'self> { diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 3e65f7bdefbc5..8729382141b8a 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -46,17 +46,17 @@ pub mod totalord; pub mod generic; -pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt, - Span, - x: &struct_def, - Ident, - y: &Generics) - -> @item; -pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt, - Span, - x: &enum_def, - Ident, - y: &Generics) +pub type ExpandDerivingStructDefFn<'self> = 'self |@ExtCtxt, + Span, + x: &struct_def, + Ident, + y: &Generics| + -> @item; +pub type ExpandDerivingEnumDefFn<'self> = 'self |@ExtCtxt, + Span, + x: &enum_def, + Ident, + y: &Generics| -> @item; pub fn expand_meta_deriving(cx: @ExtCtxt, diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs index a3ead83321f64..3855a348f60c0 100644 --- a/src/test/auxiliary/iss.rs +++ b/src/test/auxiliary/iss.rs @@ -13,7 +13,7 @@ // part of issue-6919.rs struct C<'self> { - k: &'self fn(), + k: 'self ||, } fn no_op() { } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 78b31b335c93d..bf6e2ca3e5a83 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -14,11 +14,11 @@ // returns an infinite iterator of repeated applications of f to x, // i.e. [x, f(x), f(f(x)), ...], as haskell iterate function. -fn iterate<'a, T>(x: T, f: &'a fn(&T) -> T) -> Iterate<'a, T> { +fn iterate<'a, T>(x: T, f: 'a |&T| -> T) -> Iterate<'a, T> { Iterate {f: f, next: x} } struct Iterate<'self, T> { - priv f: &'self fn(&T) -> T, + priv f: &'self |&T| -> T, priv next: T } impl<'self, T> Iterator for Iterate<'self, T> { diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 032b2564f4fb2..4cfa543a93fbe 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -10,7 +10,9 @@ fn id(t: T) -> T { t } -fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime +fn f<'r, T>(v: &'r T) -> 'r || -> T { + id(|| *v) //~ ERROR cannot infer an appropriate lifetime +} fn main() { let v = &5; diff --git a/src/test/compile-fail/issue-4523.rs b/src/test/compile-fail/issue-4523.rs index 332db60c836fc..952a528b427ba 100644 --- a/src/test/compile-fail/issue-4523.rs +++ b/src/test/compile-fail/issue-4523.rs @@ -10,7 +10,7 @@ fn foopy() {} -static f: &'static fn() = foopy; //~ ERROR found extern fn +static f: 'static || = foopy; //~ ERROR found extern fn fn main () { f(); diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index db8effb1de3df..bf7383f9c72b8 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -16,7 +16,7 @@ struct R<'self> { // This struct is needed to create the // otherwise infinite type of a fn that // accepts itself as argument: - c: &'self fn(&R, bool) + c: 'self |&R, bool| } fn innocent_looking_victim() { diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 251be91235975..7e5abe8e2f7e4 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn wants_static_fn(_x: &'static fn()) {} +fn wants_static_fn(_x: 'static ||) {} fn main() { let i = 3; diff --git a/src/test/compile-fail/regions-infer-at-fn-not-param.rs b/src/test/compile-fail/regions-infer-at-fn-not-param.rs index 3ddae976ce317..6347fa97c4dd5 100644 --- a/src/test/compile-fail/regions-infer-at-fn-not-param.rs +++ b/src/test/compile-fail/regions-infer-at-fn-not-param.rs @@ -9,15 +9,15 @@ // except according to those terms. struct parameterized1<'self> { - g: &'self fn() + g: 'self || } struct not_parameterized1 { - g: &'static fn() + g: 'static || } struct not_parameterized2 { - g: &'static fn() + g: 'static || } fn take1(p: parameterized1) -> parameterized1 { p } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs index 775164453e0d8..c7364a60bdf91 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs @@ -11,7 +11,7 @@ #[feature(managed_boxes)]; struct invariant<'self> { - f: &'static fn(x: @mut &'self int) + f: 'static |x: @mut &'self int| } fn to_same_lifetime<'r>(bi: invariant<'r>) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index 44856d9e531e6..8070d1f1dce72 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -11,7 +11,7 @@ #[feature(managed_boxes)]; struct invariant<'self> { - f: &'static fn() -> @mut &'self int + f: 'static || -> @mut &'self int } fn to_same_lifetime<'r>(bi: invariant<'r>) { diff --git a/src/test/compile-fail/regions-infer-not-param.rs b/src/test/compile-fail/regions-infer-not-param.rs index 47c1f7a5757de..92159489ae707 100644 --- a/src/test/compile-fail/regions-infer-not-param.rs +++ b/src/test/compile-fail/regions-infer-not-param.rs @@ -14,12 +14,12 @@ struct direct<'self> { struct indirect1 { // Here the lifetime parameter of direct is bound by the fn() - g: &'static fn(direct) + g: 'static |direct| } struct indirect2<'self> { // But here it is set to 'self - g: &'static fn(direct<'self>) + g: 'static |direct<'self>| } fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types diff --git a/src/test/compile-fail/regions-steal-closure.rs b/src/test/compile-fail/regions-steal-closure.rs index be034eda67dcf..292e282dd073e 100644 --- a/src/test/compile-fail/regions-steal-closure.rs +++ b/src/test/compile-fail/regions-steal-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn() + cl: 'self || } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index bd415e9eac3e7..ee570fa2e950d 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -16,7 +16,7 @@ fn main() { let cheese = ~"roquefort"; let carrots = @~"crunchy"; - let result: &'static fn(@~str, |~str|) = (|tasties, macerate| { + let result: 'static |@~str, |~str|| = (|tasties, macerate| { macerate((*tasties).clone()); }); result(carrots, |food| { diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index dfcfb30f77ffb..126d53621dd7b 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -12,7 +12,7 @@ fn foo() -> int { return 0xca7f000d; } -struct Bar<'self> { f: &'self fn() -> int } +struct Bar<'self> { f: 'self || -> int } static b : Bar<'static> = Bar { f: foo }; diff --git a/src/test/run-pass/const-vec-of-fns.rs b/src/test/run-pass/const-vec-of-fns.rs index 6117ea962afac..593d0e3125d67 100644 --- a/src/test/run-pass/const-vec-of-fns.rs +++ b/src/test/run-pass/const-vec-of-fns.rs @@ -20,7 +20,7 @@ fn f() { } static bare_fns: &'static [extern fn()] = &[f, f]; -struct S<'self>(&'self fn()); +struct S<'self>('self ||); static closures: &'static [S<'static>] = &[S(f), S(f)]; pub fn main() { diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index 63e5c7688d345..e18509252235d 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -11,7 +11,7 @@ fn test_fn() { - type t = &'static fn() -> int; + type t = 'static || -> int; fn ten() -> int { return 10; } let rs: t = { ten }; assert!((rs() == 10)); diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 04c96bb2b9804..f081d13a5b0b1 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 562c3c1e52303..04721c6bd94ec 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 159c2bfb8eff4..f1df0e167b9a1 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -10,7 +10,7 @@ -type compare<'self, T> = &'self fn(~T, ~T) -> bool; +type compare<'self, T> = 'self |~T, ~T| -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index ff811a9f458f3..b666a2f6760e6 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -10,7 +10,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 800f22169d3d4..bc8c4c8983d96 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -12,7 +12,7 @@ // xfail-fast // Tests for standalone blocks as expressions with dynamic type sizes -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index e6039d0601e38..cba01fbd8dd81 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, not_expected: @T, eq: compare) { let actual: @T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index b8d872742ab61..5ef97832221bf 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 8e6e3f7ddda85..bd1a550e205fc 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -11,7 +11,7 @@ // xfail-fast // Tests for if as expressions with dynamic type sizes -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; diff --git a/src/test/run-pass/expr-match-generic-box1.rs b/src/test/run-pass/expr-match-generic-box1.rs index 9220b0d697a8e..82e80e7da7dc3 100644 --- a/src/test/run-pass/expr-match-generic-box1.rs +++ b/src/test/run-pass/expr-match-generic-box1.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -type compare = &'static fn(@T, @T) -> bool; +type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = match true { true => { expected }, _ => fail!() }; diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs index 430bd0f52c313..8fed749e3022e 100644 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ b/src/test/run-pass/expr-match-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast -type compare = &'static fn(T, T) -> bool; +type compare = 'static |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index b4bc7d3bef697..af9022ed3222c 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -10,7 +10,7 @@ -type compare = &'static fn(~T, ~T) -> bool; +type compare = 'static |~T, ~T| -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index 8eb5861f71ee7..2bd0f18ba0a74 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -10,7 +10,7 @@ // xfail-fast -type compare<'self, T> = &'self fn(T, T) -> bool; +type compare<'self, T> = 'self |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { diff --git a/src/test/run-pass/fn-coerce-field.rs b/src/test/run-pass/fn-coerce-field.rs index ae2e353f913ba..809005258b51a 100644 --- a/src/test/run-pass/fn-coerce-field.rs +++ b/src/test/run-pass/fn-coerce-field.rs @@ -9,7 +9,7 @@ // except according to those terms. struct r<'self> { - field: &'self fn() + field: 'self || } pub fn main() { diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 73595fd782c47..1716f882dd86e 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -24,7 +24,7 @@ mod map_reduce { use std::str; use std::task; - pub type putter<'self> = &'self fn(~str, ~str); + pub type putter<'self> = 'self |~str, ~str|; pub type mapper = extern fn(~str, putter); diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 4b73d83595e64..f3ffed7dc7bc3 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let early_error: &'static fn(&str) -> ! = |_msg| { fail!() }; + let early_error: 'static |&str| -> ! = |_msg| { fail!() }; } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index afe7656b7a343..9ebeec092cf15 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -18,7 +18,7 @@ // // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait -// issue-2185.rs:24 impl iterable for &'static fn(|uint|) { +// issue-2185.rs:24 impl iterable for 'static ||uint|| { // issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) } // issue-2185.rs:26 } // issue-2185.rs:20:0: 22:1 note: note conflicting implementation here diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index cb1ffc3890898..8179d85e601f3 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -type Connection = &'static fn(~[u8]); +type Connection = 'static |~[u8]|; fn f() -> Option { let mock_connection: Connection = |_| {}; diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index d014a3cf1a15c..b72ef59075ce2 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -12,10 +12,10 @@ struct A { a: ~int } -fn foo() -> &'static fn() -> int { +fn foo() -> 'static || -> int { let k = ~22; let _u = A {a: k.clone()}; - let result: &'static fn() -> int = || 22; + let result: 'static || -> int = || 22; result } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 0b962731ecf3c..19fd120641997 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn(), + cl: 'self ||, } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions-dependent-autofn.rs b/src/test/run-pass/regions-dependent-autofn.rs index bce2159cc7b9f..b50930dd2947b 100644 --- a/src/test/run-pass/regions-dependent-autofn.rs +++ b/src/test/run-pass/regions-dependent-autofn.rs @@ -11,9 +11,9 @@ // Test lifetimes are linked properly when we autoslice a vector. // Issue #3148. -fn subslice<'r>(v: &'r fn()) -> &'r fn() { v } +fn subslice<'r>(v: 'r ||) -> 'r || { v } -fn both<'r>(v: &'r fn()) -> &'r fn() { +fn both<'r>(v: 'r ||) -> 'r || { subslice(subslice(v)) } diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index a2eb459ce206e..941f2c5edfda0 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -9,10 +9,10 @@ // except according to those terms. struct closure_box<'self> { - cl: &'self fn(), + cl: 'self ||, } -fn box_it<'r>(x: &'r fn()) -> closure_box<'r> { +fn box_it<'r>(x: 'r ||) -> closure_box<'r> { closure_box {cl: x} } From 3b2685574bfe0cb0ec228d2ebc9923953301c2c7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Nov 2013 18:15:10 -0800 Subject: [PATCH 3/3] libsyntax: Remove the old-style borrowed closure type syntax from the language. --- src/compiletest/compiletest.rs | 4 ++-- src/compiletest/header.rs | 2 +- src/compiletest/runtest.rs | 9 ++++++--- src/librustuv/addrinfo.rs | 2 +- src/librustuv/file.rs | 7 +++---- src/librustuv/lib.rs | 2 +- src/librustuv/net.rs | 2 +- src/librustuv/process.rs | 4 ++-- src/librustuv/uvio.rs | 2 +- src/libsyntax/parse/obsolete.rs | 6 ++++++ src/libsyntax/parse/parser.rs | 3 ++- .../closure-bounds-cant-promote-superkind-in-struct.rs | 4 ++-- src/test/compile-fail/once-cant-call-twice-on-stack.rs | 2 +- src/test/compile-fail/once-fn-subtyping.rs | 4 ++-- src/test/run-pass/once-move-out-on-stack.rs | 2 +- 15 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 15bddfc80221c..9c8fdafe9ad10 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -301,8 +301,8 @@ pub fn is_test(config: &config, testfile: &Path) -> bool { return valid; } -pub fn make_test(config: &config, testfile: &Path, - f: &fn()->test::TestFn) -> test::TestDescAndFn { +pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn) + -> test::TestDescAndFn { test::TestDescAndFn { desc: test::TestDesc { name: make_test_name(config, testfile), diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index c63436a2c55bd..2197e9d9faa70 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -102,7 +102,7 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { !val } -fn iter_header(testfile: &Path, it: &fn(&str) -> bool) -> bool { +fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool { use std::io::buffered::BufferedReader; use std::io::File; diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 33bd62632095f..2c753a8de7755 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -730,9 +730,12 @@ fn compose_and_run(config: &config, testfile: &Path, prog, args, procenv, input); } -fn make_compile_args(config: &config, props: &TestProps, extras: ~[~str], - xform: &fn(&config, (&Path)) -> Path, - testfile: &Path) -> ProcArgs { +fn make_compile_args(config: &config, + props: &TestProps, + extras: ~[~str], + xform: |&config, &Path| -> Path, + testfile: &Path) + -> ProcArgs { let xform_file = xform(config, testfile); // FIXME (#9639): This needs to handle non-utf8 paths let mut args = ~[testfile.as_str().unwrap().to_owned(), diff --git a/src/librustuv/addrinfo.rs b/src/librustuv/addrinfo.rs index 49782c62838f8..e90d320e72321 100644 --- a/src/librustuv/addrinfo.rs +++ b/src/librustuv/addrinfo.rs @@ -120,7 +120,7 @@ impl Drop for Addrinfo { } } -fn each_ai_flag(_f: &fn(c_int, ai::Flag)) { +fn each_ai_flag(_f: |c_int, ai::Flag|) { /* XXX: do we really want to support these? unsafe { f(uvll::rust_AI_ADDRCONFIG(), ai::AddrConfig); diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index 984b9ee53c210..53c17d52c888b 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -295,7 +295,7 @@ impl Drop for FsRequest { } } -fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) +fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) -> Result { return do task::unkillable { @@ -329,9 +329,8 @@ fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) } } -fn execute_nop(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) - -> Result<(), UvError> -{ +fn execute_nop(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) + -> Result<(), UvError> { execute(f).map(|_| {}) } diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index e8ce8113033a9..4690a347f1143 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -196,7 +196,7 @@ impl Drop for ForbidUnwind { } } -fn wait_until_woken_after(slot: *mut Option, f: &fn()) { +fn wait_until_woken_after(slot: *mut Option, f: ||) { let _f = ForbidUnwind::new("wait_until_woken_after"); unsafe { assert!((*slot).is_none()); diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index 05f708355b0e7..d3364b60608aa 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -35,7 +35,7 @@ use uvll::sockaddr; /// Generic functions related to dealing with sockaddr things //////////////////////////////////////////////////////////////////////////////// -fn socket_addr_as_sockaddr(addr: SocketAddr, f: &fn(*sockaddr) -> T) -> T { +fn socket_addr_as_sockaddr(addr: SocketAddr, f: |*sockaddr| -> T) -> T { let malloc = match addr.ip { Ipv4Addr(*) => uvll::rust_malloc_ip4_addr, Ipv6Addr(*) => uvll::rust_malloc_ip6_addr, diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index c537ee582cb8d..1ab84210face7 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -148,7 +148,7 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t, } /// Converts the program and arguments to the argv array expected by libuv -fn with_argv(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T { +fn with_argv(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T { // First, allocation space to put all the C-strings (we need to have // ownership of them somewhere let mut c_strs = vec::with_capacity(args.len() + 1); @@ -167,7 +167,7 @@ fn with_argv(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T { } /// Converts the environment to the env array expected by libuv -fn with_env(env: Option<&[(~str, ~str)]>, f: &fn(**libc::c_char) -> T) -> T { +fn with_env(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T { let env = match env { Some(s) => s, None => { return f(ptr::null()); } diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 6f9dbc8ec9095..c562f2da2d540 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -171,7 +171,7 @@ impl EventLoop for UvEventLoop { ~AsyncWatcher::new(self.uvio.uv_loop(), f) as ~RemoteCallback } - fn io<'a>(&'a mut self, f: &fn(&'a mut IoFactory)) { + fn io<'a>(&'a mut self, f: |&'a mut IoFactory|) { f(&mut self.uvio as &mut IoFactory) } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 3adedf76eb840..8e291ca6705f3 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -43,6 +43,7 @@ pub enum ObsoleteSyntax { ObsoleteStructWildcard, ObsoleteVecDotDotWildcard, ObsoleteBoxedClosure, + ObsoleteClosureType, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -134,6 +135,11 @@ impl ParserObsoleteMethods for Parser { "managed closures have been removed and owned closures are \ now written `proc()`" ), + ObsoleteClosureType => ( + "closure type", + "closures are now written `|A| -> B` rather than `&fn(A) -> \ + B`." + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6c2df4ad3142a..61a8ebb1c4e71 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1286,7 +1286,7 @@ impl Parser { return self.parse_ty_closure(Some(sigil), Some(lifetime)); } - token::IDENT(*) if sigil == ast::BorrowedSigil => { + token::IDENT(*) => { if self.token_is_old_style_closure_keyword() { self.obsolete(*self.last_span, ObsoleteBoxedClosure); return self.parse_ty_closure(Some(sigil), None); @@ -1311,6 +1311,7 @@ impl Parser { let opt_lifetime = self.parse_opt_lifetime(); if self.token_is_old_style_closure_keyword() { + self.obsolete(*self.last_span, ObsoleteClosureType); return self.parse_ty_closure(Some(BorrowedSigil), opt_lifetime); } diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index 00eb31485b9d7..e5898b33e7785 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -9,10 +9,10 @@ // except according to those terms. struct X { - field: &'static fn:Send(), + field: 'static ||:Send, } -fn foo(blk: &'static fn:()) -> X { +fn foo(blk: 'static ||:) -> X { return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds } diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs index 9469d123d18d7..9cc69228c56f5 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-stack.rs @@ -16,7 +16,7 @@ extern mod extra; use extra::arc; use std::util; -fn foo(blk: &once fn()) { +fn foo(blk: once ||) { blk(); blk(); //~ ERROR use of moved value } diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs index 503b4d3e77b97..3a0afd70e3e71 100644 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ b/src/test/compile-fail/once-fn-subtyping.rs @@ -10,8 +10,8 @@ #[feature(once_fns)]; fn main() { - let f: &once fn() = ||(); + let f: once || = ||(); let g: || = f; //~ ERROR mismatched types let h: || = ||(); - let i: &once fn() = h; // ok + let i: once || = h; // ok } diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs index 8e340275d7fde..645948f142625 100644 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ b/src/test/run-pass/once-move-out-on-stack.rs @@ -17,7 +17,7 @@ extern mod extra; use extra::arc; use std::util; -fn foo(blk: &once fn()) { +fn foo(blk: once ||) { blk(); }