File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,13 @@ impl Builder {
545
545
scope_data.increment_num_running_threads();
546
546
}
547
547
548
+ let main = Box::new(main);
549
+ #[cfg(bootstrap)]
550
+ let main =
551
+ unsafe { mem::transmute::<Box<dyn FnOnce() + 'a>, Box<dyn FnOnce() + 'static>>(main) };
552
+ #[cfg(not(bootstrap))]
553
+ let main = unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + 'static)) };
554
+
548
555
Ok(JoinInner {
549
556
// SAFETY:
550
557
//
@@ -559,14 +566,7 @@ impl Builder {
559
566
// Similarly, the `sys` implementation must guarantee that no references to the closure
560
567
// exist after the thread has terminated, which is signaled by `Thread::join`
561
568
// returning.
562
- native: unsafe {
563
- imp::Thread::new(
564
- stack_size,
565
- mem::transmute::<Box<dyn FnOnce() + 'a>, Box<dyn FnOnce() + 'static>>(
566
- Box::new(main),
567
- ),
568
- )?
569
- },
569
+ native: unsafe { imp::Thread::new(stack_size, main)? },
570
570
thread: my_thread,
571
571
packet: my_packet,
572
572
})
You can’t perform that action at this time.
0 commit comments