Skip to content

Commit affa388

Browse files
committed
core: Fix unsafe code in spawn_raw
1 parent 6bb0399 commit affa388

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/libcore/task/spawn.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,8 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
511511

512512
let child_wrapper = make_child_wrapper(new_task, move child_tg,
513513
move ancestors, is_main, move notify_chan, move f);
514-
/*
515-
Truly awful, but otherwise the borrow checker complains about
516-
the move in the last line of this block, for reasons I can't
517-
understand. -- tjc
518-
*/
519-
let tmp: u64 = cast::reinterpret_cast(&(&child_wrapper));
520-
let whatever: &~fn() = cast::reinterpret_cast(&tmp);
521-
let fptr = ptr::p2::addr_of(whatever);
522-
let closure: *rust_closure = cast::reinterpret_cast(&fptr);
514+
515+
let closure = cast::transmute(&child_wrapper);
523516

524517
// Getting killed between these two calls would free the child's
525518
// closure. (Reordering them wouldn't help - then getting killed

0 commit comments

Comments
 (0)