Skip to content

Commit 8d777cd

Browse files
committed
Apply suggestions from review
1 parent f69fab5 commit 8d777cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/liballoc/boxed.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<T: ?Sized, A: AllocRef> Box<T, A> {
594594
/// Behaves like [`into_raw`] but also returns the allocator
595595
///
596596
/// [`into_raw`]: #method.into_raw
597-
#[stable(feature = "box_raw", since = "1.4.0")]
597+
#[unstable(feature = "allocator_api", issue = "32838")]
598598
#[inline]
599599
pub fn into_raw_with_alloc(b: Self) -> (*mut T, A) {
600600
let (leaked, alloc) = Box::into_unique_with_alloc(b);
@@ -659,6 +659,11 @@ impl<T: ?Sized, A: AllocRef> Box<T, A> {
659659
#[inline]
660660
#[doc(hidden)]
661661
pub fn into_unique_with_alloc(b: Self) -> (Unique<T>, A) {
662+
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
663+
// raw pointer for the type system. Turning it directly into a raw pointer would not be
664+
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
665+
// so all raw pointer methods go through `leak` which creates a (unique)
666+
// mutable reference. Turning *that* to a raw pointer behaves correctly.
662667
let (leaked, alloc) = Box::leak_with_alloc(b);
663668
(leaked.into(), alloc)
664669
}

0 commit comments

Comments
 (0)