@@ -382,7 +382,7 @@ pub trait LayoutCalculator {
382382 * offset += this_offset;
383383 }
384384 }
385- _ => {
385+ FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( .. ) => {
386386 panic ! ( "Layout of fields should be Arbitrary for variants" )
387387 }
388388 }
@@ -600,7 +600,9 @@ pub trait LayoutCalculator {
600600 variant. size = new_ity_size;
601601 }
602602 }
603- _ => panic ! ( ) ,
603+ FieldsShape :: Primitive | FieldsShape :: Array { .. } | FieldsShape :: Union ( ..) => {
604+ panic ! ( "encountered a non-arbitrary layout during enum layout" )
605+ }
604606 }
605607 }
606608 }
@@ -628,7 +630,7 @@ pub trait LayoutCalculator {
628630 let mut common_prim_initialized_in_all_variants = true ;
629631 for ( field_layouts, layout_variant) in iter:: zip ( variants, & layout_variants) {
630632 let FieldsShape :: Arbitrary { ref offsets, .. } = layout_variant. fields else {
631- panic ! ( ) ;
633+ panic ! ( "encountered a non-arbitrary layout during enum layout" ) ;
632634 } ;
633635 // We skip *all* ZST here and later check if we are good in terms of alignment.
634636 // This lets us handle some cases involving aligned ZST.
@@ -681,7 +683,7 @@ pub trait LayoutCalculator {
681683 assert_eq ! ( memory_index. raw, [ 0 , 1 ] ) ;
682684 offsets
683685 }
684- _ => panic ! ( ) ,
686+ _ => panic ! ( "encountered a non-arbitrary layout during enum layout" ) ,
685687 } ;
686688 if pair_offsets[ FieldIdx :: new ( 0 ) ] == Size :: ZERO
687689 && pair_offsets[ FieldIdx :: new ( 1 ) ] == * offset
@@ -758,7 +760,9 @@ pub trait LayoutCalculator {
758760 Variants :: Multiple { tag, tag_encoding, tag_field, .. } => {
759761 Variants :: Multiple { tag, tag_encoding, tag_field, variants : best_layout. variants }
760762 }
761- _ => panic ! ( ) ,
763+ Variants :: Single { .. } => {
764+ panic ! ( "encountered a single-variant enum during multi-variant layout" )
765+ }
762766 } ;
763767 Some ( best_layout. layout )
764768 }
@@ -1154,7 +1158,11 @@ fn univariant<
11541158 assert_eq ! ( memory_index. raw, [ 0 , 1 ] ) ;
11551159 offsets
11561160 }
1157- _ => panic ! ( ) ,
1161+ FieldsShape :: Primitive
1162+ | FieldsShape :: Array { .. }
1163+ | FieldsShape :: Union ( ..) => {
1164+ panic ! ( "encountered a non-arbitrary layout during enum layout" )
1165+ }
11581166 } ;
11591167 if offsets[ i] == pair_offsets[ FieldIdx :: new ( 0 ) ]
11601168 && offsets[ j] == pair_offsets[ FieldIdx :: new ( 1 ) ]
0 commit comments