Skip to content

Commit 5435093

Browse files
committed
test: Remove fn@, fn~, and fn& from the test suite. rs=defun
1 parent 2a01674 commit 5435093

File tree

117 files changed

+282
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+282
-267
lines changed

src/test/auxiliary/cci_nested_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::dvec::DVec;
1414

1515
pub struct Entry<A,B> {key: A, value: B}
1616

17-
pub struct alist<A,B> { eq_fn: fn@(A,A) -> bool, data: DVec<Entry<A,B>> }
17+
pub struct alist<A,B> { eq_fn: @fn(A,A) -> bool, data: DVec<Entry<A,B>> }
1818

1919
pub fn alist_add<A:Copy,B:Copy>(lst: alist<A,B>, k: A, v: B) {
2020
lst.data.push(Entry{key:k, value:v});

src/test/auxiliary/issue4516_ty_param_lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
// except according to those terms.
1010

1111
pub fn to_closure<A:Durable + Copy>(x: A) -> @fn() -> A {
12-
fn@() -> A { copy x }
12+
let result: @fn() -> A = || copy x;
13+
result
1314
}

src/test/bench/graph500-bfs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
267267
colors = do par::mapi(*color_vec) {
268268
let colors = arc::clone(&color);
269269
let graph = arc::clone(&graph);
270-
fn~(+i: uint, +c: &color) -> color {
270+
let result: ~fn(uint, &color) -> color = |i, c| {
271271
let colors = arc::get(&colors);
272272
let graph = arc::get(&graph);
273273
match *c {
@@ -290,14 +290,15 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
290290
gray(parent) => { black(parent) }
291291
black(parent) => { black(parent) }
292292
}
293-
}
293+
};
294+
result
294295
};
295296
assert(colors.len() == old_len);
296297
}
297298
298299
// Convert the results.
299300
do par::map(colors) {
300-
fn~(c: &color) -> i64 {
301+
let result: ~fn(c: &color) -> i64 = |c| {
301302
match *c {
302303
white => { -1i64 }
303304
black(parent) => { parent }
@@ -387,14 +388,15 @@ fn validate(edges: ~[(node_id, node_id)],
387388
388389
let status = do par::alli(tree) {
389390
let edges = copy edges;
390-
fn~(+u: uint, v: &i64) -> bool {
391+
let result: ~fn(uint, v: &i64) -> bool = |u, v| {
391392
let u = u as node_id;
392393
if *v == -1i64 || u == root {
393394
true
394395
} else {
395396
edges.contains(&(u, *v)) || edges.contains(&(*v, u))
396397
}
397-
}
398+
};
399+
result
398400
};
399401
400402
if !status { return status }

src/test/bench/task-perf-alloc-unwind.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type nillist = List<()>;
4646
struct State {
4747
box: @nillist,
4848
unique: ~nillist,
49-
fn_box: fn@() -> @nillist,
49+
fn_box: @fn() -> @nillist,
5050
tuple: (@nillist, ~nillist),
5151
vec: ~[@nillist],
5252
res: r
@@ -78,7 +78,7 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
7878
State {
7979
box: @Nil,
8080
unique: ~Nil,
81-
fn_box: fn@() -> @nillist { @Nil::<()> },
81+
fn_box: || @Nil::<()>,
8282
tuple: (@Nil, ~Nil),
8383
vec: ~[@Nil],
8484
res: r(@Nil)
@@ -90,7 +90,7 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
9090
State {
9191
box: @Cons((), st.box),
9292
unique: ~Cons((), @*st.unique),
93-
fn_box: fn@() -> @nillist { @Cons((), fn_box()) },
93+
fn_box: || @Cons((), fn_box()),
9494
tuple: (@Cons((), st.tuple.first()),
9595
~Cons((), @*st.tuple.second())),
9696
vec: st.vec + ~[@Cons((), st.vec.last())],

src/test/bench/task-perf-linked-failure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn grandchild_group(num_tasks: uint) {
4646
// Master grandchild task exits early.
4747
}
4848

49-
fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
49+
fn spawn_supervised_blocking(myname: &str, +f: ~fn()) {
5050
let mut res = None;
5151
task::task().future_result(|+r| res = Some(r)).supervised().spawn(f);
5252
error!("%s group waiting", myname);

src/test/compile-fail/assign-to-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ fn cat(in_x : uint, in_y : int) -> cat {
2828

2929
fn main() {
3030
let nyan : cat = cat(52u, 99);
31-
nyan.speak = fn@() { debug!("meow"); }; //~ ERROR attempted to take value of method
31+
nyan.speak = || debug!("meow"); //~ ERROR attempted to take value of method
3232
}

src/test/compile-fail/borrowck-addr-of-upvar.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn foo(x: @int) -> fn@() -> &static/int {
12-
fn@() -> &static/int {&*x} //~ ERROR illegal borrow
11+
fn foo(x: @int) -> @fn() -> &static/int {
12+
let result: @fn() -> &static/int = || &*x; //~ ERROR illegal borrow
13+
result
1314
}
1415

15-
fn bar(x: @int) -> fn@() -> &int {
16-
fn@() -> &int {&*x} //~ ERROR illegal borrow
16+
fn bar(x: @int) -> @fn() -> &int {
17+
let result: @fn() -> &int = || &*x; //~ ERROR illegal borrow
18+
result
1719
}
1820

19-
fn zed(x: @int) -> fn@() -> int {
20-
fn@() -> int {*&*x}
21+
fn zed(x: @int) -> @fn() -> int {
22+
let result: @fn() -> int = || *&*x;
23+
result
2124
}
2225

2326
fn main() {

src/test/compile-fail/borrowck-call-sendfn.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
// xfail-test #2978
1212

13-
fn call(x: @{f: fn~()}) {
13+
struct Foo {
14+
f: ~fn()
15+
}
16+
17+
fn call(x: @Foo) {
1418
x.f(); //~ ERROR foo
1519
//~^ NOTE bar
1620
}

src/test/compile-fail/borrowck-loan-blocks-move-cc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn box_imm() {
2222

2323
let v = ~3;
2424
let _w = &v; //~ NOTE loan of immutable local variable granted here
25-
task::spawn(fn~() {
25+
task::spawn(|| {
2626
debug!("v=%d", *v);
2727
//~^ ERROR by-move capture of immutable local variable prohibited due to outstanding loan
2828
});

src/test/compile-fail/do2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn f(f: fn@(int) -> bool) -> bool { f(10i) }
11+
fn f(f: @fn(int) -> bool) -> bool { f(10i) }
1212

1313
fn main() {
1414
assert do f() |i| { i == 10i } == 10i;

src/test/compile-fail/fn-variance-2.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn reproduce<T:Copy>(t: T) -> fn@() -> T {
12-
fn@() -> T { t }
11+
fn reproduce<T:Copy>(t: T) -> @fn() -> T {
12+
let result: @fn() -> T = || t;
13+
result
1314
}
1415

1516
fn main() {
1617
// type of x is the variable X,
1718
// with the lower bound @mut int
1819
let x = @mut 3;
1920

20-
// type of r is fn@() -> X
21+
// type of r is @fn() -> X
2122
let r = reproduce(x);
2223

2324
// Requires that X be a subtype of

src/test/compile-fail/fn-variance-3.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn mk_identity<T:Copy>() -> fn@(T) -> T {
12-
fn@(t: T) -> T { t }
11+
fn mk_identity<T:Copy>() -> @fn(T) -> T {
12+
let result: @fn(t: T) -> T = |t| t;
13+
result
1314
}
1415

1516
fn main() {
16-
// type of r is fn@(X) -> X
17+
// type of r is @fn(X) -> X
1718
// for some fresh X
1819
let r = mk_identity();
1920

src/test/compile-fail/issue-1451.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// xfail-test
12-
struct T { f: fn@() };
13-
struct S { f: fn@() };
12+
struct T { f: @fn() };
13+
struct S { f: @fn() };
1414

1515
fn fooS(t: S) {
1616
}
@@ -22,11 +22,11 @@ fn bar() {
2222
}
2323

2424
fn main() {
25-
let x: fn@() = bar;
25+
let x: @fn() = bar;
2626
fooS(S {f: x});
2727
fooS(S {f: bar});
2828

29-
let x: fn@() = bar;
29+
let x: @fn() = bar;
3030
fooT(T {f: x});
3131
fooT(T {f: bar});
3232
}

src/test/compile-fail/issue-1896-1.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct boxedFn { theFn: fn~() -> uint }
11+
struct boxedFn { theFn: ~fn() -> uint }
1212

1313
fn createClosure (closedUint: uint) -> boxedFn {
14-
boxedFn {theFn: fn@ () -> uint { closedUint }} //~ ERROR mismatched types
14+
let result: @fn() -> uint = || closedUint;
15+
boxedFn { theFn: result } //~ ERROR mismatched types
1516
}
1617

1718
fn main () {

src/test/compile-fail/issue-2074.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
// xfail-test
1212
fn main() {
13-
let one = fn@() -> uint {
13+
let one: @fn() -> uint = || {
1414
enum r { a };
15-
return a as uint;
15+
a as uint
1616
};
17-
let two = fn@() -> uint {
17+
let two = @fn() -> uint = || {
1818
enum r { a };
19-
return a as uint;
19+
a as uint
2020
};
2121
one(); two();
2222
}

src/test/compile-fail/kindck-nonsendable-1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn foo(_x: @uint) {}
1212

1313
fn main() {
1414
let x = @3u;
15-
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
16-
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
17-
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
15+
let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint`
16+
let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint`
17+
let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint`
1818
}

src/test/compile-fail/kindck-owned.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn copy1<T:Copy>(t: T) -> fn@() -> T {
12-
fn@() -> T { t } //~ ERROR value may contain borrowed pointers
11+
fn copy1<T:Copy>(t: T) -> @fn() -> T {
12+
let result: @fn() -> T = || t; //~ ERROR value may contain borrowed pointers
13+
result
1314
}
1415

15-
fn copy2<T:Copy + &static>(t: T) -> fn@() -> T {
16-
fn@() -> T { t }
16+
fn copy2<T:Copy + &static>(t: T) -> @fn() -> T {
17+
let result: @fn() -> T = || t;
18+
result
1719
}
1820

1921
fn main() {
@@ -23,7 +25,10 @@ fn main() {
2325
copy2(@3);
2426
copy2(@&x); //~ ERROR does not fulfill `&static`
2527

26-
copy2(fn@() {});
27-
copy2(fn~() {}); //~ ERROR does not fulfill `Copy`
28-
copy2(fn&() {}); //~ ERROR does not fulfill `&static`
28+
let boxed: @fn() = || {};
29+
copy2(boxed);
30+
let owned: ~fn() = || {};
31+
copy2(owned); //~ ERROR does not fulfill `Copy`
32+
let borrowed: &fn() = || {};
33+
copy2(borrowed); //~ ERROR does not fulfill `&static`
2934
}

src/test/compile-fail/lambda-mutate-nested.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
// except according to those terms.
1010

1111
// error-pattern:assigning to captured outer immutable variable in a stack closure
12-
// Make sure that nesting a block within a fn@ doesn't let us
13-
// mutate upvars from a fn@.
14-
fn f2(x: fn()) { x(); }
12+
// Make sure that nesting a block within a @fn doesn't let us
13+
// mutate upvars from a @fn.
14+
fn f2(x: &fn()) { x(); }
1515

1616
fn main() {
1717
let i = 0;
18-
let ctr = fn@ () -> int { f2(|| i = i + 1 ); return i; };
18+
let ctr: @fn() -> int = || { f2(|| i = i + 1 ); i };
1919
log(error, ctr());
2020
log(error, ctr());
2121
log(error, ctr());

src/test/compile-fail/lambda-mutate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// except according to those terms.
1010

1111
// error-pattern:assigning to captured outer variable in a heap closure
12-
// Make sure we can't write to upvars from fn@s
12+
// Make sure we can't write to upvars from @fns
1313
fn main() {
1414
let i = 0;
15-
let ctr = fn@ () -> int { i = i + 1; return i; };
15+
let ctr: @fn() -> int = || { i = i + 1; i };
1616
log(error, ctr());
1717
log(error, ctr());
1818
log(error, ctr());

src/test/compile-fail/liveness-block-unint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn force(f: fn()) { f(); }
11+
fn force(f: &fn()) { f(); }
1212
fn main() {
1313
let x: int;
14-
force(fn&() {
14+
force(|| {
1515
log(debug, x); //~ ERROR capture of possibly uninitialized variable: `x`
1616
});
1717
}

src/test/compile-fail/liveness-init-in-called-fn-expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let j = fn@() -> int {
12+
let j: @fn() -> int = || {
1313
let i: int;
14-
return i; //~ ERROR use of possibly uninitialized variable: `i`
14+
i //~ ERROR use of possibly uninitialized variable: `i`
1515
};
1616
j();
1717
}

src/test/compile-fail/liveness-init-in-fn-expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let f = fn@() -> int {
12+
let f: @fn() -> int = || {
1313
let i: int;
14-
return i; //~ ERROR use of possibly uninitialized variable: `i`
14+
i //~ ERROR use of possibly uninitialized variable: `i`
1515
};
1616
log(error, f());
1717
}

src/test/compile-fail/liveness-issue-2163.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn main() {
1212
let a: ~[int] = ~[];
13-
vec::each(a, fn@(_x: &int) -> bool {
14-
//~^ ERROR not all control paths return a value
13+
vec::each(a, |_| -> bool {
14+
//~^ ERROR mismatched types
1515
});
1616
}

src/test/compile-fail/liveness-unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ impl Drop for r {
6868

6969
fn main() {
7070
let x = r { x: () };
71-
fn@() { copy x; }; //~ ERROR copying a value of non-copyable type
71+
|| { copy x; }; //~ ERROR copying a value of non-copyable type
7272
}

0 commit comments

Comments
 (0)