@@ -33,8 +33,8 @@ unsafe impl<'a, T: 'static + AsULE + ?Sized> Yokeable<'a> for ZeroVec<'static, T
3333 #[ inline]
3434 unsafe fn make ( from : Self :: Output ) -> Self {
3535 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
36- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
37- mem :: forget ( from) ;
36+ let from = mem :: ManuallyDrop :: new ( from ) ;
37+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
3838 ptr:: read ( ptr)
3939 }
4040 #[ inline]
@@ -61,8 +61,8 @@ unsafe impl<'a, T: 'static + VarULE + ?Sized> Yokeable<'a> for VarZeroVec<'stati
6161 #[ inline]
6262 unsafe fn make ( from : Self :: Output ) -> Self {
6363 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
64- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
65- mem :: forget ( from) ;
64+ let from = mem :: ManuallyDrop :: new ( from ) ;
65+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
6666 ptr:: read ( ptr)
6767 }
6868 #[ inline]
@@ -89,8 +89,8 @@ unsafe impl<'a> Yokeable<'a> for FlexZeroVec<'static> {
8989 #[ inline]
9090 unsafe fn make ( from : Self :: Output ) -> Self {
9191 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
92- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
93- mem :: forget ( from) ;
92+ let from = mem :: ManuallyDrop :: new ( from ) ;
93+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
9494 ptr:: read ( ptr)
9595 }
9696 #[ inline]
@@ -127,16 +127,16 @@ where
127127 unsafe {
128128 // Similar problem as transform(), but we need to use ptr::read since
129129 // the compiler isn't sure of the sizes
130- let ptr : * const Self :: Output = ( & self as * const Self ) . cast ( ) ;
131- mem :: forget ( self ) ;
130+ let this = mem :: ManuallyDrop :: new ( self ) ;
131+ let ptr : * const Self :: Output = ( & * this as * const Self ) . cast ( ) ;
132132 ptr:: read ( ptr)
133133 }
134134 }
135135 #[ inline]
136136 unsafe fn make ( from : Self :: Output ) -> Self {
137137 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
138- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
139- mem :: forget ( from) ;
138+ let from = mem :: ManuallyDrop :: new ( from ) ;
139+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
140140 ptr:: read ( ptr)
141141 }
142142 #[ inline]
@@ -173,16 +173,16 @@ where
173173 unsafe {
174174 // Similar problem as transform(), but we need to use ptr::read since
175175 // the compiler isn't sure of the sizes
176- let ptr : * const Self :: Output = ( & self as * const Self ) . cast ( ) ;
177- mem :: forget ( self ) ;
176+ let this = mem :: ManuallyDrop :: new ( self ) ;
177+ let ptr : * const Self :: Output = ( & * this as * const Self ) . cast ( ) ;
178178 ptr:: read ( ptr)
179179 }
180180 }
181181 #[ inline]
182182 unsafe fn make ( from : Self :: Output ) -> Self {
183183 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
184- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
185- mem :: forget ( from) ;
184+ let from = mem :: ManuallyDrop :: new ( from ) ;
185+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
186186 ptr:: read ( ptr)
187187 }
188188 #[ inline]
@@ -221,16 +221,16 @@ where
221221 unsafe {
222222 // Similar problem as transform(), but we need to use ptr::read since
223223 // the compiler isn't sure of the sizes
224- let ptr : * const Self :: Output = ( & self as * const Self ) . cast ( ) ;
225- mem :: forget ( self ) ;
224+ let this = mem :: ManuallyDrop :: new ( self ) ;
225+ let ptr : * const Self :: Output = ( & * this as * const Self ) . cast ( ) ;
226226 ptr:: read ( ptr)
227227 }
228228 }
229229 #[ inline]
230230 unsafe fn make ( from : Self :: Output ) -> Self {
231231 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
232- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
233- mem :: forget ( from) ;
232+ let from = mem :: ManuallyDrop :: new ( from ) ;
233+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
234234 ptr:: read ( ptr)
235235 }
236236 #[ inline]
@@ -269,16 +269,16 @@ where
269269 unsafe {
270270 // Similar problem as transform(), but we need to use ptr::read since
271271 // the compiler isn't sure of the sizes
272- let ptr : * const Self :: Output = ( & self as * const Self ) . cast ( ) ;
273- mem :: forget ( self ) ;
272+ let this = mem :: ManuallyDrop :: new ( self ) ;
273+ let ptr : * const Self :: Output = ( & * this as * const Self ) . cast ( ) ;
274274 ptr:: read ( ptr)
275275 }
276276 }
277277 #[ inline]
278278 unsafe fn make ( from : Self :: Output ) -> Self {
279279 debug_assert ! ( mem:: size_of:: <Self :: Output >( ) == mem:: size_of:: <Self >( ) ) ;
280- let ptr : * const Self = ( & from as * const Self :: Output ) . cast ( ) ;
281- mem :: forget ( from) ;
280+ let from = mem :: ManuallyDrop :: new ( from ) ;
281+ let ptr : * const Self = ( & * from as * const Self :: Output ) . cast ( ) ;
282282 ptr:: read ( ptr)
283283 }
284284 #[ inline]
0 commit comments