File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1150,8 +1150,11 @@ impl<T: ?Sized> Box<T> {
1150
1150
#[ stable( feature = "box_raw" , since = "1.4.0" ) ]
1151
1151
#[ inline]
1152
1152
pub fn into_raw ( b : Self ) -> * mut T {
1153
- // Make sure Miri realizes that we transition from a noalias pointer to a raw pointer here.
1154
- unsafe { & raw mut * & mut * Self :: into_raw_with_allocator ( b) . 0 }
1153
+ // Avoid `into_raw_with_allocator` as that interacts poorly with Miri's Stacked Borrows.
1154
+ let mut b = mem:: ManuallyDrop :: new ( b) ;
1155
+ // We go through the built-in deref for `Box`, which is crucial for Miri to recognize this
1156
+ // operation for it's alias tracking.
1157
+ & raw mut * * b
1155
1158
}
1156
1159
1157
1160
/// Consumes the `Box`, returning a wrapped `NonNull` pointer.
You can’t perform that action at this time.
0 commit comments