diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index 301547cadaf7c..2b193b72b79c8 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -645,6 +645,12 @@ pub union MaybeUninit { pub value: ManuallyDrop, } +pub mod ptr { + #[lang = "Alignment"] + #[repr(transparent)] + pub struct Alignment(pub usize); +} + pub mod intrinsics { #[rustc_intrinsic] pub fn abort() -> !; @@ -653,9 +659,9 @@ pub mod intrinsics { #[rustc_intrinsic] pub unsafe fn size_of_val(val: *const T) -> usize; #[rustc_intrinsic] - pub const fn align_of() -> usize; + pub const fn align_of() -> crate::ptr::Alignment; #[rustc_intrinsic] - pub unsafe fn align_of_val(val: *const T) -> usize; + pub unsafe fn align_of_val(val: *const T) -> crate::ptr::Alignment; #[rustc_intrinsic] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize); #[rustc_intrinsic] @@ -723,7 +729,7 @@ pub const fn size_of() -> usize { } pub const fn align_of() -> usize { - ::ALIGN + ::ALIGN.0 } trait SizedTypeProperties: Sized { @@ -731,7 +737,7 @@ trait SizedTypeProperties: Sized { const SIZE: usize = intrinsics::size_of::(); #[lang = "mem_align_const"] - const ALIGN: usize = intrinsics::align_of::(); + const ALIGN: crate::ptr::Alignment = intrinsics::align_of::(); } impl SizedTypeProperties for T {} 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..f4b315da2e15d 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -216,7 +216,7 @@ fn main() { assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); assert_eq!(align_of::() as u8, 2); - assert_eq!(intrinsics::align_of_val(&a) as u8, align_of::<&str>() as u8); + assert_eq!(intrinsics::align_of_val(&a).0 as u8, align_of::<&str>() as u8); let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index ab9a11305baa3..0cbea47550c22 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -602,7 +602,8 @@ fn codegen_regular_intrinsic_call<'tcx>( None }; let (_size, align) = crate::unsize::size_and_align_of(fx, layout, meta); - ret.write_cvalue(fx, CValue::by_val(align, usize_layout)); + let alignment_layout = fx.layout_of(fx.tcx.ty_alignment(source_info.span)); + ret.write_cvalue(fx, CValue::by_val(align, alignment_layout)); } sym::vtable_size => { diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 0aba44a88c5a4..9dc0f533ee154 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -651,6 +651,12 @@ pub union MaybeUninit { pub value: ManuallyDrop, } +pub mod ptr { + #[lang = "Alignment"] + #[repr(transparent)] + pub struct Alignment(pub usize); +} + pub mod intrinsics { #[rustc_intrinsic] pub const fn black_box(_dummy: T) -> T; @@ -661,9 +667,9 @@ pub mod intrinsics { #[rustc_intrinsic] pub unsafe fn size_of_val(val: *const T) -> usize; #[rustc_intrinsic] - pub const fn align_of() -> usize; + pub const fn align_of() -> crate::ptr::Alignment; #[rustc_intrinsic] - pub unsafe fn align_of_val(val: *const T) -> usize; + pub unsafe fn align_of_val(val: *const T) -> crate::ptr::Alignment; #[rustc_intrinsic] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize); #[rustc_intrinsic] @@ -704,7 +710,7 @@ pub const fn size_of() -> usize { } pub const fn align_of() -> usize { - ::ALIGN + ::ALIGN.0 } trait SizedTypeProperties: Sized { @@ -712,7 +718,7 @@ trait SizedTypeProperties: Sized { const SIZE: usize = intrinsics::size_of::(); #[lang = "mem_align_const"] - const ALIGN: usize = intrinsics::align_of::(); + const ALIGN: crate::ptr::Alignment = intrinsics::align_of::(); } impl SizedTypeProperties for T {} diff --git a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs index d5c386ffb3dd1..5d794d3c1593a 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs @@ -196,7 +196,7 @@ fn main() { assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); assert_eq!(align_of::() as u8, 2); - assert_eq!(intrinsics::align_of_val(&a) as u8, align_of::<&str>() as u8); + assert_eq!(intrinsics::align_of_val(&a).0 as u8, align_of::<&str>() as u8); let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 0325fd2ceab94..3da44733ea2a8 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -156,6 +156,7 @@ language_item_table! { MetaSized, sym::meta_sized, meta_sized_trait, Target::Trait, GenericRequirement::Exact(0); PointeeSized, sym::pointee_sized, pointee_sized_trait, Target::Trait, GenericRequirement::Exact(0); Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1); + Alignment, sym::Alignment, alignment_type, Target::Struct, GenericRequirement::Exact(0); AlignOf, sym::mem_align_const, align_const, Target::AssocConst, GenericRequirement::Exact(0); SizeOf, sym::mem_size_const, size_const, Target::AssocConst, GenericRequirement::Exact(0); OffsetOf, sym::offset_of, offset_of, Target::Fn, GenericRequirement::Exact(1); diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 6946d1a70040d..60cf68428f055 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -292,10 +292,10 @@ pub(crate) fn check_intrinsic_type( sym::amdgpu_dispatch_ptr => (0, 0, vec![], Ty::new_imm_ptr(tcx, tcx.types.unit)), sym::unreachable => (0, 0, vec![], tcx.types.never), sym::breakpoint => (0, 0, vec![], tcx.types.unit), - sym::size_of | sym::align_of | sym::variant_count => (1, 0, vec![], tcx.types.usize), - sym::size_of_val | sym::align_of_val => { - (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.usize) - } + sym::size_of | sym::variant_count => (1, 0, vec![], tcx.types.usize), + sym::align_of => (1, 0, vec![], tcx.ty_alignment(span)), + sym::size_of_val => (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.usize), + sym::align_of_val => (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.ty_alignment(span)), sym::offset_of => (1, 0, vec![tcx.types.u32, tcx.types.u32], tcx.types.usize), sym::rustc_peek => (1, 0, vec![param(0)], param(0)), sym::caller_location => (0, 0, vec![], tcx.caller_location_ty()), diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 430890d5a42d8..56b372e89a29f 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1079,6 +1079,13 @@ impl<'tcx> TyCtxt<'tcx> { self.type_of(ordering_enum).no_bound_vars().unwrap() } + /// Gets a `Ty` representing the [`LangItem::Alignment`] + #[track_caller] + pub fn ty_alignment(self, span: Span) -> Ty<'tcx> { + let alignment = self.require_lang_item(hir::LangItem::Alignment, span); + self.type_of(alignment).no_bound_vars().unwrap() + } + /// Obtain the given diagnostic item's `DefId`. Use `is_diagnostic_item` if you just want to /// compare against another `DefId`, since `is_diagnostic_item` is cheaper. pub fn get_diagnostic_item(self, name: Symbol) -> Option { diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index e06883dd0fd10..776eeb7566ef0 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -55,14 +55,23 @@ fn insert_alignment_check<'tcx>( stmts.push(Statement::new(source_info, StatementKind::Assign(Box::new((thin_ptr, rvalue))))); // Transmute the pointer to a usize (equivalent to `ptr.addr()`). - let rvalue = Rvalue::Cast(CastKind::Transmute, Operand::Copy(thin_ptr), tcx.types.usize); + let rvalue = Rvalue::Cast(CastKind::Transmute, Operand::Move(thin_ptr), tcx.types.usize); let addr = local_decls.push(LocalDecl::with_source_info(tcx.types.usize, source_info)).into(); stmts.push(Statement::new(source_info, StatementKind::Assign(Box::new((addr, rvalue))))); // Get the alignment of the pointee let align_def_id = tcx.require_lang_item(LangItem::AlignOf, source_info.span); + let alignment_usize = + local_decls.push(LocalDecl::with_source_info(tcx.types.usize, source_info)).into(); let alignment = Operand::unevaluated_constant(tcx, align_def_id, &[pointee_ty.into()], source_info.span); + stmts.push(Statement::new( + source_info, + StatementKind::Assign(Box::new(( + alignment_usize, + Rvalue::Cast(CastKind::Transmute, alignment.clone(), tcx.types.usize), + ))), + )); // Subtract 1 from the alignment to get the alignment mask let alignment_mask = @@ -76,7 +85,7 @@ fn insert_alignment_check<'tcx>( source_info, StatementKind::Assign(Box::new(( alignment_mask, - Rvalue::BinaryOp(BinOp::Sub, Box::new((alignment.clone(), one))), + Rvalue::BinaryOp(BinOp::SubUnchecked, Box::new((Operand::Move(alignment_usize), one))), ))), )); @@ -139,10 +148,10 @@ fn insert_alignment_check<'tcx>( // Emit a check that asserts on the alignment and otherwise triggers a // AssertKind::MisalignedPointerDereference. PointerCheck { - cond: Operand::Copy(is_ok), + cond: Operand::Move(is_ok), assert_kind: Box::new(AssertKind::MisalignedPointerDereference { required: alignment, - found: Operand::Copy(addr), + found: Operand::Move(addr), }), } } diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 263bb1036d8c2..e753fc94db60d 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -484,8 +484,8 @@ unsafe impl const Allocator for Global { #[lang = "exchange_malloc"] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces -unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { - let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; +unsafe fn exchange_malloc(size: usize, align: Alignment) -> *mut u8 { + let layout = unsafe { Layout::from_size_alignment_unchecked(size, align) }; match Global.allocate(layout) { Ok(ptr) => ptr.as_mut_ptr(), Err(_) => handle_alloc_error(layout), diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 7fded188ddbf8..316dc7d5c98a0 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -2802,7 +2802,7 @@ pub const fn size_of() -> usize; #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -pub const fn align_of() -> usize; +pub const fn align_of() -> ptr::Alignment; /// The offset of a field inside a type. /// @@ -2862,7 +2862,7 @@ pub const unsafe fn size_of_val(ptr: *const T) -> usize; #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] #[rustc_intrinsic_const_stable_indirect] -pub const unsafe fn align_of_val(ptr: *const T) -> usize; +pub const unsafe fn align_of_val(ptr: *const T) -> ptr::Alignment; /// Compute the type information of a concrete type. /// It can only be called at compile time, the backends do diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index eb6f8f9757215..a422fbab8891d 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -450,7 +450,7 @@ pub const unsafe fn size_of_val_raw(val: *const T) -> usize { #[stable(feature = "rust1", since = "1.0.0")] #[deprecated(note = "use `align_of` instead", since = "1.2.0", suggestion = "align_of")] pub fn min_align_of() -> usize { - ::ALIGN + align_of::() } /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in @@ -473,8 +473,7 @@ pub fn min_align_of() -> usize { #[stable(feature = "rust1", since = "1.0.0")] #[deprecated(note = "use `align_of_val` instead", since = "1.2.0", suggestion = "align_of_val")] pub fn min_align_of_val(val: &T) -> usize { - // SAFETY: val is a reference, so it's a valid raw pointer - unsafe { intrinsics::align_of_val(val) } + align_of_val(val) } /// Returns the [ABI]-required minimum alignment of a type in bytes. @@ -497,7 +496,7 @@ pub fn min_align_of_val(val: &T) -> usize { #[rustc_const_stable(feature = "const_align_of", since = "1.24.0")] #[rustc_diagnostic_item = "mem_align_of"] pub const fn align_of() -> usize { - ::ALIGN + Alignment::of::().as_usize() } /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in @@ -517,8 +516,7 @@ pub const fn align_of() -> usize { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_align_of_val", since = "1.85.0")] pub const fn align_of_val(val: &T) -> usize { - // SAFETY: val is a reference, so it's a valid raw pointer - unsafe { intrinsics::align_of_val(val) } + Alignment::of_val(val).as_usize() } /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in @@ -565,7 +563,7 @@ pub const fn align_of_val(val: &T) -> usize { #[unstable(feature = "layout_for_ptr", issue = "69835")] pub const unsafe fn align_of_val_raw(val: *const T) -> usize { // SAFETY: the caller must provide a valid raw pointer - unsafe { intrinsics::align_of_val(val) } + unsafe { Alignment::of_val_raw(val) }.as_usize() } /// Returns `true` if dropping values of type `T` matters. @@ -1256,14 +1254,8 @@ pub trait SizedTypeProperties: Sized { #[doc(hidden)] #[unstable(feature = "sized_type_properties", issue = "none")] #[lang = "mem_align_const"] - const ALIGN: usize = intrinsics::align_of::(); - - #[doc(hidden)] - #[unstable(feature = "ptr_alignment_type", issue = "102070")] - const ALIGNMENT: Alignment = { - // This can't panic since type alignment is always a power of two. - Alignment::new(Self::ALIGN).unwrap() - }; + // #[unstable(feature = "ptr_alignment_type", issue = "102070")] + const ALIGNMENT: Alignment = intrinsics::align_of::(); /// `true` if this type requires no storage. /// `false` if its [size](size_of) is greater than zero. @@ -1300,7 +1292,7 @@ pub trait SizedTypeProperties: Sized { // SAFETY: if the type is instantiated, rustc already ensures that its // layout is valid. Use the unchecked constructor to avoid inserting a // panicking codepath that needs to be optimized out. - unsafe { Layout::from_size_align_unchecked(Self::SIZE, Self::ALIGN) } + unsafe { Layout::from_size_alignment_unchecked(Self::SIZE, Self::ALIGNMENT) } }; /// The largest safe length for a `[Self]`. diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index b106314f14d12..ed88c026cbbaa 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -3,7 +3,7 @@ use crate::marker::MetaSized; use crate::num::NonZero; use crate::ub_checks::assert_unsafe_precondition; -use crate::{cmp, fmt, hash, mem, num}; +use crate::{cmp, fmt, hash, intrinsics, mem, num}; /// A type storing a `usize` which is a power of two, and thus /// represents a possible alignment in the Rust abstract machine. @@ -11,7 +11,10 @@ use crate::{cmp, fmt, hash, mem, num}; /// Note that particularly large alignments, while representable in this type, /// are likely not to be supported by actual allocators and linkers. #[unstable(feature = "ptr_alignment_type", issue = "102070")] +// No special behaviour, but used as the return type from an intrinsic +#[lang = "Alignment"] #[derive(Copy, Clone, PartialEq, Eq)] +// This being transparent is critical for its use in `__rust_alloc` and friends #[repr(transparent)] pub struct Alignment { // This field is never used directly (nor is the enum), @@ -73,9 +76,8 @@ impl Alignment { #[must_use] #[unstable(feature = "ptr_alignment_type", issue = "102070")] pub const fn of_val(val: &T) -> Self { - let align = mem::align_of_val(val); - // SAFETY: `align_of_val` returns valid alignment - unsafe { Alignment::new_unchecked(align) } + // SAFETY: val is a reference, so it's a valid raw pointer + unsafe { Alignment::of_val_raw(val) } } /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. @@ -122,9 +124,7 @@ impl Alignment { // #[unstable(feature = "layout_for_ptr", issue = "69835")] pub const unsafe fn of_val_raw(val: *const T) -> Self { // SAFETY: precondition propagated to the caller - let align = unsafe { mem::align_of_val_raw(val) }; - // SAFETY: `align_of_val_raw` returns valid alignment - unsafe { Alignment::new_unchecked(align) } + unsafe { intrinsics::align_of_val(val) } } /// Creates an `Alignment` from a `usize`, or returns `None` if it's diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index c4546f4dea93a..bc1cc78f978d2 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -271,6 +271,12 @@ trait Drop { fn drop(&mut self); } +pub mod ptr { + #[lang = "Alignment"] + #[repr(transparent)] + pub struct Alignment(usize); +} + pub mod mem { #[rustc_nounwind] #[rustc_intrinsic] @@ -279,9 +285,10 @@ pub mod mem { #[rustc_nounwind] #[rustc_intrinsic] pub const fn size_of() -> usize; + #[rustc_nounwind] #[rustc_intrinsic] - pub const fn align_of() -> usize; + pub const fn align_of() -> crate::ptr::Alignment; } #[lang = "c_void"] diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 54ab656c53db3..ec3e2d5b58ae6 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -46,8 +46,7 @@ pub fn foo2() -> Box { //~ MONO_ITEM fn foo2 //~ MONO_ITEM fn std::alloc::Global::alloc_impl_runtime //~ MONO_ITEM fn std::boxed::Box::::new -//~ MONO_ITEM fn std::alloc::Layout::from_size_align_unchecked::precondition_check -//~ MONO_ITEM fn std::ptr::Alignment::new_unchecked::precondition_check +//~ MONO_ITEM fn std::alloc::Layout::from_size_alignment_unchecked::precondition_check //~ MONO_ITEM fn std::ptr::NonNull::::new_unchecked::precondition_check struct Counter { diff --git a/tests/mir-opt/alignment_checks.rs b/tests/mir-opt/alignment_checks.rs new file mode 100644 index 0000000000000..809b3c2fc497e --- /dev/null +++ b/tests/mir-opt/alignment_checks.rs @@ -0,0 +1,19 @@ +//@ compile-flags: -Copt-level=1 -Zmir-opt-level=2 -Zub-checks +//@ only-64bit +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +#![crate_type = "lib"] + +// The diff shows exactly what is generated by the pass; +// then we check the final `-O1` output for people who want to run them +// without the codegen being too terrible. + +// EMIT_MIR alignment_checks.sized_ptr.CheckAlignment.diff +pub unsafe fn sized_ptr(ptr: *const u32) -> u32 { + // CHECK-LABEL: fn sized_ptr(_1: *const u32) + // CHECK: _2 = copy _1 as usize (Transmute); + // CHECK: _3 = BitAnd(copy _2, const 3_usize); + // CHECK: _4 = Eq(copy _3, const 0_usize); + // CHECK: assert(move _4, + *ptr +} diff --git a/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-abort.diff b/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-abort.diff new file mode 100644 index 0000000000000..71725b2824bc0 --- /dev/null +++ b/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-abort.diff @@ -0,0 +1,29 @@ +- // MIR for `sized_ptr` before CheckAlignment ++ // MIR for `sized_ptr` after CheckAlignment + + fn sized_ptr(_1: *const u32) -> u32 { + debug ptr => _1; + let mut _0: u32; ++ let mut _2: *const (); ++ let mut _3: usize; ++ let mut _4: usize; ++ let mut _5: usize; ++ let mut _6: usize; ++ let mut _7: bool; + + bb0: { ++ _2 = copy _1 as *const () (PtrToPtr); ++ _3 = move _2 as usize (Transmute); ++ _4 = const ::ALIGNMENT as usize (Transmute); ++ _5 = SubUnchecked(move _4, const 1_usize); ++ _6 = BitAnd(copy _3, copy _5); ++ _7 = Eq(copy _6, const 0_usize); ++ assert(move _7, "misaligned pointer dereference: address must be a multiple of {} but is {}", const ::ALIGNMENT, move _3) -> [success: bb1, unwind unreachable]; ++ } ++ ++ bb1: { + _0 = copy (*_1); + return; + } + } + diff --git a/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-unwind.diff b/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-unwind.diff new file mode 100644 index 0000000000000..71725b2824bc0 --- /dev/null +++ b/tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-unwind.diff @@ -0,0 +1,29 @@ +- // MIR for `sized_ptr` before CheckAlignment ++ // MIR for `sized_ptr` after CheckAlignment + + fn sized_ptr(_1: *const u32) -> u32 { + debug ptr => _1; + let mut _0: u32; ++ let mut _2: *const (); ++ let mut _3: usize; ++ let mut _4: usize; ++ let mut _5: usize; ++ let mut _6: usize; ++ let mut _7: bool; + + bb0: { ++ _2 = copy _1 as *const () (PtrToPtr); ++ _3 = move _2 as usize (Transmute); ++ _4 = const ::ALIGNMENT as usize (Transmute); ++ _5 = SubUnchecked(move _4, const 1_usize); ++ _6 = BitAnd(copy _3, copy _5); ++ _7 = Eq(copy _6, const 0_usize); ++ assert(move _7, "misaligned pointer dereference: address must be a multiple of {} but is {}", const ::ALIGNMENT, move _3) -> [success: bb1, unwind unreachable]; ++ } ++ ++ bb1: { + _0 = copy (*_1); + return; + } + } + diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.diff b/tests/mir-opt/box_expr.main.ElaborateDrops.diff index 4fa77cf82d819..d563ef2490136 100644 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.diff +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.diff @@ -17,7 +17,7 @@ bb0: { StorageLive(_1); - _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir index 839bdeca86a88..01d9b58c838d0 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -20,7 +20,7 @@ fn move_out_by_subslice() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind: bb13]; } bb1: { @@ -34,7 +34,7 @@ fn move_out_by_subslice() -> () { bb2: { StorageDead(_4); StorageLive(_5); - _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb3, unwind: bb12]; + _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb3, unwind: bb12]; } bb3: { diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir index 7fda69c7500a3..7e4dad2e18e6f 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -20,7 +20,7 @@ fn move_out_from_end() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + _3 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind: bb13]; } bb1: { @@ -34,7 +34,7 @@ fn move_out_from_end() -> () { bb2: { StorageDead(_4); StorageLive(_5); - _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb3, unwind: bb12]; + _6 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb3, unwind: bb12]; } bb3: { 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..9c753955d77e4 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 @@ -22,7 +22,7 @@ - StorageLive(_2); + nop; StorageLive(_3); - _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind unreachable]; + _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind unreachable]; } bb1: { 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..d4e8a36f0f1d0 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 @@ -22,7 +22,7 @@ - StorageLive(_2); + nop; StorageLive(_3); - _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + _4 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind continue]; } bb1: { 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..8ad89982c2d90 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 @@ -12,8 +12,8 @@ let mut _10: std::boxed::Box<()>; let mut _11: *const (); let mut _16: usize; - let mut _17: usize; - let mut _26: usize; + let mut _17: std::ptr::Alignment; + let mut _25: 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 _26: *const [()]; } } scope 17 (inlined slice_from_raw_parts::<()>) { @@ -52,7 +52,7 @@ 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 _24: *mut [u8]; scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -66,9 +66,8 @@ } } } - scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { + scope 9 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { let _23: (); - let mut _24: std::ptr::Alignment; } } } @@ -88,8 +87,8 @@ - _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>::ALIGNMENT; ++ _17 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; StorageLive(_18); StorageLive(_20); StorageLive(_21); @@ -115,11 +114,11 @@ bb4: { _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_25); +- StorageLive(_24); + nop; - _25 = copy _21 as *mut [u8] (Transmute); - _12 = copy _25 as *mut u8 (PtrToPtr); -- StorageDead(_25); + _24 = copy _21 as *mut [u8] (Transmute); + _12 = copy _24 as *mut u8 (PtrToPtr); +- StorageDead(_24); + nop; StorageDead(_19); StorageDead(_23); @@ -130,7 +129,7 @@ StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _25 as *const () (PtrToPtr); ++ _13 = copy _24 as *const () (PtrToPtr); _14 = NonNull::<()> { pointer: copy _13 }; _15 = std::ptr::Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); @@ -153,21 +152,21 @@ + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_26); - _26 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _26); + StorageLive(_25); + _25 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _25); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_26); + StorageDead(_25); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_27); -- _27 = copy _9; + StorageLive(_26); +- _26 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _27 = copy _6; ++ _26 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_27); + StorageDead(_26); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -179,17 +178,13 @@ } 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]; +- _23 = Layout::from_size_alignment_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_alignment_unchecked::precondition_check(const 0_usize, const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}) -> [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 = Layout { size: copy _16, align: copy _17 }; + _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]; 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..421b8eb2a2339 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 @@ -12,8 +12,8 @@ let mut _10: std::boxed::Box<()>; let mut _11: *const (); let mut _16: usize; - let mut _17: usize; - let mut _26: usize; + let mut _17: std::ptr::Alignment; + let mut _25: 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 _26: *const [()]; } } scope 17 (inlined slice_from_raw_parts::<()>) { @@ -52,7 +52,7 @@ 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 _24: *mut [u8]; scope 15 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -66,9 +66,8 @@ } } } - scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { + scope 9 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { let _23: (); - let mut _24: std::ptr::Alignment; } } } @@ -88,8 +87,8 @@ - _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>::ALIGNMENT; ++ _17 = const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}; StorageLive(_18); StorageLive(_20); StorageLive(_21); @@ -115,11 +114,11 @@ bb4: { _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_25); +- StorageLive(_24); + nop; - _25 = copy _21 as *mut [u8] (Transmute); - _12 = copy _25 as *mut u8 (PtrToPtr); -- StorageDead(_25); + _24 = copy _21 as *mut [u8] (Transmute); + _12 = copy _24 as *mut u8 (PtrToPtr); +- StorageDead(_24); + nop; StorageDead(_19); StorageDead(_23); @@ -130,7 +129,7 @@ StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _25 as *const () (PtrToPtr); ++ _13 = copy _24 as *const () (PtrToPtr); _14 = NonNull::<()> { pointer: copy _13 }; _15 = std::ptr::Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); @@ -153,21 +152,21 @@ + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_26); - _26 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _26); + StorageLive(_25); + _25 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _25); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_26); + StorageDead(_25); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_27); -- _27 = copy _9; + StorageLive(_26); +- _26 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _27 = copy _6; ++ _26 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_27); + StorageDead(_26); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -179,17 +178,13 @@ } 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]; +- _23 = Layout::from_size_alignment_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_alignment_unchecked::precondition_check(const 0_usize, const std::ptr::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }}) -> [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 = Layout { size: copy _16, align: copy _17 }; + _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]; diff --git a/tests/mir-opt/instsimplify/align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff index bbcc9012a25dd..08a53c3c8804d 100644 --- a/tests/mir-opt/instsimplify/align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff @@ -1,16 +1,16 @@ - // MIR for `of_val_slice` before InstSimplify-after-simplifycfg + // MIR for `of_val_slice` after InstSimplify-after-simplifycfg - fn of_val_slice(_1: &[T]) -> usize { + fn of_val_slice(_1: &[T]) -> std::ptr::Alignment { debug slice => _1; - let mut _0: usize; + let mut _0: std::ptr::Alignment; let mut _2: *const [T]; bb0: { StorageLive(_2); _2 = &raw const (*_1); - _0 = std::intrinsics::align_of_val::<[T]>(move _2) -> [return: bb1, unwind unreachable]; -+ _0 = const ::ALIGN; ++ _0 = const ::ALIGNMENT; + goto -> bb1; } diff --git a/tests/mir-opt/instsimplify/align_of_slice.rs b/tests/mir-opt/instsimplify/align_of_slice.rs index 99a68e444fe5d..9b240cefb5685 100644 --- a/tests/mir-opt/instsimplify/align_of_slice.rs +++ b/tests/mir-opt/instsimplify/align_of_slice.rs @@ -3,10 +3,11 @@ #![crate_type = "lib"] #![feature(core_intrinsics)] +#![feature(ptr_alignment_type)] // EMIT_MIR align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff -pub fn of_val_slice(slice: &[T]) -> usize { +pub fn of_val_slice(slice: &[T]) -> std::ptr::Alignment { // CHECK-LABEL: fn of_val_slice(_1: &[T]) - // CHECK: _0 = const ::ALIGN; + // CHECK: _0 = const ::ALIGNMENT; unsafe { core::intrinsics::align_of_val(slice) } } diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir index c46549c5742f2..e1033e46d4039 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir @@ -25,7 +25,7 @@ fn test() -> Option> { bb0: { StorageLive(_1); - _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind: bb13]; + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind: bb13]; } bb1: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir index 9f26debdbb6d6..63de15b1d101e 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -25,7 +25,7 @@ fn test() -> Option> { bb0: { StorageLive(_1); - _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGN) -> [return: bb1, unwind continue]; + _2 = alloc::alloc::exchange_malloc(const ::SIZE, const ::ALIGNMENT) -> [return: bb1, unwind continue]; } bb1: { 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..8327cf3660e07 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,33 +8,33 @@ 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 _8: (); scope 3 { scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined std::ptr::Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined std::ptr::Unique::::as_non_null_ptr) { } } - 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; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _7: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::alignment) { } } } @@ -47,25 +47,14 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } } scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } } } } @@ -82,22 +71,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGNMENT; StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } 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]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } 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..8327cf3660e07 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,33 +8,33 @@ 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 _8: (); scope 3 { scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined std::ptr::Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined std::ptr::Unique::::as_non_null_ptr) { } } - 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; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _7: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::alignment) { } } } @@ -47,25 +47,14 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } } scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } } } } @@ -82,22 +71,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGNMENT; StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } 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]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } 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..8327cf3660e07 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,33 +8,33 @@ 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 _8: (); scope 3 { scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined std::ptr::Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined std::ptr::Unique::::as_non_null_ptr) { } } - 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; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _7: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::alignment) { } } } @@ -47,25 +47,14 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } } scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } } } } @@ -82,22 +71,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGNMENT; StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } 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]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } 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..8327cf3660e07 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,33 +8,33 @@ 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 _8: (); scope 3 { scope 4 { - scope 17 (inlined Layout::size) { + scope 12 (inlined Layout::size) { } - scope 18 (inlined std::ptr::Unique::<[T]>::cast::) { - scope 19 (inlined NonNull::<[T]>::cast::) { - scope 20 (inlined NonNull::<[T]>::as_ptr) { + scope 13 (inlined std::ptr::Unique::<[T]>::cast::) { + scope 14 (inlined NonNull::<[T]>::cast::) { + scope 15 (inlined NonNull::<[T]>::as_ptr) { } } } - scope 21 (inlined as From>>::from) { - scope 22 (inlined std::ptr::Unique::::as_non_null_ptr) { + scope 16 (inlined as From>>::from) { + scope 17 (inlined std::ptr::Unique::::as_non_null_ptr) { } } - 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; - scope 26 (inlined Layout::size) { + scope 18 (inlined ::deallocate) { + scope 19 (inlined std::alloc::Global::deallocate_impl) { + scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) { + let mut _7: *mut u8; + scope 21 (inlined Layout::size) { } - scope 27 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { } - scope 28 (inlined std::alloc::dealloc) { - scope 29 (inlined Layout::size) { + scope 23 (inlined std::alloc::dealloc) { + scope 24 (inlined Layout::size) { } - scope 30 (inlined Layout::alignment) { + scope 25 (inlined Layout::alignment) { } } } @@ -47,25 +47,14 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { - scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { + scope 11 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } } scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; - scope 11 { - scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { - scope 14 (inlined core::ub_checks::check_language_ub) { - scope 15 (inlined core::ub_checks::check_language_ub::runtime) { - } - } - } - } - scope 12 (inlined align_of_val_raw::<[T]>) { - } } } } @@ -82,22 +71,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGNMENT; StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } 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]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs index ae10cfb0b1713..49cbb57969609 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs @@ -9,8 +9,7 @@ pub unsafe fn generic_in_place(ptr: *mut Box<[T]>) { // CHECK-LABEL: fn generic_in_place(_1: *mut Box<[T]>) // CHECK: (inlined as Drop>::drop) // CHECK: [[SIZE:_.+]] = std::intrinsics::size_of_val::<[T]> - // CHECK: [[ALIGN:_.+]] = const ::ALIGN; - // CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute); - // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[B]]) -> + // CHECK: [[ALIGN:_.+]] = const ::ALIGNMENT; + // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[ALIGN]]) -> std::ptr::drop_in_place(ptr) } diff --git a/tests/ui/consts/auxiliary/unstable_intrinsic.rs b/tests/ui/consts/auxiliary/unstable_intrinsic.rs index c1c7571e0c90c..b5aecd8c73e23 100644 --- a/tests/ui/consts/auxiliary/unstable_intrinsic.rs +++ b/tests/ui/consts/auxiliary/unstable_intrinsic.rs @@ -1,5 +1,5 @@ -#![feature(staged_api, rustc_attrs, intrinsics)] -#![stable(since="1.0.0", feature = "stable")] +#![feature(staged_api, rustc_attrs, intrinsics, ptr_alignment_type)] +#![stable(since = "1.0.0", feature = "stable")] #[unstable(feature = "unstable", issue = "42")] #[rustc_intrinsic] @@ -8,4 +8,4 @@ pub const unsafe fn size_of_val(x: *const T) -> usize; #[unstable(feature = "unstable", issue = "42")] #[rustc_const_unstable(feature = "unstable", issue = "42")] #[rustc_intrinsic] -pub const unsafe fn align_of_val(x: *const T) -> usize; +pub const unsafe fn align_of_val(x: *const T) -> std::ptr::Alignment; diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 55d430a08aadb..cf302effd886c 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -1,7 +1,9 @@ #![feature(extern_types)] #![feature(core_intrinsics)] +#![feature(ptr_alignment_type)] use std::intrinsics::{align_of_val, size_of_val}; +use std::ptr::Alignment; extern "C" { type Opaque; @@ -9,7 +11,7 @@ extern "C" { const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~^ ERROR: the size for values of type `Opaque` cannot be known -const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) }; +const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) }; //~^ ERROR: the size for values of type `Opaque` cannot be known fn main() {} diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index 825b9e941584c..513accb0a6832 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `Opaque` cannot be known - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:43 + --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:43 | LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; | ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque` @@ -17,22 +17,22 @@ LL | const _SIZE: usize = unsafe { size_of_val(&mut (&4 as *const i32 as *const | ++++++ + error[E0277]: the size for values of type `Opaque` cannot be known - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:45 + --> $DIR/const-size_of_val-align_of_val-extern-type.rs:14:49 | -LL | const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque` - | | - | required by a bound introduced by this call +LL | const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) }; + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque` + | | + | required by a bound introduced by this call | = note: the trait bound `Opaque: MetaSized` is not satisfied note: required by a bound in `std::intrinsics::align_of_val` --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL help: consider borrowing here | -LL | const _ALIGN: usize = unsafe { align_of_val(&(&4 as *const i32 as *const Opaque)) }; - | ++ + -LL | const _ALIGN: usize = unsafe { align_of_val(&mut (&4 as *const i32 as *const Opaque)) }; - | ++++++ + +LL | const _ALIGN: Alignment = unsafe { align_of_val(&(&4 as *const i32 as *const Opaque)) }; + | ++ + +LL | const _ALIGN: Alignment = unsafe { align_of_val(&mut (&4 as *const i32 as *const Opaque)) }; + | ++++++ + error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-unstable-intrinsic.rs b/tests/ui/consts/const-unstable-intrinsic.rs index d130eb6c707f8..6ae39582335b6 100644 --- a/tests/ui/consts/const-unstable-intrinsic.rs +++ b/tests/ui/consts/const-unstable-intrinsic.rs @@ -1,7 +1,7 @@ //! Ensure that unstable intrinsics can actually not be called, //! neither within a crate nor cross-crate. //@ aux-build:unstable_intrinsic.rs -#![feature(staged_api, rustc_attrs, intrinsics)] +#![feature(staged_api, rustc_attrs, intrinsics, ptr_alignment_type)] #![stable(since = "1.0.0", feature = "stable")] #![feature(local)] @@ -35,7 +35,7 @@ pub const unsafe fn size_of_val(x: *const T) -> usize; #[unstable(feature = "local", issue = "42")] #[rustc_const_unstable(feature = "local", issue = "42")] #[rustc_intrinsic] -pub const unsafe fn align_of_val(x: *const T) -> usize; +pub const unsafe fn align_of_val(x: *const T) -> std::ptr::Alignment; #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr index b08e37dbd7472..0446afea0ca64 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -21,7 +21,7 @@ LL | struct MySlice(T); error[E0080]: the type `MySlice<[bool]>` has an unknown layout --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | - = note: evaluation of `::ALIGN` failed here + = note: evaluation of `::ALIGNMENT` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/limits/issue-17913.32bit.stderr b/tests/ui/limits/issue-17913.32bit.stderr index 1311822d0d0c4..c544696ae9dec 100644 --- a/tests/ui/limits/issue-17913.32bit.stderr +++ b/tests/ui/limits/issue-17913.32bit.stderr @@ -6,7 +6,7 @@ error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the targ error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | - = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::ALIGN` failed here + = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::ALIGNMENT` failed here note: the above error was encountered while instantiating `fn Box::<[&usize; usize::MAX]>::new` --> $DIR/issue-17913.rs:16:21 diff --git a/tests/ui/limits/issue-17913.64bit.stderr b/tests/ui/limits/issue-17913.64bit.stderr index b0481ee99378c..7c9eca120e062 100644 --- a/tests/ui/limits/issue-17913.64bit.stderr +++ b/tests/ui/limits/issue-17913.64bit.stderr @@ -6,7 +6,7 @@ error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the targ error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | - = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::ALIGN` failed here + = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::ALIGNMENT` failed here note: the above error was encountered while instantiating `fn Box::<[&usize; usize::MAX]>::new` --> $DIR/issue-17913.rs:9:21