diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-01-23 14:59:00 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-01-23 19:06:33 -0800 |
| commit | 5e13d19cc07a1e8fbf478d21cabbd7b9f80e3b54 (patch) | |
| tree | c1fc2dd89c651efa1daa4e7d63c5b82b2a5f4bd2 /src/test | |
| parent | 04351a84ca342f4580e40b9c195b5403b864090b (diff) | |
s/block()/fn()/g
Diffstat (limited to 'src/test')
31 files changed, 41 insertions, 37 deletions
diff --git a/src/test/bench/99bob-iter.rs b/src/test/bench/99bob-iter.rs index eaab9d6b731..02d55cf64d3 100644 --- a/src/test/bench/99bob-iter.rs +++ b/src/test/bench/99bob-iter.rs @@ -40,7 +40,7 @@ fn sub(t: str, n: int) -> str { /* Using an interator */ -fn ninetynine(it: block(int)) { +fn ninetynine(it: fn(int)) { let n: int = 100; while n > 1 { n -= 1; it(n); } } diff --git a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs index a7348b26fa2..2abaabc3ef8 100644 --- a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs +++ b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs @@ -4,7 +4,7 @@ fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint { ret f; } -fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { +fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint { ret to_lambda1({|x| b(x)}); } diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 42c893a2064..95d1bdf0787 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -2,11 +2,11 @@ // other tycons. fn coerce(b: fn()) -> native fn() { - fn lol(f: native fn(block()) -> native fn(), + fn lol(f: native fn(fn()) -> native fn(), g: fn()) -> native fn() { ret f(g); } fn fn_id(f: native fn()) -> native fn() { ret f } ret lol(fn_id, b); - //!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()` + //!^ ERROR mismatched types: expected `native fn(fn()) -> native fn()` } fn main() { diff --git a/src/test/compile-fail/block-copy.rs b/src/test/compile-fail/block-copy.rs index 63a2e9bcb39..e986330ee0e 100644 --- a/src/test/compile-fail/block-copy.rs +++ b/src/test/compile-fail/block-copy.rs @@ -1,8 +1,8 @@ // error-pattern: block type can only appear -fn lol(f: block()) -> block() { ret f; } +fn lol(f: fn()) -> fn() { ret f; } fn main() { let i = 8; - let f = lol(block () { log(error, i); }); + let f = lol(fn&() { log(error, i); }); f(); } diff --git a/src/test/compile-fail/block-deinitializes-upvar.rs b/src/test/compile-fail/block-deinitializes-upvar.rs index 65367a01a7b..6de84a2a163 100644 --- a/src/test/compile-fail/block-deinitializes-upvar.rs +++ b/src/test/compile-fail/block-deinitializes-upvar.rs @@ -1,5 +1,5 @@ // error-pattern:Tried to deinitialize a variable declared in a different -fn force(f: block()) { f(); } +fn force(f: fn()) { f(); } fn main() { let x = @{x: 17, y: 2}; let y = @{x: 5, y: 5}; diff --git a/src/test/compile-fail/block-require-return.rs b/src/test/compile-fail/block-require-return.rs index dc14053084d..6a05ccf0605 100644 --- a/src/test/compile-fail/block-require-return.rs +++ b/src/test/compile-fail/block-require-return.rs @@ -1,3 +1,3 @@ // error-pattern: not all control paths return -fn force(f: block() -> int) -> int { f() } +fn force(f: fn() -> int) -> int { f() } fn main() { log(error, force({|| })); } diff --git a/src/test/compile-fail/block-uninit.rs b/src/test/compile-fail/block-uninit.rs index 4d7f73b341c..94df3392bbb 100644 --- a/src/test/compile-fail/block-uninit.rs +++ b/src/test/compile-fail/block-uninit.rs @@ -1,4 +1,4 @@ // error-pattern: Unsatisfied precondition constraint -fn force(f: block()) { f(); } -fn main() { let x: int; force(block () { log(error, x); }); } +fn force(f: fn()) { f(); } +fn main() { let x: int; force(fn&() { log(error, x); }); } diff --git a/src/test/compile-fail/cap-clause-illegal-cap.rs b/src/test/compile-fail/cap-clause-illegal-cap.rs index 6f4972fdf66..32b21797976 100644 --- a/src/test/compile-fail/cap-clause-illegal-cap.rs +++ b/src/test/compile-fail/cap-clause-illegal-cap.rs @@ -1,6 +1,6 @@ // error-pattern: copying a noncopyable value -fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { +fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint { // test case where copy clause specifies a value that is not used // in fn@ body, but value is illegal to copy: ret fn@[copy b](u: uint) -> uint { 22u }; diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs index 2117eeefe8b..1f052679065 100644 --- a/src/test/compile-fail/lambda-mutate-nested.rs +++ b/src/test/compile-fail/lambda-mutate-nested.rs @@ -1,7 +1,7 @@ // error-pattern:assigning to upvar // Make sure that nesting a block within a fn@ doesn't let us // mutate upvars from a fn@. -fn f2(x: block()) { x(); } +fn f2(x: fn()) { x(); } fn main() { let i = 0; diff --git a/src/test/pretty/block-arg-disambig.rs b/src/test/pretty/block-arg-disambig.rs index 0f249b99d19..e57c7be48a9 100644 --- a/src/test/pretty/block-arg-disambig.rs +++ b/src/test/pretty/block-arg-disambig.rs @@ -1,2 +1,2 @@ -fn blk1(b: block()) -> fn@() { ret fn@() { }; } +fn blk1(b: fn()) -> fn@() { ret fn@() { }; } fn test1() { (blk1 {|| #debug["hi"]; })(); } diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 5c346f672ec..bc272ab3b97 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -1,6 +1,6 @@ // error-pattern:fail -fn x(it: block(int)) { +fn x(it: fn(int)) { fail; it(0); } diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index 7b7cba966e9..e1e93ac94cd 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -1,6 +1,6 @@ // error-pattern:fail -fn x(it: block(int)) { +fn x(it: fn(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 b2b1d4ed85d..72fd69ec675 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -4,7 +4,7 @@ fn main() { let cheese = "roquefort"; let carrots = @"crunchy"; - fn@(tasties: @str, macerate: block(str)) { + fn@(tasties: @str, macerate: fn(str)) { macerate(*tasties); } (carrots, { |food| let mush = food + cheese; diff --git a/src/test/run-pass/alt-phi.rs b/src/test/run-pass/alt-phi.rs index 11f0ff87a68..c63c622e2ef 100644 --- a/src/test/run-pass/alt-phi.rs +++ b/src/test/run-pass/alt-phi.rs @@ -2,7 +2,7 @@ enum thing { a, b, c, } -fn foo(it: block(int)) { it(10); } +fn foo(it: fn(int)) { it(10); } fn main() { let x = true; diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 9c301ae2ac2..24184cdc2d9 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -6,7 +6,7 @@ fn f1(a: {mutable x: int}, &b: int, -c: int) -> int { ret r; } -fn f2(a: int, f: block(int)) -> int { f(1); ret a; } +fn f2(a: int, f: fn(int)) -> int { f(1); ret a; } fn main() { let a = {mutable x: 1}, b = 2, c = 3; diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index 1e3c0a7e2af..bf65441e7fa 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -8,7 +8,11 @@ fn asLambda( f : fn@()->uint ) -> uint { ret f(); } -fn asBlock( f : block()->uint ) -> uint { +fn asBlock( f : fn&()->uint ) -> uint { + ret f(); +} + +fn asAny( f : fn()->uint ) -> uint { ret 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 8fd79740512..71342eee6e8 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 @@ -1,5 +1,5 @@ fn main() { - fn f(i: block() -> uint) -> uint { i() } + fn f(i: fn() -> uint) -> uint { i() } let v = [-1f, 0f, 1f, 2f, 3f]; let z = vec::foldl(f, v) { |x, _y| x } { || 22u }; assert z == 22u; diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index 85bb68e7387..230df12e621 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -1,4 +1,4 @@ fn main() { - fn as_buf<T>(s: str, f: block(str) -> T) -> T { f(s) } + fn as_buf<T>(s: str, f: fn(str) -> T) -> T { f(s) } as_buf("foo", {|foo: str| -> () log(error, foo);}); } diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index a9a4ba557ed..0b6413fc3ec 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -1,4 +1,4 @@ -fn force(f: block() -> int) -> int { ret f(); } +fn force(f: fn() -> int) -> int { ret f(); } fn main() { fn f() -> int { ret 7; } assert (force(f) == 7); diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 0f09aae2409..8a01150e313 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -1,4 +1,4 @@ -fn iter_vec<T>(v: [T], f: block(T)) { for x: T in v { f(x); } } +fn iter_vec<T>(v: [T], f: fn(T)) { for x: T in v { f(x); } } 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 bec21791c90..085f468c60a 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -1,4 +1,4 @@ -fn iter_vec<T>(v: [T], f: block(T)) { for x: T in v { f(x); } } +fn iter_vec<T>(v: [T], f: fn(T)) { for x: T in v { f(x); } } fn main() { let v = [1, 2, 3, 4, 5]; 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 9da242f572f..67662525a1d 100644 --- a/src/test/run-pass/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/fn-bare-coerce-to-block.rs @@ -1,6 +1,6 @@ fn bare() {} -fn likes_block(f: block()) { f() } +fn likes_block(f: fn()) { f() } fn main() { likes_block(bare); diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 08e7b843611..c77a37cf27c 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn two(it: block(int)) { it(0); it(1); } +fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mutable int] = [mutable -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 5919ee91b44..d5ceb820264 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -1,6 +1,6 @@ -fn pairs(it: block((int, int))) { +fn pairs(it: fn((int, int))) { let i: int = 0; let 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 90356d15b4b..047819bfb75 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -10,7 +10,7 @@ fn main() { assert (sum == 45); } -fn first_ten(it: block(int)) { +fn first_ten(it: fn(int)) { let i: int = 0; while i < 10 { #debug("first_ten"); it(i); i = i + 1; } } diff --git a/src/test/run-pass/iface-generic.rs b/src/test/run-pass/iface-generic.rs index 2286642cda1..c37dc989f38 100644 --- a/src/test/run-pass/iface-generic.rs +++ b/src/test/run-pass/iface-generic.rs @@ -12,10 +12,10 @@ impl of to_str for () { } iface map<T> { - fn map<U>(f: block(T) -> U) -> [U]; + fn map<U>(f: fn(T) -> U) -> [U]; } impl <T> of map<T> for [T] { - fn map<U>(f: block(T) -> U) -> [U] { + fn map<U>(f: fn(T) -> U) -> [U] { let r = []; for x in self { r += [f(x)]; } r diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index c02fc34ae8b..c82c1eb97e9 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -1,6 +1,6 @@ -fn range(a: int, b: int, it: block(int)) { +fn range(a: int, b: int, it: fn(int)) { assert (a < b); let i: int = a; while i < b { it(i); i += 1; } diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 71ac2fc0c62..1476a015828 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -1,4 +1,4 @@ -fn test(f: block(uint) -> uint) -> uint { +fn test(f: fn(uint) -> uint) -> uint { ret f(22u); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 8f9acab6128..fbc29c55a31 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -11,7 +11,7 @@ mod b { impl util for uint { fn str() -> str { uint::str(self) } - fn times(f: block(uint)) { + fn times(f: fn(uint)) { let c = 0u; while c < self { f(c); c += 1u; } } @@ -19,8 +19,8 @@ impl util for uint { impl util<T> for [T] { fn len() -> uint { vec::len(self) } - fn iter(f: block(T)) { for x in self { f(x); } } - fn map<U>(f: block(T) -> U) -> [U] { + fn iter(f: fn(T)) { for x in self { f(x); } } + fn map<U>(f: fn(T) -> U) -> [U] { let r = []; for elt in self { r += [f(elt)]; } r 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 67b0f366acd..645f6407bfe 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -1,6 +1,6 @@ -fn range(lo: uint, hi: uint, it: block(uint)) { +fn range(lo: uint, hi: uint, it: fn(uint)) { let lo_ = lo; while lo_ < hi { it(lo_); lo_ += 1u; } } diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index b2069f3a265..d54a7f5a5e0 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -7,7 +7,7 @@ import std::list::*; // Can't easily be written as a "pure fn" because there's // no syntax for specifying that f is pure. -fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: block(T, U) -> U) -> U { +fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: fn(T, U) -> U) -> U { alt ls { nil { u } cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) } |
