diff --git a/compiler/rustc_builtin_macros/src/pattern_type.rs b/compiler/rustc_builtin_macros/src/pattern_type.rs index 4126547b0515a..53ab3fcd9b34b 100644 --- a/compiler/rustc_builtin_macros/src/pattern_type.rs +++ b/compiler/rustc_builtin_macros/src/pattern_type.rs @@ -80,6 +80,7 @@ fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> TyPat { TyPatKind::Or(variants.into_iter().map(|pat| pat_to_ty_pat(cx, pat)).collect()) } ast::PatKind::Err(guar) => TyPatKind::Err(guar), + ast::PatKind::Paren(p) => pat_to_ty_pat(cx, *p).kind, _ => TyPatKind::Err(cx.dcx().span_err(pat.span, "pattern not supported in pattern types")), }; ty_pat(kind, pat.span) diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index 301547cadaf7c..c720975c98ea6 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -8,6 +8,7 @@ rustc_attrs, rustc_private, transparent_unions, + pattern_types, auto_traits, freeze_impls, thread_local @@ -15,6 +16,30 @@ #![no_core] #![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)] +#[lang = "pointee_trait"] +pub trait Pointee: PointeeSized { + #[lang = "metadata_type"] + // needed so that layout_of will return `TooGeneric` instead of `Unknown` + // when asked for the layout of `*const T`. Which is important for making + // transmutes between raw pointers (and especially pattern types of raw pointers) + // work. + type Metadata: Copy + Sync + Unpin + Freeze; +} + +#[lang = "dyn_metadata"] +pub struct DynMetadata { + _vtable_ptr: NonNull, + _phantom: PhantomData, +} + +unsafe extern "C" { + /// Opaque type for accessing vtables. + /// + /// Private implementation detail of `DynMetadata::size_of` etc. + /// There is conceptually not actually any Abstract Machine memory behind this pointer. + type VTable; +} + #[lang = "pointee_sized"] pub trait PointeeSized {} @@ -105,7 +130,7 @@ unsafe impl<'a, T: PointeeSized> Sync for &'a T {} unsafe impl Sync for [T; N] {} #[lang = "freeze"] -unsafe auto trait Freeze {} +pub unsafe auto trait Freeze {} unsafe impl Freeze for PhantomData {} unsafe impl Freeze for *const T {} @@ -570,10 +595,24 @@ pub trait Deref { fn deref(&self) -> &Self::Target; } +#[rustc_builtin_macro(pattern_type)] +#[macro_export] +macro_rules! pattern_type { + ($($arg:tt)*) => { + /* compiler built-in */ + }; +} + +impl CoerceUnsized for pattern_type!(*const T is !null) where + T: Unsize +{ +} + +impl, U> DispatchFromDyn for pattern_type!(T is !null) {} + #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] -pub struct NonNull(pub *const T); +pub struct NonNull(pub pattern_type!(*const T is !null)); impl CoerceUnsized> for NonNull where T: Unsize {} impl DispatchFromDyn> for NonNull where T: Unsize {} @@ -600,7 +639,16 @@ impl Box { let size = size_of::(); let ptr = libc::malloc(size); intrinsics::copy(&val as *const T as *const u8, ptr, size); - Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global) + Box( + Unique { + pointer: NonNull(intrinsics::transmute::< + *mut u8, + pattern_type!(*const T is !null), + >(ptr)), + _marker: PhantomData, + }, + Global, + ) } } } @@ -609,7 +657,9 @@ impl Drop for Box { fn drop(&mut self) { // inner value is dropped by compiler unsafe { - libc::free(self.0.pointer.0 as *mut u8); + libc::free(intrinsics::transmute::( + self.0.pointer.0, + ) as *mut u8); } } } diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index 10549cd2a41e2..556cb8127868f 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -6,6 +6,7 @@ extern_types, thread_local, repr_simd, + pattern_types, rustc_private )] #![no_core] @@ -161,7 +162,10 @@ extern "C" fn bool_struct_in_11(_arg0: bool_11) {} #[allow(unreachable_code)] // FIXME false positive fn main() { - take_unique(Unique { pointer: unsafe { NonNull(1 as *mut ()) }, _marker: PhantomData }); + take_unique(Unique { + pointer: unsafe { NonNull(intrinsics::transmute(1 as *mut ())) }, + _marker: PhantomData, + }); take_f32(0.1); call_return_u128_pair(); @@ -227,7 +231,12 @@ fn main() { let noisy_unsized_drop = const { intrinsics::needs_drop::() }; assert!(noisy_unsized_drop); - Unique { pointer: NonNull(1 as *mut &str), _marker: PhantomData } as Unique; + Unique { + pointer: NonNull(intrinsics::transmute::<_, pattern_type!(*const &str is !null)>( + 1 as *mut &str, + )), + _marker: PhantomData, + } as Unique; struct MyDst(T); diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 0aba44a88c5a4..8a42b4c90b09e 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -9,6 +9,7 @@ transparent_unions, auto_traits, freeze_impls, + pattern_types, thread_local )] #![no_core] @@ -580,9 +581,16 @@ pub struct Global; impl Allocator for Global {} #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] -pub struct NonNull(pub *const T); +pub struct NonNull(pub pattern_type!(*const T is !null)); + +#[rustc_builtin_macro(pattern_type)] +#[macro_export] +macro_rules! pattern_type { + ($($arg:tt)*) => { + /* compiler built-in */ + }; +} impl CoerceUnsized> for NonNull where T: Unsize {} impl DispatchFromDyn> for NonNull where T: Unsize {} diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 85c8890d661c5..37094b0203511 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -27,7 +27,7 @@ use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem, MonoItemPartitions}; use rustc_middle::query::Providers; use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout}; -use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; +use rustc_middle::ty::{self, Instance, PatternKind, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::Session; use rustc_session::config::{self, CrateType, EntryFnType}; @@ -273,6 +273,13 @@ pub(crate) fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let src_ty = src.layout.ty; let dst_ty = dst.layout.ty; match (src_ty.kind(), dst_ty.kind()) { + (&ty::Pat(s, sp), &ty::Pat(d, dp)) + if let (PatternKind::NotNull, PatternKind::NotNull) = (*sp, *dp) => + { + let src = src.project_type(bx, s); + let dst = dst.project_type(bx, d); + coerce_unsized_into(bx, src, dst) + } (&ty::Ref(..), &ty::Ref(..) | &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => { let (base, info) = match bx.load_operand(src).val { OperandValue::Pair(base, info) => unsize_ptr(bx, base, src_ty, dst_ty, Some(info)), diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index a8d472bc2ea23..53a1fda78d116 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -124,7 +124,12 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { // ... that contains a `NonNull`... (gladly, only a single field here) assert_eq!(nonnull_ptr.layout().fields.count(), 1); - let raw_ptr = self.ecx().project_field(&nonnull_ptr, FieldIdx::ZERO)?; // the actual raw ptr + let pat_ty = self.ecx().project_field(&nonnull_ptr, FieldIdx::ZERO)?; // `*mut T is !null` + let base = match *pat_ty.layout().ty.kind() { + ty::Pat(base, _) => self.ecx().layout_of(base)?, + _ => unreachable!(), + }; + let raw_ptr = pat_ty.transmute(base, self.ecx())?; // The actual raw pointer // ... whose only field finally is a raw ptr we can dereference. self.visit_box(ty, &raw_ptr)?; diff --git a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs index 808be19cbd817..b0e1e3846449d 100644 --- a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs +++ b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs @@ -10,7 +10,7 @@ use rustc_index::{IndexVec, indexvec}; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::*; use rustc_middle::span_bug; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, PatternKind, Ty, TyCtxt}; use crate::patch::MirPatch; @@ -20,21 +20,27 @@ fn build_ptr_tys<'tcx>( pointee: Ty<'tcx>, unique_def: ty::AdtDef<'tcx>, nonnull_def: ty::AdtDef<'tcx>, -) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) { +) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) { let args = tcx.mk_args(&[pointee.into()]); let unique_ty = Ty::new_adt(tcx, unique_def, args); let nonnull_ty = Ty::new_adt(tcx, nonnull_def, args); let ptr_ty = Ty::new_imm_ptr(tcx, pointee); + let pat_ty = Ty::new_pat(tcx, ptr_ty, tcx.mk_pat(PatternKind::NotNull)); - (unique_ty, nonnull_ty, ptr_ty) + (unique_ty, nonnull_ty, pat_ty, ptr_ty) } /// Constructs the projection needed to access a Box's pointer pub(super) fn build_projection<'tcx>( unique_ty: Ty<'tcx>, nonnull_ty: Ty<'tcx>, -) -> [PlaceElem<'tcx>; 2] { - [PlaceElem::Field(FieldIdx::ZERO, unique_ty), PlaceElem::Field(FieldIdx::ZERO, nonnull_ty)] + pat_ty: Ty<'tcx>, +) -> [PlaceElem<'tcx>; 3] { + [ + PlaceElem::Field(FieldIdx::ZERO, unique_ty), + PlaceElem::Field(FieldIdx::ZERO, nonnull_ty), + PlaceElem::Field(FieldIdx::ZERO, pat_ty), + ] } struct ElaborateBoxDerefVisitor<'a, 'tcx> { @@ -66,7 +72,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> { { let source_info = self.local_decls[place.local].source_info; - let (unique_ty, nonnull_ty, ptr_ty) = + let (unique_ty, nonnull_ty, pat_ty, ptr_ty) = build_ptr_tys(tcx, boxed_ty, self.unique_def, self.nonnull_def); let ptr_local = self.patch.new_temp(ptr_ty, source_info.span); @@ -78,7 +84,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> { CastKind::Transmute, Operand::Copy( Place::from(place.local) - .project_deeper(&build_projection(unique_ty, nonnull_ty), tcx), + .project_deeper(&build_projection(unique_ty, nonnull_ty, pat_ty), tcx), ), ptr_ty, ), @@ -101,7 +107,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> { && let ty::Adt(box_adt, box_args) = Ty::new_box(tcx, pointee).kind() { let args = tcx.mk_args(&[pointee.into()]); - let (unique_ty, nonnull_ty, ptr_ty) = + // We skip the pointer type by directly transmuting from the `*const u8` of + // `ShallowInitBox` to the pattern type that will get placed inside `NonNull` + let (unique_ty, nonnull_ty, pat_ty, _ptr_ty) = build_ptr_tys(tcx, pointee, self.unique_def, self.nonnull_def); let adt_kind = |def: ty::AdtDef<'tcx>, args| { Box::new(AggregateKind::Adt(def.did(), VariantIdx::ZERO, args, None, None)) @@ -114,11 +122,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> { })) }; - let constptr = self.patch.new_temp(ptr_ty, source_info.span); + let constptr = self.patch.new_temp(pat_ty, source_info.span); self.patch.add_assign( location, constptr.into(), - Rvalue::Cast(CastKind::Transmute, mutptr_to_u8.clone(), ptr_ty), + Rvalue::Cast(CastKind::Transmute, mutptr_to_u8.clone(), pat_ty), ); let nonnull = self.patch.new_temp(nonnull_ty, source_info.span); @@ -199,10 +207,11 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs { let new_projections = new_projections.get_or_insert_with(|| base.projection.to_vec()); - let (unique_ty, nonnull_ty, ptr_ty) = + let (unique_ty, nonnull_ty, pat_ty, ptr_ty) = build_ptr_tys(tcx, boxed_ty, unique_def, nonnull_def); - new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_ty)); + new_projections + .extend_from_slice(&build_projection(unique_ty, nonnull_ty, pat_ty)); // While we can't project into `NonNull<_>` in a basic block // due to MCP#807, this is debug info where it's fine. new_projections.push(PlaceElem::Field(FieldIdx::ZERO, ptr_ty)); diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 7b9e638289bf0..cb33d663da58d 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; @@ -70,13 +70,10 @@ use crate::{fmt, hash, intrinsics, mem, ptr}; /// [null pointer optimization]: crate::option#representation #[stable(feature = "nonnull", since = "1.25.0")] #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] #[rustc_diagnostic_item = "NonNull"] pub struct NonNull { - // Remember to use `.as_ptr()` instead of `.pointer`, as field projecting to - // this is banned by . - pointer: *const T, + pointer: crate::pattern_type!(*const T is !null), } /// `NonNull` pointers are not `Send` because the data they reference may be aliased. @@ -100,9 +97,9 @@ impl NonNull { #[must_use] #[inline] pub const fn without_provenance(addr: NonZero) -> Self { - let pointer = crate::ptr::without_provenance(addr.get()); + let pointer: *const T = crate::ptr::without_provenance(addr.get()); // SAFETY: we know `addr` is non-zero. - unsafe { NonNull { pointer } } + unsafe { NonNull { pointer: transmute(pointer) } } } /// Creates a new `NonNull` that is dangling, but well-aligned. @@ -239,7 +236,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 _ } + NonNull { pointer: transmute(ptr) } } } @@ -282,7 +279,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 { NonNull { pointer: transmute(r as *const T) } } } /// Converts a mutable reference to a `NonNull` pointer. @@ -291,7 +288,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 { NonNull { pointer: transmute(r as *mut T) } } } /// Performs the same functionality as [`std::ptr::from_raw_parts`], except that a @@ -502,7 +499,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 { NonNull { pointer: transmute(self.as_ptr() as *mut U) } } } /// Try to cast to a pointer of another type by checking alignment. @@ -581,7 +578,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 { NonNull { pointer: transmute(intrinsics::offset(self.as_ptr(), count)) } } } /// Calculates the offset from a pointer in bytes. @@ -605,7 +602,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 { NonNull { pointer: transmute(self.as_ptr().byte_offset(count)) } } } /// Adds an offset to a pointer (convenience for `.offset(count as isize)`). @@ -657,7 +654,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 { NonNull { pointer: transmute(intrinsics::offset(self.as_ptr(), count)) } } } /// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`). @@ -681,7 +678,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 { NonNull { pointer: transmute(self.as_ptr().byte_add(count)) } } } /// Subtracts an offset from a pointer (convenience for @@ -763,7 +760,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 { NonNull { pointer: 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/library/std/src/os/unix/io/tests.rs b/library/std/src/os/unix/io/tests.rs index fc147730578ac..ce5e7aac5a99d 100644 --- a/library/std/src/os/unix/io/tests.rs +++ b/library/std/src/os/unix/io/tests.rs @@ -2,8 +2,7 @@ use crate::os::unix::io::RawFd; #[test] fn test_raw_fd_layout() { - // `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start` - // and `rustc_layout_scalar_valid_range_end`, with values that depend on + // `OwnedFd` and `BorrowedFd` use pattern types, with ranges that depend on // the bit width of `RawFd`. If this ever changes, those values will need // to be updated. assert_eq!(size_of::(), 4); diff --git a/library/std/src/os/wasi/io/tests.rs b/library/std/src/os/wasi/io/tests.rs index c5c6a19a6c885..d18b9fe10cab0 100644 --- a/library/std/src/os/wasi/io/tests.rs +++ b/library/std/src/os/wasi/io/tests.rs @@ -2,8 +2,7 @@ use crate::os::wasi::io::RawFd; #[test] fn test_raw_fd_layout() { - // `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start` - // and `rustc_layout_scalar_valid_range_end`, with values that depend on + // `OwnedFd` and `BorrowedFd` use pattern types with ranges that depend on // the bit width of `RawFd`. If this ever changes, those values will need // to be updated. assert_eq!(size_of::(), 4); diff --git a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs index 3e6aae475ecce..c097f7773099a 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -242,6 +242,10 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> loop { ty = cx.tcx.try_normalize_erasing_regions(cx.typing_env(), ty).unwrap_or(ty); return match *ty.kind() { + ty::Pat(base, _) => { + ty = base; + continue; + }, ty::Array(sub_ty, _) if matches!(sub_ty.kind(), ty::Int(_) | ty::Uint(_)) => { ReducedTy::TypeErasure { raw_ptr_only: false } }, diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index c4546f4dea93a..66e358c679c70 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -22,6 +22,7 @@ auto_traits, freeze_impls, negative_impls, + pattern_types, rustc_attrs, decl_macro, f16, @@ -123,17 +124,41 @@ pub struct ManuallyDrop { impl Copy for ManuallyDrop {} #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] pub struct NonNull { - pointer: *const T, + pointer: pattern_type!(*const T is !null), } impl Copy for NonNull {} #[repr(transparent)] -#[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] -pub struct NonZero(T); +pub struct NonZero(T::NonZeroInner); + +pub trait ZeroablePrimitive { + type NonZeroInner; +} + +macro_rules! define_valid_range_type { + ($( + $name:ident($int:ident is $pat:pat); + )+) => {$( + #[repr(transparent)] + pub struct $name(pattern_type!($int is $pat)); + + impl ZeroablePrimitive for $int { + type NonZeroInner = $name; + } + )+}; +} + +define_valid_range_type! { + NonZeroU8Inner(u8 is 1..=0xFF); + NonZeroU16Inner(u16 is 1..=0xFFFF); + NonZeroU32Inner(u32 is 1..=0xFFFF_FFFF); + NonZeroU64Inner(u64 is 1..=0xFFFF_FFFF_FFFF_FFFF); + + NonZeroI8Inner(i8 is (-128..=-1 | 1..=0x7F)); +} pub struct Unique { pub pointer: NonNull, @@ -291,6 +316,14 @@ pub enum c_void { __variant2, } +#[rustc_builtin_macro(pattern_type)] +#[macro_export] +macro_rules! pattern_type { + ($($arg:tt)*) => { + /* compiler built-in */ + }; +} + #[lang = "Ordering"] #[repr(i8)] pub enum Ordering { 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/mir-opt/box_expr.rs b/tests/mir-opt/box_expr.rs index dbb07a028a939..33407a8bba73b 100644 --- a/tests/mir-opt/box_expr.rs +++ b/tests/mir-opt/box_expr.rs @@ -6,11 +6,11 @@ // EMIT_MIR box_expr.main.ElaborateDrops.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: [[ptr:_.*]] = move {{_.*}} as *const S (Transmute); + // CHECK: [[ptr:_.*]] = move {{_.*}} as (*const S) is !null (Transmute); // CHECK: [[nonnull:_.*]] = NonNull:: { pointer: move [[ptr]] }; // CHECK: [[unique:_.*]] = std::ptr::Unique:: { pointer: move [[nonnull]], _marker: const PhantomData:: }; // CHECK: [[box:_.*]] = Box::(move [[unique]], const std::alloc::Global); - // CHECK: [[ptr:_.*]] = copy (([[box]].0: std::ptr::Unique).0: std::ptr::NonNull) as *const S (Transmute); + // CHECK: [[ptr:_.*]] = copy ((([[box]].0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const S) is !null) as *const S (Transmute); // CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]]; // CHECK: [[ret]]: { // CHECK: [[box2:_.*]] = move [[box]]; diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff index ecc4b35ebcb6c..d7032991d73ba 100644 --- a/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff @@ -8,7 +8,7 @@ let mut _3: std::boxed::Box; let mut _4: *mut u8; let mut _5: std::boxed::Box; - let mut _6: *const i32; + let mut _6: (*const i32) is !null; let mut _7: std::ptr::NonNull; let mut _8: std::ptr::Unique; let mut _9: *const i32; @@ -27,20 +27,17 @@ bb1: { StorageLive(_5); -- _6 = move _4 as *const i32 (Transmute); + _6 = move _4 as (*const i32) is !null (Transmute); - _7 = NonNull:: { pointer: move _6 }; -- _8 = std::ptr::Unique:: { pointer: move _7, _marker: const PhantomData:: }; -+ _6 = copy _4 as *const i32 (PtrToPtr); + _7 = NonNull:: { pointer: copy _6 }; -+ _8 = std::ptr::Unique:: { pointer: copy _7, _marker: const PhantomData:: }; + _8 = std::ptr::Unique:: { pointer: move _7, _marker: const PhantomData:: }; _5 = Box::(move _8, const std::alloc::Global); -- _9 = copy ((_5.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); -- (*_9) = const 42_i32; -+ _9 = copy _6; -+ (*_6) = const 42_i32; +- _9 = copy (((_5.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); ++ _9 = copy _6 as *const i32 (Transmute); + (*_9) = const 42_i32; _3 = move _5; StorageDead(_5); - _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _10 = copy (((_3.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); _2 = copy (*_10); - _1 = Add(move _2, const 0_i32); - StorageDead(_2); diff --git a/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff index aba1a4f1df47f..ff8ee555ed305 100644 --- a/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff @@ -8,7 +8,7 @@ let mut _3: std::boxed::Box; let mut _4: *mut u8; let mut _5: std::boxed::Box; - let mut _6: *const i32; + let mut _6: (*const i32) is !null; let mut _7: std::ptr::NonNull; let mut _8: std::ptr::Unique; let mut _9: *const i32; @@ -27,20 +27,17 @@ bb1: { StorageLive(_5); -- _6 = move _4 as *const i32 (Transmute); + _6 = move _4 as (*const i32) is !null (Transmute); - _7 = NonNull:: { pointer: move _6 }; -- _8 = std::ptr::Unique:: { pointer: move _7, _marker: const PhantomData:: }; -+ _6 = copy _4 as *const i32 (PtrToPtr); + _7 = NonNull:: { pointer: copy _6 }; -+ _8 = std::ptr::Unique:: { pointer: copy _7, _marker: const PhantomData:: }; + _8 = std::ptr::Unique:: { pointer: move _7, _marker: const PhantomData:: }; _5 = Box::(move _8, const std::alloc::Global); -- _9 = copy ((_5.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); -- (*_9) = const 42_i32; -+ _9 = copy _6; -+ (*_6) = const 42_i32; +- _9 = copy (((_5.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); ++ _9 = copy _6 as *const i32 (Transmute); + (*_9) = const 42_i32; _3 = move _5; StorageDead(_5); - _10 = copy ((_3.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _10 = copy (((_3.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); _2 = copy (*_10); - _1 = Add(move _2, const 0_i32); - StorageDead(_2); diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff index bd24af602c88c..62152fc5a3b03 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff @@ -12,9 +12,9 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -- _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); -+ _2 = const std::ptr::NonNull:: {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute); +- _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); ++ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _2 = const {0x1 as *const Never} is !null as *const Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff index bd24af602c88c..62152fc5a3b03 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff @@ -12,9 +12,9 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -- _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); -+ _2 = const std::ptr::NonNull:: {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute); +- _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); ++ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData:: }}, std::alloc::Global); ++ _2 = const {0x1 as *const Never} is !null as *const Never (Transmute); unreachable; } } 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..cc3de5b2c3991 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +44,16 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _6 = const {0x1 as *const [bool; 0]} is !null; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; 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..27ee44f8b9aee 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +44,16 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _6 = const {0x1 as *const [bool; 0]} is !null; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; 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..94ffb9aa98cde 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +44,16 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _6 = const {0x1 as *const [bool; 0]} is !null; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; 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..21951f51b5065 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,16 +44,16 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _6 = const {0x1 as *const [bool; 0]} is !null; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; + _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; 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..838123ff794a3 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +44,22 @@ 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]} }}; +- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as (*const [bool; 0]) is !null (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: move _6 }; ++ _6 = const {0x1 as *const [bool; 0]} is !null; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; ++ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; 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..1bcb82708b08d 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +44,22 @@ 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]} }}; +- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as (*const [bool; 0]) is !null (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: move _6 }; ++ _6 = const {0x1 as *const [bool; 0]} is !null; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; ++ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; 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..1c7a8fbf523e6 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +44,22 @@ 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]} }}; +- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as (*const [bool; 0]) is !null (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: move _6 }; ++ _6 = const {0x1 as *const [bool; 0]} is !null; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; ++ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; 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..b1085f32789f8 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,7 +20,7 @@ scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _6: *const [bool; 0]; + let mut _6: (*const [bool; 0]) is !null; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -44,22 +44,22 @@ 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]} }}; +- _6 = const <[bool; 0] as std::mem::SizedTypeProperties>::ALIGNMENT as (*const [bool; 0]) is !null (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: move _6 }; ++ _6 = const {0x1 as *const [bool; 0]} is !null; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}; StorageDead(_6); - _4 = std::ptr::Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; ++ _4 = const std::ptr::Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit)); -+ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; ++ _3 = const std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(copy _3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); ++ _2 = const Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_3); - _1 = A { foo: move _2 }; -+ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; ++ _1 = const A {{ foo: Box::<[bool]>(std::ptr::Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff index 3bc5f85075909..3d6ec81b6ab10 100644 --- a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff @@ -12,8 +12,8 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); ++ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData:: }}, std::alloc::Global); + _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff index 3bc5f85075909..3d6ec81b6ab10 100644 --- a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff @@ -12,8 +12,8 @@ bb0: { StorageLive(_1); - _1 = const 1_usize as std::boxed::Box (Transmute); -+ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); ++ _1 = const Box::(std::ptr::Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData:: }}, std::alloc::Global); + _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index f3ccc66cdc956..a16ddc71885d0 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -11,9 +11,9 @@ let mut _9: *const [()]; let mut _10: std::boxed::Box<()>; let mut _11: *const (); - let mut _16: usize; let mut _17: usize; - let mut _26: usize; + let mut _18: usize; + let mut _29: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -27,7 +27,7 @@ debug _x => _8; } scope 19 (inlined foo) { - let mut _27: *const [()]; + let mut _30: *const [()]; } } scope 17 (inlined slice_from_raw_parts::<()>) { @@ -38,21 +38,24 @@ } scope 5 (inlined Box::<()>::new) { let mut _12: *mut u8; - let mut _13: *const (); + let mut _13: (*const ()) is !null; let mut _14: std::ptr::NonNull<()>; let mut _15: std::ptr::Unique<()>; + let mut _16: *const (); scope 6 (inlined alloc::alloc::exchange_malloc) { - let _18: std::alloc::Layout; - let mut _19: std::result::Result, std::alloc::AllocError>; - let mut _20: isize; - let mut _22: !; + let _19: std::alloc::Layout; + let mut _20: std::result::Result, std::alloc::AllocError>; + let mut _21: isize; + let mut _23: !; scope 7 { - let _21: std::ptr::NonNull<[u8]>; + let _22: std::ptr::NonNull<[u8]>; scope 8 { scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 14 (inlined NonNull::<[u8]>::cast::) { - let mut _25: *mut [u8]; + let mut _26: (*const u8) is !null; + let mut _27: *mut u8; + let mut _28: *mut [u8]; scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -67,8 +70,8 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let _23: (); - let mut _24: std::ptr::Alignment; + let _24: (); + let mut _25: std::ptr::Alignment; } } } @@ -85,16 +88,17 @@ StorageLive(_14); StorageLive(_15); StorageLive(_16); -- _16 = const <() as std::mem::SizedTypeProperties>::SIZE; -+ _16 = const 0_usize; StorageLive(_17); -- _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; -+ _17 = const 1_usize; +- _17 = const <() as std::mem::SizedTypeProperties>::SIZE; ++ _17 = const 0_usize; StorageLive(_18); - StorageLive(_20); +- _18 = const <() as std::mem::SizedTypeProperties>::ALIGN; ++ _18 = const 1_usize; + StorageLive(_19); StorageLive(_21); StorageLive(_22); StorageLive(_23); + StorageLive(_24); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -109,33 +113,41 @@ } bb3: { -- _22 = handle_alloc_error(move _18) -> unwind unreachable; -+ _22 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; +- _23 = handle_alloc_error(move _19) -> unwind unreachable; ++ _23 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; } bb4: { - _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_25); + _22 = copy ((_20 as Ok).0: std::ptr::NonNull<[u8]>); + StorageLive(_26); +- StorageLive(_27); + nop; - _25 = copy _21 as *mut [u8] (Transmute); - _12 = copy _25 as *mut u8 (PtrToPtr); -- StorageDead(_25); + StorageLive(_28); + _28 = copy _22 as *mut [u8] (Transmute); + _27 = copy _28 as *mut u8 (PtrToPtr); + StorageDead(_28); + _26 = copy _27 as (*const u8) is !null (Transmute); +- StorageDead(_27); + nop; - StorageDead(_19); + _12 = copy _26 as *mut u8 (Transmute); + StorageDead(_26); + StorageDead(_20); + StorageDead(_24); StorageDead(_23); StorageDead(_22); StorageDead(_21); - StorageDead(_20); + StorageDead(_19); StorageDead(_18); StorageDead(_17); - StorageDead(_16); -- _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _25 as *const () (PtrToPtr); +- _13 = copy _12 as (*const ()) is !null (Transmute); ++ _13 = copy _27 as (*const ()) is !null (Transmute); _14 = NonNull::<()> { pointer: copy _13 }; - _15 = std::ptr::Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; + _15 = std::ptr::Unique::<()> { pointer: move _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); -- (*_13) = move _4; -+ (*_13) = const (); + _16 = copy _13 as *const () (Transmute); +- (*_16) = move _4; ++ (*_16) = const (); + StorageDead(_16); StorageDead(_15); StorageDead(_14); StorageDead(_13); @@ -147,27 +159,27 @@ - StorageLive(_5); + nop; _10 = copy (*_1); - _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _11 = copy (((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>).0: (*const ()) is !null) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_26); - _26 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _26); + StorageLive(_29); + _29 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _29); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_26); + StorageDead(_29); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_27); -- _27 = copy _9; + StorageLive(_30); +- _30 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _27 = copy _6; ++ _30 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_27); + StorageDead(_30); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -179,25 +191,25 @@ } bb5: { -- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; -+ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _24 = Layout::from_size_align_unchecked::precondition_check(copy _17, copy _18) -> [return: bb6, unwind unreachable]; ++ _24 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageLive(_24); -- _24 = copy _17 as std::ptr::Alignment (Transmute); -- _18 = Layout { size: copy _16, align: move _24 }; -+ _24 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; -+ _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; - StorageDead(_24); - StorageLive(_19); -- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable]; -+ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; + StorageLive(_25); +- _25 = copy _18 as std::ptr::Alignment (Transmute); +- _19 = Layout { size: copy _17, align: move _25 }; ++ _25 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; ++ _19 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; + StorageDead(_25); + StorageLive(_20); +- _20 = std::alloc::Global::alloc_impl_runtime(copy _19, const false) -> [return: bb7, unwind unreachable]; ++ _20 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb4, 1: bb3, otherwise: bb2]; + _21 = discriminant(_20); + switchInt(move _21) -> [0: bb4, 1: bb3, otherwise: bb2]; } + } + diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff index 9a354fc005ed5..1896f5aafad23 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff @@ -54,7 +54,7 @@ - StorageLive(_5); + nop; _10 = copy (*_1); - _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _11 = copy (((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>).0: (*const ()) is !null) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index f8d781bb706f0..d6dfa5b93571d 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -11,9 +11,9 @@ let mut _9: *const [()]; let mut _10: std::boxed::Box<()>; let mut _11: *const (); - let mut _16: usize; let mut _17: usize; - let mut _26: usize; + let mut _18: usize; + let mut _29: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -27,7 +27,7 @@ debug _x => _8; } scope 19 (inlined foo) { - let mut _27: *const [()]; + let mut _30: *const [()]; } } scope 17 (inlined slice_from_raw_parts::<()>) { @@ -38,21 +38,24 @@ } scope 5 (inlined Box::<()>::new) { let mut _12: *mut u8; - let mut _13: *const (); + let mut _13: (*const ()) is !null; let mut _14: std::ptr::NonNull<()>; let mut _15: std::ptr::Unique<()>; + let mut _16: *const (); scope 6 (inlined alloc::alloc::exchange_malloc) { - let _18: std::alloc::Layout; - let mut _19: std::result::Result, std::alloc::AllocError>; - let mut _20: isize; - let mut _22: !; + let _19: std::alloc::Layout; + let mut _20: std::result::Result, std::alloc::AllocError>; + let mut _21: isize; + let mut _23: !; scope 7 { - let _21: std::ptr::NonNull<[u8]>; + let _22: std::ptr::NonNull<[u8]>; scope 8 { scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 14 (inlined NonNull::<[u8]>::cast::) { - let mut _25: *mut [u8]; + let mut _26: (*const u8) is !null; + let mut _27: *mut u8; + let mut _28: *mut [u8]; scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -67,8 +70,8 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let _23: (); - let mut _24: std::ptr::Alignment; + let _24: (); + let mut _25: std::ptr::Alignment; } } } @@ -85,16 +88,17 @@ StorageLive(_14); StorageLive(_15); StorageLive(_16); -- _16 = const <() as std::mem::SizedTypeProperties>::SIZE; -+ _16 = const 0_usize; StorageLive(_17); -- _17 = const <() as std::mem::SizedTypeProperties>::ALIGN; -+ _17 = const 1_usize; +- _17 = const <() as std::mem::SizedTypeProperties>::SIZE; ++ _17 = const 0_usize; StorageLive(_18); - StorageLive(_20); +- _18 = const <() as std::mem::SizedTypeProperties>::ALIGN; ++ _18 = const 1_usize; + StorageLive(_19); StorageLive(_21); StorageLive(_22); StorageLive(_23); + StorageLive(_24); switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } @@ -109,33 +113,41 @@ } bb3: { -- _22 = handle_alloc_error(move _18) -> unwind unreachable; -+ _22 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; +- _23 = handle_alloc_error(move _19) -> unwind unreachable; ++ _23 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> unwind unreachable; } bb4: { - _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_25); + _22 = copy ((_20 as Ok).0: std::ptr::NonNull<[u8]>); + StorageLive(_26); +- StorageLive(_27); + nop; - _25 = copy _21 as *mut [u8] (Transmute); - _12 = copy _25 as *mut u8 (PtrToPtr); -- StorageDead(_25); + StorageLive(_28); + _28 = copy _22 as *mut [u8] (Transmute); + _27 = copy _28 as *mut u8 (PtrToPtr); + StorageDead(_28); + _26 = copy _27 as (*const u8) is !null (Transmute); +- StorageDead(_27); + nop; - StorageDead(_19); + _12 = copy _26 as *mut u8 (Transmute); + StorageDead(_26); + StorageDead(_20); + StorageDead(_24); StorageDead(_23); StorageDead(_22); StorageDead(_21); - StorageDead(_20); + StorageDead(_19); StorageDead(_18); StorageDead(_17); - StorageDead(_16); -- _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _25 as *const () (PtrToPtr); +- _13 = copy _12 as (*const ()) is !null (Transmute); ++ _13 = copy _27 as (*const ()) is !null (Transmute); _14 = NonNull::<()> { pointer: copy _13 }; - _15 = std::ptr::Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; + _15 = std::ptr::Unique::<()> { pointer: move _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); -- (*_13) = move _4; -+ (*_13) = const (); + _16 = copy _13 as *const () (Transmute); +- (*_16) = move _4; ++ (*_16) = const (); + StorageDead(_16); StorageDead(_15); StorageDead(_14); StorageDead(_13); @@ -147,27 +159,27 @@ - StorageLive(_5); + nop; _10 = copy (*_1); - _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _11 = copy (((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>).0: (*const ()) is !null) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_26); - _26 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _26); + StorageLive(_29); + _29 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _29); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_26); + StorageDead(_29); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_27); -- _27 = copy _9; + StorageLive(_30); +- _30 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _27 = copy _6; ++ _30 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_27); + StorageDead(_30); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -179,25 +191,25 @@ } bb5: { -- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; -+ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _24 = Layout::from_size_align_unchecked::precondition_check(copy _17, copy _18) -> [return: bb6, unwind unreachable]; ++ _24 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageLive(_24); -- _24 = copy _17 as std::ptr::Alignment (Transmute); -- _18 = Layout { size: copy _16, align: move _24 }; -+ _24 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; -+ _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; - StorageDead(_24); - StorageLive(_19); -- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable]; -+ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; + StorageLive(_25); +- _25 = copy _18 as std::ptr::Alignment (Transmute); +- _19 = Layout { size: copy _17, align: move _25 }; ++ _25 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; ++ _19 = const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}; + StorageDead(_25); + StorageLive(_20); +- _20 = std::alloc::Global::alloc_impl_runtime(copy _19, const false) -> [return: bb7, unwind unreachable]; ++ _20 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb4, 1: bb3, otherwise: bb2]; + _21 = discriminant(_20); + switchInt(move _21) -> [0: bb4, 1: bb3, otherwise: bb2]; } + } + diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff index 9a354fc005ed5..1896f5aafad23 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff @@ -54,7 +54,7 @@ - StorageLive(_5); + nop; _10 = copy (*_1); - _11 = copy ((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _11 = copy (((_10.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>).0: (*const ()) is !null) as *const () (Transmute); _5 = &raw const (*_11); - StorageLive(_6); + nop; diff --git a/tests/mir-opt/elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff b/tests/mir-opt/elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff index 279c1a1990dc8..6075d7895eeb3 100644 --- a/tests/mir-opt/elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff +++ b/tests/mir-opt/elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff @@ -3,7 +3,7 @@ fn pointee(_1: Box) -> () { - debug foo => (*_1); -+ debug foo => (*(((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const i32)); ++ debug foo => (*((((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null).0: *const i32)); let mut _0: (); bb0: { diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff index 86e8749fb0b51..d2e25368322f4 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-abort.diff @@ -10,7 +10,7 @@ + scope 1 (inlined > as FnMut>::call_mut) { + let mut _5: &mut dyn std::ops::FnMut; + let mut _6: *const dyn std::ops::FnMut; -+ let mut _7: std::ptr::NonNull>; ++ let mut _7: (*const dyn std::ops::FnMut) is !null; + } bb0: { @@ -22,7 +22,7 @@ + StorageLive(_6); + StorageLive(_7); + StorageLive(_5); -+ _7 = copy (((*_3).0: std::ptr::Unique>).0: std::ptr::NonNull>); ++ _7 = copy ((((*_3).0: std::ptr::Unique>).0: std::ptr::NonNull>).0: (*const dyn std::ops::FnMut) is !null); + _6 = copy _7 as *const dyn std::ops::FnMut (Transmute); + _5 = &mut (*_6); + _0 = as FnMut>::call_mut(move _5, move _4) -> [return: bb2, unwind unreachable]; diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff index 50136ae8766b2..181f29866f923 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ + scope 1 (inlined > as FnMut>::call_mut) { + let mut _5: &mut dyn std::ops::FnMut; + let mut _6: *const dyn std::ops::FnMut; -+ let mut _7: std::ptr::NonNull>; ++ let mut _7: (*const dyn std::ops::FnMut) is !null; + } bb0: { @@ -22,7 +22,7 @@ + StorageLive(_6); + StorageLive(_7); + StorageLive(_5); -+ _7 = copy (((*_3).0: std::ptr::Unique>).0: std::ptr::NonNull>); ++ _7 = copy ((((*_3).0: std::ptr::Unique>).0: std::ptr::NonNull>).0: (*const dyn std::ops::FnMut) is !null); + _6 = copy _7 as *const dyn std::ops::FnMut (Transmute); + _5 = &mut (*_6); + _0 = as FnMut>::call_mut(move _5, move _4) -> [return: bb4, unwind: bb2]; diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff index 97a8a99d9805e..67a46ec24d3bc 100644 --- a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-abort.diff @@ -10,7 +10,7 @@ + scope 1 (inlined as Fn<(i32,)>>::call) { + let mut _5: &dyn std::ops::Fn(i32); + let mut _6: *const dyn std::ops::Fn(i32); -+ let mut _7: std::ptr::NonNull; ++ let mut _7: (*const dyn std::ops::Fn(i32)) is !null; + } bb0: { @@ -23,7 +23,7 @@ + StorageLive(_6); + StorageLive(_7); + StorageLive(_5); -+ _7 = copy (((*_3).0: std::ptr::Unique).0: std::ptr::NonNull); ++ _7 = copy ((((*_3).0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const dyn std::ops::Fn(i32)) is !null); + _6 = copy _7 as *const dyn std::ops::Fn(i32) (Transmute); + _5 = &(*_6); + _2 = >::call(move _5, move _4) -> [return: bb2, unwind unreachable]; diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff index 3b18052616e2f..77ff90546e33b 100644 --- a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ + scope 1 (inlined as Fn<(i32,)>>::call) { + let mut _5: &dyn std::ops::Fn(i32); + let mut _6: *const dyn std::ops::Fn(i32); -+ let mut _7: std::ptr::NonNull; ++ let mut _7: (*const dyn std::ops::Fn(i32)) is !null; + } bb0: { @@ -23,7 +23,7 @@ + StorageLive(_6); + StorageLive(_7); + StorageLive(_5); -+ _7 = copy (((*_3).0: std::ptr::Unique).0: std::ptr::NonNull); ++ _7 = copy ((((*_3).0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const dyn std::ops::Fn(i32)) is !null); + _6 = copy _7 as *const dyn std::ops::Fn(i32) (Transmute); + _5 = &(*_6); + _2 = >::call(move _5, move _4) -> [return: bb4, unwind: bb2]; diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index 688e6967c2f85..7ec117ff85994 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -9,7 +9,7 @@ fn b(_1: &mut Box) -> &mut T { scope 1 (inlined as AsMut>::as_mut) { debug self => _4; let mut _5: *const T; - let mut _6: std::ptr::NonNull; + let mut _6: (*const T) is !null; } bb0: { @@ -19,7 +19,7 @@ fn b(_1: &mut Box) -> &mut T { _4 = copy _1; StorageLive(_5); StorageLive(_6); - _6 = copy (((*_4).0: std::ptr::Unique).0: std::ptr::NonNull); + _6 = copy ((((*_4).0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const T) is !null); _5 = copy _6 as *const T (Transmute); _3 = &mut (*_5); StorageDead(_6); diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index 663741c62fb84..e2ab5194ddb27 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -8,7 +8,7 @@ fn d(_1: &Box) -> &T { scope 1 (inlined as AsRef>::as_ref) { debug self => _3; let mut _4: *const T; - let mut _5: std::ptr::NonNull; + let mut _5: (*const T) is !null; } bb0: { @@ -17,7 +17,7 @@ fn d(_1: &Box) -> &T { _3 = copy _1; StorageLive(_4); StorageLive(_5); - _5 = copy (((*_3).0: std::ptr::Unique).0: std::ptr::NonNull); + _5 = copy ((((*_3).0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const T) is !null); _4 = copy _5 as *const T (Transmute); _2 = &(*_4); StorageDead(_5); diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff index 644d6d320de04..bef8e43903e56 100644 --- a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -12,7 +12,7 @@ StorageLive(_2); StorageLive(_3); _3 = move _1; - _4 = copy ((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>) as *const [i32] (Transmute); + _4 = copy (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: (*const [i32]) is !null) as *const [i32] (Transmute); _2 = callee(move (*_4)) -> [return: bb1, unwind: bb3]; } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-abort.diff index 4f8b7c4160f99..4d97a9f5c5251 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-abort.diff @@ -17,7 +17,7 @@ } bb1: { - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); + _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); PlaceMention((*_2)); unreachable; } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff index 4f8b7c4160f99..4d97a9f5c5251 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff @@ -17,7 +17,7 @@ } bb1: { - _2 = copy ((_1.0: std::ptr::Unique).0: std::ptr::NonNull) as *const Never (Transmute); + _2 = copy (((_1.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const Never) is !null) as *const Never (Transmute); PlaceMention((*_2)); unreachable; } 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 f8e575f490b0c..1a8c1c83da9fc 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 _9: (); + let _11: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _8: *mut u8; + let mut _9: (*const u8) is !null; 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 _8: *mut u8; + let mut _10: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -73,6 +75,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -93,16 +96,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_8); _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + _9 = copy _8 as (*const u8) is !null (Transmute); + StorageDead(_8); + StorageLive(_10); + _10 = copy _9 as *mut u8 (Transmute); + _11 = alloc::alloc::__rust_dealloc(move _10, move _5, move _7) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); goto -> bb4; } bb4: { StorageDead(_2); + 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 f8e575f490b0c..1a8c1c83da9fc 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 _9: (); + let _11: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _8: *mut u8; + let mut _9: (*const u8) is !null; 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 _8: *mut u8; + let mut _10: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -73,6 +75,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -93,16 +96,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_8); _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + _9 = copy _8 as (*const u8) is !null (Transmute); + StorageDead(_8); + StorageLive(_10); + _10 = copy _9 as *mut u8 (Transmute); + _11 = alloc::alloc::__rust_dealloc(move _10, move _5, move _7) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); goto -> bb4; } bb4: { StorageDead(_2); + 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 f8e575f490b0c..1a8c1c83da9fc 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 _9: (); + let _11: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _8: *mut u8; + let mut _9: (*const u8) is !null; 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 _8: *mut u8; + let mut _10: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -73,6 +75,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -93,16 +96,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_8); _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + _9 = copy _8 as (*const u8) is !null (Transmute); + StorageDead(_8); + StorageLive(_10); + _10 = copy _9 as *mut u8 (Transmute); + _11 = alloc::alloc::__rust_dealloc(move _10, move _5, move _7) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); goto -> bb4; } bb4: { StorageDead(_2); + 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 f8e575f490b0c..1a8c1c83da9fc 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 _9: (); + let _11: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { } scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { scope 19 (inlined NonNull::<[T]>::cast::) { + let mut _8: *mut u8; + let mut _9: (*const u8) is !null; 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 _8: *mut u8; + let mut _10: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -73,6 +75,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb0: { + StorageLive(_3); StorageLive(_2); _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>); StorageLive(_4); @@ -93,16 +96,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { bb2: { StorageLive(_8); _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + _9 = copy _8 as (*const u8) is !null (Transmute); + StorageDead(_8); + StorageLive(_10); + _10 = copy _9 as *mut u8 (Transmute); + _11 = alloc::alloc::__rust_dealloc(move _10, move _5, move _7) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_10); goto -> bb4; } bb4: { StorageDead(_2); + 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..0d5bcc4ae6193 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 @@ -3,17 +3,17 @@ fn vec_move(_1: Vec) -> () { debug v => _1; let mut _0: (); - let mut _22: std::vec::IntoIter; let mut _23: std::vec::IntoIter; - let mut _24: &mut std::vec::IntoIter; - let mut _25: std::option::Option; - let mut _26: isize; - let _28: (); + let mut _24: std::vec::IntoIter; + let mut _25: &mut std::vec::IntoIter; + let mut _26: std::option::Option; + let mut _27: isize; + let _29: (); scope 1 { - debug iter => _23; - let _27: impl Sized; + debug iter => _24; + let _28: impl Sized; scope 2 { - debug x => _27; + debug x => _28; } } scope 3 (inlined as IntoIterator>::into_iter) { @@ -24,16 +24,16 @@ fn vec_move(_1: Vec) -> () { let mut _11: *mut impl Sized; let mut _12: *const impl Sized; let mut _13: usize; - let _29: &std::vec::Vec; - let mut _30: &std::mem::ManuallyDrop>; - let mut _31: &alloc::raw_vec::RawVec; - let mut _32: &std::mem::ManuallyDrop>; - let _33: &std::vec::Vec; - let mut _34: &std::mem::ManuallyDrop>; - let _35: &std::vec::Vec; - let mut _36: &std::mem::ManuallyDrop>; - let mut _37: &alloc::raw_vec::RawVec; - let mut _38: &std::mem::ManuallyDrop>; + let _30: &std::vec::Vec; + let mut _31: &std::mem::ManuallyDrop>; + let mut _32: &alloc::raw_vec::RawVec; + let mut _33: &std::mem::ManuallyDrop>; + let _34: &std::vec::Vec; + let mut _35: &std::mem::ManuallyDrop>; + let _36: &std::vec::Vec; + let mut _37: &std::mem::ManuallyDrop>; + let mut _38: &alloc::raw_vec::RawVec; + let mut _39: &std::mem::ManuallyDrop>; scope 4 { debug me => _3; scope 5 { @@ -46,37 +46,37 @@ fn vec_move(_1: Vec) -> () { debug begin => _8; scope 8 { debug end => _12; - let _20: usize; + let _21: usize; scope 9 { - debug cap => _20; + debug cap => _21; } scope 45 (inlined > as Deref>::deref) { - debug self => _38; + debug self => _39; scope 46 (inlined MaybeDangling::>::as_ref) { } } scope 47 (inlined alloc::raw_vec::RawVec::::capacity) { - debug self => _37; - let mut _39: &alloc::raw_vec::RawVecInner; + debug self => _38; + let mut _40: &alloc::raw_vec::RawVecInner; scope 48 (inlined std::mem::size_of::) { } scope 49 (inlined alloc::raw_vec::RawVecInner::capacity) { - debug self => _39; + debug self => _40; debug elem_size => const ::SIZE; - let mut _21: core::num::niche_types::UsizeNoHighBit; + let mut _22: core::num::niche_types::UsizeNoHighBit; scope 50 (inlined core::num::niche_types::UsizeNoHighBit::as_inner) { - debug self => _21; + debug self => _22; } } } } scope 29 (inlined > as Deref>::deref) { - debug self => _34; + debug self => _35; scope 30 (inlined MaybeDangling::>::as_ref) { } } scope 31 (inlined Vec::::len) { - debug self => _33; + debug self => _34; let mut _14: bool; scope 32 { } @@ -86,6 +86,7 @@ fn vec_move(_1: Vec) -> () { debug count => _13; let mut _15: *mut u8; let mut _19: *mut u8; + let mut _20: *const impl Sized; scope 34 (inlined std::ptr::mut_ptr::::cast::) { debug self => _8; } @@ -102,21 +103,21 @@ fn vec_move(_1: Vec) -> () { } scope 37 (inlined std::ptr::mut_ptr::::with_metadata_of::) { debug self => _19; - debug meta => _6; + debug meta => _20; scope 38 (inlined std::ptr::metadata::) { - debug ptr => _6; + debug ptr => _20; } scope 39 (inlined std::ptr::from_raw_parts_mut::) { } } } scope 40 (inlined > as Deref>::deref) { - debug self => _36; + debug self => _37; scope 41 (inlined MaybeDangling::>::as_ref) { } } scope 42 (inlined Vec::::len) { - debug self => _35; + debug self => _36; let mut _10: bool; scope 43 { } @@ -131,17 +132,17 @@ fn vec_move(_1: Vec) -> () { } } scope 20 (inlined > as Deref>::deref) { - debug self => _32; + debug self => _33; scope 21 (inlined MaybeDangling::>::as_ref) { } } scope 22 (inlined alloc::raw_vec::RawVec::::non_null) { - debug self => _31; + debug self => _32; scope 23 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _5: std::ptr::NonNull; scope 24 (inlined std::ptr::Unique::::cast::) { scope 25 (inlined NonNull::::cast::) { - let mut _6: *const impl Sized; + let mut _6: (*const impl Sized) is !null; scope 26 (inlined NonNull::::as_ptr) { } } @@ -152,12 +153,12 @@ fn vec_move(_1: Vec) -> () { } } scope 12 (inlined > as Deref>::deref) { - debug self => _30; + debug self => _31; scope 13 (inlined MaybeDangling::>::as_ref) { } } scope 14 (inlined Vec::::allocator) { - debug self => _29; + debug self => _30; scope 15 (inlined alloc::raw_vec::RawVec::::allocator) { scope 16 (inlined alloc::raw_vec::RawVecInner::allocator) { } @@ -181,12 +182,11 @@ fn vec_move(_1: Vec) -> () { } bb0: { - StorageLive(_22); + StorageLive(_23); StorageLive(_7); StorageLive(_8); StorageLive(_12); - StorageLive(_20); - StorageLive(_6); + StorageLive(_21); StorageLive(_5); StorageLive(_18); StorageLive(_3); @@ -195,15 +195,17 @@ fn vec_move(_1: Vec) -> () { _3 = ManuallyDrop::> { value: move _2 }; StorageDead(_2); StorageLive(_4); - // DBG: _30 = &_3; - // DBG: _29 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); + // DBG: _31 = &_3; + // DBG: _30 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); _4 = &raw const (((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).2: std::alloc::Global); StorageDead(_4); - // DBG: _32 = &_3; - // DBG: _31 = &(((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec); + // DBG: _33 = &_3; + // DBG: _32 = &(((_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 }; + StorageLive(_6); + _6 = copy _5 as (*const impl Sized) is !null (Transmute); + _7 = NonNull:: { pointer: move _6 }; + StorageDead(_6); _8 = copy _5 as *mut impl Sized (Transmute); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } @@ -211,8 +213,8 @@ fn vec_move(_1: Vec) -> () { bb1: { StorageLive(_11); StorageLive(_9); - // DBG: _36 = &_3; - // DBG: _35 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); + // DBG: _37 = &_3; + // DBG: _36 = &((_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); @@ -227,8 +229,8 @@ fn vec_move(_1: Vec) -> () { bb2: { StorageLive(_13); - // DBG: _34 = &_3; - // DBG: _33 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); + // DBG: _35 = &_3; + // DBG: _34 = &((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec); _13 = copy (((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).1: usize); StorageLive(_14); _14 = Le(copy _13, const ::MAX_SLICE_LEN); @@ -249,6 +251,9 @@ fn vec_move(_1: Vec) -> () { _19 = copy _18 as *mut u8 (PtrToPtr); StorageDead(_16); StorageDead(_15); + StorageLive(_20); + _20 = copy _5 as *const impl Sized (Transmute); + StorageDead(_20); StorageDead(_19); StorageDead(_13); _12 = copy _18 as *const impl Sized (PtrToPtr); @@ -256,69 +261,68 @@ fn vec_move(_1: Vec) -> () { } bb4: { - // DBG: _38 = &_3; - // DBG: _37 = &(((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec); - // DBG: _39 = &((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); + // DBG: _39 = &_3; + // DBG: _38 = &(((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec); + // DBG: _40 = &((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); switchInt(const ::SIZE) -> [0: bb5, otherwise: bb6]; } bb5: { - _20 = const usize::MAX; + _21 = const usize::MAX; goto -> bb7; } bb6: { - StorageLive(_21); - _21 = copy (((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).1: core::num::niche_types::UsizeNoHighBit); - _20 = copy _21 as usize (Transmute); - StorageDead(_21); + StorageLive(_22); + _22 = copy (((((_3.0: std::mem::MaybeDangling>).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).1: core::num::niche_types::UsizeNoHighBit); + _21 = copy _22 as usize (Transmute); + StorageDead(_22); goto -> bb7; } 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 }; + _23 = std::vec::IntoIter:: { buf: copy _7, phantom: const ZeroSized: PhantomData, cap: move _21, alloc: const ManuallyDrop:: {{ value: MaybeDangling::(std::alloc::Global) }}, ptr: copy _7, end: copy _12 }; StorageDead(_3); StorageDead(_18); StorageDead(_5); - StorageDead(_6); - StorageDead(_20); + StorageDead(_21); StorageDead(_12); StorageDead(_8); StorageDead(_7); - StorageLive(_23); - _23 = move _22; + StorageLive(_24); + _24 = move _23; goto -> bb8; } bb8: { - StorageLive(_25); - _24 = &mut _23; - _25 = as Iterator>::next(move _24) -> [return: bb9, unwind: bb15]; + StorageLive(_26); + _25 = &mut _24; + _26 = as Iterator>::next(move _25) -> [return: bb9, unwind: bb15]; } bb9: { - _26 = discriminant(_25); - switchInt(move _26) -> [0: bb10, 1: bb12, otherwise: bb14]; + _27 = discriminant(_26); + switchInt(move _27) -> [0: bb10, 1: bb12, otherwise: bb14]; } bb10: { - StorageDead(_25); - drop(_23) -> [return: bb11, unwind continue]; + StorageDead(_26); + drop(_24) -> [return: bb11, unwind continue]; } bb11: { + StorageDead(_24); StorageDead(_23); - StorageDead(_22); return; } bb12: { - _27 = move ((_25 as Some).0: impl Sized); - _28 = opaque::(move _27) -> [return: bb13, unwind: bb15]; + _28 = move ((_26 as Some).0: impl Sized); + _29 = opaque::(move _28) -> [return: bb13, unwind: bb15]; } bb13: { - StorageDead(_25); + StorageDead(_26); goto -> bb8; } @@ -327,7 +331,7 @@ fn vec_move(_1: Vec) -> () { } bb15 (cleanup): { - drop(_23) -> [return: bb16, unwind terminate(cleanup)]; + drop(_24) -> [return: bb16, unwind terminate(cleanup)]; } bb16 (cleanup): { 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 f72611b7cb8e3..dc3e2f204d5dd 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,34 +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 _28: std::option::Option<(usize, &T)>; - let mut _31: &impl Fn(usize, &T); - let mut _32: (usize, &T); - let _33: (); + let mut _13: usize; + let mut _34: std::option::Option<(usize, &T)>; + let mut _37: &impl Fn(usize, &T); + let mut _38: (usize, &T); + let _39: (); 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) => _9; + debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _12; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - debug ((iter: Enumerate>).1: usize) => _10; - let _29: usize; - let _30: &T; + debug ((iter: Enumerate>).1: usize) => _13; + let _35: usize; + let _36: &T; scope 2 { - debug i => _29; - debug x => _30; + debug i => _35; + debug x => _36; } scope 18 (inlined > as Iterator>::next) { - let mut _23: std::option::Option<&T>; - let mut _26: (usize, bool); - let mut _27: (usize, &T); + let mut _24: std::option::Option; + let mut _29: std::option::Option<&T>; + let mut _32: (usize, bool); + let mut _33: (usize, &T); scope 19 { - let _25: usize; + let _31: usize; scope 24 { } } scope 20 { scope 21 { scope 27 (inlined as FromResidual>>::from_residual) { + let mut _23: isize; + let mut _25: bool; } } } @@ -40,21 +43,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let _24: &T; + let _30: &T; scope 26 { } } scope 28 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _11: std::ptr::NonNull; - let _13: std::ptr::NonNull; - let mut _16: bool; - let mut _20: usize; - let _22: &T; + let mut _9: std::ptr::NonNull; + let _14: std::ptr::NonNull; + let _16: std::ptr::NonNull; + let mut _19: bool; + let mut _26: usize; + let _28: &T; scope 29 { - let _12: *const T; + let _15: *const T; scope 30 { - let _19: usize; + let _22: usize; scope 31 { scope 34 (inlined #[track_caller] core::num::::unchecked_sub) { scope 35 (inlined core::ub_checks::check_language_ub) { @@ -70,21 +73,21 @@ 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 _17: *mut T; + let mut _18: *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 _20: *mut T; + let mut _21: (*const T) is !null; scope 42 (inlined NonNull::::as_ptr) { } } scope 43 (inlined NonNull::::as_ref::<'_>) { - let _21: *const T; + let _27: *const T; scope 44 (inlined NonNull::::as_ptr) { } scope 45 (inlined std::ptr::mut_ptr::::cast_const) { @@ -98,11 +101,11 @@ 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 _10: *mut T; + let mut _11: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -116,9 +119,12 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -134,89 +140,97 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); + StorageDead(_8); + StorageDead(_5); StorageDead(_3); - StorageLive(_10); - _10 = const 0_usize; + StorageLive(_13); + _13 = const 0_usize; goto -> bb4; } bb4: { - StorageLive(_28); - StorageLive(_25); - StorageLive(_26); - StorageLive(_23); - StorageLive(_11); - StorageLive(_12); - StorageLive(_19); - StorageLive(_20); - StorageLive(_13); + StorageLive(_34); + StorageLive(_31); + StorageLive(_32); + StorageLive(_29); + StorageLive(_14); + StorageLive(_15); StorageLive(_22); - _11 = copy _6; - _12 = copy _9; + StorageLive(_26); + StorageLive(_16); + StorageLive(_28); + StorageLive(_17); + _14 = copy _9; + _15 = copy _12; 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(_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(_19); + _16 = copy _15 as std::ptr::NonNull (Transmute); + _17 = copy _14 as *mut T (Transmute); + StorageLive(_18); + _18 = copy _16 as *mut T (Transmute); + _19 = Eq(copy _17, copy _18); + StorageDead(_18); + switchInt(move _19) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_16); - StorageLive(_18); - StorageLive(_17); - _17 = copy _11 as *const T (Transmute); - _18 = Offset(copy _17, const 1_usize); - StorageDead(_17); - _6 = NonNull:: { pointer: copy _18 }; - StorageDead(_18); + StorageDead(_19); + StorageLive(_21); + StorageLive(_20); + _20 = Offset(copy _17, const 1_usize); + _21 = copy _20 as (*const T) is !null (Transmute); + StorageDead(_20); + _9 = NonNull:: { pointer: move _21 }; + StorageDead(_21); goto -> bb13; } bb7: { - StorageDead(_16); + StorageDead(_19); goto -> bb10; } bb8: { - _19 = copy _12 as usize (Transmute); - switchInt(copy _19) -> [0: bb9, otherwise: bb12]; + _22 = copy _15 as usize (Transmute); + switchInt(copy _22) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -224,17 +238,25 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb10: { - StorageDead(_22); - StorageDead(_13); - StorageDead(_20); - StorageDead(_19); - StorageDead(_12); - StorageDead(_11); - StorageDead(_23); + StorageDead(_17); + StorageDead(_28); + StorageDead(_16); StorageDead(_26); + StorageDead(_22); + StorageDead(_15); + StorageDead(_14); + StorageDead(_29); + StorageLive(_23); + StorageLive(_25); + _23 = discriminant(_24); + _25 = Eq(copy _23, const 0_isize); + assume(move _25); StorageDead(_25); - StorageDead(_28); - StorageDead(_10); + StorageDead(_23); + StorageDead(_32); + StorageDead(_31); + StorageDead(_34); + StorageDead(_13); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -243,51 +265,52 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12: { - _20 = SubUnchecked(copy _19, const 1_usize); - _9 = copy _20 as *const T (Transmute); + _26 = SubUnchecked(copy _22, const 1_usize); + _12 = copy _26 as *const T (Transmute); goto -> bb13; } bb13: { - StorageLive(_21); - _21 = copy _11 as *const T (Transmute); - _22 = &(*_21); - StorageDead(_21); - _23 = Option::<&T>::Some(copy _22); - StorageDead(_22); - StorageDead(_13); - StorageDead(_20); - StorageDead(_19); - StorageDead(_12); - StorageDead(_11); - _24 = copy ((_23 as Some).0: &T); - StorageDead(_23); - _25 = copy _10; - _26 = AddWithOverflow(copy _10, const 1_usize); - assert(!move (_26.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _10, const 1_usize) -> [success: bb14, unwind unreachable]; - } - - bb14: { - _10 = move (_26.0: usize); StorageLive(_27); - _27 = (copy _25, copy _24); - _28 = Option::<(usize, &T)>::Some(move _27); + _27 = copy _14 as *const T (Transmute); + _28 = &(*_27); StorageDead(_27); + _29 = Option::<&T>::Some(copy _28); + StorageDead(_17); + StorageDead(_28); + StorageDead(_16); StorageDead(_26); - StorageDead(_25); - _29 = copy (((_28 as Some).0: (usize, &T)).0: usize); - _30 = copy (((_28 as Some).0: (usize, &T)).1: &T); - StorageLive(_31); - _31 = &_2; - StorageLive(_32); - _32 = (copy _29, copy _30); - _33 = >::call(move _31, move _32) -> [return: bb15, unwind unreachable]; + StorageDead(_22); + StorageDead(_15); + StorageDead(_14); + _30 = copy ((_29 as Some).0: &T); + StorageDead(_29); + _31 = copy _13; + _32 = AddWithOverflow(copy _13, const 1_usize); + assert(!move (_32.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _13, const 1_usize) -> [success: bb14, unwind unreachable]; } - bb15: { + bb14: { + _13 = move (_32.0: usize); + StorageLive(_33); + _33 = (copy _31, copy _30); + _34 = Option::<(usize, &T)>::Some(move _33); + StorageDead(_33); StorageDead(_32); StorageDead(_31); - StorageDead(_28); + _35 = copy (((_34 as Some).0: (usize, &T)).0: usize); + _36 = copy (((_34 as Some).0: (usize, &T)).1: &T); + StorageLive(_37); + _37 = &_2; + StorageLive(_38); + _38 = (copy _35, copy _36); + _39 = >::call(move _37, move _38) -> [return: bb15, unwind unreachable]; + } + + bb15: { + StorageDead(_38); + StorageDead(_37); + StorageDead(_34); 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..3932bf10ed308 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,33 @@ 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 _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate>; + let mut _15: std::iter::Enumerate>; + let mut _16: &mut std::iter::Enumerate>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _12; - let _16: usize; - let _17: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _16; - debug x => _17; + debug i => _19; + debug x => _20; } } 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 _10: *mut T; + let mut _11: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _9: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -44,9 +44,12 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -61,61 +64,70 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); StorageLive(_9); - StorageLive(_4); + StorageLive(_12); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = 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); + _13 = std::slice::Iter::<'_, T> { ptr: copy _9, end_or_len: copy _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_8); + StorageDead(_5); + StorageDead(_12); StorageDead(_9); - StorageDead(_6); StorageDead(_3); - _11 = Enumerate::> { iter: copy _10, count: const 0_usize }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _14 = Enumerate::> { iter: copy _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - _13 = &mut _12; - _14 = > as Iterator>::next(move _13) -> [return: bb5, unwind: bb11]; + _16 = &mut _15; + _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_12); + StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -124,18 +136,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]; + _19 = copy (((_17 as Some).0: (usize, &T)).0: usize); + _20 = copy (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = copy ((_17 as Some).0: (usize, &T)); + _23 = >::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_19); - StorageDead(_18); + StorageDead(_22); + StorageDead(_21); 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..4d755d7fdd1a1 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 _25: std::option::Option<&T>; + let mut _27: &impl Fn(&T); + let mut _28: (&T,); + let _29: (); 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) => _9; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; + let _26: &T; scope 2 { - debug x => _23; + debug x => _26; } scope 16 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _10: std::ptr::NonNull; - let _12: std::ptr::NonNull; - let mut _15: bool; - let mut _19: usize; - let _21: &T; + let mut _9: std::ptr::NonNull; + let _13: std::ptr::NonNull; + let _15: std::ptr::NonNull; + let mut _18: bool; + let mut _22: usize; + let _24: &T; scope 17 { - let _11: *const T; + let _14: *const T; scope 18 { - let _18: usize; + let _21: usize; scope 19 { scope 22 (inlined #[track_caller] core::num::::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { @@ -42,21 +42,21 @@ 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 _16: *mut T; + let mut _17: *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 _19: *mut T; + let mut _20: (*const T) is !null; scope 30 (inlined NonNull::::as_ptr) { } } scope 31 (inlined NonNull::::as_ref::<'_>) { - let _20: *const T; + let _23: *const T; scope 32 (inlined NonNull::::as_ptr) { } scope 33 (inlined std::ptr::mut_ptr::::cast_const) { @@ -69,11 +69,11 @@ 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 _10: *mut T; + let mut _11: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -87,9 +87,12 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -101,84 +104,92 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); + StorageDead(_8); + StorageDead(_5); StorageDead(_3); goto -> bb4; } bb4: { - StorageLive(_22); - StorageLive(_10); - StorageLive(_11); - StorageLive(_18); - StorageLive(_19); - StorageLive(_12); + StorageLive(_25); + StorageLive(_13); + StorageLive(_14); StorageLive(_21); - _10 = copy _6; - _11 = copy _9; + StorageLive(_22); + StorageLive(_15); + StorageLive(_24); + StorageLive(_16); + _13 = copy _9; + _14 = copy _12; 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(_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(_18); + _15 = copy _14 as std::ptr::NonNull (Transmute); + _16 = copy _13 as *mut T (Transmute); + StorageLive(_17); + _17 = copy _15 as *mut T (Transmute); + _18 = Eq(copy _16, copy _17); + StorageDead(_17); + switchInt(move _18) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_15); - StorageLive(_17); - StorageLive(_16); - _16 = copy _10 as *const T (Transmute); - _17 = Offset(copy _16, const 1_usize); - StorageDead(_16); - _6 = NonNull:: { pointer: copy _17 }; - StorageDead(_17); + StorageDead(_18); + StorageLive(_20); + StorageLive(_19); + _19 = Offset(copy _16, const 1_usize); + _20 = copy _19 as (*const T) is !null (Transmute); + StorageDead(_19); + _9 = NonNull:: { pointer: move _20 }; + StorageDead(_20); goto -> bb13; } bb7: { - StorageDead(_15); + StorageDead(_18); goto -> bb10; } bb8: { - _18 = copy _11 as usize (Transmute); - switchInt(copy _18) -> [0: bb9, otherwise: bb12]; + _21 = copy _14 as usize (Transmute); + switchInt(copy _21) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -186,13 +197,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); + StorageDead(_16); + StorageDead(_24); + StorageDead(_15); StorageDead(_22); + StorageDead(_21); + StorageDead(_14); + StorageDead(_13); + StorageDead(_25); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -201,35 +213,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); + _22 = SubUnchecked(copy _21, const 1_usize); + _12 = copy _22 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(_23); + _23 = copy _13 as *const T (Transmute); + _24 = &(*_23); + StorageDead(_23); + _25 = Option::<&T>::Some(copy _24); + StorageDead(_16); + StorageDead(_24); + StorageDead(_15); + StorageDead(_22); StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); - StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind unreachable]; + StorageDead(_14); + StorageDead(_13); + _26 = copy ((_25 as Some).0: &T); + StorageLive(_27); + _27 = &_2; + StorageLive(_28); + _28 = (copy _26,); + _29 = >::call(move _27, move _28) -> [return: bb14, unwind unreachable]; } bb14: { + StorageDead(_28); + StorageDead(_27); StorageDead(_25); - StorageDead(_24); - StorageDead(_22); 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..7c5eed7d57512 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 _25: std::option::Option<&T>; + let mut _27: &impl Fn(&T); + let mut _28: (&T,); + let _29: (); 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) => _9; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _23: &T; + let _26: &T; scope 2 { - debug x => _23; + debug x => _26; } scope 16 (inlined as Iterator>::next) { - let mut _6: std::ptr::NonNull; - let _10: std::ptr::NonNull; - let _12: std::ptr::NonNull; - let mut _15: bool; - let mut _19: usize; - let _21: &T; + let mut _9: std::ptr::NonNull; + let _13: std::ptr::NonNull; + let _15: std::ptr::NonNull; + let mut _18: bool; + let mut _22: usize; + let _24: &T; scope 17 { - let _11: *const T; + let _14: *const T; scope 18 { - let _18: usize; + let _21: usize; scope 19 { scope 22 (inlined #[track_caller] core::num::::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { @@ -42,21 +42,21 @@ 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 _16: *mut T; + let mut _17: *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 _19: *mut T; + let mut _20: (*const T) is !null; scope 30 (inlined NonNull::::as_ptr) { } } scope 31 (inlined NonNull::::as_ref::<'_>) { - let _20: *const T; + let _23: *const T; scope 32 (inlined NonNull::::as_ptr) { } scope 33 (inlined std::ptr::mut_ptr::::cast_const) { @@ -69,11 +69,11 @@ 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 _10: *mut T; + let mut _11: *mut T; scope 5 { scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -87,9 +87,12 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -101,84 +104,92 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_4); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_4); + StorageDead(_8); + StorageDead(_5); StorageDead(_3); goto -> bb4; } bb4: { - StorageLive(_22); - StorageLive(_10); - StorageLive(_11); - StorageLive(_18); - StorageLive(_19); - StorageLive(_12); + StorageLive(_25); + StorageLive(_13); + StorageLive(_14); StorageLive(_21); - _10 = copy _6; - _11 = copy _9; + StorageLive(_22); + StorageLive(_15); + StorageLive(_24); + StorageLive(_16); + _13 = copy _9; + _14 = copy _12; 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(_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(_18); + _15 = copy _14 as std::ptr::NonNull (Transmute); + _16 = copy _13 as *mut T (Transmute); + StorageLive(_17); + _17 = copy _15 as *mut T (Transmute); + _18 = Eq(copy _16, copy _17); + StorageDead(_17); + switchInt(move _18) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_15); - StorageLive(_17); - StorageLive(_16); - _16 = copy _10 as *const T (Transmute); - _17 = Offset(copy _16, const 1_usize); - StorageDead(_16); - _6 = NonNull:: { pointer: copy _17 }; - StorageDead(_17); + StorageDead(_18); + StorageLive(_20); + StorageLive(_19); + _19 = Offset(copy _16, const 1_usize); + _20 = copy _19 as (*const T) is !null (Transmute); + StorageDead(_19); + _9 = NonNull:: { pointer: move _20 }; + StorageDead(_20); goto -> bb13; } bb7: { - StorageDead(_15); + StorageDead(_18); goto -> bb10; } bb8: { - _18 = copy _11 as usize (Transmute); - switchInt(copy _18) -> [0: bb9, otherwise: bb12]; + _21 = copy _14 as usize (Transmute); + switchInt(copy _21) -> [0: bb9, otherwise: bb12]; } bb9: { @@ -186,13 +197,14 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb10: { - StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); + StorageDead(_16); + StorageDead(_24); + StorageDead(_15); StorageDead(_22); + StorageDead(_21); + StorageDead(_14); + StorageDead(_13); + StorageDead(_25); drop(_2) -> [return: bb11, unwind continue]; } @@ -201,35 +213,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); + _22 = SubUnchecked(copy _21, const 1_usize); + _12 = copy _22 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(_23); + _23 = copy _13 as *const T (Transmute); + _24 = &(*_23); + StorageDead(_23); + _25 = Option::<&T>::Some(copy _24); + StorageDead(_16); + StorageDead(_24); + StorageDead(_15); + StorageDead(_22); StorageDead(_21); - StorageDead(_12); - StorageDead(_19); - StorageDead(_18); - StorageDead(_11); - StorageDead(_10); - _23 = copy ((_22 as Some).0: &T); - StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _23,); - _26 = >::call(move _24, move _25) -> [return: bb14, unwind: bb15]; + StorageDead(_14); + StorageDead(_13); + _26 = copy ((_25 as Some).0: &T); + StorageLive(_27); + _27 = &_2; + StorageLive(_28); + _28 = (copy _26,); + _29 = >::call(move _27, move _28) -> [return: bb14, unwind: bb15]; } bb14: { + StorageDead(_28); + StorageDead(_27); StorageDead(_25); - StorageDead(_24); - StorageDead(_22); 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..a383f48e3dcb2 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 _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev>; + let mut _15: std::iter::Rev>; + let mut _37: std::option::Option<&T>; + let mut _39: &impl Fn(&T); + let mut _40: (&T,); + let _41: (); scope 1 { - debug iter => _12; - let _34: &T; + debug iter => _15; + let _38: &T; scope 2 { - debug x => _34; + debug x => _38; } 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 _16: *const T; + let mut _21: bool; + let mut _22: *const T; + let _36: &T; scope 20 { - let _14: std::ptr::NonNull; - let _20: usize; + let _17: std::ptr::NonNull; + let _23: 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 _18: std::ptr::NonNull; + let mut _19: *mut T; + let mut _20: *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 _30: 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 _24: *mut *const T; + let mut _25: *mut std::ptr::NonNull; + let mut _26: std::ptr::NonNull; + let mut _31: *mut *const T; + let mut _32: *mut usize; + let mut _33: usize; + let mut _34: usize; scope 30 { scope 31 { } @@ -66,8 +66,9 @@ 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 _27: *mut T; + let mut _28: *mut T; + let mut _29: (*const T) is !null; scope 40 (inlined NonNull::::as_ptr) { } } @@ -80,7 +81,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 41 (inlined NonNull::::as_ref::<'_>) { - let _31: *const T; + let _35: *const T; scope 42 (inlined NonNull::::as_ptr) { } scope 43 (inlined std::ptr::mut_ptr::::cast_const) { @@ -93,12 +94,12 @@ 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 _10: *mut T; + let mut _11: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _9: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -112,9 +113,12 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -129,176 +133,188 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); StorageLive(_9); - StorageLive(_4); + StorageLive(_12); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = 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); + _13 = std::slice::Iter::<'_, T> { ptr: copy _9, end_or_len: copy _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_8); + StorageDead(_5); + StorageDead(_12); StorageDead(_9); - StorageDead(_6); StorageDead(_3); - _11 = Rev::> { iter: copy _10 }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _14 = Rev::> { iter: copy _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - StorageLive(_33); - StorageLive(_20); - StorageLive(_19); - StorageLive(_14); - StorageLive(_32); - StorageLive(_18); + StorageLive(_37); + StorageLive(_23); + StorageLive(_22); + StorageLive(_17); + StorageLive(_36); + StorageLive(_21); 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); - StorageDead(_15); - StorageLive(_17); - _17 = copy _14 as *mut T (Transmute); - _18 = Eq(copy _16, copy _17); - StorageDead(_17); + _16 = copy ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _17 = copy _16 as std::ptr::NonNull (Transmute); StorageDead(_16); + StorageLive(_19); + StorageLive(_18); + _18 = copy ((_15.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + _19 = copy _18 as *mut T (Transmute); + StorageDead(_18); + StorageLive(_20); + _20 = copy _17 as *mut T (Transmute); + _21 = Eq(copy _19, copy _20); + StorageDead(_20); + StorageDead(_19); 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); + _22 = copy ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _23 = copy _22 as usize (Transmute); + _21 = Eq(copy _23, const 0_usize); goto -> bb7; } bb7: { - switchInt(move _18) -> [0: bb8, otherwise: bb15]; + switchInt(move _21) -> [0: bb8, otherwise: bb15]; } bb8: { + StorageLive(_30); + StorageLive(_32); + StorageLive(_25); StorageLive(_26); - StorageLive(_28); - StorageLive(_22); - StorageLive(_23); 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(_24); + _24 = &raw mut ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _25 = copy _24 as *mut std::ptr::NonNull (PtrToPtr); + StorageDead(_24); + _26 = copy (*_25); 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(_29); + StorageLive(_28); + StorageLive(_27); + _27 = copy _26 as *mut T (Transmute); + _28 = Offset(copy _27, const -1_isize); + StorageDead(_27); + _29 = copy _28 as (*const T) is !null (Transmute); + StorageDead(_28); + _26 = NonNull:: { pointer: move _29 }; + StorageDead(_29); goto -> bb11; } bb11: { - (*_22) = move _23; - _26 = copy (*_22); + (*_25) = move _26; + _30 = copy (*_25); 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); - StorageDead(_29); - (*_28) = move _30; - StorageDead(_30); - _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + StorageLive(_31); + _31 = &raw mut ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _32 = copy _31 as *mut usize (PtrToPtr); + StorageDead(_31); + StorageLive(_34); + StorageLive(_33); + _33 = copy (*_32); + _34 = SubUnchecked(move _33, const 1_usize); + StorageDead(_33); + (*_32) = move _34; + StorageDead(_34); + _30 = copy ((_15.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); goto -> bb13; } bb13: { - StorageDead(_23); - StorageDead(_22); - 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(_25); StorageDead(_32); - StorageDead(_14); - StorageDead(_19); - 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]; + _35 = copy _30 as *const T (Transmute); + _36 = &(*_35); + StorageDead(_35); + StorageDead(_30); + _37 = Option::<&T>::Some(copy _36); + StorageDead(_21); + StorageDead(_36); + StorageDead(_17); + StorageDead(_22); + StorageDead(_23); + _38 = copy ((_37 as Some).0: &T); + StorageLive(_39); + _39 = &_2; + StorageLive(_40); + _40 = (copy _38,); + _41 = >::call(move _39, move _40) -> [return: bb14, unwind unreachable]; } bb14: { - StorageDead(_36); - StorageDead(_35); - StorageDead(_33); + StorageDead(_40); + StorageDead(_39); + StorageDead(_37); goto -> bb4; } bb15: { - StorageDead(_18); - StorageDead(_32); - StorageDead(_14); - StorageDead(_19); - StorageDead(_20); - StorageDead(_33); - StorageDead(_12); + StorageDead(_21); + StorageDead(_36); + StorageDead(_17); + StorageDead(_22); + StorageDead(_23); + StorageDead(_37); + StorageDead(_15); 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..8a32a5bd4c151 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 _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev>; + let mut _15: std::iter::Rev>; + let mut _37: std::option::Option<&T>; + let mut _39: &impl Fn(&T); + let mut _40: (&T,); + let _41: (); scope 1 { - debug iter => _12; - let _34: &T; + debug iter => _15; + let _38: &T; scope 2 { - debug x => _34; + debug x => _38; } 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 _16: *const T; + let mut _21: bool; + let mut _22: *const T; + let _36: &T; scope 20 { - let _14: std::ptr::NonNull; - let _20: usize; + let _17: std::ptr::NonNull; + let _23: 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 _18: std::ptr::NonNull; + let mut _19: *mut T; + let mut _20: *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 _30: 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 _24: *mut *const T; + let mut _25: *mut std::ptr::NonNull; + let mut _26: std::ptr::NonNull; + let mut _31: *mut *const T; + let mut _32: *mut usize; + let mut _33: usize; + let mut _34: usize; scope 30 { scope 31 { } @@ -66,8 +66,9 @@ 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 _27: *mut T; + let mut _28: *mut T; + let mut _29: (*const T) is !null; scope 40 (inlined NonNull::::as_ptr) { } } @@ -80,7 +81,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 41 (inlined NonNull::::as_ref::<'_>) { - let _31: *const T; + let _35: *const T; scope 42 (inlined NonNull::::as_ptr) { } scope 43 (inlined std::ptr::mut_ptr::::cast_const) { @@ -93,12 +94,12 @@ 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 _10: *mut T; + let mut _11: *mut T; scope 5 { - let _6: std::ptr::NonNull; + let _9: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _12: *const T; scope 7 { } scope 11 (inlined std::ptr::without_provenance::) { @@ -112,9 +113,12 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 8 (inlined NonNull::<[T]>::from_ref) { let mut _4: *const [T]; + let mut _5: (*const [T]) is !null; } scope 9 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *mut T; + let mut _8: (*const T) is !null; scope 10 (inlined NonNull::<[T]>::as_ptr) { } } @@ -129,165 +133,177 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_10); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); StorageLive(_9); - StorageLive(_4); + StorageLive(_12); + StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_4); _4 = &raw const (*_1); - StorageLive(_5); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_5); + _5 = copy _4 as (*const [T]) is !null (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 (*const T) is !null (Transmute); + _9 = NonNull:: { pointer: copy _8 }; + StorageDead(_7); 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(_11); + StorageLive(_10); + _10 = copy _8 as *mut T (Transmute); + _11 = Offset(copy _10, copy _3); + StorageDead(_10); + _12 = copy _11 as *const T (PtrToPtr); + StorageDead(_11); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _12 = 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); + _13 = std::slice::Iter::<'_, T> { ptr: copy _9, end_or_len: copy _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_8); + StorageDead(_5); + StorageDead(_12); StorageDead(_9); - StorageDead(_6); StorageDead(_3); - _11 = Rev::> { iter: copy _10 }; - StorageDead(_10); - StorageLive(_12); - _12 = copy _11; + _14 = Rev::> { iter: copy _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - StorageLive(_33); - StorageLive(_20); - StorageLive(_19); - StorageLive(_14); - StorageLive(_32); - StorageLive(_18); + StorageLive(_37); + StorageLive(_23); + StorageLive(_22); + StorageLive(_17); + StorageLive(_36); + StorageLive(_21); 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); - StorageDead(_15); - StorageLive(_17); - _17 = copy _14 as *mut T (Transmute); - _18 = Eq(copy _16, copy _17); - StorageDead(_17); + _16 = copy ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _17 = copy _16 as std::ptr::NonNull (Transmute); StorageDead(_16); + StorageLive(_19); + StorageLive(_18); + _18 = copy ((_15.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + _19 = copy _18 as *mut T (Transmute); + StorageDead(_18); + StorageLive(_20); + _20 = copy _17 as *mut T (Transmute); + _21 = Eq(copy _19, copy _20); + StorageDead(_20); + StorageDead(_19); 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); + _22 = copy ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _23 = copy _22 as usize (Transmute); + _21 = Eq(copy _23, const 0_usize); goto -> bb7; } bb7: { - switchInt(move _18) -> [0: bb8, otherwise: bb17]; + switchInt(move _21) -> [0: bb8, otherwise: bb17]; } bb8: { + StorageLive(_30); + StorageLive(_32); + StorageLive(_25); StorageLive(_26); - StorageLive(_28); - StorageLive(_22); - StorageLive(_23); 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(_24); + _24 = &raw mut ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _25 = copy _24 as *mut std::ptr::NonNull (PtrToPtr); + StorageDead(_24); + _26 = copy (*_25); 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(_29); + StorageLive(_28); + StorageLive(_27); + _27 = copy _26 as *mut T (Transmute); + _28 = Offset(copy _27, const -1_isize); + StorageDead(_27); + _29 = copy _28 as (*const T) is !null (Transmute); + StorageDead(_28); + _26 = NonNull:: { pointer: move _29 }; + StorageDead(_29); goto -> bb11; } bb11: { - (*_22) = move _23; - _26 = copy (*_22); + (*_25) = move _26; + _30 = copy (*_25); 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); - StorageDead(_29); - (*_28) = move _30; - StorageDead(_30); - _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); + StorageLive(_31); + _31 = &raw mut ((_15.0: std::slice::Iter<'_, T>).1: *const T); + _32 = copy _31 as *mut usize (PtrToPtr); + StorageDead(_31); + StorageLive(_34); + StorageLive(_33); + _33 = copy (*_32); + _34 = SubUnchecked(move _33, const 1_usize); + StorageDead(_33); + (*_32) = move _34; + StorageDead(_34); + _30 = copy ((_15.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull); goto -> bb13; } bb13: { - StorageDead(_23); - StorageDead(_22); - 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(_25); StorageDead(_32); - StorageDead(_14); - StorageDead(_19); - 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]; + _35 = copy _30 as *const T (Transmute); + _36 = &(*_35); + StorageDead(_35); + StorageDead(_30); + _37 = Option::<&T>::Some(copy _36); + StorageDead(_21); + StorageDead(_36); + StorageDead(_17); + StorageDead(_22); + StorageDead(_23); + _38 = copy ((_37 as Some).0: &T); + StorageLive(_39); + _39 = &_2; + StorageLive(_40); + _40 = (copy _38,); + _41 = >::call(move _39, move _40) -> [return: bb14, unwind: bb15]; } bb14: { - StorageDead(_36); - StorageDead(_35); - StorageDead(_33); + StorageDead(_40); + StorageDead(_39); + StorageDead(_37); goto -> bb4; } @@ -300,13 +316,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(_21); + StorageDead(_36); + StorageDead(_17); + StorageDead(_22); + StorageDead(_23); + StorageDead(_37); + StorageDead(_15); 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..1f2d7d7c81f04 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 @@ -7,7 +7,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut let mut _2: *mut T; let mut _7: bool; let mut _8: *mut T; - let mut _21: &mut T; + let mut _22: &mut T; scope 2 { let _3: std::ptr::NonNull; let _9: usize; @@ -30,15 +30,15 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 10 (inlined std::slice::IterMut::<'_, T>::next_back_unchecked) { - let mut _15: std::ptr::NonNull; + let mut _16: std::ptr::NonNull; scope 11 (inlined std::slice::IterMut::<'_, T>::pre_dec_end) { let mut _10: *mut *mut T; let mut _11: *mut std::ptr::NonNull; let mut _12: std::ptr::NonNull; - let mut _16: *mut *mut T; - let mut _17: *mut usize; - let mut _18: usize; + let mut _17: *mut *mut T; + let mut _18: *mut usize; let mut _19: usize; + let mut _20: usize; scope 12 { scope 13 { } @@ -51,8 +51,9 @@ 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; + let mut _15: (*const T) is !null; scope 22 (inlined NonNull::::as_ptr) { } } @@ -65,7 +66,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 23 (inlined NonNull::::as_mut::<'_>) { - let mut _20: *mut T; + let mut _21: *mut T; scope 24 (inlined NonNull::::as_ptr) { } } @@ -77,7 +78,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut StorageLive(_8); StorageLive(_3); StorageLive(_2); - StorageLive(_21); + StorageLive(_22); StorageLive(_7); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } @@ -110,8 +111,8 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } bb4: { - StorageLive(_15); - StorageLive(_17); + StorageLive(_16); + StorageLive(_18); StorageLive(_11); StorageLive(_12); switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; @@ -127,48 +128,51 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } bb6: { + StorageLive(_15); 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 }; + _15 = copy _14 as (*const T) is !null (Transmute); StorageDead(_14); + _12 = NonNull:: { pointer: move _15 }; + StorageDead(_15); goto -> bb7; } bb7: { (*_11) = move _12; - _15 = copy (*_11); + _16 = copy (*_11); goto -> bb9; } bb8: { - StorageLive(_16); - _16 = &raw mut ((*_1).1: *mut T); - _17 = copy _16 as *mut usize (PtrToPtr); - StorageDead(_16); + StorageLive(_17); + _17 = &raw mut ((*_1).1: *mut T); + _18 = copy _17 as *mut usize (PtrToPtr); + StorageDead(_17); + StorageLive(_20); StorageLive(_19); - StorageLive(_18); - _18 = copy (*_17); - _19 = SubUnchecked(move _18, const 1_usize); - StorageDead(_18); - (*_17) = move _19; + _19 = copy (*_18); + _20 = SubUnchecked(move _19, const 1_usize); StorageDead(_19); - _15 = copy ((*_1).0: std::ptr::NonNull); + (*_18) = move _20; + StorageDead(_20); + _16 = copy ((*_1).0: std::ptr::NonNull); goto -> bb9; } bb9: { StorageDead(_12); StorageDead(_11); - StorageDead(_17); - StorageLive(_20); - _20 = copy _15 as *mut T (Transmute); - _21 = &mut (*_20); - StorageDead(_20); - StorageDead(_15); - _0 = Option::<&mut T>::Some(copy _21); + StorageDead(_18); + StorageLive(_21); + _21 = copy _16 as *mut T (Transmute); + _22 = &mut (*_21); + StorageDead(_21); + StorageDead(_16); + _0 = Option::<&mut T>::Some(copy _22); goto -> bb11; } @@ -179,7 +183,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut bb11: { StorageDead(_7); - StorageDead(_21); + StorageDead(_22); StorageDead(_2); StorageDead(_3); StorageDead(_8); 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..1f2d7d7c81f04 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 @@ -7,7 +7,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut let mut _2: *mut T; let mut _7: bool; let mut _8: *mut T; - let mut _21: &mut T; + let mut _22: &mut T; scope 2 { let _3: std::ptr::NonNull; let _9: usize; @@ -30,15 +30,15 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 10 (inlined std::slice::IterMut::<'_, T>::next_back_unchecked) { - let mut _15: std::ptr::NonNull; + let mut _16: std::ptr::NonNull; scope 11 (inlined std::slice::IterMut::<'_, T>::pre_dec_end) { let mut _10: *mut *mut T; let mut _11: *mut std::ptr::NonNull; let mut _12: std::ptr::NonNull; - let mut _16: *mut *mut T; - let mut _17: *mut usize; - let mut _18: usize; + let mut _17: *mut *mut T; + let mut _18: *mut usize; let mut _19: usize; + let mut _20: usize; scope 12 { scope 13 { } @@ -51,8 +51,9 @@ 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; + let mut _15: (*const T) is !null; scope 22 (inlined NonNull::::as_ptr) { } } @@ -65,7 +66,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } } scope 23 (inlined NonNull::::as_mut::<'_>) { - let mut _20: *mut T; + let mut _21: *mut T; scope 24 (inlined NonNull::::as_ptr) { } } @@ -77,7 +78,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut StorageLive(_8); StorageLive(_3); StorageLive(_2); - StorageLive(_21); + StorageLive(_22); StorageLive(_7); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } @@ -110,8 +111,8 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } bb4: { - StorageLive(_15); - StorageLive(_17); + StorageLive(_16); + StorageLive(_18); StorageLive(_11); StorageLive(_12); switchInt(const ::IS_ZST) -> [0: bb5, otherwise: bb8]; @@ -127,48 +128,51 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut } bb6: { + StorageLive(_15); 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 }; + _15 = copy _14 as (*const T) is !null (Transmute); StorageDead(_14); + _12 = NonNull:: { pointer: move _15 }; + StorageDead(_15); goto -> bb7; } bb7: { (*_11) = move _12; - _15 = copy (*_11); + _16 = copy (*_11); goto -> bb9; } bb8: { - StorageLive(_16); - _16 = &raw mut ((*_1).1: *mut T); - _17 = copy _16 as *mut usize (PtrToPtr); - StorageDead(_16); + StorageLive(_17); + _17 = &raw mut ((*_1).1: *mut T); + _18 = copy _17 as *mut usize (PtrToPtr); + StorageDead(_17); + StorageLive(_20); StorageLive(_19); - StorageLive(_18); - _18 = copy (*_17); - _19 = SubUnchecked(move _18, const 1_usize); - StorageDead(_18); - (*_17) = move _19; + _19 = copy (*_18); + _20 = SubUnchecked(move _19, const 1_usize); StorageDead(_19); - _15 = copy ((*_1).0: std::ptr::NonNull); + (*_18) = move _20; + StorageDead(_20); + _16 = copy ((*_1).0: std::ptr::NonNull); goto -> bb9; } bb9: { StorageDead(_12); StorageDead(_11); - StorageDead(_17); - StorageLive(_20); - _20 = copy _15 as *mut T (Transmute); - _21 = &mut (*_20); - StorageDead(_20); - StorageDead(_15); - _0 = Option::<&mut T>::Some(copy _21); + StorageDead(_18); + StorageLive(_21); + _21 = copy _16 as *mut T (Transmute); + _22 = &mut (*_21); + StorageDead(_21); + StorageDead(_16); + _0 = Option::<&mut T>::Some(copy _22); goto -> bb11; } @@ -179,7 +183,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut bb11: { StorageDead(_7); - StorageDead(_21); + StorageDead(_22); StorageDead(_2); StorageDead(_3); StorageDead(_8); 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..6cf1c59158e87 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 @@ -37,8 +37,8 @@ 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; + let mut _9: (*const T) is !null; scope 15 (inlined NonNull::::as_ptr) { } } @@ -60,6 +60,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { StorageLive(_12); StorageLive(_4); StorageLive(_14); + StorageLive(_5); _2 = copy ((*_1).0: std::ptr::NonNull); _3 = copy ((*_1).1: *const T); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb4]; @@ -68,13 +69,11 @@ 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]; } @@ -83,10 +82,10 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { 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 (*const T) is !null (Transmute); StorageDead(_8); - _10 = NonNull:: { pointer: copy _9 }; + _10 = NonNull:: { pointer: move _9 }; StorageDead(_9); ((*_1).0: std::ptr::NonNull) = move _10; StorageDead(_10); @@ -125,6 +124,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb8: { + StorageDead(_5); StorageDead(_14); StorageDead(_4); StorageDead(_12); 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..6cf1c59158e87 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 @@ -37,8 +37,8 @@ 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; + let mut _9: (*const T) is !null; scope 15 (inlined NonNull::::as_ptr) { } } @@ -60,6 +60,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { StorageLive(_12); StorageLive(_4); StorageLive(_14); + StorageLive(_5); _2 = copy ((*_1).0: std::ptr::NonNull); _3 = copy ((*_1).1: *const T); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb4]; @@ -68,13 +69,11 @@ 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]; } @@ -83,10 +82,10 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { 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 (*const T) is !null (Transmute); StorageDead(_8); - _10 = NonNull:: { pointer: copy _9 }; + _10 = NonNull:: { pointer: move _9 }; StorageDead(_9); ((*_1).0: std::ptr::NonNull) = move _10; StorageDead(_10); @@ -125,6 +124,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { } bb8: { + StorageDead(_5); StorageDead(_14); StorageDead(_4); StorageDead(_12); diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir index 910983ee79d35..ae7b2cc0b6fc7 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir @@ -164,6 +164,7 @@ fn array_casts() -> () { _31 = &(*_32); StorageLive(_33); _33 = Option::>::None; + Retag(_33); _27 = core::panicking::assert_failed::(move _28, move _29, move _31, move _33) -> unwind unreachable; } } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir index 8cc6bce0e6bd4..789bc34263849 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir @@ -164,6 +164,7 @@ fn array_casts() -> () { _31 = &(*_32); StorageLive(_33); _33 = Option::>::None; + Retag(_33); _27 = core::panicking::assert_failed::(move _28, move _29, move _31, move _33) -> unwind continue; } } diff --git a/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-abort.mir b/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-abort.mir index 4861abead2f32..39bb397d1dd96 100644 --- a/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-abort.mir +++ b/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-abort.mir @@ -9,7 +9,7 @@ fn box_to_raw_mut(_1: &mut Box) -> *mut i32 { bb0: { Retag([fn entry] _1); _2 = copy (*_1); - _3 = copy ((_2.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _3 = copy (((_2.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); _0 = &raw mut (*_3); Retag([raw] _0); return; diff --git a/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-unwind.mir b/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-unwind.mir index 4861abead2f32..39bb397d1dd96 100644 --- a/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-unwind.mir +++ b/tests/mir-opt/retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-unwind.mir @@ -9,7 +9,7 @@ fn box_to_raw_mut(_1: &mut Box) -> *mut i32 { bb0: { Retag([fn entry] _1); _2 = copy (*_1); - _3 = copy ((_2.0: std::ptr::Unique).0: std::ptr::NonNull) as *const i32 (Transmute); + _3 = copy (((_2.0: std::ptr::Unique).0: std::ptr::NonNull).0: (*const i32) is !null) as *const i32 (Transmute); _0 = &raw mut (*_3); Retag([raw] _0); return; diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 6071ad9bb435b..9c9ce6272209e 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -71,7 +71,7 @@ //@[nvptx64] compile-flags: --target nvptx64-nvidia-cuda //@[nvptx64] needs-llvm-components: nvptx //@ ignore-backends: gcc -#![feature(no_core, rustc_attrs, lang_items)] +#![feature(no_core, rustc_attrs, lang_items, pattern_types)] #![feature(unsized_fn_params, transparent_unions)] #![no_core] #![allow(unused, improper_ctypes_definitions, internal_features)] @@ -201,7 +201,7 @@ test_abi_compatible!(isize_int, isize, i64); // Compatibility of 1-ZST. test_abi_compatible!(zst_unit, Zst, ()); test_abi_compatible!(zst_array, Zst, [u8; 0]); -test_abi_compatible!(nonzero_int, NonZero, i32); +test_abi_compatible!(nonzero_int, pattern_type!(i32 is 1..=0x7FFF_FFFF), i32); // `#[repr(C)]` enums should not change ABI based on individual variant inhabitedness. // (However, this is *not* a guarantee. We only guarantee same layout, not same ABI.) @@ -318,6 +318,6 @@ test_nonnull!(mut_unsized, &mut [i32]); test_nonnull!(fn_, fn()); test_nonnull!(nonnull, NonNull); test_nonnull!(nonnull_unsized, NonNull); -test_nonnull!(non_zero, NonZero); +test_nonnull!(non_zero, pattern_type!(i32 is 1..=0x7FFF_FFFF)); fn main() {} diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index be3b539b269a0..3712f4293328e 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -53,7 +53,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; @@ -108,7 +108,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; 14 00 00 00 │ .... } -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 9950ac726ca76..d507896772db4 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -53,7 +53,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; @@ -108,7 +108,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; 14 00 00 00 │ .... } -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index be5c6f77a0877..a51c8ca279aa3 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,4 +1,4 @@ -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:16:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; @@ -69,7 +69,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; HEX_DUMP } -error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 +error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:53:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { @@ -80,7 +80,7 @@ LL | const NULL_FAT_PTR: NonNull = unsafe { HEX_DUMP } -error[E0080]: constructing invalid value: encountered a maybe-null pointer, but expected something that is definitely non-zero +error[E0080]: constructing invalid value at .pointer: encountered a maybe-null pointer, but expected something that is definitely non-zero --> $DIR/ub-nonnull.rs:61:1 | LL | const MAYBE_NULL_PTR: NonNull<()> = unsafe { mem::transmute((&raw const S).wrapping_add(4)) }; diff --git a/tests/ui/lint/invalid_value.stderr b/tests/ui/lint/invalid_value.stderr index 3dd2a521ff2e1..63df1e5d11d68 100644 --- a/tests/ui/lint/invalid_value.stderr +++ b/tests/ui/lint/invalid_value.stderr @@ -314,7 +314,6 @@ LL | let _val: NonNull = mem::uninitialized(); | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull` must be non-null - = note: raw pointers must be initialized error: the type `(NonZero, i32)` does not permit zero-initialization --> $DIR/invalid_value.rs:94:41 @@ -623,7 +622,6 @@ LL | let _val: NonNull = MaybeUninit::uninit().assume_init(); | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull` must be non-null - = note: raw pointers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:158:26 diff --git a/tests/ui/mir/ssa-analysis-regression-50041.rs b/tests/ui/mir/ssa-analysis-regression-50041.rs index 82654c8c0b55c..28690624f63ec 100644 --- a/tests/ui/mir/ssa-analysis-regression-50041.rs +++ b/tests/ui/mir/ssa-analysis-regression-50041.rs @@ -2,10 +2,10 @@ //@ compile-flags: -Z mir-opt-level=4 #![crate_type = "lib"] -#![feature(lang_items)] +#![feature(lang_items, pattern_type_macro, pattern_types)] #![no_std] -struct NonNull(*const T); +struct NonNull(pattern_type!(*const T is !null)); struct Unique(NonNull); @@ -20,7 +20,7 @@ impl Drop for Box { } #[inline(never)] -fn dealloc(_: *const T) {} +fn dealloc(_: pattern_type!(*const T is !null)) {} pub struct Foo(T);