@@ -224,7 +224,7 @@ mod if_alloc {
224
224
}
225
225
226
226
unsafe fn drop ( ptr : * mut ( dyn Future < Output = T > + ' a ) ) {
227
- drop ( Box :: from_raw ( ptr as * mut F ) )
227
+ drop ( Box :: from_raw ( ptr. cast :: < F > ( ) ) )
228
228
}
229
229
}
230
230
@@ -252,10 +252,9 @@ mod if_alloc {
252
252
where
253
253
F : Future < Output = T > + ' a ,
254
254
{
255
- fn into_raw ( mut self ) -> * mut ( dyn Future < Output = T > + ' a ) {
256
- let ptr = unsafe { self . as_mut ( ) . get_unchecked_mut ( ) as * mut _ } ;
257
- mem:: forget ( self ) ;
258
- ptr
255
+ fn into_raw ( self ) -> * mut ( dyn Future < Output = T > + ' a ) {
256
+ let mut this = mem:: ManuallyDrop :: new ( self ) ;
257
+ unsafe { this. as_mut ( ) . get_unchecked_mut ( ) as * mut _ }
259
258
}
260
259
261
260
unsafe fn drop ( ptr : * mut ( dyn Future < Output = T > + ' a ) ) {
@@ -264,10 +263,9 @@ mod if_alloc {
264
263
}
265
264
266
265
unsafe impl < ' a , T : ' a > UnsafeFutureObj < ' a , T > for Pin < Box < dyn Future < Output = T > + ' a > > {
267
- fn into_raw ( mut self ) -> * mut ( dyn Future < Output = T > + ' a ) {
268
- let ptr = unsafe { self . as_mut ( ) . get_unchecked_mut ( ) as * mut _ } ;
269
- mem:: forget ( self ) ;
270
- ptr
266
+ fn into_raw ( self ) -> * mut ( dyn Future < Output = T > + ' a ) {
267
+ let mut this = mem:: ManuallyDrop :: new ( self ) ;
268
+ unsafe { this. as_mut ( ) . get_unchecked_mut ( ) as * mut _ }
271
269
}
272
270
273
271
unsafe fn drop ( ptr : * mut ( dyn Future < Output = T > + ' a ) ) {
@@ -276,10 +274,9 @@ mod if_alloc {
276
274
}
277
275
278
276
unsafe impl < ' a , T : ' a > UnsafeFutureObj < ' a , T > for Pin < Box < dyn Future < Output = T > + Send + ' a > > {
279
- fn into_raw ( mut self ) -> * mut ( dyn Future < Output = T > + ' a ) {
280
- let ptr = unsafe { self . as_mut ( ) . get_unchecked_mut ( ) as * mut _ } ;
281
- mem:: forget ( self ) ;
282
- ptr
277
+ fn into_raw ( self ) -> * mut ( dyn Future < Output = T > + ' a ) {
278
+ let mut this = mem:: ManuallyDrop :: new ( self ) ;
279
+ unsafe { this. as_mut ( ) . get_unchecked_mut ( ) as * mut _ }
283
280
}
284
281
285
282
unsafe fn drop ( ptr : * mut ( dyn Future < Output = T > + ' a ) ) {
0 commit comments