]> git.lizzy.rs Git - rust.git/commitdiff
test: Remove most uses of `&fn()` from the tests.
authorPatrick Walton <pcwalton@mimiga.net>
Wed, 20 Nov 2013 00:34:19 +0000 (16:34 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 26 Nov 2013 16:19:00 +0000 (08:19 -0800)
145 files changed:
src/test/auxiliary/cci_impl_lib.rs
src/test/auxiliary/cci_iter_lib.rs
src/test/auxiliary/cci_no_inline_lib.rs
src/test/bench/core-map.rs
src/test/bench/core-set.rs
src/test/bench/core-std.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/compile-fail/access-mode-in-closures.rs
src/test/compile-fail/block-coerce-no-2.rs
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-autoref-3261.rs
src/test/compile-fail/borrowck-insert-during-each.rs
src/test/compile-fail/borrowck-lend-flow-if.rs
src/test/compile-fail/borrowck-lend-flow-loop.rs
src/test/compile-fail/borrowck-lend-flow.rs
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
src/test/compile-fail/borrowck-loan-rcvr.rs
src/test/compile-fail/borrowck-loan-vec-content.rs
src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
src/test/compile-fail/closure-bounds-not-builtin.rs
src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
src/test/compile-fail/closure-bounds-subtype.rs
src/test/compile-fail/closure-that-fails.rs
src/test/compile-fail/do2.rs
src/test/compile-fail/extern-wrong-value-type.rs
src/test/compile-fail/fn-variance-1.rs
src/test/compile-fail/immut-function-arguments.rs
src/test/compile-fail/issue-2074.rs
src/test/compile-fail/issue-2149.rs
src/test/compile-fail/issue-5216.rs
src/test/compile-fail/issue-5239-1.rs
src/test/compile-fail/issue-6762.rs
src/test/compile-fail/issue-7573.rs
src/test/compile-fail/kindck-freeze.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-unsafe.rs
src/test/compile-fail/liveness-block-unint.rs
src/test/compile-fail/liveness-closure-require-ret.rs
src/test/compile-fail/liveness-init-in-called-fn-expr.rs
src/test/compile-fail/liveness-init-in-fn-expr.rs
src/test/compile-fail/missing-do.rs
src/test/compile-fail/moves-based-on-type-block-bad.rs
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
src/test/compile-fail/omitted-arg-wrong-types.rs
src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs
src/test/compile-fail/once-fn-subtyping.rs
src/test/compile-fail/qquote-1.rs
src/test/compile-fail/qquote-2.rs
src/test/compile-fail/regionck-closure-lifetimes.rs
src/test/compile-fail/regions-creating-enums.rs
src/test/compile-fail/regions-escape-bound-fn-2.rs
src/test/compile-fail/regions-escape-bound-fn.rs
src/test/compile-fail/regions-escape-via-trait-or-not.rs
src/test/compile-fail/regions-fn-bound.rs
src/test/compile-fail/regions-fn-subtyping.rs
src/test/compile-fail/regions-fns.rs
src/test/compile-fail/regions-free-region-ordering-callee.rs
src/test/compile-fail/regions-free-region-ordering-caller.rs
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
src/test/compile-fail/regions-infer-call-3.rs
src/test/compile-fail/regions-name-undeclared.rs
src/test/compile-fail/regions-nested-fns-2.rs
src/test/compile-fail/regions-nested-fns.rs
src/test/compile-fail/regions-ref-in-fn-arg.rs
src/test/compile-fail/regions-ret-borrowed-1.rs
src/test/compile-fail/regions-ret-borrowed.rs
src/test/compile-fail/type-arg-out-of-scope.rs
src/test/debug-info/lexical-scope-in-stack-closure.rs
src/test/run-fail/unwind-iter.rs
src/test/run-fail/unwind-iter2.rs
src/test/run-fail/unwind-lambda.rs
src/test/run-pass-fulldeps/qquote.rs
src/test/run-pass/argument-passing.rs
src/test/run-pass/assignability-trait.rs
src/test/run-pass/autobind.rs
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
src/test/run-pass/block-arg-used-as-any.rs
src/test/run-pass/block-explicit-types.rs
src/test/run-pass/block-fn-coerce.rs
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-2.rs
src/test/run-pass/borrowck-borrow-from-expr-block.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-preserve-box-in-field.rs
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
src/test/run-pass/borrowck-preserve-box.rs
src/test/run-pass/borrowck-preserve-expl-deref.rs
src/test/run-pass/closure-inference.rs
src/test/run-pass/do-empty-args.rs
src/test/run-pass/do-no-args.rs
src/test/run-pass/do-pure.rs
src/test/run-pass/do-stack.rs
src/test/run-pass/do1.rs
src/test/run-pass/do2.rs
src/test/run-pass/do3.rs
src/test/run-pass/fn-bare-coerce-to-block.rs
src/test/run-pass/fn-pattern-expected-type.rs
src/test/run-pass/fn-type-infer.rs
src/test/run-pass/foreach-nested.rs
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/fun-call-variants.rs
src/test/run-pass/generic-static-methods.rs
src/test/run-pass/issue-1458.rs
src/test/run-pass/issue-2185.rs
src/test/run-pass/issue-2190-2.rs
src/test/run-pass/issue-2487-a.rs
src/test/run-pass/issue-3429.rs
src/test/run-pass/issue-3796.rs
src/test/run-pass/issue-3874.rs
src/test/run-pass/issue-3904.rs
src/test/run-pass/issue-5239-2.rs
src/test/run-pass/issue-6153.rs
src/test/run-pass/issue-868.rs
src/test/run-pass/iter-range.rs
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/last-use-in-block.rs
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/match-phi.rs
src/test/run-pass/monad.rs
src/test/run-pass/move-nullary-fn.rs
src/test/run-pass/mut-function-arguments.rs
src/test/run-pass/newlambdas.rs
src/test/run-pass/non-legacy-modes.rs
src/test/run-pass/purity-infer.rs
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/regions-fn-subtyping-2.rs
src/test/run-pass/regions-fn-subtyping.rs
src/test/run-pass/regions-infer-call-2.rs
src/test/run-pass/regions-params.rs
src/test/run-pass/sendfn-is-a-block.rs
src/test/run-pass/static-impl.rs
src/test/run-pass/task-killjoin-rsrc.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/trait-generic.rs
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/unnamed_argument_mode.rs
src/test/run-pass/unused-move-capture.rs
src/test/run-pass/variadic-ffi.rs
src/test/run-pass/vec-matching-fold.rs

index aebe9382f64a74e8ad185fd07c43581250596247..f038acf67a82ed8eeee50beee03cd96517fac6ca 100644 (file)
 #[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);
index a264c7d238f523ef20374e22d68075c497d88ed4..e08a2f7fcbbecc07f117c616980fc1648f4ee027 100644 (file)
@@ -11,7 +11,7 @@
 #[link(name="cci_iter_lib", vers="0.0")];
 
 #[inline]
-pub fn iter<T>(v: &[T], f: &fn(&T)) {
+pub fn iter<T>(v: &[T], f: |&T|) {
     let mut i = 0u;
     let n = v.len();
     while i < n {
index fbdb7806b5e6775f578b2ca2687f4e928121e90a..99d13e91752ab6a11b6252ebf5800a83ade23061 100644 (file)
@@ -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 {
index 37efa5768af7cd819dc7b2fc159448cc10281832..3cfe615b9c019a6bb2e3c56efc200cc9f475d8f0 100644 (file)
@@ -19,7 +19,7 @@
 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();
index 9f65dc1e5555bd3ce182a277876521b0460f7093..f9a3618d2abb61566decb693a14fc117c77cc05a 100644 (file)
@@ -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<T:MutableSet<uint>,
-                 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 @@ pub fn bench_int<T:MutableSet<uint>,
     }
 
     pub fn bench_str<T:MutableSet<~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) {
index 4f1e267257538607958f606ba288f1a986120106..c7036f8d9db312a11aa70eb012eafc7033809b2c 100644 (file)
@@ -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() {
index 7becdee43a4ab26a865f0d26d16e3e78448302c1..853b4eaba9d6832975adce4277373e93e4b2b2f5 100644 (file)
@@ -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();
index f2ba0d40ebc69290bce9292ab197ca6058177a66..f8ac5154e7b0d7ed10b5d82f5bad0cd6639b68c9 100644 (file)
@@ -154,7 +154,7 @@ fn lookup<C:TableCallback>(&mut self, key: Code, c: C) {
         }
     }
 
-    fn each(&self, f: &fn(entry: &Entry) -> bool) {
+    fn each(&self, f: |entry: &Entry| -> bool) {
         for self.items.each |item| {
             match *item {
                 None => {}
index 61fb754f7619fa9814e65d634b7a3339c01845f2..ef853f57ef5e16b79e9bb65313c6044d9eb04061 100644 (file)
@@ -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| {
index 3e38ce9ab358bef650dce605e5f8ea43dcfefdf5..52359bed59c90438db721632d7da2cfbee3c0908 100644 (file)
@@ -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);
index 71afba18bb1ff46f197b5ebdf00ae44ce9cd91a1..d07c3feb1942372dfe95db9cf08e4a29c4364bc4 100644 (file)
@@ -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
index 81e16b6b615ed715544cb2909f057fc0ea740ca9..55ef70ad8520fe37eb6eeae99cd9792428b3f35f 100644 (file)
@@ -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
index 4bbd1b0decf57c8b3f222bf80669e30564b0f0b4..f834642eb3cc5874b7c170f35aef19dfb06e5b0c 100644 (file)
@@ -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)
     }
 }
index e507f0e9e5b92c01dc2ef6ab8d7c3b1be74a7edf..358305aee08fbfa65a12621aa0e3f5ea26ee0d4f 100644 (file)
@@ -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);
         }
index 563f63b98be05528580535b642cbc6bc77fd11f6..80b8770397fb2727bd5137bd58803c5c462e0e07 100644 (file)
@@ -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>() -> T { fail!(); }
 
 fn inc(v: &mut ~int) {
index 9286340f6c9f5f79803c7fe8100ea3fb098ba481..14994c0245da99b1bbc9742c58898503250c5e92 100644 (file)
@@ -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() {
index ea840a28b4e6ac97efd6fe7ebb3af8bbcbe691a9..5e4e5bb1e73f1b51e9d273e0d283083b78e4959d 100644 (file)
@@ -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>() -> T { fail!(); }
 
 fn inc(v: &mut ~int) {
index 0284f234d9a5a21841e68ac51a2800ce8ecd1b12..7a226b8b67c0b797c806653de11285f9e1b3daa2 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::task;
 
-fn borrow(v: &int, f: &fn(x: &int)) {
+fn borrow(v: &int, f: |x: &int|) {
     f(v);
 }
 
index ae8779eafcc70627466671443b58e3ddb253c154..417330b6864a7658480420416076bddda9b6a3ea 100644 (file)
@@ -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);
 }
 
index 27a66557434b0eb76ca151021ad9e213f6fc72a9..e04eaa4d7af6ad256dcbd704351e19b734f37a9f 100644 (file)
@@ -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() {
index 8a4a2cdedb23095987208afbdf2383b9e9c1722f..0617d1991911461483e77a37521974912123ae91 100644 (file)
@@ -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();
 }
 
index 628ccd1a5d782e537c4de34007e732d4b38f7290..7615036300f6fefcf09b46f983e58cc9ea58f09f 100644 (file)
@@ -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
index fbf1acb60665b307c9b5d6fc4c5fa6ea779fb049..4afab8db5468b525cae2ed29fd6109ccfdbd189f 100644 (file)
@@ -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
 }
 
index cac1244a560920b3180b05f2261ad0f437b2682b..8fb64ee6dacec413e40ca847578dfe3c90e066b3 100644 (file)
@@ -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: &()) {
index f04da0575b9540a75e7d2bcd020a0cc014b492ba..77281b26554b1f502fb49db5774486a0abdb880f 100644 (file)
@@ -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`
 }
index aad0e8bcbb6dd874fa5ead459190574cdcfeb112..fc8e2d4d853f1e4f5ce23d5e07524536092bb29e 100644 (file)
@@ -1,4 +1,4 @@
-fn foo(f: &fn() -> !) {}
+fn foo(f: || -> !) {}
 
 fn main() {
     // Type inference didn't use to be able to handle this:
index 1bffdaa682cdcd5c1ee13f78c9dd7f99074abf4e..ffb779da354f8c590f1d5c30ca62cbede95a2aad 100644 (file)
@@ -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);
index 069c5a77c6c330ffb439019ea3b487cfbc494df3..6b01b83db21fd31d0c097a459a52f00c9ba10411 100644 (file)
@@ -14,5 +14,5 @@
 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
 }
index dd14d89a380c1820b967ca4040e8d0696d5be3aa..a4ebfef1774c63e13cda067a152263547693485e 100644 (file)
@@ -13,7 +13,7 @@
 fn takes_mut(x: @mut int) { }
 fn takes_imm(x: @int) { }
 
-fn apply<T>(t: T, f: &fn(T)) {
+fn apply<T>(t: T, f: |T|) {
     f(t)
 }
 
index 66b5bd172cace9e5b2cee9e3960ea10b9a6aded0..663a50e9e553e1236b9de0ea08678193d8a68b80 100644 (file)
@@ -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
 
 }
 
index 7815fca16c69bd72898cd336f5822f0af744bd0c..3b8c552db2bd29341b12a3fe07cc44e84a052bb9 100644 (file)
 
 // 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
     };
index 3da01c6fb01398fb105dae508654b5cde55c4551..8d2bdd2d2eb3673db1e55a61a99d604a8c39d11b 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 trait vec_monad<A> {
-    fn bind<B>(&self, f: &fn(A) -> ~[B]);
+    fn bind<B>(&self, f: |A| -> ~[B]);
 }
 
 impl<A> vec_monad<A> for ~[A] {
-    fn bind<B>(&self, f: &fn(A) -> ~[B]) {
+    fn bind<B>(&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
index 8205a6dae64704714081991b0dfd2d5f0f6f0180..ec9ec9565c4066fd5205793b05dbe9e57141a055 100644 (file)
@@ -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() {}
index 97317ec762ad1a64450a49358a50b3586ba5236f..a316e3df042e03fb4aa7757148a00112c340b49e 100644 (file)
@@ -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`
 }
index 14dcc4ea8a3a89d2ce2a52ee7bd975eb833af4b0..22bb660a080666160761e4c61c79c5cb9b8aee82 100644 (file)
@@ -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);
index 9dc29e59f904a0238126761ffe329ade0fe97e19..4ab0ac6386e4c4fe75cff9206f8f64154b3f8746 100644 (file)
@@ -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() {
index c83892e2a3b31a0ffb5e720efb6b6ec4e6c4178b..474c1b1d3cfa4aa9a4bbae28c66c7398e451421d 100644 (file)
@@ -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>();
index 3abacdba18340b83a98327f8cfa1f919800f3b38..d73f0e6ab1e68f2f52624194cd57fad91b75e3fb 100644 (file)
@@ -55,7 +55,7 @@ fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
     let mut _allowed = 1;
 }
 
-fn callback(f: &fn()) {}
+fn callback(f: ||) {}
 
 // make sure the lint attribute can be turned off
 #[allow(unused_mut)]
index 50cc9ceb94e91a1f9c69470c6222ccee50057d0d..253459be85a82df3279f82a37d50a868c18dd4a1 100644 (file)
@@ -18,7 +18,7 @@ mod foo {
     }
 }
 
-fn callback<T>(_f: &fn() -> T) -> T { fail!() }
+fn callback<T>(_f: || -> T) -> T { fail!() }
 unsafe fn unsf() {}
 
 fn bad1() { unsafe {} }                  //~ ERROR: unnecessary `unsafe` block
index 98b6cabb6ffac6f73c6bfa9832710701d5eb6ffb..c46b9013a068d79ac00033711ef2ba6f8a436426 100644 (file)
@@ -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(|| {
index 8f9941e668895326d12bfa83f4fd1c3a182ef5c4..9d46202d64e21143a62f5e1d62fe8b20c2734255 100644 (file)
@@ -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
index 7054cb0d901ce54a9cf3d27ed224c1545e7bea0e..d759a5738bd22703b7187705b8dd3fdca5511201 100644 (file)
@@ -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`
     };
index 13816313884498313c6e37333048e9f6f41f612a..f6bb2f5428370893c8394bb9a2ee1a56b4eb6790 100644 (file)
@@ -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`
     };
index e6a7698d0f07519326345507c16d9d0900dbb90e..5448766c30a72cb501e63666513baa0bce841815 100644 (file)
@@ -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
index 11c4d078208eee242dd32127bfc77a5a97c4b1a1..355305b6c630c6a3f5901b9c5edf8bf4a3483ffb 100644 (file)
@@ -8,7 +8,7 @@ enum E {
     Baz
 }
 
-fn f(s: &S, g: &fn(&S)) {
+fn f(s: &S, g: |&S|) {
     g(s)
 }
 
index 2762140be3793c04fc2010aa596b6491d09b4dae..db8effb1de3df0d6badac72a9ea9e2b470bb957d 100644 (file)
@@ -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
 }
index a44c113269b98f4a77f6473fa13041a5fa5319a8..f43ff0421a9a76d4cef0f1e36261f3f3592fa811 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 // xfail-test - #2093
-fn let_in<T>(x: T, f: &fn(T)) {}
+fn let_in<T>(x: T, f: |T|) {}
 
 fn main() {
     let_in(3u, |i| { assert!(i == 3); });
index aedeb92df787c35bbb2b205a9ada425e669c854a..4927acde48d8740bbaf4a28dc0d241370f16434b 100644 (file)
@@ -15,7 +15,7 @@
 use extra::arc;
 use std::util;
 
-fn foo(blk: &fn()) {
+fn foo(blk: ||) {
     blk();
     blk();
 }
index 5f7393fdf8b8cad2b432428894d79174672c2df3..503b4d3e77b978e5ea0a80fb8e25cbe57e4a8669 100644 (file)
@@ -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
 }
index 0112c0adea298ddd9c263cb4207e66b999cb61ee..f55fcfc204b2fcb3d47a621738b078675ea7c9a3 100644 (file)
@@ -62,6 +62,6 @@ fn main() {
     check_pp(expr3,  pprust::print_expr, "2 - 23 + 7");
 }
 
-fn check_pp<T>(expr: T, f: &fn(pprust::ps, T), expect: str) {
+fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) {
     fail!();
 }
index 57355885e2f46d1db79b46d746224300554a003a..262abc045a411d820fc597008e2324c27d4e28fb 100644 (file)
@@ -57,6 +57,6 @@ fn main() {
     check_pp(*stmt,  pprust::print_stmt, "");
 }
 
-fn check_pp<T>(expr: T, f: &fn(pprust::ps, T), expect: str) {
+fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) {
     fail!();
 }
index c9a3e044d9c4783ed2722401dddfc57957b6b029..f66b17d68c76fa954eff2ba7432ee359e703c6fd 100644 (file)
@@ -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.
     //
index c2d8427d5eb39fed8fa1b238f745238723039bc5..0a370425c4165388684a516df56f74327bb6538a 100644 (file)
@@ -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
index 305aa68528493f52cc7706ef6ce691e7762ad576..d2551ec4fedb444991cd1b402ed4b3640369ff74 100644 (file)
@@ -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);
 }
index 5ac5e334be23d1e5b4d5ba531c2c5e497f943f80..eb72b4b0c53219a532c62ea42451f3302417d09b 100644 (file)
@@ -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);
 }
index 5b6dc1b2f4fb48b11db5dba500fd12b01d12ae7d..32ec59d97413b006c70296e525d77bfba00bf90d 100644 (file)
@@ -18,7 +18,7 @@ fn get(self) -> int {
     }
 }
 
-fn with<R:deref>(f: &fn(x: &int) -> R) -> int {
+fn with<R:deref>(f: |x: &int| -> R) -> int {
     f(&3).get()
 }
 
index add53d3d9b0b9779ecfd7ae066df3ce46ccd4577..09801d37ee92c5ec6f91375d603419324974b608 100644 (file)
@@ -11,8 +11,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn of<T>() -> &fn(T) { fail!(); }
-fn subtype<T>(x: &fn(T)) { fail!(); }
+fn of<T>() -> |T| { fail!(); }
+fn subtype<T>(x: |T|) { fail!(); }
 
 fn test_fn<T>(_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<T>(_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 ||>());
 
 }
index cad73daa46b157f7806fd93a099cbc6a80f8204e..0cbd37a3b9a5ea9531fdb48ac096fa3fffb364a5 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn of<T>() -> &fn(T) { fail!(); }
-fn subtype<T>(x: &fn(T)) { fail!(); }
+fn of<T>() -> |T| { fail!(); }
+fn subtype<T>(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::<T1>(of::<T2>()) 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() {}
index 715261d816a4e3f6998ec6d0fd36e35921b9259c..854584ec535e66ddb57ae48002b9c1a82e8bd3af 100644 (file)
@@ -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);
 }
index fb31e477ba279658a8e85e6a0ff73eb6aa019c3c..94c617b21826617339f10052014fd6a849e39519 100644 (file)
@@ -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;
 }
 
index 58fa437a6a365b2c5947005756ff1339a11d3b0a..808e850907f28d94f5679fbb68dc2eb7255e6eec 100644 (file)
@@ -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
 }
 
index e0764d392913393f33008f9602c01885d6d8c9b9..26b0f2b66c38770db385309de9591815c2d0ff19 100644 (file)
@@ -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: &int;
     loop {
         let x = box();
index 585b56d5a420b38b465ab565a40a699f9019a3e0..8002f8bcc50d2db1ae4a12a7a55b32acf2c2872e 100644 (file)
@@ -10,7 +10,7 @@
 
 fn select<'r>(x: &'r int, y: &'r int) -> &'r int { x }
 
-fn with<T>(f: &fn(x: &int) -> T) -> T {
+fn with<T>(f: |x: &int| -> T) -> T {
     f(&20)
 }
 
index abff33e05149126f18c4da94dfc48d7234b26fa0..ba3d7bd29f4acf507f83551d094aa3b58cf2f2e9 100644 (file)
@@ -43,16 +43,16 @@ fn f(a: &'a int) { } //~ ERROR undeclared lifetime
 
     // &'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
 {
 }
index fe995052c52e4a961a2eaf4ca9cf7375139b168d..8e9a7546541d09675fbb5d4b26564490b41c2ddb 100644 (file)
@@ -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;
index 244e9cc06a1acd54f52a3fb7a68286087f809e90..11610f422a0c8121ca7192cf9c1118fd346de6da 100644 (file)
@@ -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; }
index 4848262750720fc61766f40f9f48786ab25e2e1b..9574f05fa5852fdc9cd1054b8d2cd8df106afc5b 100644 (file)
@@ -2,7 +2,7 @@ fn arg_item(~ref x: ~int) -> &'static int {
     x //~^ ERROR borrowed value does not live long enough
 }
 
-fn with<R>(f: &fn(~int) -> R) -> R { f(~3) }
+fn with<R>(f: |~int| -> R) -> R { f(~3) }
 
 fn arg_closure() -> &'static int {
     with(|~ref x| x) //~ ERROR borrowed value does not live long enough
index ee6ed3b0d76f631f872a8993a91541f02a62d1af..7eb5fa3c60be6de41b98526e9e562609c5591008 100644 (file)
@@ -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<R>(f: &fn<'a>(x: &'a int) -> R) -> R {
+fn with<R>(f: <'a>|x: &'a int| -> R) -> R {
     f(&3)
 }
 
index c2e48053260cfb222ae2c28e8010e11e14986bdf..2f6f2f44cda585e9cf60a53ca65e74ef607b2b2b 100644 (file)
@@ -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<R>(f: &fn(x: &int) -> R) -> R {
+fn with<R>(f: |x: &int| -> R) -> R {
     f(&3)
 }
 
index 07dc677c0476338b7a0a76a795bda0b481d02256..240b1aa06d472853d02ba0850fe9a035895c9e9e 100644 (file)
@@ -10,6 +10,6 @@
 
 // error-pattern:attempt to use a type argument out of scope
 fn foo<T>(x: T) {
-    fn bar(f: &fn(T) -> T) { }
+    fn bar(f: |T| -> T) { }
 }
 fn main() { foo(1); }
index 238ad3c519d1364fde95bebc44efb7cdd430feb4..f052448c146a637a922a1e55d871e7c5d1ccd799 100644 (file)
@@ -51,7 +51,7 @@ fn main() {
     zzz();
     sentinel();
 
-    let stack_closure: &fn(int) = |x| {
+    let stack_closure: |int| = |x| {
         zzz();
         sentinel();
 
index 51c6cb3adf318cc137df1099e0b9d92ad54cfc58..1f5e455564e348d6cfc2e2c11423c81ba42e8ae6 100644 (file)
@@ -13,7 +13,7 @@
 #[allow(unreachable_code)];
 #[allow(unused_variable)];
 
-fn x(it: &fn(int)) {
+fn x(it: |int|) {
     fail!();
     it(0);
 }
index 17936df6959f2bb0423f3f32939e9f469cc9c204..d0726d2544ca6fb1463bcd1409a1a0eff465f99f 100644 (file)
@@ -10,7 +10,7 @@
 
 // error-pattern:fail
 
-fn x(it: &fn(int)) {
+fn x(it: |int|) {
     let _a = @0;
     it(1);
 }
index 4b95afc0ee28b159e89c58567b06e8bc1c2ccd83..bd415e9eac3e73eb9223ac84c987df0c4841afbd 100644 (file)
@@ -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")
         };
index c7c8e3a19a6cd0734100691fb4a26ea2dda7c675..0fcd49790e072604bb373e0d6ccfb3bd65e51990 100644 (file)
@@ -74,7 +74,7 @@ fn main() {
 }
 
 fn check_pp<T>(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);
index 6d6ae3da62fef1b599524d7be3e24bdcc865b2a2..7f43642463e1e4092a6a0111e01a2d77c200b2af 100644 (file)
@@ -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};
index 5269f7dab5aad92570635f8608b7adf0924674b5..1da5023dce023f92432eb46515eab05c9c9bdab5 100644 (file)
 // it.
 
 trait iterable<A> {
-    fn iterate(&self, blk: &fn(x: &A) -> bool) -> bool;
+    fn iterate(&self, blk: |x: &A| -> bool) -> bool;
 }
 
 impl<'self,A> iterable<A> 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<A> iterable<A> for ~[A] {
-    fn iterate(&self, f: &fn(x: &A) -> bool) -> bool {
+    fn iterate(&self, f: |x: &A| -> bool) -> bool {
         self.iter().advance(f)
     }
 }
index 440ad723a12ce38ed34fa12a4223552c5e2569a6..c0ceb50a2c4bec72ee84612d963589a96b0484cc 100644 (file)
 
 fn f<T>(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");
 }
index 5aa28258792e682f963e1fdbbe1aedc415d105bf..70307e1ff0465424f4b5f99d785c3747d7738445 100644 (file)
 
 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();
 }
 
index ed8641eaf85f99ddfc7afba968357acf934e1ae7..0d82e294caf22bd035c631ae36d28f82085b840d 100644 (file)
@@ -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);
index 7ee9d9e5b5489f174559f6d16facf1abb8e6e16b..f05eb8e30b17cd2f5c8748976c96e4150a18a5e8 100644 (file)
@@ -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();
 }
 
index 379fced1d334b099bac4ca63f82f7f41f26b8c86..82e563ae41ced32dd91533988bf6313ec0fc2440 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 pub fn main() {
-    fn as_buf<T>(s: ~str, f: &fn(~str) -> T) -> T { f(s) }
+    fn as_buf<T>(s: ~str, f: |~str| -> T) -> T { f(s) }
     as_buf(~"foo", |foo: ~str| -> () error!("{}", foo) );
 }
index 19e1fd4099b74408a851ac143be2ccdb84c2ca04..bbb30e9578e9e10a26389db3b2e3efafa327f6c0 100644 (file)
@@ -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);
index a977eb40992bb5479b170cb04bb699b0adb7cd74..821f4b17a79b18393785488686b820724be48790 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-fast
 
-fn iter_vec<T>(v: ~[T], f: &fn(&T)) { for x in v.iter() { f(x); } }
+fn iter_vec<T>(v: ~[T], f: |&T|) { for x in v.iter() { f(x); } }
 
 pub fn main() {
     let v = ~[1, 2, 3, 4, 5, 6, 7];
index e5ea54c2a3eb3f97a7e15cb9f59cb8984b8f1317..ddaf7f233cf01f0c6c11ef15b2afe86b1ec5e4fe 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-fast
 
-fn iter_vec<T>(v: ~[T], f: &fn(&T)) { for x in v.iter() { f(x); } }
+fn iter_vec<T>(v: ~[T], f: |&T|) { for x in v.iter() { f(x); } }
 
 pub fn main() {
     let v = ~[1, 2, 3, 4, 5];
index bc3078f88eabbdc152cbc01401de058b8f3305d2..dae10ed6d3917d634d71b308b8c9559d96e47e7c 100644 (file)
@@ -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)
 }
 
index 9057ebf7983f1cbcbc64c9b8ae58c8fc94e81fcc..7b4c4247a353bc7dfaff0f9788ec47c3fe5f4b35 100644 (file)
@@ -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]))
 }
index 214753c009cda4611c591336e18e7cb539a64dd4..bc8eeb5cd41784f036867660152008840ea40ddf 100644 (file)
@@ -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;
index 239dd4c6dc43c67a91d59d72606fcac1ce9d1020..3ff30192efed897fa79a8974fdb6952d267fe28a 100644 (file)
@@ -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;
index 8a97e8f1b5caf6d43995b9edeb022aae2e8fdd1a..e83621d6bb280b8fb395211864488e6410c2a71b 100644 (file)
@@ -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;
index a0010d36190910477a29a4b4603323969f9972b9..6041fa977f5c37441eb35b3d095b48c728a313af 100644 (file)
@@ -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;
index 167fbdf3fc0524c9801664e5e4dee1ecc59e59c8..b6943b45700180f145160b2c6ebd42cffa385474 100644 (file)
@@ -12,7 +12,7 @@
 
 fn foo(i: int) -> int { i + 1 }
 
-fn apply<A>(f: &fn(A) -> A, v: A) -> A { f(v) }
+fn apply<A>(f: |A| -> A, v: A) -> A { f(v) }
 
 pub fn main() {
     let f = {|i| foo(i)};
index 485d59da7d4b2af0672bd0e3f959162ade9d5919..0078294eb89d58e92906bf1f979199f3d0d424f9 100644 (file)
@@ -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
 }
 
index 1f725ffb3576a3858e424767642b6077771b246b..eb6a4a3db542150e56007ced3bc7b8fba3ace8b9 100644 (file)
@@ -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 { }
index 8a0509c177432d9284720e0ee80781925cf815d5..85bb84c6061ac4477b8d78c968952f8b13cc9fb2 100644 (file)
@@ -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() {
index 0444b269cb34f2225cca898ef585c98eea6abc8f..fddf3b15c78da4ec5bf8af7a1bc904b718a659f0 100644 (file)
@@ -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) }
index 0444b269cb34f2225cca898ef585c98eea6abc8f..fddf3b15c78da4ec5bf8af7a1bc904b718a659f0 100644 (file)
@@ -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) }
index 9feededc9800b68587a00323526e19e988f692a7..1bfb10a9f7568771ca224947e9f2addadc166e05 100644 (file)
@@ -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);
index eeb983b455792826b08a748cc17ef504e3eae27c..c08842a45ce7743151e8f903673bcd76e0445722 100644 (file)
@@ -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);
index db7604d11484d583b7c67d31098363be64af10e1..1231a49dcd31be7f521683c87b9e8797fdcfa495 100644 (file)
@@ -10,7 +10,7 @@
 
 fn bare() {}
 
-fn likes_block(f: &fn()) { f() }
+fn likes_block(f: ||) { f() }
 
 pub fn main() {
     likes_block(bare);
index 450e2a70aab9b91e309cd103c6960cf5eebcef65..fb75abc6ea0934bba220ecef8d2e6234bda73dc0 100644 (file)
@@ -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);
     };
index 09e7ababa6cb6d6acff9075392e24796345f6130..cf783ca141c0aa8b3c877952a59ebdbc4e6f7d00 100644 (file)
@@ -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;
     };
index 36c086093cff0799e7640141851e238c8e9fee80..1f63bd68d34f7b1fe8dc4d3c2884de16d1be0c2b 100644 (file)
@@ -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];
index 2b57cc033f9f68308b342e9c09f791695d641a90..91468841e092355acd98797433c70de615cb0fbc 100644 (file)
@@ -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; }
index f38ac1ed38b4a80c395c94f4c8fd4ca40a743a38..34b131893269a3d081a95f195870d0d123f46be2 100644 (file)
@@ -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; }
 }
index 0edfe174680e6c28b1b410834b0aeede79e0bef8..479f4f8387fb46a00dd780d6671d453d5a852ecf 100644 (file)
@@ -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; }
 
index 2e281812d138f317f4cab0b4c1ab228626b7800c..5832c565d7f4c901c1d61f5f9e68d97b8fa6bd3b 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 trait vec_utils<T> {
-    fn map_<U>(x: &Self, f: &fn(&T) -> U) -> ~[U];
+    fn map_<U>(x: &Self, f: |&T| -> U) -> ~[U];
 }
 
 impl<T> vec_utils<T> for ~[T] {
-    fn map_<U>(x: &~[T], f: &fn(&T) -> U) -> ~[U] {
+    fn map_<U>(x: &~[T], f: |&T| -> U) -> ~[U] {
         let mut r = ~[];
         for elt in x.iter() {
             r.push(f(elt));
index e22f38287ad5d88d118a835b5e43e277957595ed..ce5c932f8da2e82b3a42941f5cf2b42122e4c51c 100644 (file)
@@ -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;
 }
 
index fdf88f414ecfc798e3c8c9660db2398c803e2e0a..afe7656b7a343756876bb2d4ba7d2ccba0ebf2a2 100644 (file)
 //
 // Running /usr/local/bin/rustc:
 // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
-// issue-2185.rs:24 impl iterable<uint> 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<uint> 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<A> iterable<A> for &'static fn(&fn(A)) {
-// issue-2185.rs:21     fn iter(&self, blk: &fn(A)) { self(blk); }
+// issue-2185.rs:20 impl<A> iterable<A> 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<uint> and iterable<A> for the type iterable<uint>. Is it okay if I just remove this test?
 // warrant still having a test, so I inlined the old definitions.
 
 trait iterable<A> {
-    fn iter(&self, blk: &fn(A));
+    fn iter(&self, blk: |A|);
 }
 
-impl<A> iterable<A> for &'static fn(&fn(A)) {
-    fn iter(&self, blk: &fn(A)) { self(blk); }
+impl<A> iterable<A> for 'static ||A|| {
+    fn iter(&self, blk: |A|) { self(blk); }
 }
 
-impl iterable<uint> for &'static fn(&fn(uint)) {
-    fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
+impl iterable<uint> for 'static ||uint|| {
+    fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) }
 }
 
-fn filter<A,IA:iterable<A>>(self: IA,
-                            prd: &'static fn(A) -> bool,
-                            blk: &fn(A)) {
+fn filter<A,IA:iterable<A>>(self: IA, prd: 'static |A| -> bool, blk: |A|) {
     do self.iter |a| {
         if prd(a) { blk(a) }
     }
 }
 
-fn foldl<A,B,IA:iterable<A>>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B {
+fn foldl<A,B,IA:iterable<A>>(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<A,B,IA:iterable<A>>(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);
index d5ee712d412bca43b86a39b9ead0fda9739f089e..571944e5300b8262fa4724421d307a439098f7a0 100644 (file)
 
 // 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())); }
 }
index c12325e6ff52ebec38f9b43e211e8f99d5cd11a6..110bceced82a1085772eedae9e5ae7b4c0a31c5d 100644 (file)
@@ -31,7 +31,7 @@ fn socket() -> socket {
     }
 }
 
-fn closure(f: &fn()) { f() }
+fn closure(f: ||) { f() }
 
 fn setsockopt_bytes(_sock: int) { }
 
index fc493485b794e752751e9de07c5dc4ce781203dd..cce90f8a2cd29339edf892cfdfce9f55f0b3618a 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
   let x = 1;
-  let y: &fn() -> int = || x;
+  let y: || -> int = || x;
   let _z = y();
 }
index 5f4409391396a39ca339c564b75dabb4a175a985..a7c6f86b45357b5f7dbd6ca0d54e798c25015e28 100644 (file)
@@ -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);
index ea1242ae21613030e3f5a00203bd14d7a341d2d7..40725311f313cbab9770b6923aacf76a55449d0f 100644 (file)
@@ -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);
 }
index 6b678ffdb1c4ae631cf9b1f0691e9bf0d5e40b77..4a9b58067b0561717d3621f674259a610f36df79 100644 (file)
@@ -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)
index ba70fac0e4e8f67635aa30e61ea6b1365fc460d4..eabc1cfeb595ff891d1bc965f7266d1b398c7606 100644 (file)
@@ -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);
 }
index 668d6f3ae45e3aecafa93b4030cd0527f3ed2281..f7d0316880a4d3d196c38b59c560d5838c3032a1 100644 (file)
@@ -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)
 }
index 2a82f559d547ceef32de4da4d2c2f96464c476cc..12dcc4ecd2c3a1b6685f364250b606bc581a2c0e 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f<T>(g: &fn() -> T) -> T { g() }
+fn f<T>(g: || -> T) -> T { g() }
 
 pub fn main() {
   let _x = f( | | { 10 });
index 5ada4aa8c7583b3e610acab170f1e3b02b22b9f4..c44b7389666f9fe0a42a9c78352c605cda050c45 100644 (file)
@@ -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; }
index e615cfae6add006535353afae6d5f630c3273caa..b6ee2d10fb33f9f3e32a0a632f3b1577f4fe4e6d 100644 (file)
@@ -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);
 }
index e2dbf7d29db1931aba8850a272009d378ddb4955..8117c5657e9892b8e742da0b6433d223ce33867e 100644 (file)
@@ -10,7 +10,7 @@
 
 // Issue #1818
 
-fn lp<T>(s: ~str, f: &fn(~str) -> T) -> T {
+fn lp<T>(s: ~str, f: |~str| -> T) -> T {
     while false {
         let r = f(s);
         return (r);
@@ -18,8 +18,8 @@ fn lp<T>(s: ~str, f: &fn(~str) -> T) -> T {
     fail!();
 }
 
-fn apply<T>(s: ~str, f: &fn(~str) -> T) -> T {
-    fn g<T>(s: ~str, f: &fn(~str) -> T) -> T {f(s)}
+fn apply<T>(s: ~str, f: |~str| -> T) -> T {
+    fn g<T>(s: ~str, f: |~str| -> T) -> T {f(s)}
     g(s, |v| { let r = f(v); r })
 }
 
index 5c349a095513e55773de0186d9f070e4b5bce9ca..c34e65b2b421388de2f71f4ffda6deaaa4be9c1d 100644 (file)
@@ -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()) )
index c25f573e73bce131e51b0b47d87cb17e8468f3c5..fc851e444e86be7803b2fcaa6b8364ea7842e1fc 100644 (file)
@@ -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;
index 8baf15c8493be409930dc1d19c5622cde63a76b2..891ee4812c1b89a6370124467851881072598de0 100644 (file)
 // xfail-fast
 
 trait vec_monad<A> {
-    fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
+    fn bind<B>(&self, f: |&A| -> ~[B]) -> ~[B];
 }
 
 impl<A> vec_monad<A> for ~[A] {
-    fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
+    fn bind<B>(&self, f: |&A| -> ~[B]) -> ~[B] {
         let mut r = ~[];
         for elt in self.iter() {
             r.push_all_move(f(elt));
@@ -25,11 +25,11 @@ fn bind<B>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
 }
 
 trait option_monad<A> {
-    fn bind<B>(&self, f: &fn(&A) -> Option<B>) -> Option<B>;
+    fn bind<B>(&self, f: |&A| -> Option<B>) -> Option<B>;
 }
 
 impl<A> option_monad<A> for Option<A> {
-    fn bind<B>(&self, f: &fn(&A) -> Option<B>) -> Option<B> {
+    fn bind<B>(&self, f: |&A| -> Option<B>) -> Option<B> {
         match *self {
             Some(ref a) => { f(a) }
             None => { None }
index 87281c2fd225314787432a573e661d0ae0348f36..4b613e9beaab2605b237bc2463828a655cab11ec 100644 (file)
@@ -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);
 }
 
index 0fa89ba0f049da61ee7f93c261f3352ac42de3ce..5801ccebb0fcdd57fea7926f287951aa06ce25e8 100644 (file)
@@ -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);
 
index d9d0daa7138cdf76873eb74e76549097d5420b4e..1835514c0d1fe8766e9de233f1b7997a80d50f23 100644 (file)
@@ -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);
index 642686e06e5ddf0ba40167a77c535b84c058bdb1..8262432db607f3b04fd0127535fa0940a6776004 100644 (file)
@@ -12,7 +12,7 @@ struct X {
     repr: int
 }
 
-fn apply<T>(x: T, f: &fn(T)) {
+fn apply<T>(x: T, f: |T|) {
     f(x);
 }
 
index debde77b21128d08853803e6a500898682218ba7..bbb312842ce14587aacf1b3a46174a9852648aca 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 
-fn something(f: &fn()) { f(); }
+fn something(f: ||) { f(); }
 pub fn main() {
     something(|| error!("hi!") );
 }
index 42614f76539283df7ee882252f948d3f2b17e592..96081d30275fb32be75273c5d3bffa8cba895aea 100644 (file)
@@ -22,7 +22,7 @@
 
 /// 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<T:Clone>(&mut self, f: &fn(T)) {
+    pub fn get<T:Clone>(&mut self, f: |T|) {
         unsafe {
             f((*(self.ptr1 as *T)).clone());
         }
@@ -490,7 +490,7 @@ pub fn visit_inner(&mut self, inner: *TyDesc) -> bool {
 struct Inner<V> { 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);
     }
index ef8d9970c2b479ae2cd0b0ee48c5d4e7f352f31f..9d2a959eae1c7fa807a8697eda8c1db0c857994b 100644 (file)
 // 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() {
index 06c8aca4741645da3756fb932d864bc51d94732f..14e56bd6181177688f301f251b4b1e236ba3f195 100644 (file)
 #[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;
 }
 
index 42be3b5b97553897a2f5c35f1228dacd97b73a5f..061f27972871fe334f6fa322808ff806dfb9a3ee 100644 (file)
@@ -10,7 +10,7 @@
 
 fn takes_two(x: &int, y: &int) -> int { *x + *y }
 
-fn with<T>(f: &fn(x: &int) -> T) -> T {
+fn with<T>(f: |x: &int| -> T) -> T {
     f(&20)
 }
 
index ea32cf866a0cd0dd9af671485a09234eb69ddbee..5fe92f527d05bba6a3ded0ae67adccf2a1064bae 100644 (file)
@@ -12,7 +12,7 @@
 
 fn region_identity<'r>(x: &'r uint) -> &'r uint { x }
 
-fn apply<T>(t: T, f: &fn(T) -> T) -> T { f(t) }
+fn apply<T>(t: T, f: |T| -> T) -> T { f(t) }
 
 fn parameterized(x: &uint) -> uint {
     let z = apply(x, ({|y|
index f7808f7f8ac8b48ab6fdda6b10b4ee99aa9c8053..1b80d7648a6df116c07eedf225319b3ea149f46b 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-fast
 
-fn test(f: &fn(uint) -> uint) -> uint {
+fn test(f: |uint| -> uint) -> uint {
     return f(22u);
 }
 
index 651b3342d5833e3f612c1f62384b9fab8d65c76f..28aab18cf6cfcd96151ee41621a539598ac81436 100644 (file)
@@ -26,12 +26,12 @@ impl plus for ~str { fn plus(&self) -> int { 200 } }
 
 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 @@ fn multi(&self, f: &fn(uint)) {
 
 trait vec_utils<T> {
     fn length_(&self, ) -> uint;
-    fn iter_(&self, f: &fn(&T));
-    fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U];
+    fn iter_(&self, f: |&T|);
+    fn map_<U>(&self, f: |&T| -> U) -> ~[U];
 }
 
 impl<T> vec_utils<T> for ~[T] {
     fn length_(&self) -> uint { self.len() }
-    fn iter_(&self, f: &fn(&T)) { for x in self.iter() { f(x); } }
-    fn map_<U>(&self, f: &fn(&T) -> U) -> ~[U] {
+    fn iter_(&self, f: |&T|) { for x in self.iter() { f(x); } }
+    fn map_<U>(&self, f: |&T| -> U) -> ~[U] {
         let mut r = ~[];
         for elt in self.iter() {
             r.push(f(elt));
index 395d6b0b51ad2559da63f417a2d5899670216393..94e402bfa90211a2945ffe341c07220fbc065120 100644 (file)
@@ -45,7 +45,7 @@ fn notify(ch: Chan<bool>, v: @mut bool) -> notify {
 }
 
 fn joinable(f: proc()) -> Port<bool> {
-    fn wrapper(c: Chan<bool>, f: &fn()) {
+    fn wrapper(c: Chan<bool>, f: ||) {
         let b = @mut false;
         error!("wrapper: task=%? allocated v=%x",
                0,
index a10753451400a6cc9e4c3509f468c9794d1b3a40..cee2079251a28cd5658d8ccd9fabbb60757c7d9e 100644 (file)
@@ -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()));
 
index a4510ef70e1b257b1db70f9dbcddf21b79801084..7b331c43568075c88f021bff1e3633b7f2c4f34c 100644 (file)
@@ -22,7 +22,7 @@
 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 }
 }
index f448bcb4ab5d27fda032df640a84f5ae4f3ff2b3..90f87d832ff89935f3d4289fc2594fde96a6ddbc 100644 (file)
@@ -24,10 +24,10 @@ fn to_string(&self) -> ~str { ~"()" }
 }
 
 trait map<T> {
-    fn map<U>(&self, f: &fn(&T) -> U) -> ~[U];
+    fn map<U>(&self, f: |&T| -> U) -> ~[U];
 }
 impl<T> map<T> for ~[T] {
-    fn map<U>(&self, f: &fn(&T) -> U) -> ~[U] {
+    fn map<U>(&self, f: |&T| -> U) -> ~[U] {
         let mut r = ~[];
         // FIXME: #7355 generates bad code with VecIterator
         for i in range(0u, self.len()) {
index a5a9075af7b247e0d9f1af8cdd50ef00a7d184fe..042b5e96bbc08a1ab60077ecc859cf59ef287fbb 100644 (file)
@@ -13,7 +13,7 @@ struct S<T> {
     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; }
 }
index c52658542f05b539a521ba3bcd805080df8301c8..948824834df844071542df662b62507db80a0336 100644 (file)
@@ -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() {
index 662121a09931fbc50658319a1f8701b9e99a9c1f..ceb91d557f6aea0ec78e9338cf1bd55f509a6be2 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
     let _x = ~1;
-    let lam_move: &fn() = || {};
+    let lam_move: || = || {};
     lam_move();
 }
index d82e2890ae8d3c95206c3378753f05e4085fac2f..06026d58f6005f124d1463af87bac6892b702ecc 100644 (file)
@@ -15,7 +15,7 @@
     fn sprintf(s: *mut c_char, format: *c_char, ...) -> c_int;
 }
 
-unsafe fn check<T>(expected: &str, f: &fn(*mut c_char) -> T) {
+unsafe fn check<T>(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);
index 22f1ccb8bbb058ab7409b92f76abb7f513902fec..75c48da8d812d11b5739f34fcd3ade83e4052db6 100644 (file)
@@ -1,6 +1,6 @@
 fn foldl<T,U:Clone>(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<T,U:Clone>(values: &[T],
 
 fn foldr<T,U:Clone>(values: &[T],
                     initial: U,
-                    function: &fn(element: &T, partial: U) -> U)
+                    function: |element: &T, partial: U| -> U)
                     -> U {
     match values {
         [..head, ref tail] =>