From d1d2efd88bca58aa0f22a87e29222f956755d11d Mon Sep 17 00:00:00 2001 From: Moulins Date: Wed, 17 Dec 2025 21:33:34 +0100 Subject: [PATCH 1/6] Introduce `VariantLayout` struct For now, this is a 1-to-1 copy of `LayoutData`, but this will change. --- compiler/rustc_abi/src/layout.rs | 6 +-- compiler/rustc_abi/src/layout/coroutine.rs | 4 +- compiler/rustc_abi/src/layout/simple.rs | 21 ++++++++++ compiler/rustc_abi/src/lib.rs | 39 ++++++++++++++++++- compiler/rustc_middle/src/ty/layout.rs | 4 +- src/librustdoc/html/render/type_layout.rs | 2 +- .../enum-discriminant/wrapping_niche.stderr | 12 +++--- tests/ui/layout/debug.stderr | 8 ++-- tests/ui/layout/hexagon-enum.stderr | 10 ++--- ...-scalarpair-payload-might-be-uninit.stderr | 24 ++++++------ .../issue-96185-overaligned-enum.stderr | 8 ++-- tests/ui/layout/thumb-enum.stderr | 10 ++--- .../layout/zero-sized-array-enum-niche.stderr | 18 ++++----- ...-variants.aarch64-unknown-linux-gnu.stderr | 10 ++--- ...-c-dead-variants.armebv7r-none-eabi.stderr | 10 ++--- ...-dead-variants.i686-pc-windows-msvc.stderr | 10 ++--- ...d-variants.x86_64-unknown-linux-gnu.stderr | 10 ++--- tests/ui/repr/repr-c-int-dead-variants.stderr | 10 ++--- tests/ui/type/pattern_types/non_null.stderr | 4 +- .../type/pattern_types/range_patterns.stderr | 8 ++-- 20 files changed, 143 insertions(+), 85 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index cca1d499088f4..b111ff22c9706 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -11,7 +11,7 @@ use tracing::{debug, trace}; use crate::{ AbiAlign, Align, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer, LayoutData, Niche, NonZeroUsize, NumScalableVectors, Primitive, ReprOptions, Scalar, Size, - StructKind, TagEncoding, TargetDataLayout, Variants, WrappingRange, + StructKind, TagEncoding, TargetDataLayout, VariantLayout, Variants, WrappingRange, }; mod coroutine; @@ -660,7 +660,7 @@ impl LayoutCalculator { max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); - Some(st) + Some(VariantLayout::from_layout(st)) }) .collect::>>()?; @@ -900,7 +900,7 @@ impl LayoutCalculator { align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); - Ok(st) + Ok(VariantLayout::from_layout(st)) }) .collect::, _>>()?; diff --git a/compiler/rustc_abi/src/layout/coroutine.rs b/compiler/rustc_abi/src/layout/coroutine.rs index 815cf1e28a08c..812ed1f4274fd 100644 --- a/compiler/rustc_abi/src/layout/coroutine.rs +++ b/compiler/rustc_abi/src/layout/coroutine.rs @@ -27,7 +27,7 @@ use tracing::{debug, trace}; use crate::{ BackendRepr, FieldsShape, HasDataLayout, Integer, LayoutData, Primitive, ReprOptions, Scalar, - StructKind, TagEncoding, Variants, WrappingRange, + StructKind, TagEncoding, VariantLayout, Variants, WrappingRange, }; /// Overlap eligibility and variant assignment for each CoroutineSavedLocal. @@ -281,7 +281,7 @@ pub(super) fn layout< size = size.max(variant.size); align = align.max(variant.align); - Ok(variant) + Ok(VariantLayout::from_layout(variant)) }) .collect::, _>>()?; diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 3784611b157be..cb584d7cf5788 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -146,4 +146,25 @@ impl LayoutData { randomization_seed: Hash64::ZERO, } } + + /// Returns a layout for an inhabited variant. + pub fn for_variant(parent: &Self, index: VariantIdx) -> Self { + let layout = match &parent.variants { + Variants::Multiple { variants, .. } => &variants[index], + _ => panic!("Expected multi-variant layout in `Layout::for_variant`"), + }; + + Self { + fields: layout.fields.clone(), + variants: layout.variants.clone(), + backend_repr: layout.backend_repr, + largest_niche: layout.largest_niche, + uninhabited: layout.uninhabited, + align: layout.align, + size: layout.size, + max_repr_align: layout.max_repr_align, + unadjusted_abi_align: layout.unadjusted_abi_align, + randomization_seed: layout.randomization_seed, + } + } } diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index f148b776852aa..40a70f9fa87ec 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1894,7 +1894,7 @@ pub enum Variants { tag: Scalar, tag_encoding: TagEncoding, tag_field: FieldIdx, - variants: IndexVec>, + variants: IndexVec>, }, } @@ -2250,3 +2250,40 @@ pub enum AbiFromStrErr { /// no "-unwind" variant can be used here NoExplicitUnwind, } + +// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. +#[derive(PartialEq, Eq, Hash, Clone, Debug)] +#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +pub struct VariantLayout { + pub size: Size, + pub align: AbiAlign, + pub backend_repr: BackendRepr, + pub fields: FieldsShape, + largest_niche: Option, + uninhabited: bool, + pub variants: Variants, + max_repr_align: Option, + unadjusted_abi_align: Align, + randomization_seed: Hash64, +} + +impl VariantLayout { + pub fn from_layout(layout: LayoutData) -> Self { + Self { + size: layout.size, + align: layout.align, + backend_repr: layout.backend_repr, + fields: layout.fields, + largest_niche: layout.largest_niche, + uninhabited: layout.uninhabited, + variants: layout.variants, + max_repr_align: layout.max_repr_align, + unadjusted_abi_align: layout.unadjusted_abi_align, + randomization_seed: layout.randomization_seed, + } + } + + pub fn is_uninhabited(&self) -> bool { + self.uninhabited + } +} diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 46682abc823d8..64b1604eca38e 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -757,8 +757,8 @@ where tcx.mk_layout(LayoutData::uninhabited_variant(cx, variant_index, fields)) } - Variants::Multiple { ref variants, .. } => { - cx.tcx().mk_layout(variants[variant_index].clone()) + Variants::Multiple { .. } => { + cx.tcx().mk_layout(LayoutData::for_variant(&this, variant_index)) } }; diff --git a/src/librustdoc/html/render/type_layout.rs b/src/librustdoc/html/render/type_layout.rs index 5d5b8d5df685b..0bfe1fa977876 100644 --- a/src/librustdoc/html/render/type_layout.rs +++ b/src/librustdoc/html/render/type_layout.rs @@ -54,7 +54,7 @@ pub(crate) fn document_type_layout(cx: &Context<'_>, ty_def_id: DefId) -> impl f span_bug!(tcx.def_span(ty_def_id), "not an adt") }; let name = adt.variant(variant_idx).name; - let is_unsized = variant_layout.is_unsized(); + let is_unsized = variant_layout.backend_repr.is_unsized(); let is_uninhabited = variant_layout.is_uninhabited(); let size = variant_layout.size.bytes() - tag_size; let type_layout_size = TypeLayoutSize { is_unsized, is_uninhabited, size }; diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index 9b97ad4aeac7e..b130d022ea922 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -42,7 +42,7 @@ error: layout_of(UnsignedAroundZero) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -63,7 +63,7 @@ error: layout_of(UnsignedAroundZero) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: 9885373149222004003, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -84,7 +84,7 @@ error: layout_of(UnsignedAroundZero) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: 9885373149222004003, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -160,7 +160,7 @@ error: layout_of(SignedAroundZero) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -181,7 +181,7 @@ error: layout_of(SignedAroundZero) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: 2684536712112553499, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -202,7 +202,7 @@ error: layout_of(SignedAroundZero) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: 2684536712112553499, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index c92f876fa5a13..7092b0d0e79a8 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -58,7 +58,7 @@ error: layout_of(E) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -79,7 +79,7 @@ error: layout_of(E) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(12 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -242,7 +242,7 @@ error: layout_of(Result) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -280,7 +280,7 @@ error: layout_of(Result) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 20e0a8642a66f..e2f888a9dd860 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -42,7 +42,7 @@ error: layout_of(A) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -118,7 +118,7 @@ error: layout_of(B) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -194,7 +194,7 @@ error: layout_of(C) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -270,7 +270,7 @@ error: layout_of(P) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -346,7 +346,7 @@ error: layout_of(T) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 61cfcbdc07f75..bcb38889bded8 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -48,7 +48,7 @@ error: layout_of(MissingPayloadField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -85,7 +85,7 @@ error: layout_of(MissingPayloadField) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -168,7 +168,7 @@ error: layout_of(CommonPayloadField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -206,7 +206,7 @@ error: layout_of(CommonPayloadField) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -305,7 +305,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -342,7 +342,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -444,7 +444,7 @@ error: layout_of(NicheFirst) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -493,7 +493,7 @@ error: layout_of(NicheFirst) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -514,7 +514,7 @@ error: layout_of(NicheFirst) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -600,7 +600,7 @@ error: layout_of(NicheSecond) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -649,7 +649,7 @@ error: layout_of(NicheSecond) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -670,7 +670,7 @@ error: layout_of(NicheSecond) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 64e2f42c042f1..20607303599ec 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -36,7 +36,7 @@ error: layout_of(Aligned1) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -59,7 +59,7 @@ error: layout_of(Aligned1) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -139,7 +139,7 @@ error: layout_of(Aligned2) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -162,7 +162,7 @@ error: layout_of(Aligned2) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index a6e603652123b..07be46db6ed85 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -42,7 +42,7 @@ error: layout_of(A) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -118,7 +118,7 @@ error: layout_of(B) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -194,7 +194,7 @@ error: layout_of(C) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -270,7 +270,7 @@ error: layout_of(P) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -346,7 +346,7 @@ error: layout_of(T) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 23f9092778085..94462d737d3cd 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -36,7 +36,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -61,7 +61,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -144,7 +144,7 @@ error: layout_of(MultipleAlignments) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(2 bytes), @@ -169,7 +169,7 @@ error: layout_of(MultipleAlignments) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -194,7 +194,7 @@ error: layout_of(MultipleAlignments) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -277,7 +277,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -302,7 +302,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(3 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -389,7 +389,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -414,7 +414,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 62f6ec92d493c..5e764a7c77e91 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -42,7 +42,7 @@ error: layout_of(Univariant) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -134,7 +134,7 @@ error: layout_of(TwoVariants) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -171,7 +171,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -257,7 +257,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -286,7 +286,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 3e0efad974cd2..05bbb6004545f 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -42,7 +42,7 @@ error: layout_of(Univariant) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -134,7 +134,7 @@ error: layout_of(TwoVariants) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -171,7 +171,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -257,7 +257,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -286,7 +286,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 62f6ec92d493c..5e764a7c77e91 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -42,7 +42,7 @@ error: layout_of(Univariant) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -134,7 +134,7 @@ error: layout_of(TwoVariants) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -171,7 +171,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -257,7 +257,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -286,7 +286,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 62f6ec92d493c..5e764a7c77e91 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -42,7 +42,7 @@ error: layout_of(Univariant) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -134,7 +134,7 @@ error: layout_of(TwoVariants) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -171,7 +171,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -257,7 +257,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -286,7 +286,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index b25e4a9b7b6f5..12155358ad517 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -42,7 +42,7 @@ error: layout_of(UnivariantU8) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(1 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -134,7 +134,7 @@ error: layout_of(TwoVariantsU8) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -171,7 +171,7 @@ error: layout_of(TwoVariantsU8) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(2 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -257,7 +257,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { tag_encoding: Direct, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), @@ -286,7 +286,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index 0847af2d086fa..d1f1fc4b322fe 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -86,7 +86,7 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -107,7 +107,7 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(8 bytes), align: AbiAlign { abi: Align(8 bytes), diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index 6c9acac7eb7b8..fe38f70d008aa 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -127,7 +127,7 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -148,7 +148,7 @@ error: layout_of(Option<(u32) is 1..>) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), @@ -238,7 +238,7 @@ error: layout_of(Option>) = Layout { }, tag_field: 0, variants: [ - Layout { + VariantLayout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes), @@ -259,7 +259,7 @@ error: layout_of(Option>) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, }, - Layout { + VariantLayout { size: Size(4 bytes), align: AbiAlign { abi: Align(4 bytes), From dcc9f81f74fe71d8b7017ae7f9a4e471f850d66b Mon Sep 17 00:00:00 2001 From: Moulins Date: Wed, 17 Dec 2025 22:37:23 +0100 Subject: [PATCH 2/6] Remove redundant `VariantLayout.variants` field It was always set to `Variants::Single`. --- compiler/rustc_abi/src/layout.rs | 14 ++++---- compiler/rustc_abi/src/layout/coroutine.rs | 1 - compiler/rustc_abi/src/layout/simple.rs | 2 +- compiler/rustc_abi/src/lib.rs | 10 +++--- .../rustc_ty_utils/src/layout/invariant.rs | 2 -- .../enum-discriminant/wrapping_niche.stderr | 18 ---------- tests/ui/layout/debug.stderr | 12 ------- tests/ui/layout/hexagon-enum.stderr | 15 -------- ...-scalarpair-payload-might-be-uninit.stderr | 36 ------------------- .../issue-96185-overaligned-enum.stderr | 12 ------- tests/ui/layout/thumb-enum.stderr | 15 -------- .../layout/zero-sized-array-enum-niche.stderr | 27 -------------- ...-variants.aarch64-unknown-linux-gnu.stderr | 15 -------- ...-c-dead-variants.armebv7r-none-eabi.stderr | 15 -------- ...-dead-variants.i686-pc-windows-msvc.stderr | 15 -------- ...d-variants.x86_64-unknown-linux-gnu.stderr | 15 -------- tests/ui/repr/repr-c-int-dead-variants.stderr | 15 -------- tests/ui/type/pattern_types/non_null.stderr | 6 ---- .../type/pattern_types/range_patterns.stderr | 12 ------- 19 files changed, 11 insertions(+), 246 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index b111ff22c9706..18852c305b748 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -651,10 +651,9 @@ impl LayoutCalculator { let mut unadjusted_abi_align = align; let mut variant_layouts = variants - .iter_enumerated() - .map(|(j, v)| { - let mut st = self.univariant(v, repr, StructKind::AlwaysSized).ok()?; - st.variants = Variants::Single { index: j }; + .iter() + .map(|v| { + let st = self.univariant(v, repr, StructKind::AlwaysSized).ok()?; align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); @@ -879,14 +878,13 @@ impl LayoutCalculator { // Create the set of structs that represent each variant. let mut layout_variants = variants - .iter_enumerated() - .map(|(i, field_layouts)| { - let mut st = self.univariant( + .iter() + .map(|field_layouts| { + let st = self.univariant( field_layouts, repr, StructKind::Prefixed(min_ity.size(), prefix_align), )?; - st.variants = Variants::Single { index: i }; // Find the first field we can't move later // to make room for a larger discriminant. for field_idx in st.fields.index_by_increasing_offset() { diff --git a/compiler/rustc_abi/src/layout/coroutine.rs b/compiler/rustc_abi/src/layout/coroutine.rs index 812ed1f4274fd..fd68d06c93829 100644 --- a/compiler/rustc_abi/src/layout/coroutine.rs +++ b/compiler/rustc_abi/src/layout/coroutine.rs @@ -230,7 +230,6 @@ pub(super) fn layout< &ReprOptions::default(), StructKind::Prefixed(prefix_size, prefix_align.abi), )?; - variant.variants = Variants::Single { index }; let FieldsShape::Arbitrary { offsets, in_memory_order } = variant.fields else { unreachable!(); diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index cb584d7cf5788..7c714b6a880df 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -156,7 +156,7 @@ impl LayoutData { Self { fields: layout.fields.clone(), - variants: layout.variants.clone(), + variants: Variants::Single { index }, backend_repr: layout.backend_repr, largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 40a70f9fa87ec..5339c0cf8e873 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1894,7 +1894,7 @@ pub enum Variants { tag: Scalar, tag_encoding: TagEncoding, tag_field: FieldIdx, - variants: IndexVec>, + variants: IndexVec>, }, } @@ -2254,21 +2254,20 @@ pub enum AbiFromStrErr { // NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] #[cfg_attr(feature = "nightly", derive(HashStable_Generic))] -pub struct VariantLayout { +pub struct VariantLayout { pub size: Size, pub align: AbiAlign, pub backend_repr: BackendRepr, pub fields: FieldsShape, largest_niche: Option, uninhabited: bool, - pub variants: Variants, max_repr_align: Option, unadjusted_abi_align: Align, randomization_seed: Hash64, } -impl VariantLayout { - pub fn from_layout(layout: LayoutData) -> Self { +impl VariantLayout { + pub fn from_layout(layout: LayoutData) -> Self { Self { size: layout.size, align: layout.align, @@ -2276,7 +2275,6 @@ impl VariantLayout { fields: layout.fields, largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, - variants: layout.variants, max_repr_align: layout.max_repr_align, unadjusted_abi_align: layout.unadjusted_abi_align, randomization_seed: layout.randomization_seed, diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index 03ac1674dbd50..fc09d8664f713 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -294,8 +294,6 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou } } for variant in variants.iter() { - // No nested "multiple". - assert_matches!(variant.variants, Variants::Single { .. }); // Variants should have the same or a smaller size as the full thing, // and same for alignment. if variant.size > layout.size { diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index b130d022ea922..568922c224584 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -56,9 +56,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 9885373149222004003, @@ -77,9 +74,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 9885373149222004003, @@ -98,9 +92,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 2, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 9885373149222004003, @@ -174,9 +165,6 @@ error: layout_of(SignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 2684536712112553499, @@ -195,9 +183,6 @@ error: layout_of(SignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 2684536712112553499, @@ -216,9 +201,6 @@ error: layout_of(SignedAroundZero) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 2, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: 2684536712112553499, diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 7092b0d0e79a8..1b08a25c7969e 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -72,9 +72,6 @@ error: layout_of(E) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -101,9 +98,6 @@ error: layout_of(E) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -273,9 +267,6 @@ error: layout_of(Result) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -311,9 +302,6 @@ error: layout_of(Result) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index e2f888a9dd860..ce68514f30277 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -56,9 +56,6 @@ error: layout_of(A) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -132,9 +129,6 @@ error: layout_of(B) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -208,9 +202,6 @@ error: layout_of(C) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, @@ -284,9 +275,6 @@ error: layout_of(P) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -360,9 +348,6 @@ error: layout_of(T) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index bcb38889bded8..9f78cfd792365 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -78,9 +78,6 @@ error: layout_of(MissingPayloadField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -99,9 +96,6 @@ error: layout_of(MissingPayloadField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -199,9 +193,6 @@ error: layout_of(CommonPayloadField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -237,9 +228,6 @@ error: layout_of(CommonPayloadField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -335,9 +323,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -372,9 +357,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -486,9 +468,6 @@ error: layout_of(NicheFirst) = Layout { }, ), uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -507,9 +486,6 @@ error: layout_of(NicheFirst) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -528,9 +504,6 @@ error: layout_of(NicheFirst) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 2, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -642,9 +615,6 @@ error: layout_of(NicheSecond) = Layout { }, ), uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -663,9 +633,6 @@ error: layout_of(NicheSecond) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -684,9 +651,6 @@ error: layout_of(NicheSecond) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 2, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 20607303599ec..cc5818e78c71b 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -50,9 +50,6 @@ error: layout_of(Aligned1) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -73,9 +70,6 @@ error: layout_of(Aligned1) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: Some( Align(8 bytes), ), @@ -153,9 +147,6 @@ error: layout_of(Aligned2) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(1 bytes), ), @@ -176,9 +167,6 @@ error: layout_of(Aligned2) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: Some( Align(1 bytes), ), diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 07be46db6ed85..3c5f906d67aa8 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -56,9 +56,6 @@ error: layout_of(A) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -132,9 +129,6 @@ error: layout_of(B) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -208,9 +202,6 @@ error: layout_of(C) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, @@ -284,9 +275,6 @@ error: layout_of(P) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -360,9 +348,6 @@ error: layout_of(T) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 94462d737d3cd..ddceaeb7bd4ef 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -54,9 +54,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -88,9 +85,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -162,9 +156,6 @@ error: layout_of(MultipleAlignments) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, @@ -187,9 +178,6 @@ error: layout_of(MultipleAlignments) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -221,9 +209,6 @@ error: layout_of(MultipleAlignments) = Layout { }, ), uninhabited: false, - variants: Single { - index: 2, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -295,9 +280,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -329,9 +311,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -407,9 +386,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -441,9 +417,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 5e764a7c77e91..e8a99c7226af5 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -66,9 +66,6 @@ error: layout_of(Univariant) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -164,9 +161,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -201,9 +195,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -277,9 +268,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -304,9 +292,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 05bbb6004545f..30e0b7923bbd0 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -66,9 +66,6 @@ error: layout_of(Univariant) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -164,9 +161,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -201,9 +195,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -277,9 +268,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -304,9 +292,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 5e764a7c77e91..e8a99c7226af5 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -66,9 +66,6 @@ error: layout_of(Univariant) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -164,9 +161,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -201,9 +195,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -277,9 +268,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -304,9 +292,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 5e764a7c77e91..e8a99c7226af5 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -66,9 +66,6 @@ error: layout_of(Univariant) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -164,9 +161,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -201,9 +195,6 @@ error: layout_of(TwoVariants) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -277,9 +268,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -304,9 +292,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index 12155358ad517..73a2898b67608 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -66,9 +66,6 @@ error: layout_of(UnivariantU8) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -164,9 +161,6 @@ error: layout_of(TwoVariantsU8) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -201,9 +195,6 @@ error: layout_of(TwoVariantsU8) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -277,9 +268,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { }, largest_niche: None, uninhabited: true, - variants: Single { - index: 0, - }, max_repr_align: Some( Align(8 bytes), ), @@ -304,9 +292,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index d1f1fc4b322fe..8480992d4878f 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -100,9 +100,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -142,9 +139,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index fe38f70d008aa..bbded0607e058 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -141,9 +141,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -181,9 +178,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, @@ -252,9 +246,6 @@ error: layout_of(Option>) = Layout { }, largest_niche: None, uninhabited: false, - variants: Single { - index: 0, - }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, @@ -292,9 +283,6 @@ error: layout_of(Option>) = Layout { }, ), uninhabited: false, - variants: Single { - index: 1, - }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, From 82a3a13473a23a9f4ad1bff701ee2cd4046bdb93 Mon Sep 17 00:00:00 2001 From: Moulins Date: Wed, 17 Dec 2025 23:18:27 +0100 Subject: [PATCH 3/6] Store `FieldsShape::Arbitrary` fields directly in `VariantLayout` Enum variants always have `Arbitrary` layout, so the enum isn't needed. --- compiler/rustc_abi/src/layout.rs | 43 ++---- compiler/rustc_abi/src/layout/simple.rs | 5 +- compiler/rustc_abi/src/lib.rs | 14 +- .../src/unstable/convert/stable/abi.rs | 7 +- .../rustc_ty_utils/src/layout/invariant.rs | 5 +- .../enum-discriminant/wrapping_niche.stderr | 36 ++--- tests/ui/layout/debug.stderr | 56 ++++---- tests/ui/layout/hexagon-enum.stderr | 30 ++-- ...-scalarpair-payload-might-be-uninit.stderr | 136 ++++++++---------- .../issue-96185-overaligned-enum.stderr | 24 ++-- tests/ui/layout/thumb-enum.stderr | 30 ++-- .../layout/zero-sized-array-enum-niche.stderr | 126 +++++++--------- ...-variants.aarch64-unknown-linux-gnu.stderr | 74 +++++----- ...-c-dead-variants.armebv7r-none-eabi.stderr | 74 +++++----- ...-dead-variants.i686-pc-windows-msvc.stderr | 74 +++++----- ...d-variants.x86_64-unknown-linux-gnu.stderr | 74 +++++----- tests/ui/repr/repr-c-int-dead-variants.stderr | 74 +++++----- tests/ui/type/pattern_types/non_null.stderr | 20 ++- .../type/pattern_types/range_patterns.stderr | 40 +++--- 19 files changed, 390 insertions(+), 552 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 18852c305b748..6bdaf0bb5c655 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -705,15 +705,8 @@ impl LayoutCalculator { } // It'll fit, but we need to make some adjustments. - match layout.fields { - FieldsShape::Arbitrary { ref mut offsets, .. } => { - for offset in offsets.iter_mut() { - *offset += this_offset; - } - } - FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => { - panic!("Layout of fields should be Arbitrary for variants") - } + for offset in layout.field_offsets.iter_mut() { + *offset += this_offset; } // It can't be a Scalar or ScalarPair because the offset isn't 0. @@ -953,23 +946,16 @@ impl LayoutCalculator { let old_ity_size = min_ity.size(); let new_ity_size = ity.size(); for variant in &mut layout_variants { - match variant.fields { - FieldsShape::Arbitrary { ref mut offsets, .. } => { - for i in offsets { - if *i <= old_ity_size { - assert_eq!(*i, old_ity_size); - *i = new_ity_size; - } - } - // We might be making the struct larger. - if variant.size <= old_ity_size { - variant.size = new_ity_size; - } - } - FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => { - panic!("encountered a non-arbitrary layout during enum layout") + for i in &mut variant.field_offsets { + if *i <= old_ity_size { + assert_eq!(*i, old_ity_size); + *i = new_ity_size; } } + // We might be making the struct larger. + if variant.size <= old_ity_size { + variant.size = new_ity_size; + } } } @@ -994,12 +980,10 @@ impl LayoutCalculator { let mut common_prim = None; let mut common_prim_initialized_in_all_variants = true; for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) { - let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else { - panic!("encountered a non-arbitrary layout during enum layout"); - }; // We skip *all* ZST here and later check if we are good in terms of alignment. // This lets us handle some cases involving aligned ZST. - let mut fields = iter::zip(field_layouts, offsets).filter(|p| !p.0.is_zst()); + let mut fields = iter::zip(field_layouts, &layout_variant.field_offsets) + .filter(|p| !p.0.is_zst()); let (field, offset) = match (fields.next(), fields.next()) { (None, None) => { common_prim_initialized_in_all_variants = false; @@ -1094,8 +1078,7 @@ impl LayoutCalculator { for variant in &mut layout_variants { // We only do this for variants with fields; the others are not accessed anyway. // Also do not overwrite any already existing "clever" ABIs. - if variant.fields.count() > 0 - && matches!(variant.backend_repr, BackendRepr::Memory { .. }) + if matches!(variant.backend_repr, BackendRepr::Memory { .. } if variant.has_fields()) { variant.backend_repr = abi; // Also need to bump up the size and alignment, so that the entire value fits diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 7c714b6a880df..1ce22a0293346 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -155,7 +155,10 @@ impl LayoutData { }; Self { - fields: layout.fields.clone(), + fields: FieldsShape::Arbitrary { + offsets: layout.field_offsets.clone(), + in_memory_order: layout.fields_in_memory_order.clone(), + }, variants: Variants::Single { index }, backend_repr: layout.backend_repr, largest_niche: layout.largest_niche, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 5339c0cf8e873..973041c0d77d1 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2258,7 +2258,8 @@ pub struct VariantLayout { pub size: Size, pub align: AbiAlign, pub backend_repr: BackendRepr, - pub fields: FieldsShape, + pub field_offsets: IndexVec, + fields_in_memory_order: IndexVec, largest_niche: Option, uninhabited: bool, max_repr_align: Option, @@ -2268,11 +2269,16 @@ pub struct VariantLayout { impl VariantLayout { pub fn from_layout(layout: LayoutData) -> Self { + let FieldsShape::Arbitrary { offsets, in_memory_order } = layout.fields else { + panic!("Layout of fields should be Arbitrary for variants"); + }; + Self { size: layout.size, align: layout.align, backend_repr: layout.backend_repr, - fields: layout.fields, + field_offsets: offsets, + fields_in_memory_order: in_memory_order, largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, max_repr_align: layout.max_repr_align, @@ -2284,4 +2290,8 @@ impl VariantLayout { pub fn is_uninhabited(&self) -> bool { self.uninhabited } + + pub fn has_fields(&self) -> bool { + self.field_offsets.len() > 0 + } } diff --git a/compiler/rustc_public/src/unstable/convert/stable/abi.rs b/compiler/rustc_public/src/unstable/convert/stable/abi.rs index d8c4cee7abbe4..970a31d02d789 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/abi.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/abi.rs @@ -216,11 +216,8 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Variants VariantFields { - offsets: offsets.iter().as_slice().stable(tables, cx), - }, - _ => panic!("variant layout should be Arbitrary"), + .map(|v| VariantFields { + offsets: v.field_offsets.iter().as_slice().stable(tables, cx), }) .collect(), } diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index fc09d8664f713..98e6ca351964e 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -311,10 +311,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou ) } // Skip empty variants. - if variant.size == Size::ZERO - || variant.fields.count() == 0 - || variant.is_uninhabited() - { + if variant.size == Size::ZERO || !variant.has_fields() || variant.is_uninhabited() { // These are never actually accessed anyway, so we can skip the coherence check // for them. They also fail that check, since they may have // a different ABI even when the main type is diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index 568922c224584..b3b0a560b28ab 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -50,10 +50,8 @@ error: layout_of(UnsignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -68,10 +66,8 @@ error: layout_of(UnsignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -86,10 +82,8 @@ error: layout_of(UnsignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -159,10 +153,8 @@ error: layout_of(SignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -177,10 +169,8 @@ error: layout_of(SignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -195,10 +185,8 @@ error: layout_of(SignedAroundZero) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 1b08a25c7969e..b80a797f05af1 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -66,10 +66,8 @@ error: layout_of(E) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -84,18 +82,16 @@ error: layout_of(E) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(4 bytes), - Size(4 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - 2, - ], - }, + field_offsets: [ + Size(4 bytes), + Size(4 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + 2, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -257,14 +253,12 @@ error: layout_of(Result) = Layout { valid_range: 0..=4294967295, }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -292,14 +286,12 @@ error: layout_of(Result) = Layout { valid_range: 0..=4294967295, }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index ce68514f30277..e00848b1b0154 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -50,10 +50,8 @@ error: layout_of(A) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -123,10 +121,8 @@ error: layout_of(B) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -196,10 +192,8 @@ error: layout_of(C) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -269,10 +263,8 @@ error: layout_of(P) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -342,10 +334,8 @@ error: layout_of(T) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 9f78cfd792365..c9d7551a3d954 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -68,14 +68,12 @@ error: layout_of(MissingPayloadField) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -90,10 +88,8 @@ error: layout_of(MissingPayloadField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -183,14 +179,12 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -218,14 +212,12 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -313,14 +305,12 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -347,14 +337,12 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -447,16 +435,14 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=255, }, ), - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(1 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(0 bytes), + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: Some( Niche { offset: Size(0 bytes), @@ -480,10 +466,8 @@ error: layout_of(NicheFirst) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -498,10 +482,8 @@ error: layout_of(NicheFirst) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -594,16 +576,14 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=255, }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - Size(0 bytes), - ], - in_memory_order: [ - 1, - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + Size(0 bytes), + ], + fields_in_memory_order: [ + 1, + 0, + ], largest_niche: Some( Niche { offset: Size(0 bytes), @@ -627,10 +607,8 @@ error: layout_of(NicheSecond) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -645,10 +623,8 @@ error: layout_of(NicheSecond) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index cc5818e78c71b..7e88d4c6fcc9e 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -44,10 +44,8 @@ error: layout_of(Aligned1) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: Some( @@ -64,10 +62,8 @@ error: layout_of(Aligned1) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: Some( @@ -141,10 +137,8 @@ error: layout_of(Aligned2) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: Some( @@ -161,10 +155,8 @@ error: layout_of(Aligned2) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: Some( diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 3c5f906d67aa8..053ea65a48b79 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -50,10 +50,8 @@ error: layout_of(A) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -123,10 +121,8 @@ error: layout_of(B) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -196,10 +192,8 @@ error: layout_of(C) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -269,10 +263,8 @@ error: layout_of(P) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -342,10 +334,8 @@ error: layout_of(T) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index ddceaeb7bd4ef..e4ab23e3564d7 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -44,14 +44,12 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -66,14 +64,12 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(1 bytes), @@ -146,14 +142,12 @@ error: layout_of(MultipleAlignments) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(2 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(2 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -168,14 +162,12 @@ error: layout_of(MultipleAlignments) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -190,14 +182,12 @@ error: layout_of(MultipleAlignments) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(1 bytes), @@ -270,14 +260,12 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -292,14 +280,12 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(1 bytes), @@ -376,14 +362,12 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(0 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -398,14 +382,12 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(0 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(0 bytes), diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index e8a99c7226af5..46a1eee98c772 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -56,14 +56,12 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -151,14 +149,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -185,14 +181,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -256,16 +250,14 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(8 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: None, uninhabited: true, max_repr_align: Some( @@ -282,14 +274,12 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 30e0b7923bbd0..35c0d22f23254 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -56,14 +56,12 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -151,14 +149,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -185,14 +181,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -256,16 +250,14 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(8 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: None, uninhabited: true, max_repr_align: Some( @@ -282,14 +274,12 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index e8a99c7226af5..46a1eee98c772 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -56,14 +56,12 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -151,14 +149,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -185,14 +181,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -256,16 +250,14 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(8 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: None, uninhabited: true, max_repr_align: Some( @@ -282,14 +274,12 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index e8a99c7226af5..46a1eee98c772 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -56,14 +56,12 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -151,14 +149,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -185,14 +181,12 @@ error: layout_of(TwoVariants) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(4 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -256,16 +250,14 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(8 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: None, uninhabited: true, max_repr_align: Some( @@ -282,14 +274,12 @@ error: layout_of(DeadBranchHasOtherField) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index 73a2898b67608..0f0099bb18cc8 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -56,14 +56,12 @@ error: layout_of(UnivariantU8) = Layout { valid_range: 0..=0, }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -151,14 +149,12 @@ error: layout_of(TwoVariantsU8) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: true, max_repr_align: None, @@ -185,14 +181,12 @@ error: layout_of(TwoVariantsU8) = Layout { ), }, ), - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(1 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -256,16 +250,14 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - Size(8 bytes), - ], - in_memory_order: [ - 0, - 1, - ], - }, + field_offsets: [ + Size(8 bytes), + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + 1, + ], largest_niche: None, uninhabited: true, max_repr_align: Some( @@ -282,14 +274,12 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [ - Size(8 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(8 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: None, uninhabited: false, max_repr_align: None, diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index 8480992d4878f..fb8ec33f63202 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -94,10 +94,8 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -119,14 +117,12 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { valid_range: 1..=18446744073709551615, }, ), - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(0 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(0 bytes), diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index bbded0607e058..0dcbca1703a47 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -135,10 +135,8 @@ error: layout_of(Option<(u32) is 1..>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -159,14 +157,12 @@ error: layout_of(Option<(u32) is 1..>) = Layout { valid_range: 1..=4294967295, }, ), - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(0 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(0 bytes), @@ -240,10 +236,8 @@ error: layout_of(Option>) = Layout { backend_repr: Memory { sized: true, }, - fields: Arbitrary { - offsets: [], - in_memory_order: [], - }, + field_offsets: [], + fields_in_memory_order: [], largest_niche: None, uninhabited: false, max_repr_align: None, @@ -264,14 +258,12 @@ error: layout_of(Option>) = Layout { valid_range: 1..=4294967295, }, ), - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - in_memory_order: [ - 0, - ], - }, + field_offsets: [ + Size(0 bytes), + ], + fields_in_memory_order: [ + 0, + ], largest_niche: Some( Niche { offset: Size(0 bytes), From 8f0df41278b21bcf04514070fce07e8dbe18dcb6 Mon Sep 17 00:00:00 2001 From: Moulins Date: Thu, 18 Dec 2025 19:07:38 +0100 Subject: [PATCH 4/6] Remove unused `VariantLayout.randomization_seed` field This field is only used during layout calculations, so re-synthetized `LayoutData`s for enum variants can use a dummy value instead. --- compiler/rustc_abi/src/layout.rs | 14 ++++---------- compiler/rustc_abi/src/layout/simple.rs | 2 +- compiler/rustc_abi/src/lib.rs | 2 -- tests/ui/enum-discriminant/wrapping_niche.stderr | 6 ------ tests/ui/layout/debug.stderr | 4 ---- tests/ui/layout/hexagon-enum.stderr | 5 ----- ...96158-scalarpair-payload-might-be-uninit.stderr | 12 ------------ .../ui/layout/issue-96185-overaligned-enum.stderr | 4 ---- tests/ui/layout/thumb-enum.stderr | 5 ----- tests/ui/layout/zero-sized-array-enum-niche.stderr | 9 --------- ...-dead-variants.aarch64-unknown-linux-gnu.stderr | 5 ----- .../repr-c-dead-variants.armebv7r-none-eabi.stderr | 5 ----- ...epr-c-dead-variants.i686-pc-windows-msvc.stderr | 5 ----- ...c-dead-variants.x86_64-unknown-linux-gnu.stderr | 5 ----- tests/ui/repr/repr-c-int-dead-variants.stderr | 5 ----- tests/ui/type/pattern_types/non_null.stderr | 2 -- tests/ui/type/pattern_types/range_patterns.stderr | 4 ---- 17 files changed, 5 insertions(+), 89 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 6bdaf0bb5c655..d21a20d4b87bc 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -649,6 +649,7 @@ impl LayoutCalculator { let mut align = dl.aggregate_align; let mut max_repr_align = repr.align; let mut unadjusted_abi_align = align; + let mut combined_seed = repr.field_shuffle_seed; let mut variant_layouts = variants .iter() @@ -658,6 +659,7 @@ impl LayoutCalculator { align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); + combined_seed = combined_seed.wrapping_add(st.randomization_seed); Some(VariantLayout::from_layout(st)) }) @@ -751,11 +753,6 @@ impl LayoutCalculator { BackendRepr::Memory { sized: true } }; - let combined_seed = variant_layouts - .iter() - .map(|v| v.randomization_seed) - .fold(repr.field_shuffle_seed, |acc, seed| acc.wrapping_add(seed)); - let layout = LayoutData { variants: Variants::Multiple { tag: niche_scalar, @@ -848,6 +845,7 @@ impl LayoutCalculator { let mut align = dl.aggregate_align; let mut max_repr_align = repr.align; let mut unadjusted_abi_align = align; + let mut combined_seed = repr.field_shuffle_seed; let mut size = Size::ZERO; @@ -891,6 +889,7 @@ impl LayoutCalculator { align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); + combined_seed = combined_seed.wrapping_add(st.randomization_seed); Ok(VariantLayout::from_layout(st)) }) .collect::, _>>()?; @@ -1091,11 +1090,6 @@ impl LayoutCalculator { let largest_niche = Niche::from_scalar(dl, Size::ZERO, tag); - let combined_seed = layout_variants - .iter() - .map(|v| v.randomization_seed) - .fold(repr.field_shuffle_seed, |acc, seed| acc.wrapping_add(seed)); - let tagged_layout = LayoutData { variants: Variants::Multiple { tag, diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 1ce22a0293346..9b13540ca15a5 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -167,7 +167,7 @@ impl LayoutData { size: layout.size, max_repr_align: layout.max_repr_align, unadjusted_abi_align: layout.unadjusted_abi_align, - randomization_seed: layout.randomization_seed, + randomization_seed: Hash64::ZERO, } } } diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 973041c0d77d1..f0fae2d42ecfb 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2264,7 +2264,6 @@ pub struct VariantLayout { uninhabited: bool, max_repr_align: Option, unadjusted_abi_align: Align, - randomization_seed: Hash64, } impl VariantLayout { @@ -2283,7 +2282,6 @@ impl VariantLayout { uninhabited: layout.uninhabited, max_repr_align: layout.max_repr_align, unadjusted_abi_align: layout.unadjusted_abi_align, - randomization_seed: layout.randomization_seed, } } diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index b3b0a560b28ab..bd42f79c38b39 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -56,7 +56,6 @@ error: layout_of(UnsignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 9885373149222004003, }, VariantLayout { size: Size(2 bytes), @@ -72,7 +71,6 @@ error: layout_of(UnsignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 9885373149222004003, }, VariantLayout { size: Size(2 bytes), @@ -88,7 +86,6 @@ error: layout_of(UnsignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 9885373149222004003, }, ], }, @@ -159,7 +156,6 @@ error: layout_of(SignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 2684536712112553499, }, VariantLayout { size: Size(2 bytes), @@ -175,7 +171,6 @@ error: layout_of(SignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 2684536712112553499, }, VariantLayout { size: Size(2 bytes), @@ -191,7 +186,6 @@ error: layout_of(SignedAroundZero) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: 2684536712112553499, }, ], }, diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index b80a797f05af1..c218d933d6862 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -72,7 +72,6 @@ error: layout_of(E) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(12 bytes), @@ -96,7 +95,6 @@ error: layout_of(E) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -263,7 +261,6 @@ error: layout_of(Result) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -296,7 +293,6 @@ error: layout_of(Result) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index e00848b1b0154..73431de7016eb 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -56,7 +56,6 @@ error: layout_of(A) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -127,7 +126,6 @@ error: layout_of(B) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -198,7 +196,6 @@ error: layout_of(C) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: $SEED, }, ], }, @@ -269,7 +266,6 @@ error: layout_of(P) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -340,7 +336,6 @@ error: layout_of(T) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index c9d7551a3d954..20f9e69ff51d4 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -78,7 +78,6 @@ error: layout_of(MissingPayloadField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(1 bytes), @@ -94,7 +93,6 @@ error: layout_of(MissingPayloadField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -189,7 +187,6 @@ error: layout_of(CommonPayloadField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -222,7 +219,6 @@ error: layout_of(CommonPayloadField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -315,7 +311,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -347,7 +342,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -456,7 +450,6 @@ error: layout_of(NicheFirst) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(0 bytes), @@ -472,7 +465,6 @@ error: layout_of(NicheFirst) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(0 bytes), @@ -488,7 +480,6 @@ error: layout_of(NicheFirst) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -597,7 +588,6 @@ error: layout_of(NicheSecond) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(0 bytes), @@ -613,7 +603,6 @@ error: layout_of(NicheSecond) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(0 bytes), @@ -629,7 +618,6 @@ error: layout_of(NicheSecond) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 7e88d4c6fcc9e..80efc35cf6384 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -52,7 +52,6 @@ error: layout_of(Aligned1) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -70,7 +69,6 @@ error: layout_of(Aligned1) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -145,7 +143,6 @@ error: layout_of(Aligned2) = Layout { Align(1 bytes), ), unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(1 bytes), @@ -163,7 +160,6 @@ error: layout_of(Aligned2) = Layout { Align(1 bytes), ), unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 053ea65a48b79..d2d4af352a093 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -56,7 +56,6 @@ error: layout_of(A) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -127,7 +126,6 @@ error: layout_of(B) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -198,7 +196,6 @@ error: layout_of(C) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: $SEED, }, ], }, @@ -269,7 +266,6 @@ error: layout_of(P) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -340,7 +336,6 @@ error: layout_of(T) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index e4ab23e3564d7..b1a2183699488 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -54,7 +54,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -83,7 +82,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -152,7 +150,6 @@ error: layout_of(MultipleAlignments) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(4 bytes), @@ -172,7 +169,6 @@ error: layout_of(MultipleAlignments) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -201,7 +197,6 @@ error: layout_of(MultipleAlignments) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -270,7 +265,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(3 bytes), @@ -299,7 +293,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -372,7 +365,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -401,7 +393,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 46a1eee98c772..6917390e9bb91 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -66,7 +66,6 @@ error: layout_of(Univariant) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -159,7 +158,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -191,7 +189,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -264,7 +261,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(16 bytes), @@ -284,7 +280,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 35c0d22f23254..1ad3b8b22f7cc 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -66,7 +66,6 @@ error: layout_of(Univariant) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -159,7 +158,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -191,7 +189,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -264,7 +261,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(16 bytes), @@ -284,7 +280,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 46a1eee98c772..6917390e9bb91 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -66,7 +66,6 @@ error: layout_of(Univariant) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -159,7 +158,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -191,7 +189,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -264,7 +261,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(16 bytes), @@ -284,7 +280,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 46a1eee98c772..6917390e9bb91 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -66,7 +66,6 @@ error: layout_of(Univariant) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -159,7 +158,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -191,7 +189,6 @@ error: layout_of(TwoVariants) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -264,7 +261,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(16 bytes), @@ -284,7 +280,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index 0f0099bb18cc8..857002c379caa 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -66,7 +66,6 @@ error: layout_of(UnivariantU8) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -159,7 +158,6 @@ error: layout_of(TwoVariantsU8) = Layout { uninhabited: true, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(2 bytes), @@ -191,7 +189,6 @@ error: layout_of(TwoVariantsU8) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, ], }, @@ -264,7 +261,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(16 bytes), @@ -284,7 +280,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index fb8ec33f63202..38f449c282e12 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -100,7 +100,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(8 bytes), @@ -137,7 +136,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), - randomization_seed: $SEED, }, ], }, diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index 0dcbca1703a47..da9bd3e6db17f 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -141,7 +141,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(4 bytes), @@ -176,7 +175,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, @@ -242,7 +240,6 @@ error: layout_of(Option>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), - randomization_seed: $SEED, }, VariantLayout { size: Size(4 bytes), @@ -277,7 +274,6 @@ error: layout_of(Option>) = Layout { uninhabited: false, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), - randomization_seed: $SEED, }, ], }, From db81f4e7abec08f72cf19b16404a81fae6f78fe0 Mon Sep 17 00:00:00 2001 From: Moulins Date: Wed, 14 Jan 2026 00:20:50 +0100 Subject: [PATCH 5/6] Remove per-variant alignment in `VariantLayout` Reusing the alignment of the enclosing enum in `LayoutData::for_variant` doesn't appear to cause any issues. --- compiler/rustc_abi/src/layout.rs | 15 +++-- compiler/rustc_abi/src/layout/simple.rs | 6 +- compiler/rustc_abi/src/lib.rs | 6 -- .../rustc_ty_utils/src/layout/invariant.rs | 10 +--- .../enum-discriminant/wrapping_niche.stderr | 30 ---------- tests/ui/layout/debug.stderr | 20 ------- tests/ui/layout/hexagon-enum.stderr | 25 -------- ...-scalarpair-payload-might-be-uninit.stderr | 60 ------------------- .../issue-96185-overaligned-enum.stderr | 28 --------- tests/ui/layout/thumb-enum.stderr | 25 -------- .../layout/zero-sized-array-enum-niche.stderr | 45 -------------- ...-variants.aarch64-unknown-linux-gnu.stderr | 27 --------- ...-c-dead-variants.armebv7r-none-eabi.stderr | 27 --------- ...-dead-variants.i686-pc-windows-msvc.stderr | 27 --------- ...d-variants.x86_64-unknown-linux-gnu.stderr | 27 --------- tests/ui/repr/repr-c-int-dead-variants.stderr | 27 --------- tests/ui/type/pattern_types/non_null.stderr | 10 ---- .../type/pattern_types/range_patterns.stderr | 20 ------- 18 files changed, 14 insertions(+), 421 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index d21a20d4b87bc..f0b92155d0be1 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -638,6 +638,10 @@ impl LayoutCalculator { } let calculate_niche_filling_layout = || -> Option> { + struct VariantLayoutInfo { + align_abi: Align, + } + if repr.inhibit_enum_layout_opt() { return None; } @@ -651,11 +655,14 @@ impl LayoutCalculator { let mut unadjusted_abi_align = align; let mut combined_seed = repr.field_shuffle_seed; + let mut variants_info = IndexVec::::with_capacity(variants.len()); let mut variant_layouts = variants .iter() .map(|v| { let st = self.univariant(v, repr, StructKind::AlwaysSized).ok()?; + variants_info.push(VariantLayoutInfo { align_abi: st.align.abi }); + align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); @@ -699,7 +706,7 @@ impl LayoutCalculator { } // Determine if it'll fit after the niche. - let this_align = layout.align.abi; + let this_align = variants_info[i].align_abi; let this_offset = (niche_offset + niche_size).align_to(this_align); if this_offset + layout.size > size { @@ -730,7 +737,7 @@ impl LayoutCalculator { .iter_enumerated() .all(|(i, layout)| i == largest_variant_index || layout.size == Size::ZERO); let same_size = size == variant_layouts[largest_variant_index].size; - let same_align = align == variant_layouts[largest_variant_index].align.abi; + let same_align = align == variants_info[largest_variant_index].align_abi; let uninhabited = variant_layouts.iter().all(|v| v.is_uninhabited()); let abi = if same_size && same_align && others_zst { @@ -1080,10 +1087,8 @@ impl LayoutCalculator { if matches!(variant.backend_repr, BackendRepr::Memory { .. } if variant.has_fields()) { variant.backend_repr = abi; - // Also need to bump up the size and alignment, so that the entire value fits - // in here. + // Also need to bump up the size, so that the entire value fits in here. variant.size = cmp::max(variant.size, size); - variant.align.abi = cmp::max(variant.align.abi, align); } } } diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 9b13540ca15a5..48530cbf69c77 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -163,10 +163,10 @@ impl LayoutData { backend_repr: layout.backend_repr, largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, - align: layout.align, size: layout.size, - max_repr_align: layout.max_repr_align, - unadjusted_abi_align: layout.unadjusted_abi_align, + align: parent.align, + max_repr_align: parent.max_repr_align, + unadjusted_abi_align: parent.unadjusted_abi_align, randomization_seed: Hash64::ZERO, } } diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index f0fae2d42ecfb..3d4c85018ce29 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2256,14 +2256,11 @@ pub enum AbiFromStrErr { #[cfg_attr(feature = "nightly", derive(HashStable_Generic))] pub struct VariantLayout { pub size: Size, - pub align: AbiAlign, pub backend_repr: BackendRepr, pub field_offsets: IndexVec, fields_in_memory_order: IndexVec, largest_niche: Option, uninhabited: bool, - max_repr_align: Option, - unadjusted_abi_align: Align, } impl VariantLayout { @@ -2274,14 +2271,11 @@ impl VariantLayout { Self { size: layout.size, - align: layout.align, backend_repr: layout.backend_repr, field_offsets: offsets, fields_in_memory_order: in_memory_order, largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, - max_repr_align: layout.max_repr_align, - unadjusted_abi_align: layout.unadjusted_abi_align, } } diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index 98e6ca351964e..7e15c16303ddd 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -294,8 +294,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou } } for variant in variants.iter() { - // Variants should have the same or a smaller size as the full thing, - // and same for alignment. + // Variants should have the same or a smaller size as the full thing. if variant.size > layout.size { bug!( "Type with size {} bytes has variant with size {} bytes: {layout:#?}", @@ -303,13 +302,6 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou variant.size.bytes(), ) } - if variant.align.abi > layout.align.abi { - bug!( - "Type with alignment {} bytes has variant with alignment {} bytes: {layout:#?}", - layout.align.bytes(), - variant.align.bytes(), - ) - } // Skip empty variants. if variant.size == Size::ZERO || !variant.has_fields() || variant.is_uninhabited() { // These are never actually accessed anyway, so we can skip the coherence check diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index bd42f79c38b39..b24948fb39ddf 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -44,9 +44,6 @@ error: layout_of(UnsignedAroundZero) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -54,14 +51,9 @@ error: layout_of(UnsignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -69,14 +61,9 @@ error: layout_of(UnsignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -84,8 +71,6 @@ error: layout_of(UnsignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, ], }, @@ -144,9 +129,6 @@ error: layout_of(SignedAroundZero) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -154,14 +136,9 @@ error: layout_of(SignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -169,14 +146,9 @@ error: layout_of(SignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -184,8 +156,6 @@ error: layout_of(SignedAroundZero) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, ], }, diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index c218d933d6862..1c9c02c657e3e 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -60,9 +60,6 @@ error: layout_of(E) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -70,14 +67,9 @@ error: layout_of(E) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(12 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -93,8 +85,6 @@ error: layout_of(E) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -232,9 +222,6 @@ error: layout_of(Result) = Layout { variants: [ VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -259,14 +246,9 @@ error: layout_of(Result) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -291,8 +273,6 @@ error: layout_of(Result) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 73431de7016eb..993ff476b6b6c 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -44,9 +44,6 @@ error: layout_of(A) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -54,8 +51,6 @@ error: layout_of(A) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -114,9 +109,6 @@ error: layout_of(B) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -124,8 +116,6 @@ error: layout_of(B) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -184,9 +174,6 @@ error: layout_of(C) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -194,8 +181,6 @@ error: layout_of(C) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, ], }, @@ -254,9 +239,6 @@ error: layout_of(P) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -264,8 +246,6 @@ error: layout_of(P) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -324,9 +304,6 @@ error: layout_of(T) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -334,8 +311,6 @@ error: layout_of(T) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 20f9e69ff51d4..7e6294f894c3e 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -50,9 +50,6 @@ error: layout_of(MissingPayloadField) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -76,14 +73,9 @@ error: layout_of(MissingPayloadField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -91,8 +83,6 @@ error: layout_of(MissingPayloadField) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -158,9 +148,6 @@ error: layout_of(CommonPayloadField) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -185,14 +172,9 @@ error: layout_of(CommonPayloadField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -217,8 +199,6 @@ error: layout_of(CommonPayloadField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -283,9 +263,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -309,14 +286,9 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -340,8 +312,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -410,9 +380,6 @@ error: layout_of(NicheFirst) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -448,14 +415,9 @@ error: layout_of(NicheFirst) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -463,14 +425,9 @@ error: layout_of(NicheFirst) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -478,8 +435,6 @@ error: layout_of(NicheFirst) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -548,9 +503,6 @@ error: layout_of(NicheSecond) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -586,14 +538,9 @@ error: layout_of(NicheSecond) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -601,14 +548,9 @@ error: layout_of(NicheSecond) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -616,8 +558,6 @@ error: layout_of(NicheSecond) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 80efc35cf6384..8937af2f5d494 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -38,9 +38,6 @@ error: layout_of(Aligned1) = Layout { variants: [ VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -48,16 +45,9 @@ error: layout_of(Aligned1) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -65,10 +55,6 @@ error: layout_of(Aligned1) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -129,9 +115,6 @@ error: layout_of(Aligned2) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -139,16 +122,9 @@ error: layout_of(Aligned2) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: Some( - Align(1 bytes), - ), - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -156,10 +132,6 @@ error: layout_of(Aligned2) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: Some( - Align(1 bytes), - ), - unadjusted_abi_align: Align(1 bytes), }, ], }, diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index d2d4af352a093..200002490d5c5 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -44,9 +44,6 @@ error: layout_of(A) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -54,8 +51,6 @@ error: layout_of(A) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -114,9 +109,6 @@ error: layout_of(B) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -124,8 +116,6 @@ error: layout_of(B) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -184,9 +174,6 @@ error: layout_of(C) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -194,8 +181,6 @@ error: layout_of(C) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, ], }, @@ -254,9 +239,6 @@ error: layout_of(P) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -264,8 +246,6 @@ error: layout_of(P) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -324,9 +304,6 @@ error: layout_of(T) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -334,8 +311,6 @@ error: layout_of(T) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index b1a2183699488..b40e357c1a114 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -38,9 +38,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -52,14 +49,9 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -80,8 +72,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -134,9 +124,6 @@ error: layout_of(MultipleAlignments) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(2 bytes), - }, backend_repr: Memory { sized: true, }, @@ -148,14 +135,9 @@ error: layout_of(MultipleAlignments) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(2 bytes), }, VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -167,14 +149,9 @@ error: layout_of(MultipleAlignments) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -195,8 +172,6 @@ error: layout_of(MultipleAlignments) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -249,9 +224,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -263,14 +235,9 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(3 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -291,8 +258,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -349,9 +314,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { variants: [ VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Memory { sized: true, }, @@ -363,14 +325,9 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -391,8 +348,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 6917390e9bb91..28fafa7800305 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -44,9 +44,6 @@ error: layout_of(Univariant) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -64,8 +61,6 @@ error: layout_of(Univariant) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -130,9 +125,6 @@ error: layout_of(TwoVariants) = Layout { variants: [ VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -156,14 +148,9 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -187,8 +174,6 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -241,9 +226,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -257,16 +239,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(8 bytes), }, VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -278,8 +253,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 1ad3b8b22f7cc..45193552b507f 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -44,9 +44,6 @@ error: layout_of(Univariant) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -64,8 +61,6 @@ error: layout_of(Univariant) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -130,9 +125,6 @@ error: layout_of(TwoVariants) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -156,14 +148,9 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -187,8 +174,6 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -241,9 +226,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -257,16 +239,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(8 bytes), }, VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -278,8 +253,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 6917390e9bb91..28fafa7800305 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -44,9 +44,6 @@ error: layout_of(Univariant) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -64,8 +61,6 @@ error: layout_of(Univariant) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -130,9 +125,6 @@ error: layout_of(TwoVariants) = Layout { variants: [ VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -156,14 +148,9 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -187,8 +174,6 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -241,9 +226,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -257,16 +239,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(8 bytes), }, VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -278,8 +253,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 6917390e9bb91..28fafa7800305 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -44,9 +44,6 @@ error: layout_of(Univariant) = Layout { variants: [ VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -64,8 +61,6 @@ error: layout_of(Univariant) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -130,9 +125,6 @@ error: layout_of(TwoVariants) = Layout { variants: [ VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -156,14 +148,9 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -187,8 +174,6 @@ error: layout_of(TwoVariants) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -241,9 +226,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -257,16 +239,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(8 bytes), }, VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -278,8 +253,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index 857002c379caa..c2f7fec38c81f 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -44,9 +44,6 @@ error: layout_of(UnivariantU8) = Layout { variants: [ VariantLayout { size: Size(1 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -64,8 +61,6 @@ error: layout_of(UnivariantU8) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -130,9 +125,6 @@ error: layout_of(TwoVariantsU8) = Layout { variants: [ VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -156,14 +148,9 @@ error: layout_of(TwoVariantsU8) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(2 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: ScalarPair( Initialized { value: Int( @@ -187,8 +174,6 @@ error: layout_of(TwoVariantsU8) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, ], }, @@ -241,9 +226,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { variants: [ VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -257,16 +239,9 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { ], largest_niche: None, uninhabited: true, - max_repr_align: Some( - Align(8 bytes), - ), - unadjusted_abi_align: Align(8 bytes), }, VariantLayout { size: Size(16 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Memory { sized: true, }, @@ -278,8 +253,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { ], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index 38f449c282e12..e22d6cc9af10a 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -88,9 +88,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { variants: [ VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -98,14 +95,9 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(8 bytes), - align: AbiAlign { - abi: Align(8 bytes), - }, backend_repr: Scalar( Initialized { value: Pointer( @@ -134,8 +126,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(8 bytes), }, ], }, diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index da9bd3e6db17f..1efa04bc26e21 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -129,9 +129,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { variants: [ VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -139,14 +136,9 @@ error: layout_of(Option<(u32) is 1..>) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -173,8 +165,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, @@ -228,9 +218,6 @@ error: layout_of(Option>) = Layout { variants: [ VariantLayout { size: Size(0 bytes), - align: AbiAlign { - abi: Align(1 bytes), - }, backend_repr: Memory { sized: true, }, @@ -238,14 +225,9 @@ error: layout_of(Option>) = Layout { fields_in_memory_order: [], largest_niche: None, uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(1 bytes), }, VariantLayout { size: Size(4 bytes), - align: AbiAlign { - abi: Align(4 bytes), - }, backend_repr: Scalar( Initialized { value: Int( @@ -272,8 +254,6 @@ error: layout_of(Option>) = Layout { }, ), uninhabited: false, - max_repr_align: None, - unadjusted_abi_align: Align(4 bytes), }, ], }, From 7c7738908d9246687f830fa3df35426d70ebc5c2 Mon Sep 17 00:00:00 2001 From: Moulins Date: Wed, 14 Jan 2026 03:20:51 +0100 Subject: [PATCH 6/6] Remove `VariantLayout::largest_niche` field The only place inspecting the niches of a variant layout is `compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs`, which can be rewritten to use the niches of the enclosing enum instead. --- compiler/rustc_abi/src/layout.rs | 25 ++++++----- compiler/rustc_abi/src/layout/simple.rs | 2 +- compiler/rustc_abi/src/lib.rs | 2 - .../src/debuginfo/metadata/enums/mod.rs | 34 +++++++++++--- .../enum-discriminant/wrapping_niche.stderr | 6 --- tests/ui/layout/debug.stderr | 4 -- tests/ui/layout/hexagon-enum.stderr | 5 --- ...-scalarpair-payload-might-be-uninit.stderr | 30 ------------- .../issue-96185-overaligned-enum.stderr | 4 -- tests/ui/layout/thumb-enum.stderr | 5 --- .../layout/zero-sized-array-enum-niche.stderr | 45 ------------------- ...-variants.aarch64-unknown-linux-gnu.stderr | 5 --- ...-c-dead-variants.armebv7r-none-eabi.stderr | 5 --- ...-dead-variants.i686-pc-windows-msvc.stderr | 5 --- ...d-variants.x86_64-unknown-linux-gnu.stderr | 5 --- tests/ui/repr/repr-c-int-dead-variants.stderr | 5 --- tests/ui/type/pattern_types/non_null.stderr | 12 ----- .../type/pattern_types/range_patterns.stderr | 22 --------- 18 files changed, 42 insertions(+), 179 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index f0b92155d0be1..95a6210095180 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -655,14 +655,24 @@ impl LayoutCalculator { let mut unadjusted_abi_align = align; let mut combined_seed = repr.field_shuffle_seed; + let mut largest_variant_size = Size::ZERO; + let mut largest_variant_index = VariantIdx::new(0); + let mut largest_variant_niche = None; + let mut variants_info = IndexVec::::with_capacity(variants.len()); let mut variant_layouts = variants - .iter() - .map(|v| { + .iter_enumerated() + .map(|(i, v)| { let st = self.univariant(v, repr, StructKind::AlwaysSized).ok()?; variants_info.push(VariantLayoutInfo { align_abi: st.align.abi }); + if st.size > largest_variant_size { + largest_variant_index = i; + largest_variant_size = st.size; + largest_variant_niche = st.largest_niche; + } + align = align.max(st.align.abi); max_repr_align = max_repr_align.max(st.max_repr_align); unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align); @@ -672,11 +682,6 @@ impl LayoutCalculator { }) .collect::>>()?; - let largest_variant_index = variant_layouts - .iter_enumerated() - .max_by_key(|(_i, layout)| layout.size.bytes()) - .map(|(i, _layout)| i)?; - let all_indices = variants.indices(); let needs_disc = |index: VariantIdx| index != largest_variant_index && !absent(&variants[index]); @@ -687,19 +692,17 @@ impl LayoutCalculator { (niche_variants.end().index() as u128 - niche_variants.start().index() as u128) + 1; // Use the largest niche in the largest variant. - let niche = variant_layouts[largest_variant_index].largest_niche?; + let niche = largest_variant_niche?; let (niche_start, niche_scalar) = niche.reserve(dl, count)?; let niche_offset = niche.offset; let niche_size = niche.value.size(dl); - let size = variant_layouts[largest_variant_index].size.align_to(align); + let size = largest_variant_size.align_to(align); let all_variants_fit = variant_layouts.iter_enumerated_mut().all(|(i, layout)| { if i == largest_variant_index { return true; } - layout.largest_niche = None; - if layout.size <= niche_offset { // This variant will fit before the niche. return true; diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 48530cbf69c77..1f2cecb025bce 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -161,7 +161,7 @@ impl LayoutData { }, variants: Variants::Single { index }, backend_repr: layout.backend_repr, - largest_niche: layout.largest_niche, + largest_niche: None, uninhabited: layout.uninhabited, size: layout.size, align: parent.align, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 3d4c85018ce29..6fc966997e30f 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2259,7 +2259,6 @@ pub struct VariantLayout { pub backend_repr: BackendRepr, pub field_offsets: IndexVec, fields_in_memory_order: IndexVec, - largest_niche: Option, uninhabited: bool, } @@ -2274,7 +2273,6 @@ impl VariantLayout { backend_repr: layout.backend_repr, field_offsets: offsets, fields_in_memory_order: in_memory_order, - largest_niche: layout.largest_niche, uninhabited: layout.uninhabited, } } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs index 556158c286a84..11794bb38e453 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use rustc_abi::{FieldIdx, TagEncoding, VariantIdx, Variants}; +use rustc_abi::{FieldIdx, TagEncoding, VariantIdx, Variants, WrappingRange}; use rustc_codegen_ssa::debuginfo::type_names::{compute_debuginfo_type_name, cpp_like_debuginfo}; use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo}; use rustc_codegen_ssa::traits::MiscCodegenMethods; @@ -399,16 +399,36 @@ fn compute_discriminant_value<'ll, 'tcx>( ), &Variants::Multiple { tag_encoding: TagEncoding::Niche { ref niche_variants, niche_start, untagged_variant }, + tag_field, tag, .. } => { if variant_index == untagged_variant { - let valid_range = enum_type_and_layout - .for_variant(cx, variant_index) - .largest_niche - .as_ref() - .unwrap() - .valid_range; + let niche_end = niche_start + .wrapping_sub(niche_variants.start().as_u32() as u128) + .wrapping_add(niche_variants.end().as_u32() as u128); + + // Remove discriminant values of the other variants from the largest niche. This assumes + // that the largest niche, when it exists, always corresponds to the enum discriminant. + let mut valid_range = WrappingRange { + start: niche_end.wrapping_add(1), + end: niche_start.wrapping_sub(1), + }; + if let Some(niche) = &enum_type_and_layout.largest_niche { + assert_eq!(enum_type_and_layout.fields.offset(tag_field.into()), niche.offset); + + if niche.valid_range.start == niche_start { + valid_range.end = niche.valid_range.end; + } else if niche.valid_range.end == niche_end { + valid_range.start = niche.valid_range.start; + } else { + bug!( + "largest niche (range: {:?}) doesn't match with niched tag encoding (range: {:?})", + niche.valid_range, + &WrappingRange { start: niche_start, end: niche_end }, + ) + } + } let min = valid_range.start.min(valid_range.end); let min = tag.size(cx).truncate(min); diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index b24948fb39ddf..8302f8baedb1e 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -49,7 +49,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -59,7 +58,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -69,7 +67,6 @@ error: layout_of(UnsignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -134,7 +131,6 @@ error: layout_of(SignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -144,7 +140,6 @@ error: layout_of(SignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -154,7 +149,6 @@ error: layout_of(SignedAroundZero) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 1c9c02c657e3e..242a750700788 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -65,7 +65,6 @@ error: layout_of(E) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -83,7 +82,6 @@ error: layout_of(E) = Layout { 1, 2, ], - largest_niche: None, uninhabited: true, }, ], @@ -244,7 +242,6 @@ error: layout_of(Result) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -271,7 +268,6 @@ error: layout_of(Result) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 993ff476b6b6c..bead8e03213a5 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -49,7 +49,6 @@ error: layout_of(A) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -114,7 +113,6 @@ error: layout_of(B) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -179,7 +177,6 @@ error: layout_of(C) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -244,7 +241,6 @@ error: layout_of(P) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -309,7 +305,6 @@ error: layout_of(T) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 7e6294f894c3e..cae9a5d14a12d 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -71,7 +71,6 @@ error: layout_of(MissingPayloadField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -81,7 +80,6 @@ error: layout_of(MissingPayloadField) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -170,7 +168,6 @@ error: layout_of(CommonPayloadField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -197,7 +194,6 @@ error: layout_of(CommonPayloadField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -284,7 +280,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -310,7 +305,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -404,16 +398,6 @@ error: layout_of(NicheFirst) = Layout { 0, 1, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=2, - }, - ), uninhabited: false, }, VariantLayout { @@ -423,7 +407,6 @@ error: layout_of(NicheFirst) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -433,7 +416,6 @@ error: layout_of(NicheFirst) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -527,16 +509,6 @@ error: layout_of(NicheSecond) = Layout { 1, 0, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=2, - }, - ), uninhabited: false, }, VariantLayout { @@ -546,7 +518,6 @@ error: layout_of(NicheSecond) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -556,7 +527,6 @@ error: layout_of(NicheSecond) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 8937af2f5d494..1df67b906a186 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -43,7 +43,6 @@ error: layout_of(Aligned1) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -53,7 +52,6 @@ error: layout_of(Aligned1) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -120,7 +118,6 @@ error: layout_of(Aligned2) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -130,7 +127,6 @@ error: layout_of(Aligned2) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 200002490d5c5..b14e3adef8337 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -49,7 +49,6 @@ error: layout_of(A) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -114,7 +113,6 @@ error: layout_of(B) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -179,7 +177,6 @@ error: layout_of(C) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -244,7 +241,6 @@ error: layout_of(P) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], @@ -309,7 +305,6 @@ error: layout_of(T) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index b40e357c1a114..62341b83446c1 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -47,7 +47,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -61,16 +60,6 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(1 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), uninhabited: false, }, ], @@ -133,7 +122,6 @@ error: layout_of(MultipleAlignments) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -147,7 +135,6 @@ error: layout_of(MultipleAlignments) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -161,16 +148,6 @@ error: layout_of(MultipleAlignments) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(1 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), uninhabited: false, }, ], @@ -233,7 +210,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -247,16 +223,6 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(1 bytes), - value: Int( - I16, - false, - ), - valid_range: 1..=65535, - }, - ), uninhabited: false, }, ], @@ -323,7 +289,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -337,16 +302,6 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 0..=0, - }, - ), uninhabited: false, }, ], diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 28fafa7800305..cf6a520db5dd2 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -59,7 +59,6 @@ error: layout_of(Univariant) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, ], @@ -146,7 +145,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -172,7 +170,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -237,7 +234,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { 0, 1, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -251,7 +247,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 45193552b507f..b52916ca1ed0c 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -59,7 +59,6 @@ error: layout_of(Univariant) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, ], @@ -146,7 +145,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -172,7 +170,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -237,7 +234,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { 0, 1, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -251,7 +247,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 28fafa7800305..cf6a520db5dd2 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -59,7 +59,6 @@ error: layout_of(Univariant) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, ], @@ -146,7 +145,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -172,7 +170,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -237,7 +234,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { 0, 1, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -251,7 +247,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 28fafa7800305..cf6a520db5dd2 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -59,7 +59,6 @@ error: layout_of(Univariant) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, ], @@ -146,7 +145,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -172,7 +170,6 @@ error: layout_of(TwoVariants) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -237,7 +234,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { 0, 1, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -251,7 +247,6 @@ error: layout_of(DeadBranchHasOtherField) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index c2f7fec38c81f..b1a157ce664ab 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -59,7 +59,6 @@ error: layout_of(UnivariantU8) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, ], @@ -146,7 +145,6 @@ error: layout_of(TwoVariantsU8) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -172,7 +170,6 @@ error: layout_of(TwoVariantsU8) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], @@ -237,7 +234,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { 0, 1, ], - largest_niche: None, uninhabited: true, }, VariantLayout { @@ -251,7 +247,6 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: None, uninhabited: false, }, ], diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index e22d6cc9af10a..a9182e6ba9f5d 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -93,7 +93,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -114,17 +113,6 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Pointer( - AddressSpace( - 0, - ), - ), - valid_range: 1..=18446744073709551615, - }, - ), uninhabited: false, }, ], diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index 1efa04bc26e21..a0d532888ecfa 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -134,7 +134,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -154,16 +153,6 @@ error: layout_of(Option<(u32) is 1..>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 1..=4294967295, - }, - ), uninhabited: false, }, ], @@ -223,7 +212,6 @@ error: layout_of(Option>) = Layout { }, field_offsets: [], fields_in_memory_order: [], - largest_niche: None, uninhabited: false, }, VariantLayout { @@ -243,16 +231,6 @@ error: layout_of(Option>) = Layout { fields_in_memory_order: [ 0, ], - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 1..=4294967295, - }, - ), uninhabited: false, }, ],