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 {
545545 scope_data. increment_num_running_threads ( ) ;
546546 }
547547
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+
548555 Ok ( JoinInner {
549556 // SAFETY:
550557 //
@@ -559,14 +566,7 @@ impl Builder {
559566 // Similarly, the `sys` implementation must guarantee that no references to the closure
560567 // exist after the thread has terminated, which is signaled by `Thread::join`
561568 // 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) ? } ,
570570 thread : my_thread,
571571 packet : my_packet,
572572 } )
You can’t perform that action at this time.
0 commit comments