@@ -642,15 +642,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
642642 }
643643
644644 // It'll fit, but we need to make some adjustments.
645- match layout. fields {
646- FieldsShape :: Arbitrary { ref mut offsets, .. } => {
647- for offset in offsets. iter_mut ( ) {
648- * offset += this_offset;
649- }
650- }
651- FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( ..) => {
652- panic ! ( "Layout of fields should be Arbitrary for variants" )
653- }
645+ for offset in layout. field_offsets . iter_mut ( ) {
646+ * offset += this_offset;
654647 }
655648
656649 // It can't be a Scalar or ScalarPair because the offset isn't 0.
@@ -890,23 +883,16 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
890883 let old_ity_size = min_ity. size ( ) ;
891884 let new_ity_size = ity. size ( ) ;
892885 for variant in & mut layout_variants {
893- match variant. fields {
894- FieldsShape :: Arbitrary { ref mut offsets, .. } => {
895- for i in offsets {
896- if * i <= old_ity_size {
897- assert_eq ! ( * i, old_ity_size) ;
898- * i = new_ity_size;
899- }
900- }
901- // We might be making the struct larger.
902- if variant. size <= old_ity_size {
903- variant. size = new_ity_size;
904- }
905- }
906- FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( ..) => {
907- panic ! ( "encountered a non-arbitrary layout during enum layout" )
886+ for i in & mut variant. field_offsets {
887+ if * i <= old_ity_size {
888+ assert_eq ! ( * i, old_ity_size) ;
889+ * i = new_ity_size;
908890 }
909891 }
892+ // We might be making the struct larger.
893+ if variant. size <= old_ity_size {
894+ variant. size = new_ity_size;
895+ }
910896 }
911897 }
912898
@@ -931,12 +917,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
931917 let mut common_prim = None ;
932918 let mut common_prim_initialized_in_all_variants = true ;
933919 for ( field_layouts, layout_variant) in iter:: zip ( variants, & layout_variants) {
934- let FieldsShape :: Arbitrary { ref offsets, .. } = layout_variant. fields else {
935- panic ! ( "encountered a non-arbitrary layout during enum layout" ) ;
936- } ;
937920 // We skip *all* ZST here and later check if we are good in terms of alignment.
938921 // This lets us handle some cases involving aligned ZST.
939- let mut fields = iter:: zip ( field_layouts, offsets) . filter ( |p| !p. 0 . is_zst ( ) ) ;
922+ let mut fields = iter:: zip ( field_layouts, & layout_variant. field_offsets )
923+ . filter ( |p| !p. 0 . is_zst ( ) ) ;
940924 let ( field, offset) = match ( fields. next ( ) , fields. next ( ) ) {
941925 ( None , None ) => {
942926 common_prim_initialized_in_all_variants = false ;
@@ -1031,8 +1015,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10311015 for variant in & mut layout_variants {
10321016 // We only do this for variants with fields; the others are not accessed anyway.
10331017 // Also do not overwrite any already existing "clever" ABIs.
1034- if variant. fields . count ( ) > 0
1035- && matches ! ( variant. backend_repr, BackendRepr :: Memory { .. } )
1018+ if matches ! ( variant. backend_repr, BackendRepr :: Memory { .. } if variant. has_fields( ) )
10361019 {
10371020 variant. backend_repr = abi;
10381021 // Also need to bump up the size and alignment, so that the entire value fits
0 commit comments