replace transmute by raw pointer cast
This commit is contained in:
parent
31ffe48723
commit
b3f7f4dff7
1 changed files with 8 additions and 8 deletions
|
@ -545,6 +545,13 @@ impl Builder {
|
||||||
scope_data.increment_num_running_threads();
|
scope_data.increment_num_running_threads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let main = Box::new(main);
|
||||||
|
#[cfg(bootstrap)]
|
||||||
|
let main =
|
||||||
|
unsafe { mem::transmute::<Box<dyn FnOnce() + 'a>, Box<dyn FnOnce() + 'static>>(main) };
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
let main = unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + 'static)) };
|
||||||
|
|
||||||
Ok(JoinInner {
|
Ok(JoinInner {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
//
|
//
|
||||||
|
@ -559,14 +566,7 @@ impl Builder {
|
||||||
// Similarly, the `sys` implementation must guarantee that no references to the closure
|
// Similarly, the `sys` implementation must guarantee that no references to the closure
|
||||||
// exist after the thread has terminated, which is signaled by `Thread::join`
|
// exist after the thread has terminated, which is signaled by `Thread::join`
|
||||||
// returning.
|
// returning.
|
||||||
native: unsafe {
|
native: unsafe { imp::Thread::new(stack_size, main)? },
|
||||||
imp::Thread::new(
|
|
||||||
stack_size,
|
|
||||||
mem::transmute::<Box<dyn FnOnce() + 'a>, Box<dyn FnOnce() + 'static>>(
|
|
||||||
Box::new(main),
|
|
||||||
),
|
|
||||||
)?
|
|
||||||
},
|
|
||||||
thread: my_thread,
|
thread: my_thread,
|
||||||
packet: my_packet,
|
packet: my_packet,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue