From 16b2b5281a4870763707f70d2c8b5de24fb77d7e Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 13 Mar 2025 16:14:58 +0000 Subject: [PATCH] Remove object lifetime cast --- src/worker.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/worker.rs b/src/worker.rs index eed01f3..907c090 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -239,7 +239,12 @@ impl<'thread> Worker<'thread> { let our_packet = Arc::new(packet); let their_packet: Arc = our_packet.clone(); // SAFETY: we merely prolong the lifetime of the borrow. This lifetime is threaded into the ClaimedWorker struct. - let their_packet = unsafe { Arc::from_raw(Arc::into_raw(their_packet) as *mut _) }; + let their_packet = unsafe { + Arc::from_raw(std::mem::transmute::< + *const (dyn UnitOfWork + Send + Sync + '_), + *const (dyn UnitOfWork + Send + Sync + 'static), + >(Arc::into_raw(their_packet))) + }; let work = WorkItem::Task(their_packet); let barrier = self.control.send(work); ClaimedWorker {