@@ -155,7 +155,6 @@ use core::error::Error;
155
155
use core:: fmt;
156
156
use core:: future:: Future ;
157
157
use core:: hash:: { Hash , Hasher } ;
158
- use core:: intrinsics:: retag_box_to_raw;
159
158
use core:: iter:: FusedIterator ;
160
159
use core:: marker:: Tuple ;
161
160
use core:: marker:: Unsize ;
@@ -165,7 +164,7 @@ use core::ops::{
165
164
CoerceUnsized , Coroutine , CoroutineState , Deref , DerefMut , DispatchFromDyn , Receiver ,
166
165
} ;
167
166
use core:: pin:: Pin ;
168
- use core:: ptr:: { self , NonNull , Unique } ;
167
+ use core:: ptr:: { self , addr_of_mut , NonNull , Unique } ;
169
168
use core:: task:: { Context , Poll } ;
170
169
171
170
#[ cfg( not( no_global_oom_handling) ) ]
@@ -1111,16 +1110,12 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1111
1110
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1112
1111
#[ inline]
1113
1112
pub fn into_raw_with_allocator ( b : Self ) -> ( * mut T , A ) {
1114
- // This is the transition point from `Box` to raw pointers. For Stacked Borrows, these casts
1115
- // are relevant -- if this is a global allocator Box and we just get the pointer from `b.0`,
1116
- // it will have `Unique` permission, which is not what we want from a raw pointer. We could
1117
- // fix that by going through `&mut`, but then if this is *not* a global allocator Box, we'd
1118
- // be adding uniqueness assertions that we do not want. So for Miri's sake we pass this
1119
- // pointer through an intrinsic for box-to-raw casts, which can do the right thing wrt the
1120
- // aliasing model.
1121
- let b = mem:: ManuallyDrop :: new ( b) ;
1113
+ let mut b = mem:: ManuallyDrop :: new ( b) ;
1114
+ // We carefully get the raw pointer out in a way that Miri's aliasing model understands what
1115
+ // is happening: using the primitive "deref" of `Box`.
1116
+ let ptr = addr_of_mut ! ( * * b) ;
1122
1117
let alloc = unsafe { ptr:: read ( & b. 1 ) } ;
1123
- ( unsafe { retag_box_to_raw :: < T , A > ( b . 0 . as_ptr ( ) ) } , alloc)
1118
+ ( ptr , alloc)
1124
1119
}
1125
1120
1126
1121
#[ unstable(
0 commit comments