Skip to content

Commit 87a782c

Browse files
committed
Simplify default_test_to_task
Doesn't appear to require an unsafe pointer now
1 parent deef212 commit 87a782c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/lib/test.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,13 @@ fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future {
332332
}
333333

334334
// We need to run our tests in another task in order to trap test failures.
335-
// But, at least currently, functions can't be used as spawn arguments so
336-
// we've got to treat our test functions as unsafe pointers. This function
337-
// only works with functions that don't contain closures.
335+
// This function only works with functions that don't contain closures.
338336
fn default_test_to_task(f: &fn()) -> task_id {
339-
fn run_task(fptr: *mutable fn() ) {
337+
fn run_task(f: fn()) {
340338
configure_test_task();
341-
// Run the test
342-
(*fptr)()
339+
f();
343340
}
344-
let fptr = ptr::addr_of(f);
345-
ret task::spawn(bind run_task(fptr));
341+
ret task::spawn(bind run_task(f));
346342
}
347343

348344
// Call from within a test task to make sure it's set up correctly

0 commit comments

Comments
 (0)