@@ -705,15 +705,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
705705 }
706706
707707 // It'll fit, but we need to make some adjustments.
708- match layout. fields {
709- FieldsShape :: Arbitrary { ref mut offsets, .. } => {
710- for offset in offsets. iter_mut ( ) {
711- * offset += this_offset;
712- }
713- }
714- FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( ..) => {
715- panic ! ( "Layout of fields should be Arbitrary for variants" )
716- }
708+ for offset in layout. field_offsets . iter_mut ( ) {
709+ * offset += this_offset;
717710 }
718711
719712 // It can't be a Scalar or ScalarPair because the offset isn't 0.
@@ -953,23 +946,16 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
953946 let old_ity_size = min_ity. size ( ) ;
954947 let new_ity_size = ity. size ( ) ;
955948 for variant in & mut layout_variants {
956- match variant. fields {
957- FieldsShape :: Arbitrary { ref mut offsets, .. } => {
958- for i in offsets {
959- if * i <= old_ity_size {
960- assert_eq ! ( * i, old_ity_size) ;
961- * i = new_ity_size;
962- }
963- }
964- // We might be making the struct larger.
965- if variant. size <= old_ity_size {
966- variant. size = new_ity_size;
967- }
968- }
969- FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( ..) => {
970- panic ! ( "encountered a non-arbitrary layout during enum layout" )
949+ for i in & mut variant. field_offsets {
950+ if * i <= old_ity_size {
951+ assert_eq ! ( * i, old_ity_size) ;
952+ * i = new_ity_size;
971953 }
972954 }
955+ // We might be making the struct larger.
956+ if variant. size <= old_ity_size {
957+ variant. size = new_ity_size;
958+ }
973959 }
974960 }
975961
@@ -994,12 +980,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
994980 let mut common_prim = None ;
995981 let mut common_prim_initialized_in_all_variants = true ;
996982 for ( field_layouts, layout_variant) in iter:: zip ( variants, & layout_variants) {
997- let FieldsShape :: Arbitrary { ref offsets, .. } = layout_variant. fields else {
998- panic ! ( "encountered a non-arbitrary layout during enum layout" ) ;
999- } ;
1000983 // We skip *all* ZST here and later check if we are good in terms of alignment.
1001984 // This lets us handle some cases involving aligned ZST.
1002- let mut fields = iter:: zip ( field_layouts, offsets) . filter ( |p| !p. 0 . is_zst ( ) ) ;
985+ let mut fields = iter:: zip ( field_layouts, & layout_variant. field_offsets )
986+ . filter ( |p| !p. 0 . is_zst ( ) ) ;
1003987 let ( field, offset) = match ( fields. next ( ) , fields. next ( ) ) {
1004988 ( None , None ) => {
1005989 common_prim_initialized_in_all_variants = false ;
@@ -1094,8 +1078,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10941078 for variant in & mut layout_variants {
10951079 // We only do this for variants with fields; the others are not accessed anyway.
10961080 // Also do not overwrite any already existing "clever" ABIs.
1097- if variant. fields . count ( ) > 0
1098- && matches ! ( variant. backend_repr, BackendRepr :: Memory { .. } )
1081+ if matches ! ( variant. backend_repr, BackendRepr :: Memory { .. } if variant. has_fields( ) )
10991082 {
11001083 variant. backend_repr = abi;
11011084 // Also need to bump up the size and alignment, so that the entire value fits
0 commit comments