From 241cd7eeede225d08b3828a7df79f805894bd68d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 May 2025 14:35:25 +0000 Subject: [PATCH] Prepare NonNull for pattern types --- library/core/src/ptr/non_null.rs | 25 +- tests/codegen-llvm/loads.rs | 2 +- .../item-collection/opaque-return-impls.rs | 1 + ...n.DataflowConstProp.32bit.panic-abort.diff | 12 - ....DataflowConstProp.32bit.panic-unwind.diff | 12 - ...n.DataflowConstProp.64bit.panic-abort.diff | 12 - ....DataflowConstProp.64bit.panic-unwind.diff | 12 - ...oxed_slice.main.GVN.32bit.panic-abort.diff | 17 +- ...xed_slice.main.GVN.32bit.panic-unwind.diff | 17 +- ...oxed_slice.main.GVN.64bit.panic-abort.diff | 17 +- ...xed_slice.main.GVN.64bit.panic-unwind.diff | 17 +- .../gvn_ptr_eq_with_constant.main.GVN.diff | 14 +- ...rop_bytes.PreCodegen.after.panic-abort.mir | 4 +- ...op_bytes.PreCodegen.after.panic-unwind.mir | 4 +- ...p_generic.PreCodegen.after.panic-abort.mir | 14 +- ..._generic.PreCodegen.after.panic-unwind.mir | 14 +- ...ace.PreCodegen.after.32bit.panic-abort.mir | 18 +- ...ce.PreCodegen.after.32bit.panic-unwind.mir | 18 +- ...ace.PreCodegen.after.64bit.panic-abort.mir | 18 +- ...ce.PreCodegen.after.64bit.panic-unwind.mir | 18 +- .../loops.vec_move.PreCodegen.after.mir | 132 ++++----- ...ated_loop.PreCodegen.after.panic-abort.mir | 255 +++++++++-------- ...ted_loop.PreCodegen.after.panic-unwind.mir | 120 ++++---- ...ward_loop.PreCodegen.after.panic-abort.mir | 183 ++++++------ ...ard_loop.PreCodegen.after.panic-unwind.mir | 183 ++++++------ ...erse_loop.PreCodegen.after.panic-abort.mir | 268 +++++++++--------- ...rse_loop.PreCodegen.after.panic-unwind.mir | 268 +++++++++--------- ...next_back.PreCodegen.after.panic-abort.mir | 8 +- ...ext_back.PreCodegen.after.panic-unwind.mir | 8 +- ...iter_next.PreCodegen.after.panic-abort.mir | 52 ++-- ...ter_next.PreCodegen.after.panic-unwind.mir | 52 ++-- 31 files changed, 871 insertions(+), 924 deletions(-) diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 7b9e638289bf0..8be7d3a9ae925 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1,7 +1,7 @@ use crate::clone::TrivialClone; use crate::cmp::Ordering; use crate::marker::{Destruct, PointeeSized, Unsize}; -use crate::mem::{MaybeUninit, SizedTypeProperties}; +use crate::mem::{MaybeUninit, SizedTypeProperties, transmute}; use crate::num::NonZero; use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::pin::PinCoerceUnsized; @@ -100,9 +100,8 @@ impl NonNull { #[must_use] #[inline] pub const fn without_provenance(addr: NonZero) -> Self { - let pointer = crate::ptr::without_provenance(addr.get()); - // SAFETY: we know `addr` is non-zero. - unsafe { NonNull { pointer } } + // SAFETY: we know `addr` is non-zero and all nonzero integers are valid raw pointers. + unsafe { transmute(addr) } } /// Creates a new `NonNull` that is dangling, but well-aligned. @@ -239,7 +238,7 @@ impl NonNull { "NonNull::new_unchecked requires that the pointer is non-null", (ptr: *mut () = ptr as *mut ()) => !ptr.is_null() ); - NonNull { pointer: ptr as _ } + transmute(ptr) } } @@ -282,7 +281,7 @@ impl NonNull { #[inline] pub const fn from_ref(r: &T) -> Self { // SAFETY: A reference cannot be null. - unsafe { NonNull { pointer: r as *const T } } + unsafe { transmute(r as *const T) } } /// Converts a mutable reference to a `NonNull` pointer. @@ -291,7 +290,7 @@ impl NonNull { #[inline] pub const fn from_mut(r: &mut T) -> Self { // SAFETY: A mutable reference cannot be null. - unsafe { NonNull { pointer: r as *mut T } } + unsafe { transmute(r as *mut T) } } /// Performs the same functionality as [`std::ptr::from_raw_parts`], except that a @@ -502,7 +501,7 @@ impl NonNull { #[inline] pub const fn cast(self) -> NonNull { // SAFETY: `self` is a `NonNull` pointer which is necessarily non-null - unsafe { NonNull { pointer: self.as_ptr() as *mut U } } + unsafe { transmute(self.as_ptr() as *mut U) } } /// Try to cast to a pointer of another type by checking alignment. @@ -581,7 +580,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } + unsafe { transmute(intrinsics::offset(self.as_ptr(), count)) } } /// Calculates the offset from a pointer in bytes. @@ -605,7 +604,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: self.as_ptr().byte_offset(count) } } + unsafe { transmute(self.as_ptr().byte_offset(count)) } } /// Adds an offset to a pointer (convenience for `.offset(count as isize)`). @@ -657,7 +656,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } + unsafe { transmute(intrinsics::offset(self.as_ptr(), count)) } } /// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`). @@ -681,7 +680,7 @@ impl NonNull { // Additionally safety contract of `add` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.as_ptr().byte_add(count) } } + unsafe { transmute(self.as_ptr().byte_add(count)) } } /// Subtracts an offset from a pointer (convenience for @@ -763,7 +762,7 @@ impl NonNull { // Additionally safety contract of `sub` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.as_ptr().byte_sub(count) } } + unsafe { transmute(self.as_ptr().byte_sub(count)) } } /// Calculates the distance between two pointers within the same allocation. The returned value is in diff --git a/tests/codegen-llvm/loads.rs b/tests/codegen-llvm/loads.rs index 88d67642b7250..e19af7a3c2bc1 100644 --- a/tests/codegen-llvm/loads.rs +++ b/tests/codegen-llvm/loads.rs @@ -58,7 +58,7 @@ pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { // CHECK-LABEL: @load_box #[no_mangle] pub fn load_box<'a>(x: Box>) -> Box { - // CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !noundef !{{[0-9]+}} *x } diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 1c32ddf6254b5..484fbe7fe62f1 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -86,3 +86,4 @@ pub fn foo3() -> Box> { //~ MONO_ITEM fn std::boxed::Box::::new //~ MONO_ITEM fn Counter::new //~ MONO_ITEM fn std::fmt::Arguments::<'_>::from_str +//~ MONO_ITEM fn std::boxed::box_new_uninit diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 5a3342a45cd3d..91a275ee53f5f 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,10 +34,7 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 2d1b05e6e9875..68b2dcc78dc85 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,10 +34,7 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 695a06e29d3d7..3fc9369800a75 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,10 +34,7 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 17714feb1432e..0d59a279ef1c0 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,10 +34,7 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 308f19ea759dd..743cd95e46469 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,13 +34,9 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); +- _5 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as std::ptr::NonNull<[bool; 0]> (Transmute); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 819ad6054df80..fa6a636d63cf7 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,13 +34,9 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); +- _5 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as std::ptr::NonNull<[bool; 0]> (Transmute); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 7029e02a857ac..556453f873f62 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,13 +34,9 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); +- _5 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as std::ptr::NonNull<[bool; 0]> (Transmute); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 23a134f3666bb..9a025eb85e058 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -20,15 +20,6 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; - scope 10 { - } - scope 11 (inlined NonZero::::get) { - } - scope 12 (inlined std::ptr::without_provenance::<[bool; 0]>) { - scope 13 (inlined without_provenance_mut::<[bool; 0]>) { - } - } } } scope 7 (inlined std::ptr::Alignment::of::<[bool; 0]>) { @@ -43,13 +34,9 @@ StorageLive(_3); StorageLive(_4); StorageLive(_5); - StorageLive(_6); -- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _6 }; -+ _6 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; - StorageDead(_6); +- _5 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as std::ptr::NonNull<[bool; 0]> (Transmute); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); diff --git a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff index 23889b266e4ad..86d48e6dca64e 100644 --- a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff +++ b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff @@ -12,27 +12,19 @@ scope 5 (inlined std::ptr::Alignment::as_nonzero) { } scope 6 (inlined NonNull::::without_provenance) { - scope 7 { - } - scope 8 (inlined NonZero::::get) { - } - scope 9 (inlined std::ptr::without_provenance::) { - scope 10 (inlined without_provenance_mut::) { - } - } } } scope 4 (inlined std::ptr::Alignment::of::) { } } - scope 11 (inlined NonNull::::as_ptr) { + scope 7 (inlined NonNull::::as_ptr) { } } - scope 12 (inlined Foo::::cmp_ptr) { + scope 8 (inlined Foo::::cmp_ptr) { let mut _4: *const u8; let mut _5: *mut u8; let mut _6: *const u8; - scope 13 (inlined std::ptr::eq::) { + scope 9 (inlined std::ptr::eq::) { } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-abort.mir index 4b5ed1d223822..ca548be1362d0 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-abort.mir @@ -13,6 +13,7 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { } scope 18 (inlined std::ptr::Unique::<[u8; 1024]>::cast::) { scope 19 (inlined NonNull::<[u8; 1024]>::cast::) { + let mut _3: *mut u8; scope 20 (inlined NonNull::<[u8; 1024]>::as_ptr) { } } @@ -24,7 +25,6 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _3: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -69,13 +69,11 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique<[u8; 1024]>).0: std::ptr::NonNull<[u8; 1024]>); - StorageLive(_3); _3 = copy _2 as *mut u8 (Transmute); _4 = alloc::alloc::__rust_dealloc(move _3, const 1024_usize, const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-unwind.mir index 4b5ed1d223822..ca548be1362d0 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.PreCodegen.after.panic-unwind.mir @@ -13,6 +13,7 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { } scope 18 (inlined std::ptr::Unique::<[u8; 1024]>::cast::) { scope 19 (inlined NonNull::<[u8; 1024]>::cast::) { + let mut _3: *mut u8; scope 20 (inlined NonNull::<[u8; 1024]>::as_ptr) { } } @@ -24,7 +25,6 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _3: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -69,13 +69,11 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique<[u8; 1024]>).0: std::ptr::NonNull<[u8; 1024]>); - StorageLive(_3); _3 = copy _2 as *mut u8 (Transmute); _4 = alloc::alloc::__rust_dealloc(move _3, const 1024_usize, const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir index fcb804cdbfd89..a85adbd90b45e 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir @@ -13,6 +13,7 @@ fn drop_generic(_1: *mut Box) -> () { } scope 18 (inlined std::ptr::Unique::::cast::) { scope 19 (inlined NonNull::::cast::) { + let mut _4: *mut u8; scope 20 (inlined NonNull::::as_ptr) { } } @@ -24,7 +25,6 @@ fn drop_generic(_1: *mut Box) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _4: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -71,25 +71,19 @@ fn drop_generic(_1: *mut Box) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique).0: std::ptr::NonNull); _3 = const ::ALIGN as std::ptr::Alignment (Transmute); - switchInt(const ::SIZE) -> [0: bb4, otherwise: bb1]; + switchInt(const ::SIZE) -> [0: bb3, otherwise: bb1]; } bb1: { - switchInt(const ::SIZE) -> [0: bb4, otherwise: bb2]; + _4 = copy _2 as *mut u8 (Transmute); + switchInt(const ::SIZE) -> [0: bb3, otherwise: bb2]; } bb2: { - StorageLive(_4); - _4 = copy _2 as *mut u8 (Transmute); _5 = alloc::alloc::__rust_dealloc(move _4, const ::SIZE, move _3) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_4); - goto -> bb4; - } - - bb4: { return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir index fcb804cdbfd89..a85adbd90b45e 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir @@ -13,6 +13,7 @@ fn drop_generic(_1: *mut Box) -> () { } scope 18 (inlined std::ptr::Unique::::cast::) { scope 19 (inlined NonNull::::cast::) { + let mut _4: *mut u8; scope 20 (inlined NonNull::::as_ptr) { } } @@ -24,7 +25,6 @@ fn drop_generic(_1: *mut Box) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _4: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -71,25 +71,19 @@ fn drop_generic(_1: *mut Box) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique).0: std::ptr::NonNull); _3 = const ::ALIGN as std::ptr::Alignment (Transmute); - switchInt(const ::SIZE) -> [0: bb4, otherwise: bb1]; + switchInt(const ::SIZE) -> [0: bb3, otherwise: bb1]; } bb1: { - switchInt(const ::SIZE) -> [0: bb4, otherwise: bb2]; + _4 = copy _2 as *mut u8 (Transmute); + switchInt(const ::SIZE) -> [0: bb3, otherwise: bb2]; } bb2: { - StorageLive(_4); - _4 = copy _2 as *mut u8 (Transmute); _5 = alloc::alloc::__rust_dealloc(move _4, const ::SIZE, move _3) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_4); - goto -> bb4; - } - - bb4: { return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir index f4794a974bf22..9a734a90d0d1f 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir @@ -8,13 +8,15 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _8: (); + let _10: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { + let mut _8: std::ptr::NonNull; scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _7: *mut u8; scope 20 (inlined NonNull::<[T]>::as_ptr) { } } @@ -26,7 +28,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _7: *mut u8; + let mut _9: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -72,6 +74,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_8); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -89,16 +93,22 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_7); _7 = copy _3 as *mut u8 (PtrToPtr); - _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); + StorageLive(_9); + _9 = copy _8 as *mut u8 (Transmute); + _10 = alloc::alloc::__rust_dealloc(move _9, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_7); + StorageDead(_9); goto -> bb4; } bb4: { StorageDead(_2); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir index f4794a974bf22..9a734a90d0d1f 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir @@ -8,13 +8,15 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _8: (); + let _10: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { + let mut _8: std::ptr::NonNull; scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _7: *mut u8; scope 20 (inlined NonNull::<[T]>::as_ptr) { } } @@ -26,7 +28,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _7: *mut u8; + let mut _9: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -72,6 +74,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_8); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -89,16 +93,22 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_7); _7 = copy _3 as *mut u8 (PtrToPtr); - _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); + StorageLive(_9); + _9 = copy _8 as *mut u8 (Transmute); + _10 = alloc::alloc::__rust_dealloc(move _9, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_7); + StorageDead(_9); goto -> bb4; } bb4: { StorageDead(_2); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir index f4794a974bf22..9a734a90d0d1f 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir @@ -8,13 +8,15 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _8: (); + let _10: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { + let mut _8: std::ptr::NonNull; scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _7: *mut u8; scope 20 (inlined NonNull::<[T]>::as_ptr) { } } @@ -26,7 +28,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _7: *mut u8; + let mut _9: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -72,6 +74,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_8); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -89,16 +93,22 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_7); _7 = copy _3 as *mut u8 (PtrToPtr); - _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); + StorageLive(_9); + _9 = copy _8 as *mut u8 (Transmute); + _10 = alloc::alloc::__rust_dealloc(move _9, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_7); + StorageDead(_9); goto -> bb4; } bb4: { StorageDead(_2); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir index f4794a974bf22..9a734a90d0d1f 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir @@ -8,13 +8,15 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _8: (); + let _10: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { + let mut _8: std::ptr::NonNull; scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _7: *mut u8; scope 20 (inlined NonNull::<[T]>::as_ptr) { } } @@ -26,7 +28,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _7: *mut u8; + let mut _9: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -72,6 +74,8 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); + StorageLive(_8); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -89,16 +93,22 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_7); _7 = copy _3 as *mut u8 (PtrToPtr); - _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); + StorageLive(_9); + _9 = copy _8 as *mut u8 (Transmute); + _10 = alloc::alloc::__rust_dealloc(move _9, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_7); + StorageDead(_9); goto -> bb4; } bb4: { StorageDead(_2); + StorageDead(_8); + StorageDead(_3); return; } } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index c8b9ff1dbed9c..3aba69bf7fd5f 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -20,10 +20,10 @@ fn vec_move(_1: Vec) -> () { debug self => _1; let _3: std::mem::ManuallyDrop>; let mut _4: *const std::alloc::Global; - let mut _9: usize; - let mut _11: *mut impl Sized; - let mut _12: *const impl Sized; - let mut _13: usize; + let mut _8: usize; + let mut _10: *mut impl Sized; + let mut _11: *const impl Sized; + let mut _12: usize; let _29: &std::vec::Vec; let mut _30: &std::mem::ManuallyDrop>; let mut _31: &alloc::raw_vec::RawVec; @@ -38,14 +38,14 @@ fn vec_move(_1: Vec) -> () { debug me => _3; scope 5 { debug alloc => const ManuallyDrop:: {{ value: MaybeDangling::(std::alloc::Global) }}; - let _7: std::ptr::NonNull; + let _6: std::ptr::NonNull; scope 6 { - debug buf => _7; - let _8: *mut impl Sized; + debug buf => _6; + let _7: *mut impl Sized; scope 7 { - debug begin => _8; + debug begin => _7; scope 8 { - debug end => _12; + debug end => _11; let _20: usize; scope 9 { debug cap => _20; @@ -77,34 +77,35 @@ fn vec_move(_1: Vec) -> () { } scope 31 (inlined Vec::::len) { debug self => _33; - let mut _14: bool; + let mut _13: bool; scope 32 { } } scope 33 (inlined std::ptr::mut_ptr::::wrapping_byte_add) { - debug self => _8; - debug count => _13; - let mut _15: *mut u8; - let mut _19: *mut u8; + debug self => _7; + debug count => _12; + let mut _14: *mut u8; + let mut _18: *mut u8; + let mut _19: *const impl Sized; scope 34 (inlined std::ptr::mut_ptr::::cast::) { - debug self => _8; + debug self => _7; } scope 35 (inlined std::ptr::mut_ptr::::wrapping_add) { - debug self => _15; - debug count => _13; - let mut _16: isize; + debug self => _14; + debug count => _12; + let mut _15: isize; scope 36 (inlined std::ptr::mut_ptr::::wrapping_offset) { - debug self => _15; - debug count => _16; + debug self => _14; + debug count => _15; + let mut _16: *const u8; let mut _17: *const u8; - let mut _18: *const u8; } } scope 37 (inlined std::ptr::mut_ptr::::with_metadata_of::) { - debug self => _19; - debug meta => _6; + debug self => _18; + debug meta => _19; scope 38 (inlined std::ptr::metadata::) { - debug ptr => _6; + debug ptr => _19; } scope 39 (inlined std::ptr::from_raw_parts_mut::) { } @@ -117,17 +118,17 @@ fn vec_move(_1: Vec) -> () { } scope 42 (inlined Vec::::len) { debug self => _35; - let mut _10: bool; + let mut _9: bool; scope 43 { } } scope 44 (inlined #[track_caller] std::ptr::mut_ptr::::add) { - debug self => _8; - debug count => _9; + debug self => _7; + debug count => _8; } } scope 28 (inlined NonNull::::as_ptr) { - debug self => _7; + debug self => _6; } } scope 20 (inlined > as Deref>::deref) { @@ -141,7 +142,6 @@ fn vec_move(_1: Vec) -> () { let mut _5: std::ptr::NonNull; scope 24 (inlined std::ptr::Unique::::cast::) { scope 25 (inlined NonNull::::cast::) { - let mut _6: *const impl Sized; scope 26 (inlined NonNull::::as_ptr) { } } @@ -182,13 +182,12 @@ fn vec_move(_1: Vec) -> () { bb0: { StorageLive(_22); + StorageLive(_6); StorageLive(_7); - StorageLive(_8); - StorageLive(_12); + StorageLive(_11); StorageLive(_20); - StorageLive(_6); StorageLive(_5); - StorageLive(_18); + StorageLive(_17); StorageLive(_3); StorageLive(_2); _2 = MaybeDangling::>(copy _1); @@ -202,56 +201,58 @@ fn vec_move(_1: Vec) -> () { // DBG: _32 = &_3; // DBG: _31 = &(((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec); _5 = copy ((((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); - _6 = copy _5 as *const impl Sized (Transmute); - _7 = NonNull:: { pointer: copy _6 }; - _8 = copy _5 as *mut impl Sized (Transmute); + _6 = copy _5 as std::ptr::NonNull (Transmute); + _7 = copy _5 as *mut impl Sized (Transmute); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_11); - StorageLive(_9); + StorageLive(_10); + StorageLive(_8); // DBG: _36 = &_3; // DBG: _35 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); - _9 = copy (((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).1: usize); - StorageLive(_10); - _10 = Le(copy _9, const ::MAX_SLICE_LEN); - assume(move _10); - StorageDead(_10); - _11 = Offset(copy _8, copy _9); - _12 = copy _11 as *const impl Sized (PtrToPtr); + _8 = copy (((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).1: usize); + StorageLive(_9); + _9 = Le(copy _8, const ::MAX_SLICE_LEN); + assume(move _9); StorageDead(_9); - StorageDead(_11); + _10 = Offset(copy _7, copy _8); + _11 = copy _10 as *const impl Sized (PtrToPtr); + StorageDead(_8); + StorageDead(_10); goto -> bb4; } bb2: { - StorageLive(_13); + StorageLive(_12); // DBG: _34 = &_3; // DBG: _33 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); - _13 = copy (((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).1: usize); + _12 = copy (((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).1: usize); + StorageLive(_13); + _13 = Le(copy _12, const ::MAX_SLICE_LEN); + assume(move _13); + StorageDead(_13); + StorageLive(_18); StorageLive(_14); - _14 = Le(copy _13, const ::MAX_SLICE_LEN); - assume(move _14); - StorageDead(_14); - StorageLive(_19); + _14 = copy _5 as *mut u8 (Transmute); StorageLive(_15); - _15 = copy _5 as *mut u8 (Transmute); + _15 = copy _12 as isize (IntToInt); StorageLive(_16); - _16 = copy _13 as isize (IntToInt); - StorageLive(_17); - _17 = copy _5 as *const u8 (Transmute); - _18 = arith_offset::(move _17, move _16) -> [return: bb3, unwind unreachable]; + _16 = copy _5 as *const u8 (Transmute); + _17 = arith_offset::(move _16, move _15) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_17); - _19 = copy _18 as *mut u8 (PtrToPtr); StorageDead(_16); + _18 = copy _17 as *mut u8 (PtrToPtr); StorageDead(_15); + StorageDead(_14); + StorageLive(_19); + _19 = copy _5 as *const impl Sized (Transmute); StorageDead(_19); - StorageDead(_13); - _12 = copy _18 as *const impl Sized (PtrToPtr); + StorageDead(_18); + StorageDead(_12); + _11 = copy _17 as *const impl Sized (PtrToPtr); goto -> bb4; } @@ -276,15 +277,14 @@ fn vec_move(_1: Vec) -> () { } bb7: { - _22 = std::vec::IntoIter:: { buf: copy _7, phantom: const ZeroSized: PhantomData, cap: move _20, alloc: const ManuallyDrop:: {{ value: MaybeDangling::(std::alloc::Global) }}, ptr: copy _7, end: copy _12 }; + _22 = std::vec::IntoIter:: { buf: copy _6, phantom: const ZeroSized: PhantomData, cap: move _20, alloc: const ManuallyDrop:: {{ value: MaybeDangling::(std::alloc::Global) }}, ptr: copy _6, end: copy _11 }; StorageDead(_3); - StorageDead(_18); + StorageDead(_17); StorageDead(_5); - StorageDead(_6); StorageDead(_20); - StorageDead(_12); - StorageDead(_8); + StorageDead(_11); StorageDead(_7); + StorageDead(_6); StorageLive(_23); _23 = move _22; goto -> bb8; diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index f8898d65133ad..6d3519846023a 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -4,37 +4,37 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _10: usize; - let mut _31: std::option::Option<(usize, &T)>; - let mut _34: &impl Fn(usize, &T); - let mut _35: (usize, &T); - let _36: (); + let mut _12: usize; + let mut _32: std::option::Option<(usize, &T)>; + let mut _35: &impl Fn(usize, &T); + let mut _36: (usize, &T); + let _37: (); scope 1 { - debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; - debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _9; + debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _8; + debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _11; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - debug ((iter: Enumerate>).1: usize) => _10; - let _32: usize; - let _33: &T; + debug ((iter: Enumerate>).1: usize) => _12; + let _33: usize; + let _34: &T; scope 2 { - debug i => _32; - debug x => _33; + debug i => _33; + debug x => _34; } scope 18 (inlined > as Iterator>::next) { - let mut _21: std::option::Option; - let mut _26: std::option::Option<&T>; - let mut _29: (usize, bool); - let mut _30: (usize, &T); + let mut _22: std::option::Option; + let mut _27: std::option::Option<&T>; + let mut _30: (usize, bool); + let mut _31: (usize, &T); scope 19 { - let _28: usize; + let _29: usize; scope 24 { } } scope 20 { scope 21 { scope 27 (inlined as FromResidual>>::from_residual) { - let mut _20: isize; - let mut _22: bool; + let mut _21: isize; + let mut _23: bool; } } } @@ -43,21 +43,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let _27: &T; + let _28: &T; scope 26 { } } scope 28 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _11: std::ptr::NonNull; + let mut _8: std::ptr::NonNull; let _13: std::ptr::NonNull; - let mut _16: bool; - let mut _23: usize; - let _25: &T; + let _15: std::ptr::NonNull; + let mut _18: bool; + let mut _24: usize; + let _26: &T; scope 29 { - let _12: *const T; + let _14: *const T; scope 30 { - let _19: usize; + let _20: usize; scope 31 { scope 34 (inlined #[track_caller] core::num::::unchecked_sub) { scope 35 (inlined core::ub_checks::check_language_ub) { @@ -73,21 +73,20 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 38 (inlined as PartialEq>::eq) { - let mut _14: *mut T; - let mut _15: *mut T; + let mut _16: *mut T; + let mut _17: *mut T; scope 39 (inlined NonNull::::as_ptr) { } scope 40 (inlined NonNull::::as_ptr) { } } scope 41 (inlined NonNull::::add) { - let mut _17: *const T; - let mut _18: *const T; + let mut _19: *mut T; scope 42 (inlined NonNull::::as_ptr) { } } scope 43 (inlined NonNull::::as_ref::<'_>) { - let _24: *const T; + let _25: *const T; scope 44 (inlined NonNull::::as_ptr) { } scope 45 (inlined std::ptr::mut_ptr::::cast_const) { @@ -101,11 +100,12 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -121,7 +121,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -137,89 +138,91 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); StorageDead(_3); - StorageLive(_10); - _10 = const 0_usize; + StorageLive(_12); + _12 = const 0_usize; goto -> bb4; } bb4: { - StorageLive(_31); - StorageLive(_28); + StorageLive(_32); StorageLive(_29); - StorageLive(_26); - StorageLive(_11); - StorageLive(_12); - StorageLive(_19); - StorageLive(_23); + StorageLive(_30); + StorageLive(_27); StorageLive(_13); - StorageLive(_25); - _11 = copy _6; - _12 = copy _9; - switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; - } - - bb5: { - StorageLive(_16); - _13 = copy _12 as std::ptr::NonNull (Transmute); StorageLive(_14); - _14 = copy _11 as *mut T (Transmute); + StorageLive(_20); + StorageLive(_24); StorageLive(_15); - _15 = copy _13 as *mut T (Transmute); - _16 = Eq(copy _14, copy _15); - StorageDead(_15); - StorageDead(_14); - switchInt(move _16) -> [0: bb6, otherwise: bb7]; + StorageLive(_26); + StorageLive(_16); + _13 = copy _8; + _14 = copy _11; + switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; } - bb6: { - StorageDead(_16); + bb5: { StorageLive(_18); + _15 = copy _14 as std::ptr::NonNull (Transmute); + _16 = copy _13 as *mut T (Transmute); StorageLive(_17); - _17 = copy _11 as *const T (Transmute); - _18 = Offset(copy _17, const 1_usize); + _17 = copy _15 as *mut T (Transmute); + _18 = Eq(copy _16, copy _17); StorageDead(_17); - _6 = NonNull:: { pointer: copy _18 }; + switchInt(move _18) -> [0: bb6, otherwise: bb7]; + } + + bb6: { StorageDead(_18); + StorageLive(_19); + _19 = Offset(copy _16, const 1_usize); + _8 = copy _19 as std::ptr::NonNull (Transmute); + StorageDead(_19); goto -> bb13; } bb7: { - StorageDead(_16); + StorageDead(_18); goto -> bb10; } bb8: { - _19 = copy _12 as usize (Transmute); - switchInt(copy _19) -> [0: bb9, otherwise: bb12]; + _20 = copy _14 as usize (Transmute); + switchInt(copy _20) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -227,24 +230,25 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb10: { - StorageDead(_25); - StorageDead(_13); - StorageDead(_23); - StorageDead(_19); - StorageDead(_12); - StorageDead(_11); + StorageDead(_16); StorageDead(_26); - StorageLive(_20); - StorageLive(_22); - _20 = discriminant(_21); - _22 = Eq(copy _20, const 0_isize); - assume(move _22); - StorageDead(_22); + StorageDead(_15); + StorageDead(_24); StorageDead(_20); + StorageDead(_14); + StorageDead(_13); + StorageDead(_27); + StorageLive(_21); + StorageLive(_23); + _21 = discriminant(_22); + _23 = Eq(copy _21, const 0_isize); + assume(move _23); + StorageDead(_23); + StorageDead(_21); + StorageDead(_30); StorageDead(_29); - StorageDead(_28); - StorageDead(_31); - StorageDead(_10); + StorageDead(_32); + StorageDead(_12); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -253,51 +257,52 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12: { - _23 = SubUnchecked(copy _19, const 1_usize); - _9 = copy _23 as *const T (Transmute); + _24 = SubUnchecked(copy _20, const 1_usize); + _11 = copy _24 as *const T (Transmute); goto -> bb13; } bb13: { - StorageLive(_24); - _24 = copy _11 as *const T (Transmute); - _25 = &(*_24); - StorageDead(_24); - _26 = Option::<&T>::Some(copy _25); + StorageLive(_25); + _25 = copy _13 as *const T (Transmute); + _26 = &(*_25); StorageDead(_25); - StorageDead(_13); - StorageDead(_23); - StorageDead(_19); - StorageDead(_12); - StorageDead(_11); - _27 = copy ((_26 as Some).0: &T); + _27 = Option::<&T>::Some(copy _26); + StorageDead(_16); StorageDead(_26); - _28 = copy _10; - _29 = AddWithOverflow(copy _10, const 1_usize); - assert(!move (_29.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _10, const 1_usize) -> [success: bb14, unwind unreachable]; + StorageDead(_15); + StorageDead(_24); + StorageDead(_20); + StorageDead(_14); + StorageDead(_13); + _28 = copy ((_27 as Some).0: &T); + StorageDead(_27); + _29 = copy _12; + _30 = AddWithOverflow(copy _12, const 1_usize); + assert(!move (_30.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _12, const 1_usize) -> [success: bb14, unwind unreachable]; } bb14: { - _10 = move (_29.0: usize); - StorageLive(_30); - _30 = (copy _28, copy _27); - _31 = Option::<(usize, &T)>::Some(move _30); + _12 = move (_30.0: usize); + StorageLive(_31); + _31 = (copy _29, copy _28); + _32 = Option::<(usize, &T)>::Some(move _31); + StorageDead(_31); StorageDead(_30); StorageDead(_29); - StorageDead(_28); - _32 = copy (((_31 as Some).0: (usize, &T)).0: usize); - _33 = copy (((_31 as Some).0: (usize, &T)).1: &T); - StorageLive(_34); - _34 = &_2; + _33 = copy (((_32 as Some).0: (usize, &T)).0: usize); + _34 = copy (((_32 as Some).0: (usize, &T)).1: &T); StorageLive(_35); - _35 = (copy _32, copy _33); - _36 = >::call(move _34, move _35) -> [return: bb15, unwind unreachable]; + _35 = &_2; + StorageLive(_36); + _36 = (copy _33, copy _34); + _37 = >::call(move _35, move _36) -> [return: bb15, unwind unreachable]; } bb15: { + StorageDead(_36); StorageDead(_35); - StorageDead(_34); - StorageDead(_31); + StorageDead(_32); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 28b12cdf36755..13ced6ec9b016 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -4,33 +4,34 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _10: std::slice::Iter<'_, T>; - let mut _11: std::iter::Enumerate>; - let mut _12: std::iter::Enumerate>; - let mut _13: &mut std::iter::Enumerate>; - let mut _14: std::option::Option<(usize, &T)>; - let mut _15: isize; - let mut _18: &impl Fn(usize, &T); - let mut _19: (usize, &T); - let _20: (); + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Enumerate>; + let mut _14: std::iter::Enumerate>; + let mut _15: &mut std::iter::Enumerate>; + let mut _16: std::option::Option<(usize, &T)>; + let mut _17: isize; + let mut _20: &impl Fn(usize, &T); + let mut _21: (usize, &T); + let _22: (); scope 1 { - debug iter => _12; - let _16: usize; - let _17: &T; + debug iter => _14; + let _18: usize; + let _19: &T; scope 2 { - debug i => _16; - debug x => _17; + debug i => _18; + debug x => _19; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -46,7 +47,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -61,61 +63,67 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_12); StorageLive(_3); - StorageLive(_6); - StorageLive(_9); - StorageLive(_4); + StorageLive(_8); + StorageLive(_11); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - _10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_4); - StorageDead(_9); - StorageDead(_6); + _12 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: copy _11, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_11); + StorageDead(_8); StorageDead(_3); - _11 = Enumerate::> { iter: copy _10, count: const 0_usize }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _13 = Enumerate::> { iter: copy _12, count: const 0_usize }; + StorageDead(_12); + StorageLive(_14); + _14 = copy _13; goto -> bb4; } bb4: { - _13 = &mut _12; - _14 = > as Iterator>::next(move _13) -> [return: bb5, unwind: bb11]; + _15 = &mut _14; + _16 = > as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_12); + StorageDead(_14); drop(_2) -> [return: bb7, unwind continue]; } @@ -124,18 +132,18 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _16 = copy (((_14 as Some).0: (usize, &T)).0: usize); - _17 = copy (((_14 as Some).0: (usize, &T)).1: &T); - StorageLive(_18); - _18 = &_2; - StorageLive(_19); - _19 = copy ((_14 as Some).0: (usize, &T)); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind: bb11]; + _18 = copy (((_16 as Some).0: (usize, &T)).0: usize); + _19 = copy (((_16 as Some).0: (usize, &T)).1: &T); + StorageLive(_20); + _20 = &_2; + StorageLive(_21); + _21 = copy ((_16 as Some).0: (usize, &T)); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_19); - StorageDead(_18); + StorageDead(_21); + StorageDead(_20); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index b210efb1f46c2..6e27d02641687 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -4,29 +4,29 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _22: std::option::Option<&T>; - let mut _24: &impl Fn(&T); - let mut _25: (&T,); - let _26: (); + let mut _23: std::option::Option<&T>; + let mut _25: &impl Fn(&T); + let mut _26: (&T,); + let _27: (); scope 1 { - debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; - debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9; + debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _8; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _11; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; + let _24: &T; scope 2 { - debug x => _23; + debug x => _24; } scope 16 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _10: std::ptr::NonNull; + let mut _8: std::ptr::NonNull; let _12: std::ptr::NonNull; - let mut _15: bool; - let mut _19: usize; - let _21: &T; + let _14: std::ptr::NonNull; + let mut _17: bool; + let mut _20: usize; + let _22: &T; scope 17 { - let _11: *const T; + let _13: *const T; scope 18 { - let _18: usize; + let _19: usize; scope 19 { scope 22 (inlined #[track_caller] core::num::::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { @@ -42,21 +42,20 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 26 (inlined as PartialEq>::eq) { - let mut _13: *mut T; - let mut _14: *mut T; + let mut _15: *mut T; + let mut _16: *mut T; scope 27 (inlined NonNull::::as_ptr) { } scope 28 (inlined NonNull::::as_ptr) { } } scope 29 (inlined NonNull::::add) { - let mut _16: *const T; - let mut _17: *const T; + let mut _18: *mut T; scope 30 (inlined NonNull::::as_ptr) { } } scope 31 (inlined NonNull::::as_ref::<'_>) { - let _20: *const T; + let _21: *const T; scope 32 (inlined NonNull::::as_ptr) { } scope 33 (inlined std::ptr::mut_ptr::::cast_const) { @@ -69,11 +68,12 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -89,7 +89,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -101,84 +102,86 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); StorageDead(_3); goto -> bb4; } bb4: { - StorageLive(_22); - StorageLive(_10); - StorageLive(_11); - StorageLive(_18); - StorageLive(_19); + StorageLive(_23); StorageLive(_12); - StorageLive(_21); - _10 = copy _6; - _11 = copy _9; - switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; - } - - bb5: { - StorageLive(_15); - _12 = copy _11 as std::ptr::NonNull (Transmute); StorageLive(_13); - _13 = copy _10 as *mut T (Transmute); + StorageLive(_19); + StorageLive(_20); StorageLive(_14); - _14 = copy _12 as *mut T (Transmute); - _15 = Eq(copy _13, copy _14); - StorageDead(_14); - StorageDead(_13); - switchInt(move _15) -> [0: bb6, otherwise: bb7]; + StorageLive(_22); + StorageLive(_15); + _12 = copy _8; + _13 = copy _11; + switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; } - bb6: { - StorageDead(_15); + bb5: { StorageLive(_17); + _14 = copy _13 as std::ptr::NonNull (Transmute); + _15 = copy _12 as *mut T (Transmute); StorageLive(_16); - _16 = copy _10 as *const T (Transmute); - _17 = Offset(copy _16, const 1_usize); + _16 = copy _14 as *mut T (Transmute); + _17 = Eq(copy _15, copy _16); StorageDead(_16); - _6 = NonNull:: { pointer: copy _17 }; + switchInt(move _17) -> [0: bb6, otherwise: bb7]; + } + + bb6: { StorageDead(_17); + StorageLive(_18); + _18 = Offset(copy _15, const 1_usize); + _8 = copy _18 as std::ptr::NonNull (Transmute); + StorageDead(_18); goto -> bb13; } bb7: { - StorageDead(_15); + StorageDead(_17); goto -> bb10; } bb8: { - _18 = copy _11 as usize (Transmute); - switchInt(copy _18) -> [0: bb9, otherwise: bb12]; + _19 = copy _13 as usize (Transmute); + switchInt(copy _19) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -186,13 +189,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); + StorageDead(_15); StorageDead(_22); + StorageDead(_14); + StorageDead(_20); + StorageDead(_19); + StorageDead(_13); + StorageDead(_12); + StorageDead(_23); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -201,35 +205,36 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb12: { - _19 = SubUnchecked(copy _18, const 1_usize); - _9 = copy _19 as *const T (Transmute); + _20 = SubUnchecked(copy _19, const 1_usize); + _11 = copy _20 as *const T (Transmute); goto -> bb13; } bb13: { - StorageLive(_20); - _20 = copy _10 as *const T (Transmute); - _21 = &(*_20); - StorageDead(_20); - _22 = Option::<&T>::Some(copy _21); + StorageLive(_21); + _21 = copy _12 as *const T (Transmute); + _22 = &(*_21); StorageDead(_21); - StorageDead(_12); + _23 = Option::<&T>::Some(copy _22); + StorageDead(_15); + StorageDead(_22); + StorageDead(_14); + StorageDead(_20); StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); - StorageLive(_24); - _24 = &_2; + StorageDead(_13); + StorageDead(_12); + _24 = copy ((_23 as Some).0: &T); StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind unreachable]; + _25 = &_2; + StorageLive(_26); + _26 = (copy _24,); + _27 = >::call(move _25, move _26) -> [return: bb14, unwind unreachable]; } bb14: { + StorageDead(_26); StorageDead(_25); - StorageDead(_24); - StorageDead(_22); + StorageDead(_23); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index ab6e2bf0b36b3..e8728eacf7f49 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -4,29 +4,29 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _22: std::option::Option<&T>; - let mut _24: &impl Fn(&T); - let mut _25: (&T,); - let _26: (); + let mut _23: std::option::Option<&T>; + let mut _25: &impl Fn(&T); + let mut _26: (&T,); + let _27: (); scope 1 { - debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _6; - debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9; + debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _8; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _11; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; + let _24: &T; scope 2 { - debug x => _23; + debug x => _24; } scope 16 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _10: std::ptr::NonNull; + let mut _8: std::ptr::NonNull; let _12: std::ptr::NonNull; - let mut _15: bool; - let mut _19: usize; - let _21: &T; + let _14: std::ptr::NonNull; + let mut _17: bool; + let mut _20: usize; + let _22: &T; scope 17 { - let _11: *const T; + let _13: *const T; scope 18 { - let _18: usize; + let _19: usize; scope 19 { scope 22 (inlined #[track_caller] core::num::::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { @@ -42,21 +42,20 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 26 (inlined as PartialEq>::eq) { - let mut _13: *mut T; - let mut _14: *mut T; + let mut _15: *mut T; + let mut _16: *mut T; scope 27 (inlined NonNull::::as_ptr) { } scope 28 (inlined NonNull::::as_ptr) { } } scope 29 (inlined NonNull::::add) { - let mut _16: *const T; - let mut _17: *const T; + let mut _18: *mut T; scope 30 (inlined NonNull::::as_ptr) { } } scope 31 (inlined NonNull::::as_ref::<'_>) { - let _20: *const T; + let _21: *const T; scope 32 (inlined NonNull::::as_ptr) { } scope 33 (inlined std::ptr::mut_ptr::::cast_const) { @@ -69,11 +68,12 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -89,7 +89,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -101,84 +102,86 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); StorageDead(_3); goto -> bb4; } bb4: { - StorageLive(_22); - StorageLive(_10); - StorageLive(_11); - StorageLive(_18); - StorageLive(_19); + StorageLive(_23); StorageLive(_12); - StorageLive(_21); - _10 = copy _6; - _11 = copy _9; - switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; - } - - bb5: { - StorageLive(_15); - _12 = copy _11 as std::ptr::NonNull (Transmute); StorageLive(_13); - _13 = copy _10 as *mut T (Transmute); + StorageLive(_19); + StorageLive(_20); StorageLive(_14); - _14 = copy _12 as *mut T (Transmute); - _15 = Eq(copy _13, copy _14); - StorageDead(_14); - StorageDead(_13); - switchInt(move _15) -> [0: bb6, otherwise: bb7]; + StorageLive(_22); + StorageLive(_15); + _12 = copy _8; + _13 = copy _11; + switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; } - bb6: { - StorageDead(_15); + bb5: { StorageLive(_17); + _14 = copy _13 as std::ptr::NonNull (Transmute); + _15 = copy _12 as *mut T (Transmute); StorageLive(_16); - _16 = copy _10 as *const T (Transmute); - _17 = Offset(copy _16, const 1_usize); + _16 = copy _14 as *mut T (Transmute); + _17 = Eq(copy _15, copy _16); StorageDead(_16); - _6 = NonNull:: { pointer: copy _17 }; + switchInt(move _17) -> [0: bb6, otherwise: bb7]; + } + + bb6: { StorageDead(_17); + StorageLive(_18); + _18 = Offset(copy _15, const 1_usize); + _8 = copy _18 as std::ptr::NonNull (Transmute); + StorageDead(_18); goto -> bb13; } bb7: { - StorageDead(_15); + StorageDead(_17); goto -> bb10; } bb8: { - _18 = copy _11 as usize (Transmute); - switchInt(copy _18) -> [0: bb9, otherwise: bb12]; + _19 = copy _13 as usize (Transmute); + switchInt(copy _19) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -186,13 +189,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); + StorageDead(_15); StorageDead(_22); + StorageDead(_14); + StorageDead(_20); + StorageDead(_19); + StorageDead(_13); + StorageDead(_12); + StorageDead(_23); drop(_2) -> [return: bb11, unwind continue]; } @@ -201,35 +205,36 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb12: { - _19 = SubUnchecked(copy _18, const 1_usize); - _9 = copy _19 as *const T (Transmute); + _20 = SubUnchecked(copy _19, const 1_usize); + _11 = copy _20 as *const T (Transmute); goto -> bb13; } bb13: { - StorageLive(_20); - _20 = copy _10 as *const T (Transmute); - _21 = &(*_20); - StorageDead(_20); - _22 = Option::<&T>::Some(copy _21); + StorageLive(_21); + _21 = copy _12 as *const T (Transmute); + _22 = &(*_21); StorageDead(_21); - StorageDead(_12); + _23 = Option::<&T>::Some(copy _22); + StorageDead(_15); + StorageDead(_22); + StorageDead(_14); + StorageDead(_20); StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); - StorageLive(_24); - _24 = &_2; + StorageDead(_13); + StorageDead(_12); + _24 = copy ((_23 as Some).0: &T); StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind: bb15]; + _25 = &_2; + StorageLive(_26); + _26 = (copy _24,); + _27 = >::call(move _25, move _26) -> [return: bb14, unwind: bb15]; } bb14: { + StorageDead(_26); StorageDead(_25); - StorageDead(_24); - StorageDead(_22); + StorageDead(_23); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 3009be3f9dc67..ac2b0f23b9f90 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -4,35 +4,35 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _10: std::slice::Iter<'_, T>; - let mut _11: std::iter::Rev>; - let mut _12: std::iter::Rev>; - let mut _33: std::option::Option<&T>; - let mut _35: &impl Fn(&T); - let mut _36: (&T,); - let _37: (); + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Rev>; + let mut _14: std::iter::Rev>; + let mut _35: std::option::Option<&T>; + let mut _37: &impl Fn(&T); + let mut _38: (&T,); + let _39: (); scope 1 { - debug iter => _12; - let _34: &T; + debug iter => _14; + let _36: &T; scope 2 { - debug x => _34; + debug x => _36; } scope 18 (inlined > as Iterator>::next) { scope 19 (inlined as DoubleEndedIterator>::next_back) { - let mut _13: *const T; - let mut _18: bool; - let mut _19: *const T; - let _32: &T; + let mut _15: *const T; + let mut _20: bool; + let mut _21: *const T; + let _34: &T; scope 20 { - let _14: std::ptr::NonNull; - let _20: usize; + let _16: std::ptr::NonNull; + let _22: usize; scope 21 { } scope 22 { scope 25 (inlined as PartialEq>::eq) { - let mut _15: std::ptr::NonNull; - let mut _16: *mut T; - let mut _17: *mut T; + let mut _17: std::ptr::NonNull; + let mut _18: *mut T; + let mut _19: *mut T; scope 26 (inlined NonNull::::as_ptr) { } scope 27 (inlined NonNull::::as_ptr) { @@ -45,15 +45,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 28 (inlined std::slice::Iter::<'_, T>::next_back_unchecked) { - let _26: std::ptr::NonNull; + let _28: std::ptr::NonNull; scope 29 (inlined std::slice::Iter::<'_, T>::pre_dec_end) { - let mut _21: *mut *const T; - let mut _22: *mut std::ptr::NonNull; - let mut _23: std::ptr::NonNull; - let mut _27: *mut *const T; - let mut _28: *mut usize; - let mut _29: usize; - let mut _30: usize; + let mut _23: *mut *const T; + let mut _24: *mut std::ptr::NonNull; + let mut _25: std::ptr::NonNull; + let mut _29: *mut *const T; + let mut _30: *mut usize; + let mut _31: usize; + let mut _32: usize; scope 30 { scope 31 { } @@ -66,8 +66,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 39 (inlined NonNull::::offset) { - let mut _24: *const T; - let mut _25: *const T; + let mut _26: *mut T; + let mut _27: *mut T; scope 40 (inlined NonNull::::as_ptr) { } } @@ -80,7 +80,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 41 (inlined NonNull::::as_ref::<'_>) { - let _31: *const T; + let _33: *const T; scope 42 (inlined NonNull::::as_ptr) { } scope 43 (inlined std::ptr::mut_ptr::::cast_const) { @@ -93,12 +93,13 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -114,7 +115,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -129,176 +131,182 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_12); StorageLive(_3); - StorageLive(_6); - StorageLive(_9); - StorageLive(_4); + StorageLive(_8); + StorageLive(_11); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - _10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_4); - StorageDead(_9); - StorageDead(_6); + _12 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: copy _11, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_11); + StorageDead(_8); StorageDead(_3); - _11 = Rev::> { iter: copy _10 }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _13 = Rev::> { iter: copy _12 }; + StorageDead(_12); + StorageLive(_14); + _14 = copy _13; goto -> bb4; } bb4: { - StorageLive(_33); + StorageLive(_35); + StorageLive(_22); + StorageLive(_21); + StorageLive(_16); + StorageLive(_34); StorageLive(_20); - StorageLive(_19); - StorageLive(_14); - StorageLive(_32); - StorageLive(_18); switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageLive(_13); - _13 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _14 = copy _13 as std::ptr::NonNull (Transmute); - StorageDead(_13); - StorageLive(_16); StorageLive(_15); - _15 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); - _16 = copy _15 as *mut T (Transmute); + _15 = copy ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _16 = copy _15 as std::ptr::NonNull (Transmute); StorageDead(_15); + StorageLive(_18); StorageLive(_17); - _17 = copy _14 as *mut T (Transmute); - _18 = Eq(copy _16, copy _17); + _17 = copy ((_14.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + _18 = copy _17 as *mut T (Transmute); StorageDead(_17); - StorageDead(_16); + StorageLive(_19); + _19 = copy _16 as *mut T (Transmute); + _20 = Eq(copy _18, copy _19); + StorageDead(_19); + StorageDead(_18); goto -> bb7; } bb6: { - _19 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _20 = copy _19 as usize (Transmute); - _18 = Eq(copy _20, const 0_usize); + _21 = copy ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _22 = copy _21 as usize (Transmute); + _20 = Eq(copy _22, const 0_usize); goto -> bb7; } bb7: { - switchInt(move _18) -> [0: bb8, otherwise: bb15]; + switchInt(move _20) -> [0: bb8, otherwise: bb15]; } bb8: { - StorageLive(_26); StorageLive(_28); - StorageLive(_22); - StorageLive(_23); + StorageLive(_30); + StorageLive(_24); + StorageLive(_25); switchInt(const ::IS_ZST) -> [0: bb9, otherwise: bb12]; } bb9: { - StorageLive(_21); - _21 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _22 = copy _21 as *mut std::ptr::NonNull (PtrToPtr); - StorageDead(_21); - _23 = copy (*_22); + StorageLive(_23); + _23 = &raw mut ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _24 = copy _23 as *mut std::ptr::NonNull (PtrToPtr); + StorageDead(_23); + _25 = copy (*_24); switchInt(const ::IS_ZST) -> [0: bb10, otherwise: bb11]; } bb10: { - StorageLive(_25); - StorageLive(_24); - _24 = copy _23 as *const T (Transmute); - _25 = Offset(copy _24, const -1_isize); - StorageDead(_24); - _23 = NonNull:: { pointer: copy _25 }; - StorageDead(_25); + StorageLive(_27); + StorageLive(_26); + _26 = copy _25 as *mut T (Transmute); + _27 = Offset(copy _26, const -1_isize); + StorageDead(_26); + _25 = copy _27 as std::ptr::NonNull (Transmute); + StorageDead(_27); goto -> bb11; } bb11: { - (*_22) = move _23; - _26 = copy (*_22); + (*_24) = move _25; + _28 = copy (*_24); goto -> bb13; } bb12: { - StorageLive(_27); - _27 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _28 = copy _27 as *mut usize (PtrToPtr); - StorageDead(_27); - StorageLive(_30); StorageLive(_29); - _29 = copy (*_28); - _30 = SubUnchecked(move _29, const 1_usize); + _29 = &raw mut ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _30 = copy _29 as *mut usize (PtrToPtr); StorageDead(_29); - (*_28) = move _30; - StorageDead(_30); - _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + StorageLive(_32); + StorageLive(_31); + _31 = copy (*_30); + _32 = SubUnchecked(move _31, const 1_usize); + StorageDead(_31); + (*_30) = move _32; + StorageDead(_32); + _28 = copy ((_14.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); goto -> bb13; } bb13: { - StorageDead(_23); - StorageDead(_22); + StorageDead(_25); + StorageDead(_24); + StorageDead(_30); + StorageLive(_33); + _33 = copy _28 as *const T (Transmute); + _34 = &(*_33); + StorageDead(_33); StorageDead(_28); - StorageLive(_31); - _31 = copy _26 as *const T (Transmute); - _32 = &(*_31); - StorageDead(_31); - StorageDead(_26); - _33 = Option::<&T>::Some(copy _32); - StorageDead(_18); - StorageDead(_32); - StorageDead(_14); - StorageDead(_19); + _35 = Option::<&T>::Some(copy _34); StorageDead(_20); - _34 = copy ((_33 as Some).0: &T); - StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _34,); - _37 = >::call(move _35, move _36) -> [return: bb14, unwind unreachable]; + StorageDead(_34); + StorageDead(_16); + StorageDead(_21); + StorageDead(_22); + _36 = copy ((_35 as Some).0: &T); + StorageLive(_37); + _37 = &_2; + StorageLive(_38); + _38 = (copy _36,); + _39 = >::call(move _37, move _38) -> [return: bb14, unwind unreachable]; } bb14: { - StorageDead(_36); + StorageDead(_38); + StorageDead(_37); StorageDead(_35); - StorageDead(_33); goto -> bb4; } bb15: { - StorageDead(_18); - StorageDead(_32); - StorageDead(_14); - StorageDead(_19); StorageDead(_20); - StorageDead(_33); - StorageDead(_12); + StorageDead(_34); + StorageDead(_16); + StorageDead(_21); + StorageDead(_22); + StorageDead(_35); + StorageDead(_14); drop(_2) -> [return: bb16, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index e40bff5ea3504..bbb9b8e2dd50d 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -4,35 +4,35 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _10: std::slice::Iter<'_, T>; - let mut _11: std::iter::Rev>; - let mut _12: std::iter::Rev>; - let mut _33: std::option::Option<&T>; - let mut _35: &impl Fn(&T); - let mut _36: (&T,); - let _37: (); + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Rev>; + let mut _14: std::iter::Rev>; + let mut _35: std::option::Option<&T>; + let mut _37: &impl Fn(&T); + let mut _38: (&T,); + let _39: (); scope 1 { - debug iter => _12; - let _34: &T; + debug iter => _14; + let _36: &T; scope 2 { - debug x => _34; + debug x => _36; } scope 18 (inlined > as Iterator>::next) { scope 19 (inlined as DoubleEndedIterator>::next_back) { - let mut _13: *const T; - let mut _18: bool; - let mut _19: *const T; - let _32: &T; + let mut _15: *const T; + let mut _20: bool; + let mut _21: *const T; + let _34: &T; scope 20 { - let _14: std::ptr::NonNull; - let _20: usize; + let _16: std::ptr::NonNull; + let _22: usize; scope 21 { } scope 22 { scope 25 (inlined as PartialEq>::eq) { - let mut _15: std::ptr::NonNull; - let mut _16: *mut T; - let mut _17: *mut T; + let mut _17: std::ptr::NonNull; + let mut _18: *mut T; + let mut _19: *mut T; scope 26 (inlined NonNull::::as_ptr) { } scope 27 (inlined NonNull::::as_ptr) { @@ -45,15 +45,15 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 28 (inlined std::slice::Iter::<'_, T>::next_back_unchecked) { - let _26: std::ptr::NonNull; + let _28: std::ptr::NonNull; scope 29 (inlined std::slice::Iter::<'_, T>::pre_dec_end) { - let mut _21: *mut *const T; - let mut _22: *mut std::ptr::NonNull; - let mut _23: std::ptr::NonNull; - let mut _27: *mut *const T; - let mut _28: *mut usize; - let mut _29: usize; - let mut _30: usize; + let mut _23: *mut *const T; + let mut _24: *mut std::ptr::NonNull; + let mut _25: std::ptr::NonNull; + let mut _29: *mut *const T; + let mut _30: *mut usize; + let mut _31: usize; + let mut _32: usize; scope 30 { scope 31 { } @@ -66,8 +66,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 39 (inlined NonNull::::offset) { - let mut _24: *const T; - let mut _25: *const T; + let mut _26: *mut T; + let mut _27: *mut T; scope 40 (inlined NonNull::::as_ptr) { } } @@ -80,7 +80,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 41 (inlined NonNull::::as_ref::<'_>) { - let _31: *const T; + let _33: *const T; scope 42 (inlined NonNull::::as_ptr) { } scope 43 (inlined std::ptr::mut_ptr::::cast_const) { @@ -93,12 +93,13 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -114,7 +115,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -129,165 +131,171 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_12); StorageLive(_3); - StorageLive(_6); - StorageLive(_9); - StorageLive(_4); + StorageLive(_8); + StorageLive(_11); _3 = PtrMetadata(copy _1); - _4 = &raw const (*_1); StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; + StorageLive(_4); + _4 = &raw const (*_1); + _5 = copy _4 as std::ptr::NonNull<[T]> (Transmute); + StorageDead(_4); + StorageLive(_7); + StorageLive(_6); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *mut T (PtrToPtr); + StorageDead(_6); + _8 = copy _7 as std::ptr::NonNull (Transmute); + StorageDead(_7); StorageDead(_5); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = copy _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = copy _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - _10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_4); - StorageDead(_9); - StorageDead(_6); + _12 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: copy _11, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_11); + StorageDead(_8); StorageDead(_3); - _11 = Rev::> { iter: copy _10 }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _13 = Rev::> { iter: copy _12 }; + StorageDead(_12); + StorageLive(_14); + _14 = copy _13; goto -> bb4; } bb4: { - StorageLive(_33); + StorageLive(_35); + StorageLive(_22); + StorageLive(_21); + StorageLive(_16); + StorageLive(_34); StorageLive(_20); - StorageLive(_19); - StorageLive(_14); - StorageLive(_32); - StorageLive(_18); switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageLive(_13); - _13 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _14 = copy _13 as std::ptr::NonNull (Transmute); - StorageDead(_13); - StorageLive(_16); StorageLive(_15); - _15 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); - _16 = copy _15 as *mut T (Transmute); + _15 = copy ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _16 = copy _15 as std::ptr::NonNull (Transmute); StorageDead(_15); + StorageLive(_18); StorageLive(_17); - _17 = copy _14 as *mut T (Transmute); - _18 = Eq(copy _16, copy _17); + _17 = copy ((_14.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + _18 = copy _17 as *mut T (Transmute); StorageDead(_17); - StorageDead(_16); + StorageLive(_19); + _19 = copy _16 as *mut T (Transmute); + _20 = Eq(copy _18, copy _19); + StorageDead(_19); + StorageDead(_18); goto -> bb7; } bb6: { - _19 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _20 = copy _19 as usize (Transmute); - _18 = Eq(copy _20, const 0_usize); + _21 = copy ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _22 = copy _21 as usize (Transmute); + _20 = Eq(copy _22, const 0_usize); goto -> bb7; } bb7: { - switchInt(move _18) -> [0: bb8, otherwise: bb17]; + switchInt(move _20) -> [0: bb8, otherwise: bb17]; } bb8: { - StorageLive(_26); StorageLive(_28); - StorageLive(_22); - StorageLive(_23); + StorageLive(_30); + StorageLive(_24); + StorageLive(_25); switchInt(const ::IS_ZST) -> [0: bb9, otherwise: bb12]; } bb9: { - StorageLive(_21); - _21 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _22 = copy _21 as *mut std::ptr::NonNull (PtrToPtr); - StorageDead(_21); - _23 = copy (*_22); + StorageLive(_23); + _23 = &raw mut ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _24 = copy _23 as *mut std::ptr::NonNull (PtrToPtr); + StorageDead(_23); + _25 = copy (*_24); switchInt(const ::IS_ZST) -> [0: bb10, otherwise: bb11]; } bb10: { - StorageLive(_25); - StorageLive(_24); - _24 = copy _23 as *const T (Transmute); - _25 = Offset(copy _24, const -1_isize); - StorageDead(_24); - _23 = NonNull:: { pointer: copy _25 }; - StorageDead(_25); + StorageLive(_27); + StorageLive(_26); + _26 = copy _25 as *mut T (Transmute); + _27 = Offset(copy _26, const -1_isize); + StorageDead(_26); + _25 = copy _27 as std::ptr::NonNull (Transmute); + StorageDead(_27); goto -> bb11; } bb11: { - (*_22) = move _23; - _26 = copy (*_22); + (*_24) = move _25; + _28 = copy (*_24); goto -> bb13; } bb12: { - StorageLive(_27); - _27 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T); - _28 = copy _27 as *mut usize (PtrToPtr); - StorageDead(_27); - StorageLive(_30); StorageLive(_29); - _29 = copy (*_28); - _30 = SubUnchecked(move _29, const 1_usize); + _29 = &raw mut ((_14.0: std::slice::Iter<'_, T>).1: *const T); + _30 = copy _29 as *mut usize (PtrToPtr); StorageDead(_29); - (*_28) = move _30; - StorageDead(_30); - _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + StorageLive(_32); + StorageLive(_31); + _31 = copy (*_30); + _32 = SubUnchecked(move _31, const 1_usize); + StorageDead(_31); + (*_30) = move _32; + StorageDead(_32); + _28 = copy ((_14.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); goto -> bb13; } bb13: { - StorageDead(_23); - StorageDead(_22); + StorageDead(_25); + StorageDead(_24); + StorageDead(_30); + StorageLive(_33); + _33 = copy _28 as *const T (Transmute); + _34 = &(*_33); + StorageDead(_33); StorageDead(_28); - StorageLive(_31); - _31 = copy _26 as *const T (Transmute); - _32 = &(*_31); - StorageDead(_31); - StorageDead(_26); - _33 = Option::<&T>::Some(copy _32); - StorageDead(_18); - StorageDead(_32); - StorageDead(_14); - StorageDead(_19); + _35 = Option::<&T>::Some(copy _34); StorageDead(_20); - _34 = copy ((_33 as Some).0: &T); - StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _34,); - _37 = >::call(move _35, move _36) -> [return: bb14, unwind: bb15]; + StorageDead(_34); + StorageDead(_16); + StorageDead(_21); + StorageDead(_22); + _36 = copy ((_35 as Some).0: &T); + StorageLive(_37); + _37 = &_2; + StorageLive(_38); + _38 = (copy _36,); + _39 = >::call(move _37, move _38) -> [return: bb14, unwind: bb15]; } bb14: { - StorageDead(_36); + StorageDead(_38); + StorageDead(_37); StorageDead(_35); - StorageDead(_33); goto -> bb4; } @@ -300,13 +308,13 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb17: { - StorageDead(_18); - StorageDead(_32); - StorageDead(_14); - StorageDead(_19); StorageDead(_20); - StorageDead(_33); - StorageDead(_12); + StorageDead(_34); + StorageDead(_16); + StorageDead(_21); + StorageDead(_22); + StorageDead(_35); + StorageDead(_14); drop(_2) -> [return: bb18, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir index 62b738c36bf4b..99f793ea67249 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir @@ -51,8 +51,8 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 21 (inlined NonNull::::offset) { - let mut _13: *const T; - let mut _14: *const T; + let mut _13: *mut T; + let mut _14: *mut T; scope 22 (inlined NonNull::::as_ptr) { } } @@ -129,10 +129,10 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut bb6: { StorageLive(_14); StorageLive(_13); - _13 = copy _12 as *const T (Transmute); + _13 = copy _12 as *mut T (Transmute); _14 = Offset(copy _13, const -1_isize); StorageDead(_13); - _12 = NonNull:: { pointer: copy _14 }; + _12 = copy _14 as std::ptr::NonNull (Transmute); StorageDead(_14); goto -> bb7; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir index 62b738c36bf4b..99f793ea67249 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir @@ -51,8 +51,8 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 21 (inlined NonNull::::offset) { - let mut _13: *const T; - let mut _14: *const T; + let mut _13: *mut T; + let mut _14: *mut T; scope 22 (inlined NonNull::::as_ptr) { } } @@ -129,10 +129,10 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut bb6: { StorageLive(_14); StorageLive(_13); - _13 = copy _12 as *const T (Transmute); + _13 = copy _12 as *mut T (Transmute); _14 = Offset(copy _13, const -1_isize); StorageDead(_13); - _12 = NonNull:: { pointer: copy _14 }; + _12 = copy _14 as std::ptr::NonNull (Transmute); StorageDead(_14); goto -> bb7; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir index cc0fce26149e3..5711b556203ac 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir @@ -7,13 +7,13 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let _2: std::ptr::NonNull; let _4: std::ptr::NonNull; let mut _7: bool; - let mut _10: std::ptr::NonNull; - let mut _12: usize; - let _14: &T; + let mut _9: std::ptr::NonNull; + let mut _11: usize; + let _13: &T; scope 2 { let _3: *const T; scope 3 { - let _11: usize; + let _10: usize; scope 4 { scope 7 (inlined #[track_caller] core::num::::unchecked_sub) { scope 8 (inlined core::ub_checks::check_language_ub) { @@ -37,13 +37,12 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } } scope 14 (inlined NonNull::::add) { - let mut _8: *const T; - let mut _9: *const T; + let mut _8: *mut T; scope 15 (inlined NonNull::::as_ptr) { } } scope 16 (inlined NonNull::::as_ref::<'_>) { - let _13: *const T; + let _12: *const T; scope 17 (inlined NonNull::::as_ptr) { } scope 18 (inlined std::ptr::mut_ptr::::cast_const) { @@ -56,10 +55,11 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb0: { StorageLive(_2); StorageLive(_3); + StorageLive(_10); StorageLive(_11); - StorageLive(_12); StorageLive(_4); - StorageLive(_14); + StorageLive(_13); + StorageLive(_5); _2 = copy ((*_1).0: std::ptr::NonNull); _3 = copy ((*_1).1: *const T); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb4]; @@ -68,28 +68,23 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb1: { StorageLive(_7); _4 = copy _3 as std::ptr::NonNull (Transmute); - StorageLive(_5); _5 = copy _2 as *mut T (Transmute); StorageLive(_6); _6 = copy _4 as *mut T (Transmute); _7 = Eq(copy _5, copy _6); StorageDead(_6); - StorageDead(_5); switchInt(move _7) -> [0: bb2, otherwise: bb3]; } bb2: { StorageDead(_7); - StorageLive(_10); StorageLive(_9); StorageLive(_8); - _8 = copy _2 as *const T (Transmute); - _9 = Offset(copy _8, const 1_usize); + _8 = Offset(copy _5, const 1_usize); + _9 = copy _8 as std::ptr::NonNull (Transmute); StorageDead(_8); - _10 = NonNull:: { pointer: copy _9 }; + ((*_1).0: std::ptr::NonNull) = move _9; StorageDead(_9); - ((*_1).0: std::ptr::NonNull) = move _10; - StorageDead(_10); goto -> bb7; } @@ -100,8 +95,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb4: { - _11 = copy _3 as usize (Transmute); - switchInt(copy _11) -> [0: bb5, otherwise: bb6]; + _10 = copy _3 as usize (Transmute); + switchInt(copy _10) -> [0: bb5, otherwise: bb6]; } bb5: { @@ -110,25 +105,26 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb6: { - _12 = SubUnchecked(copy _11, const 1_usize); - ((*_1).1: *const T) = copy _12 as *const T (Transmute); + _11 = SubUnchecked(copy _10, const 1_usize); + ((*_1).1: *const T) = copy _11 as *const T (Transmute); goto -> bb7; } bb7: { - StorageLive(_13); - _13 = copy _2 as *const T (Transmute); - _14 = &(*_13); - StorageDead(_13); - _0 = Option::<&T>::Some(copy _14); + StorageLive(_12); + _12 = copy _2 as *const T (Transmute); + _13 = &(*_12); + StorageDead(_12); + _0 = Option::<&T>::Some(copy _13); goto -> bb8; } bb8: { - StorageDead(_14); + StorageDead(_5); + StorageDead(_13); StorageDead(_4); - StorageDead(_12); StorageDead(_11); + StorageDead(_10); StorageDead(_3); StorageDead(_2); return; diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index cc0fce26149e3..5711b556203ac 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -7,13 +7,13 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let _2: std::ptr::NonNull; let _4: std::ptr::NonNull; let mut _7: bool; - let mut _10: std::ptr::NonNull; - let mut _12: usize; - let _14: &T; + let mut _9: std::ptr::NonNull; + let mut _11: usize; + let _13: &T; scope 2 { let _3: *const T; scope 3 { - let _11: usize; + let _10: usize; scope 4 { scope 7 (inlined #[track_caller] core::num::::unchecked_sub) { scope 8 (inlined core::ub_checks::check_language_ub) { @@ -37,13 +37,12 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } } scope 14 (inlined NonNull::::add) { - let mut _8: *const T; - let mut _9: *const T; + let mut _8: *mut T; scope 15 (inlined NonNull::::as_ptr) { } } scope 16 (inlined NonNull::::as_ref::<'_>) { - let _13: *const T; + let _12: *const T; scope 17 (inlined NonNull::::as_ptr) { } scope 18 (inlined std::ptr::mut_ptr::::cast_const) { @@ -56,10 +55,11 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb0: { StorageLive(_2); StorageLive(_3); + StorageLive(_10); StorageLive(_11); - StorageLive(_12); StorageLive(_4); - StorageLive(_14); + StorageLive(_13); + StorageLive(_5); _2 = copy ((*_1).0: std::ptr::NonNull); _3 = copy ((*_1).1: *const T); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb4]; @@ -68,28 +68,23 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb1: { StorageLive(_7); _4 = copy _3 as std::ptr::NonNull (Transmute); - StorageLive(_5); _5 = copy _2 as *mut T (Transmute); StorageLive(_6); _6 = copy _4 as *mut T (Transmute); _7 = Eq(copy _5, copy _6); StorageDead(_6); - StorageDead(_5); switchInt(move _7) -> [0: bb2, otherwise: bb3]; } bb2: { StorageDead(_7); - StorageLive(_10); StorageLive(_9); StorageLive(_8); - _8 = copy _2 as *const T (Transmute); - _9 = Offset(copy _8, const 1_usize); + _8 = Offset(copy _5, const 1_usize); + _9 = copy _8 as std::ptr::NonNull (Transmute); StorageDead(_8); - _10 = NonNull:: { pointer: copy _9 }; + ((*_1).0: std::ptr::NonNull) = move _9; StorageDead(_9); - ((*_1).0: std::ptr::NonNull) = move _10; - StorageDead(_10); goto -> bb7; } @@ -100,8 +95,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb4: { - _11 = copy _3 as usize (Transmute); - switchInt(copy _11) -> [0: bb5, otherwise: bb6]; + _10 = copy _3 as usize (Transmute); + switchInt(copy _10) -> [0: bb5, otherwise: bb6]; } bb5: { @@ -110,25 +105,26 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb6: { - _12 = SubUnchecked(copy _11, const 1_usize); - ((*_1).1: *const T) = copy _12 as *const T (Transmute); + _11 = SubUnchecked(copy _10, const 1_usize); + ((*_1).1: *const T) = copy _11 as *const T (Transmute); goto -> bb7; } bb7: { - StorageLive(_13); - _13 = copy _2 as *const T (Transmute); - _14 = &(*_13); - StorageDead(_13); - _0 = Option::<&T>::Some(copy _14); + StorageLive(_12); + _12 = copy _2 as *const T (Transmute); + _13 = &(*_12); + StorageDead(_12); + _0 = Option::<&T>::Some(copy _13); goto -> bb8; } bb8: { - StorageDead(_14); + StorageDead(_5); + StorageDead(_13); StorageDead(_4); - StorageDead(_12); StorageDead(_11); + StorageDead(_10); StorageDead(_3); StorageDead(_2); return;