From 3cf753d48d89f2b8d7a6789d7a45056d72c1ca34 Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 13 Mar 2025 16:17:36 +0000 Subject: [PATCH] Remove object lifetime cast --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7cc30d1..b808510 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,9 +286,10 @@ impl<'scope, 'env> ScopedTaskSpawner<'scope, 'env> { // SAFETY: The rest of this module makes sure to only deref the `Box` when we're certain // that the 'scope borrow is still live/valid. let fut = unsafe { - ManuallyDrop::new(Box::from_raw( - Box::into_raw(fut) as *mut (dyn Future + Send + 'static) - )) + ManuallyDrop::new(Box::from_raw(std::mem::transmute::< + *mut (dyn Future + Send + '_), + *mut (dyn Future + Send + 'static), + >(Box::into_raw(fut)))) }; let _ = self.spawn_tx.send(fut);