From 87a782c0b3034d0833f677ffc1161ddfb4c6765d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 17 Aug 2011 12:47:04 -0700 Subject: [PATCH] Simplify default_test_to_task Doesn't appear to require an unsafe pointer now --- src/lib/test.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib/test.rs b/src/lib/test.rs index 682a177bdf8..5d272bded7e 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -332,17 +332,13 @@ fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future { } // We need to run our tests in another task in order to trap test failures. -// But, at least currently, functions can't be used as spawn arguments so -// we've got to treat our test functions as unsafe pointers. This function -// only works with functions that don't contain closures. +// This function only works with functions that don't contain closures. fn default_test_to_task(f: &fn()) -> task_id { - fn run_task(fptr: *mutable fn() ) { + fn run_task(f: fn()) { configure_test_task(); - // Run the test - (*fptr)() + f(); } - let fptr = ptr::addr_of(f); - ret task::spawn(bind run_task(fptr)); + ret task::spawn(bind run_task(f)); } // Call from within a test task to make sure it's set up correctly