File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -253,15 +253,15 @@ impl<T: ?Sized> Box<T> {
253
253
#[ unstable( feature = "ptr_internals" , issue = "0" , reason = "use into_raw_non_null instead" ) ]
254
254
#[ inline]
255
255
#[ doc( hidden) ]
256
- pub fn into_unique ( mut b : Box < T > ) -> Unique < T > {
256
+ pub fn into_unique ( b : Box < T > ) -> Unique < T > {
257
+ let mut unique = b. 0 ;
258
+ mem:: forget ( b) ;
257
259
// Box is kind-of a library type, but recognized as a "unique pointer" by
258
260
// Stacked Borrows. This function here corresponds to "reborrowing to
259
261
// a raw pointer", but there is no actual reborrow here -- so
260
262
// without some care, the pointer we are returning here still carries
261
263
// the `Uniq` tag. We round-trip through a mutable reference to avoid that.
262
- let unique = unsafe { b. 0 . as_mut ( ) as * mut T } ;
263
- mem:: forget ( b) ;
264
- unsafe { Unique :: new_unchecked ( unique) }
264
+ unsafe { Unique :: new_unchecked ( unique. as_mut ( ) as * mut T ) }
265
265
}
266
266
267
267
/// Consumes and leaks the `Box`, returning a mutable reference,
You can’t perform that action at this time.
0 commit comments