File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -269,7 +269,7 @@ impl<T: ?Sized> Box<T> {
269
269
#[ stable( feature = "box_raw" , since = "1.4.0" ) ]
270
270
#[ inline]
271
271
pub unsafe fn from_raw ( raw : * mut T ) -> Self {
272
- mem :: transmute ( raw)
272
+ Box ( Unique :: new_unchecked ( raw) )
273
273
}
274
274
275
275
/// Consumes the `Box`, returning the wrapped raw pointer.
@@ -295,7 +295,7 @@ impl<T: ?Sized> Box<T> {
295
295
#[ stable( feature = "box_raw" , since = "1.4.0" ) ]
296
296
#[ inline]
297
297
pub fn into_raw ( b : Box < T > ) -> * mut T {
298
- unsafe { mem :: transmute ( b) }
298
+ Box :: into_unique ( b) . as_ptr ( )
299
299
}
300
300
301
301
/// Consumes the `Box`, returning the wrapped pointer as `Unique<T>`.
@@ -326,7 +326,9 @@ impl<T: ?Sized> Box<T> {
326
326
issue = "27730" ) ]
327
327
#[ inline]
328
328
pub fn into_unique ( b : Box < T > ) -> Unique < T > {
329
- unsafe { mem:: transmute ( b) }
329
+ let u = b. 0 ;
330
+ mem:: forget ( b) ;
331
+ u
330
332
}
331
333
}
332
334
You can’t perform that action at this time.
0 commit comments