Skip to content

Commit

Permalink
Unrolled build for rust-lang#117266
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#117266 - RalfJung:cast-not-transmute, r=thomcc

replace transmute by raw pointer cast

Now that rust-lang#113257 is fixed we can finally do this. :)
  • Loading branch information
rust-timer authored Oct 27, 2023
2 parents 54e57e6 + b3f7f4d commit e5a2c08
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ impl Builder {
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 {
// SAFETY:
//
Expand All @@ -559,14 +566,7 @@ impl Builder {
// Similarly, the `sys` implementation must guarantee that no references to the closure
// exist after the thread has terminated, which is signaled by `Thread::join`
// returning.
native: unsafe {
imp::Thread::new(
stack_size,
mem::transmute::<Box<dyn FnOnce() + 'a>, Box<dyn FnOnce() + 'static>>(
Box::new(main),
),
)?
},
native: unsafe { imp::Thread::new(stack_size, main)? },
thread: my_thread,
packet: my_packet,
})
Expand Down

0 comments on commit e5a2c08

Please sign in to comment.