diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 833edd2280500..ad78d24e95465 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -232,6 +232,10 @@ fn sanity_check_layout<'tcx>( assert!(layout.abi.is_uninhabited()); } + if layout.size.bytes() % layout.align.abi.bytes() != 0 { + bug!("size is not a multiple of align, in the following layout:\n{layout:#?}"); + } + if cfg!(debug_assertions) { fn check_layout_abi<'tcx>(tcx: TyCtxt<'tcx>, layout: Layout<'tcx>) { match layout.abi() { diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index b35502d9ee42b..d4d5674e246d8 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -1279,13 +1279,14 @@ impl<'a> fmt::Debug for LayoutS<'a> { // This is how `Layout` used to print before it become // `Interned`. We print it like this to avoid having to update // expected output in a lot of tests. + let LayoutS { size, align, abi, fields, largest_niche, variants } = self; f.debug_struct("Layout") - .field("fields", &self.fields) - .field("variants", &self.variants) - .field("abi", &self.abi) - .field("largest_niche", &self.largest_niche) - .field("align", &self.align) - .field("size", &self.size) + .field("size", size) + .field("align", align) + .field("abi", abi) + .field("fields", fields) + .field("largest_niche", largest_niche) + .field("variants", variants) .finish() } } diff --git a/src/test/ui/layout/debug.stderr b/src/test/ui/layout/debug.stderr index 7ba9657fcd6f1..c5e1c41d1304c 100644 --- a/src/test/ui/layout/debug.stderr +++ b/src/test/ui/layout/debug.stderr @@ -1,4 +1,12 @@ error: layout_of(E) = Layout { + size: Size(12 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(E) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,24 +37,30 @@ error: layout_of(E) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(12 bytes), align: AbiAndPrefAlign { - abi: Align(1 bytes), + abi: Align(4 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Uninhabited, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -49,37 +73,13 @@ error: layout_of(E) = Layout { 2, ], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Uninhabited, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(12 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 0..=0, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(12 bytes), } --> $DIR/debug.rs:6:1 | @@ -87,20 +87,10 @@ LL | enum E { Foo, Bar(!, i32, i32) } | ^^^^^^ error: layout_of(S) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(0 bytes), - Size(4 bytes), - ], - memory_index: [ - 1, - 0, - 2, - ], - }, - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -118,12 +108,22 @@ error: layout_of(S) = Layout { valid_range: 0..=4294967295, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(0 bytes), + Size(4 bytes), + ], + memory_index: [ + 1, + 0, + 2, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(8 bytes), } --> $DIR/debug.rs:9:1 | @@ -131,21 +131,21 @@ LL | struct S { f1: i32, f2: (), f3: i32 } | ^^^^^^^^ error: layout_of(U) = Layout { - fields: Union( - 2, - ), - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: Aggregate { sized: true, }, + fields: Union( + 2, + ), largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(8 bytes), } --> $DIR/debug.rs:12:1 | @@ -153,6 +153,27 @@ LL | union U { f1: (i32, i32), f3: i32 } | ^^^^^^^ error: layout_of(std::result::Result) = Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: ScalarPair( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + Initialized { + value: Int( + I32, + true, + ), + valid_range: 0..=4294967295, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -161,6 +182,16 @@ error: layout_of(std::result::Result) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -173,16 +204,10 @@ error: layout_of(std::result::Result) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(4 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -200,14 +225,6 @@ error: layout_of(std::result::Result) = Layout { valid_range: 0..=4294967295, }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(4 bytes), @@ -216,8 +233,16 @@ error: layout_of(std::result::Result) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -235,46 +260,21 @@ error: layout_of(std::result::Result) = Layout { valid_range: 0..=4294967295, }, ), + fields: Arbitrary { + offsets: [ + Size(4 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(8 bytes), }, ], }, - abi: ScalarPair( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 0..=1, - }, - Initialized { - value: Int( - I32, - true, - ), - valid_range: 0..=4294967295, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), } --> $DIR/debug.rs:15:1 | @@ -282,9 +282,10 @@ LL | type Test = Result; | ^^^^^^^^^ error: layout_of(i32) = Layout { - fields: Primitive, - variants: Single { - index: 0, + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, }, abi: Scalar( Initialized { @@ -295,12 +296,11 @@ error: layout_of(i32) = Layout { valid_range: 0..=4294967295, }, ), + fields: Primitive, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 0, }, - size: Size(4 bytes), } --> $DIR/debug.rs:18:1 | diff --git a/src/test/ui/layout/hexagon-enum.stderr b/src/test/ui/layout/hexagon-enum.stderr index f3123cb0ad22e..d850dd69c96e3 100644 --- a/src/test/ui/layout/hexagon-enum.stderr +++ b/src/test/ui/layout/hexagon-enum.stderr @@ -1,4 +1,18 @@ error: layout_of(A) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +21,16 @@ error: layout_of(A) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,34 +43,54 @@ error: layout_of(A) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/hexagon-enum.rs:16:1 + | +LL | enum A { Apple } + | ^^^^^^ + +error: layout_of(B) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, abi: Scalar( Initialized { value: Int( I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -54,29 +98,9 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), - } - --> $DIR/hexagon-enum.rs:16:1 - | -LL | enum A { Apple } - | ^^^^^^ - -error: layout_of(B) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -89,49 +113,25 @@ error: layout_of(B) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(1 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(1 bytes), - }, - size: Size(1 bytes), } --> $DIR/hexagon-enum.rs:20:1 | @@ -139,6 +139,20 @@ LL | enum B { Banana = 255, } | ^^^^^^ error: layout_of(C) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(2 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -147,6 +161,16 @@ error: layout_of(C) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -159,49 +183,25 @@ error: layout_of(C) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(2 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(2 bytes), - }, - size: Size(2 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(2 bytes), - }, - size: Size(2 bytes), } --> $DIR/hexagon-enum.rs:24:1 | @@ -209,6 +209,20 @@ LL | enum C { Chaenomeles = 256, } | ^^^^^^ error: layout_of(P) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -217,6 +231,16 @@ error: layout_of(P) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -229,49 +253,25 @@ error: layout_of(P) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/hexagon-enum.rs:28:1 | @@ -279,6 +279,20 @@ LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ error: layout_of(T) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -287,6 +301,16 @@ error: layout_of(T) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -299,49 +323,25 @@ error: layout_of(T) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/hexagon-enum.rs:34:1 | diff --git a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 84d8bc799b93f..6deb1f271a728 100644 --- a/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/src/test/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -1,4 +1,24 @@ error: layout_of(MissingPayloadField) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: ScalarPair( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +27,16 @@ error: layout_of(MissingPayloadField) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,16 +49,10 @@ error: layout_of(MissingPayloadField) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -45,33 +69,51 @@ error: layout_of(MissingPayloadField) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1 + | +LL | pub enum MissingPayloadField { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(CommonPayloadField) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( @@ -80,13 +122,22 @@ error: layout_of(MissingPayloadField) = Layout { ), valid_range: 0..=1, }, - Union { + Initialized { value: Int( I8, false, ), + valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -97,26 +148,6 @@ error: layout_of(MissingPayloadField) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1 - | -LL | pub enum MissingPayloadField { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(CommonPayloadField) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -129,16 +160,10 @@ error: layout_of(CommonPayloadField) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -156,14 +181,6 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -172,8 +189,16 @@ error: layout_of(CommonPayloadField) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -191,15 +216,33 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1 + | +LL | pub enum CommonPayloadField { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( @@ -208,14 +251,21 @@ error: layout_of(CommonPayloadField) = Layout { ), valid_range: 0..=1, }, - Initialized { + Union { value: Int( I8, false, ), - valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -226,26 +276,6 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1 - | -LL | pub enum CommonPayloadField { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -258,16 +288,10 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(1 bytes), - ], - memory_index: [ - 0, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -284,14 +308,6 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - }, - Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -300,8 +316,16 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { 0, ], }, + largest_niche: None, variants: Single { - index: 1, + index: 0, + }, + }, + Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -318,22 +342,40 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(1 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1 + | +LL | pub enum CommonPayloadFieldIsMaybeUninit { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: layout_of(NicheFirst) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( Initialized { value: Int( I8, false, ), - valid_range: 0..=1, + valid_range: 0..=4, }, Union { value: Int( @@ -342,6 +384,14 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ), }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -349,29 +399,9 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { I8, false, ), - valid_range: 0..=1, + valid_range: 0..=4, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1 - | -LL | pub enum CommonPayloadFieldIsMaybeUninit { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: layout_of(NicheFirst) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -388,18 +418,10 @@ error: layout_of(NicheFirst) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(1 bytes), - ], - memory_index: [ - 0, - 1, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -417,6 +439,16 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(1 bytes), + ], + memory_index: [ + 0, + 1, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -427,68 +459,68 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=2, }, ), + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 2, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(0 bytes), }, ], }, + } + --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1 + | +LL | pub enum NicheFirst { + | ^^^^^^^^^^^^^^^^^^^ + +error: layout_of(NicheSecond) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, abi: ScalarPair( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, Union { value: Int( I8, false, ), }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), + Initialized { value: Int( I8, false, @@ -496,18 +528,6 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=4, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), - } - --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1 - | -LL | pub enum NicheFirst { - | ^^^^^^^^^^^^^^^^^^^ - -error: layout_of(NicheSecond) = Layout { fields: Arbitrary { offsets: [ Size(1 bytes), @@ -516,6 +536,16 @@ error: layout_of(NicheSecond) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(1 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=4, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -532,18 +562,10 @@ error: layout_of(NicheSecond) = Layout { tag_field: 0, variants: [ Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - Size(1 bytes), - ], - memory_index: [ - 0, - 1, - ], - }, - variants: Single { - index: 0, + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, abi: ScalarPair( Initialized { @@ -561,6 +583,16 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=2, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + Size(1 bytes), + ], + memory_index: [ + 0, + 1, + ], + }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -571,80 +603,48 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=2, }, ), + variants: Single { + index: 0, + }, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 2, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(0 bytes), }, ], }, - abi: ScalarPair( - Union { - value: Int( - I8, - false, - ), - }, - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, - ), - largest_niche: Some( - Niche { - offset: Size(1 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=4, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(2 bytes), } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:50:1 | diff --git a/src/test/ui/layout/issue-96185-overaligned-enum.stderr b/src/test/ui/layout/issue-96185-overaligned-enum.stderr index 8dc364fa7c9bd..de6177c8dfc4d 100644 --- a/src/test/ui/layout/issue-96185-overaligned-enum.stderr +++ b/src/test/ui/layout/issue-96185-overaligned-enum.stderr @@ -1,4 +1,12 @@ error: layout_of(Aligned1) = Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(8 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(Aligned1) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,49 +37,57 @@ error: layout_of(Aligned1) = Layout { tag_field: 0, variants: [ Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(8 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: $PREF_ALIGN, }, - size: Size(8 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(8 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), }, ], }, - abi: Aggregate { - sized: true, + } + --> $DIR/issue-96185-overaligned-enum.rs:8:1 + | +LL | pub enum Aligned1 { + | ^^^^^^^^^^^^^^^^^ + +error: layout_of(Aligned2) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), + abi: Scalar( + Initialized { value: Int( I8, false, @@ -69,18 +95,6 @@ error: layout_of(Aligned1) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(8 bytes), - pref: $PREF_ALIGN, - }, - size: Size(8 bytes), - } - --> $DIR/issue-96185-overaligned-enum.rs:8:1 - | -LL | pub enum Aligned1 { - | ^^^^^^^^^^^^^^^^^ - -error: layout_of(Aligned2) = Layout { fields: Arbitrary { offsets: [ Size(0 bytes), @@ -89,6 +103,16 @@ error: layout_of(Aligned2) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -101,67 +125,43 @@ error: layout_of(Aligned2) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(1 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, - }, - size: Size(1 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:16:1 | diff --git a/src/test/ui/layout/thumb-enum.stderr b/src/test/ui/layout/thumb-enum.stderr index e6ed626d5f1aa..227bd950b6666 100644 --- a/src/test/ui/layout/thumb-enum.stderr +++ b/src/test/ui/layout/thumb-enum.stderr @@ -1,4 +1,18 @@ error: layout_of(A) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +21,16 @@ error: layout_of(A) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,34 +43,54 @@ error: layout_of(A) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), }, ], }, + } + --> $DIR/thumb-enum.rs:16:1 + | +LL | enum A { Apple } + | ^^^^^^ + +error: layout_of(B) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, abi: Scalar( Initialized { value: Int( I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), + fields: Arbitrary { + offsets: [ + Size(0 bytes), + ], + memory_index: [ + 0, + ], + }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -54,29 +98,9 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: 0..=0, + valid_range: 255..=255, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), - } - --> $DIR/thumb-enum.rs:16:1 - | -LL | enum A { Apple } - | ^^^^^^ - -error: layout_of(B) = Layout { - fields: Arbitrary { - offsets: [ - Size(0 bytes), - ], - memory_index: [ - 0, - ], - }, variants: Multiple { tag: Initialized { value: Int( @@ -89,49 +113,25 @@ error: layout_of(B) = Layout { tag_field: 0, variants: [ Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 255..=255, - }, - ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: Align(4 bytes), - }, - size: Size(1 bytes), } --> $DIR/thumb-enum.rs:20:1 | @@ -139,6 +139,20 @@ LL | enum B { Banana = 255, } | ^^^^^^ error: layout_of(C) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -147,6 +161,16 @@ error: layout_of(C) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 256..=256, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -159,49 +183,25 @@ error: layout_of(C) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(4 bytes), - }, - size: Size(2 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 256..=256, - }, - ), - align: AbiAndPrefAlign { - abi: Align(2 bytes), - pref: Align(4 bytes), - }, - size: Size(2 bytes), } --> $DIR/thumb-enum.rs:24:1 | @@ -209,6 +209,20 @@ LL | enum C { Chaenomeles = 256, } | ^^^^^^ error: layout_of(P) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -217,6 +231,16 @@ error: layout_of(P) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + false, + ), + valid_range: 268435456..=268435456, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -229,49 +253,25 @@ error: layout_of(P) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - false, - ), - valid_range: 268435456..=268435456, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/thumb-enum.rs:28:1 | @@ -279,6 +279,20 @@ LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ error: layout_of(T) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Scalar( + Initialized { + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -287,6 +301,16 @@ error: layout_of(T) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I32, + true, + ), + valid_range: 2164260864..=2164260864, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -299,49 +323,25 @@ error: layout_of(T) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: Align(4 bytes), + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [], memory_index: [], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), }, ], }, - abi: Scalar( - Initialized { - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I32, - true, - ), - valid_range: 2164260864..=2164260864, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: Align(4 bytes), - }, - size: Size(4 bytes), } --> $DIR/thumb-enum.rs:34:1 | diff --git a/src/test/ui/layout/zero-sized-array-enum-niche.stderr b/src/test/ui/layout/zero-sized-array-enum-niche.stderr index 0dbecbe412b8d..56d3a52bb7ff9 100644 --- a/src/test/ui/layout/zero-sized-array-enum-niche.stderr +++ b/src/test/ui/layout/zero-sized-array-enum-niche.stderr @@ -1,4 +1,12 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -7,6 +15,16 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -19,6 +37,14 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -27,20 +53,20 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -49,12 +75,6 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -65,32 +85,12 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:13:1 | @@ -98,6 +98,14 @@ LL | type AlignedResult = Result<[u32; 0], bool>; | ^^^^^^^^^^^^^^^^^^ error: layout_of(MultipleAlignments) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -106,6 +114,16 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=2, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -118,6 +136,14 @@ error: layout_of(MultipleAlignments) = Layout { tag_field: 0, variants: [ Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(2 bytes), @@ -126,20 +152,20 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(4 bytes), align: AbiAndPrefAlign { - abi: Align(2 bytes), + abi: Align(4 bytes), pref: $PREF_ALIGN, }, - size: Size(2 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -148,20 +174,20 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 1, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -170,12 +196,6 @@ error: layout_of(MultipleAlignments) = Layout { 0, ], }, - variants: Single { - index: 2, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -186,32 +206,12 @@ error: layout_of(MultipleAlignments) = Layout { valid_range: 0..=1, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 2, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=2, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:21:1 | @@ -219,6 +219,14 @@ LL | enum MultipleAlignments { | ^^^^^^^^^^^^^^^^^^^^^^^ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -227,6 +235,16 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -239,6 +257,14 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = tag_field: 0, variants: [ Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -247,20 +273,20 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(3 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(4 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(1 bytes), @@ -269,12 +295,6 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(1 bytes), @@ -285,32 +305,12 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = valid_range: 1..=65535, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(3 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I8, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:37:1 | @@ -318,6 +318,14 @@ LL | type NicheLosesToTagged = Result<[u32; 0], Packed>; | ^^^^^^^^^^^^^^^^^^^^^^^ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -326,6 +334,16 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I16, + false, + ), + valid_range: 0..=1, + }, + ), variants: Multiple { tag: Initialized { value: Int( @@ -342,6 +360,14 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { tag_field: 0, variants: [ Layout { + size: Size(0 bytes), + align: AbiAndPrefAlign { + abi: Align(4 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -350,20 +376,20 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, + largest_niche: None, variants: Single { index: 0, }, - abi: Aggregate { - sized: true, - }, - largest_niche: None, + }, + Layout { + size: Size(2 bytes), align: AbiAndPrefAlign { - abi: Align(4 bytes), + abi: Align(1 bytes), pref: $PREF_ALIGN, }, - size: Size(0 bytes), - }, - Layout { + abi: Aggregate { + sized: true, + }, fields: Arbitrary { offsets: [ Size(0 bytes), @@ -372,12 +398,6 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { 0, ], }, - variants: Single { - index: 1, - }, - abi: Aggregate { - sized: true, - }, largest_niche: Some( Niche { offset: Size(0 bytes), @@ -388,32 +408,12 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { valid_range: 0..=0, }, ), - align: AbiAndPrefAlign { - abi: Align(1 bytes), - pref: $PREF_ALIGN, + variants: Single { + index: 1, }, - size: Size(2 bytes), }, ], }, - abi: Aggregate { - sized: true, - }, - largest_niche: Some( - Niche { - offset: Size(0 bytes), - value: Int( - I16, - false, - ), - valid_range: 0..=1, - }, - ), - align: AbiAndPrefAlign { - abi: Align(4 bytes), - pref: $PREF_ALIGN, - }, - size: Size(4 bytes), } --> $DIR/zero-sized-array-enum-niche.rs:44:1 |