Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/elaborate_box_derefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {

let ptr_local = self.patch.new_temp(ptr_ty, source_info.span);

// Project to the first field (a `Unique`), then transmute that. We could project one
// Project to the first field (a `BoxRaw`), then transmute that. We could project one
// further but in the end we'd hit a pattern type so we'd always have to transmute.
let field_place =
Place::from(place.local).project_to_field(FieldIdx::ZERO, &*self.local_decls, tcx);
Expand Down
88 changes: 79 additions & 9 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ use core::error::{self, Error};
use core::fmt;
use core::future::Future;
use core::hash::{Hash, Hasher};
use core::marker::{Tuple, Unsize};
use core::marker::{PhantomData, Tuple, Unsize};
#[cfg(not(no_global_oom_handling))]
use core::mem::MaybeUninit;
use core::mem::{self, SizedTypeProperties};
Expand All @@ -201,7 +201,7 @@ use core::ops::{
#[cfg(not(no_global_oom_handling))]
use core::ops::{Residual, Try};
use core::pin::{Pin, PinSafePointer};
use core::ptr::{self, NonNull, Unique};
use core::ptr::{self, NonNull};
use core::task::{Context, Poll};

#[cfg(not(no_global_oom_handling))]
Expand All @@ -223,6 +223,71 @@ pub use iter::BoxedArrayIntoIter;
#[unstable(feature = "thin_box", issue = "92791")]
pub use thin::ThinBox;

/// An internal wrapper for the pointer + `PhantomData` inside a `Box`.
/// This type has no semantic meaning. It only exists because the layout of
/// `Box` is hard-coded into the compiler, and because moving the
/// auto trait impls to `Box` would cause regressions (#162850).
#[repr(transparent)]
struct BoxRaw<T: ?Sized> {
pointer: NonNull<T>,
_marker: PhantomData<T>,
}

unsafe impl<T: ?Sized + Send> Send for BoxRaw<T> {}
unsafe impl<T: ?Sized + Sync> Sync for BoxRaw<T> {}
impl<T: ?Sized + core::panic::UnwindSafe> core::panic::UnwindSafe for BoxRaw<T> {}
impl<T: ?Sized, U: ?Sized> CoerceUnsized<BoxRaw<U>> for BoxRaw<T> where T: Unsize<U> {}
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<BoxRaw<U>> for BoxRaw<T> where T: Unsize<U> {}
Comment thread
maxdexh marked this conversation as resolved.

impl<T: ?Sized> BoxRaw<T> {
/// # Safety
/// `ptr` must be non-null
#[inline]
const unsafe fn new_unchecked(ptr: *mut T) -> Self {
// SAFETY: Upheld by the caller
unsafe { BoxRaw { pointer: NonNull::new_unchecked(ptr), _marker: PhantomData } }
}

#[inline]
const fn cast<U>(self) -> BoxRaw<U> {
BoxRaw { pointer: self.pointer.cast(), _marker: PhantomData }
}

#[inline]
const fn as_non_null_ptr(self) -> NonNull<T> {
self.pointer
}

#[inline]
const fn as_ptr(self) -> *mut T {
self.pointer.as_ptr()
}

#[inline]
#[cfg(not(no_global_oom_handling))]
const fn dangling() -> Self
where
T: Sized,
{
BoxRaw { pointer: NonNull::dangling(), _marker: PhantomData }
}
}

impl<T: ?Sized> Clone for BoxRaw<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T: ?Sized> Copy for BoxRaw<T> {}

#[expect(ineffective_unstable_trait_impl, reason = "See #164109")]
#[unstable(feature = "box_internals", issue = "none")]
impl<T: ?Sized> From<BoxRaw<T>> for NonNull<T> {
fn from(value: BoxRaw<T>) -> Self {
value.as_non_null_ptr()
}
}
Comment on lines +283 to +289

@mejrs mejrs Oct 10, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is just me missing something (haven't read all the linked discussion) but I don't understand why this implementation needs to exist. It is easier to just use as_non_null_ptr in Box's drop impl.

View changes since the review

@maxdexh maxdexh Oct 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We found that this code is so sensitive to minimal changes that Hanna suggested I just copy the structure of the code 1-to-1. This can be changed in a follow-up

@hanna-kruppe hanna-kruppe Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This impl and a bunch of other API surface on BoxRaw isn't expected to remain for long. But doing that kind of cleanup at the same time as the main point of this PR caused more & less obvious test diffs as well as more rustc-perf effects. So I suggested landing this like this first (which might take a while too -- I would be surprised if this lands cleanly on first try), and do the cleanup in one or several follow up PRs.

edit: too slow :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did use as_non_null_ptr before this comment: #162849 (review)

@maxdexh maxdexh Oct 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My next 2 PRs, which I'll write in parallel, will be to remove BoxRaw (flattening the fields of Box) and Unique. The former will be pretty invasive (and might end up just not working reasonably well), so yay


/// A pointer type that uniquely owns a heap allocation of type `T`.
///
/// See the [module-level documentation](../../std/boxed/index.html) for more.
Expand All @@ -236,7 +301,7 @@ pub use thin::ThinBox;
pub struct Box<
T: ?Sized,
#[stable(feature = "allocator_api", since = "1.100.0")] A: Allocator = Global,
>(Unique<T>, A);
>(BoxRaw<T>, A);

/// Monomorphic function for allocating an uninit `Box`.
#[inline]
Expand Down Expand Up @@ -1566,7 +1631,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
#[inline]
pub unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self {
// SAFETY: Upheld by caller.
Box(unsafe { Unique::new_unchecked(raw) }, alloc)
Box(unsafe { BoxRaw::new_unchecked(raw) }, alloc)
}

/// Constructs a box from a `NonNull` pointer in the given allocator.
Expand Down Expand Up @@ -2024,7 +2089,9 @@ impl<T> Default for Box<[T]> {
/// Creates an empty `[T]` inside a `Box`.
#[inline]
fn default() -> Self {
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
let ptr: BoxRaw<[T]> = BoxRaw::<[T; 0]>::dangling();
// SAFETY: `[T; 0]` is a ZST, for which `dangling` is valid to turn into a `Box`,
// even after unsize coercion.
Box(ptr, Global)
}
}
Expand All @@ -2034,10 +2101,13 @@ impl<T> Default for Box<[T]> {
impl Default for Box<str> {
#[inline]
fn default() -> Self {
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
let ptr: Unique<str> = unsafe {
let bytes: Unique<[u8]> = Unique::<[u8; 0]>::dangling();
Unique::new_unchecked(bytes.as_ptr() as *mut str)
// SAFETY:
// - `[u8; 0]` is a ZST, for which `dangling` is valid to turn into a `Box`
// - Casting `[u8]` to `str` is correct
// - The empty byte slice is valid UTF-8
let ptr: BoxRaw<str> = unsafe {
let bytes: BoxRaw<[u8]> = BoxRaw::<[u8; 0]>::dangling();
BoxRaw::new_unchecked(bytes.as_ptr() as *mut str)
};
Box(ptr, Global)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
LL | Box(unsafe { BoxRaw::new_unchecked(raw) }, alloc)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
LL | Box(unsafe { BoxRaw::new_unchecked(raw) }, alloc)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
+ }
+
+ bb22: {
+ _14 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
+ _14 = copy ((_1.0: std::boxed::BoxRaw<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
+ goto -> bb21;
+ }
+
Expand All @@ -175,7 +175,7 @@
+ }
+
+ bb28 (cleanup): {
+ _17 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
+ _17 = copy ((_1.0: std::boxed::BoxRaw<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
+ goto -> bb27;
+ }
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
+ }
+
+ bb13: {
+ _10 = copy ((_2.0: std::ptr::Unique<std::string::String>).0: std::ptr::NonNull<std::string::String>) as *const std::string::String (Transmute);
+ _10 = copy ((_2.0: std::boxed::BoxRaw<std::string::String>).0: std::ptr::NonNull<std::string::String>) as *const std::string::String (Transmute);
+ goto -> bb10;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/box_partial_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fn maybe_move(cond: bool, thing: Box<String>) -> Option<String> {
// CHECK-LABEL: fn maybe_move(
// CHECK: let mut [[PTR:_[0-9]+]]: *const std::string::String;
// CHECK: [[PTR]] = copy ((_2.0: std::ptr::Unique<std::string::String>).0: std::ptr::NonNull<std::string::String>) as *const std::string::String (Transmute);
// CHECK: [[PTR]] = copy ((_2.0: std::boxed::BoxRaw<std::string::String>).0: std::ptr::NonNull<std::string::String>) as *const std::string::String (Transmute);
// CHECK: drop((*[[PTR]]))
if cond { Some(*thing) } else { None }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
bb0: {
StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
- _2 = copy (_1.0: std::ptr::Unique<Never>) as *const Never (BoxDerefTransmute);
+ _1 = const Box::<Never>(std::ptr::Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const std::ptr::Unique::<Never> {{ pointer: std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: std::marker::PhantomData::<Never> }} as *const Never (BoxDerefTransmute);
- _2 = copy (_1.0: std::boxed::BoxRaw<Never>) as *const Never (BoxDerefTransmute);
+ _1 = const Box::<Never>(boxed::BoxRaw::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const std::boxed::BoxRaw::<Never> {{ pointer: std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: std::marker::PhantomData::<Never> }} as *const Never (BoxDerefTransmute);
unreachable;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
bb0: {
StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
- _2 = copy (_1.0: std::ptr::Unique<Never>) as *const Never (BoxDerefTransmute);
+ _1 = const Box::<Never>(std::ptr::Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const std::ptr::Unique::<Never> {{ pointer: std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: std::marker::PhantomData::<Never> }} as *const Never (BoxDerefTransmute);
- _2 = copy (_1.0: std::boxed::BoxRaw<Never>) as *const Never (BoxDerefTransmute);
+ _1 = const Box::<Never>(boxed::BoxRaw::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const std::boxed::BoxRaw::<Never> {{ pointer: std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: std::marker::PhantomData::<Never> }} as *const Never (BoxDerefTransmute);
unreachable;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIR for `build::{closure#0}` after built

| User Type Annotations
| 0: user_ty: Canonical { value: TypeOf(Box<^c_0>::new_uninit at <impl boxed::<{impl#0}> for Box<^c_1, ^c_2>>), max_universe: U0, var_kinds: [Ty { ui: U0, sub_root: 0 }, Ty { ui: U0, sub_root: 1 }, Ty { ui: U0, sub_root: 2 }] }, span: $SRC_DIR/alloc/src/macros.rs:LL:COL, inferred_ty: fn() -> std::boxed::Box<std::mem::MaybeUninit<[std::string::String; 5]>> {std::boxed::Box::<[std::string::String; 5]>::new_uninit}
| 0: user_ty: Canonical { value: TypeOf(Box<^c_0>::new_uninit at <impl boxed::<{impl#9}> for Box<^c_1, ^c_2>>), max_universe: U0, var_kinds: [Ty { ui: U0, sub_root: 0 }, Ty { ui: U0, sub_root: 1 }, Ty { ui: U0, sub_root: 2 }] }, span: $SRC_DIR/alloc/src/macros.rs:LL:COL, inferred_ty: fn() -> std::boxed::Box<std::mem::MaybeUninit<[std::string::String; 5]>> {std::boxed::Box::<[std::string::String; 5]>::new_uninit}
|
fn build::{closure#0}(_1: {async fn body of build()}, _2: std::future::ResumeTy) -> Vec<String>
yields ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
debug a => _1;
}
scope 2 (inlined <Box<[bool]> as Default>::default) {
let _3: std::ptr::Unique<[bool]>;
let mut _4: std::ptr::Unique<[bool; 0]>;
let _3: std::boxed::BoxRaw<[bool]>;
let mut _4: std::boxed::BoxRaw<[bool; 0]>;
scope 3 {
}
scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) {
scope 4 (inlined boxed::BoxRaw::<[bool; 0]>::dangling) {
let mut _5: std::ptr::NonNull<[bool; 0]>;
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
scope 6 {
Expand All @@ -35,13 +35,13 @@
StorageLive(_4);
StorageLive(_5);
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
_4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
_4 = const boxed::BoxRaw::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
StorageDead(_5);
_3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
_3 = const boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
StorageDead(_4);
_2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
_2 = const Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
StorageDead(_3);
_1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
_1 = const A {{ foo: Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
StorageDead(_2);
_0 = const ();
drop(_1) -> [return: bb1, unwind unreachable];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
debug a => _1;
}
scope 2 (inlined <Box<[bool]> as Default>::default) {
let _3: std::ptr::Unique<[bool]>;
let mut _4: std::ptr::Unique<[bool; 0]>;
let _3: std::boxed::BoxRaw<[bool]>;
let mut _4: std::boxed::BoxRaw<[bool; 0]>;
scope 3 {
}
scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) {
scope 4 (inlined boxed::BoxRaw::<[bool; 0]>::dangling) {
let mut _5: std::ptr::NonNull<[bool; 0]>;
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
scope 6 {
Expand All @@ -35,13 +35,13 @@
StorageLive(_4);
StorageLive(_5);
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
_4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
_4 = const boxed::BoxRaw::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
StorageDead(_5);
_3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
_3 = const boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
StorageDead(_4);
_2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
_2 = const Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
StorageDead(_3);
_1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
_1 = const A {{ foo: Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
StorageDead(_2);
_0 = const ();
drop(_1) -> [return: bb1, unwind: bb2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
debug a => _1;
}
scope 2 (inlined <Box<[bool]> as Default>::default) {
let _3: std::ptr::Unique<[bool]>;
let mut _4: std::ptr::Unique<[bool; 0]>;
let _3: std::boxed::BoxRaw<[bool]>;
let mut _4: std::boxed::BoxRaw<[bool; 0]>;
scope 3 {
}
scope 4 (inlined std::ptr::Unique::<[bool; 0]>::dangling) {
scope 4 (inlined boxed::BoxRaw::<[bool; 0]>::dangling) {
let mut _5: std::ptr::NonNull<[bool; 0]>;
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
scope 6 {
Expand All @@ -35,13 +35,13 @@
StorageLive(_4);
StorageLive(_5);
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
_4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
_4 = const boxed::BoxRaw::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
StorageDead(_5);
_3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
_3 = const boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }};
StorageDead(_4);
_2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
_2 = const Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
StorageDead(_3);
_1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
_1 = const A {{ foo: Box::<[bool]>(boxed::BoxRaw::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: pattern_type!(*const [bool] is !null) }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
StorageDead(_2);
_0 = const ();
drop(_1) -> [return: bb1, unwind unreachable];
Expand Down
Loading
Loading