@@ -388,7 +388,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
388388 layout:: Variants :: Single { index } => {
389389 assert_eq ! ( index, * variant_index) ;
390390 }
391- layout:: Variants :: Tagged { .. } => {
391+ layout:: Variants :: Multiple { discr_kind : layout :: DiscriminantKind :: Tag , .. } => {
392392 let ptr = place. place_field ( fx, mir:: Field :: new ( 0 ) ) ;
393393 let to = layout
394394 . ty
@@ -399,10 +399,12 @@ fn trans_stmt<'a, 'tcx: 'a>(
399399 let discr = CValue :: const_val ( fx, ptr. layout ( ) . ty , to as u64 as i64 ) ;
400400 ptr. write_cvalue ( fx, discr) ;
401401 }
402- layout:: Variants :: NicheFilling {
403- dataful_variant,
404- ref niche_variants,
405- niche_start,
402+ layout:: Variants :: Multiple {
403+ discr_kind : layout:: DiscriminantKind :: Niche {
404+ dataful_variant,
405+ ref niche_variants,
406+ niche_start,
407+ } ,
406408 ..
407409 } => {
408410 if * variant_index != dataful_variant {
@@ -613,7 +615,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
613615 lval. write_cvalue ( fx, CValue :: ByVal ( res, dest_layout) ) ;
614616 }
615617 }
616- Rvalue :: Cast ( CastKind :: ClosureFnPointer , operand, _ty) => {
618+ Rvalue :: Cast ( CastKind :: ClosureFnPointer ( _ ) , operand, _ty) => {
617619 let operand = trans_operand ( fx, operand) ;
618620 match operand. layout ( ) . ty . sty {
619621 ty:: Closure ( def_id, substs) => {
@@ -742,45 +744,44 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
742744 if layout. abi == layout:: Abi :: Uninhabited {
743745 return trap_unreachable_ret_value ( fx, dest_layout) ;
744746 }
745- match layout. variants {
747+
748+ let ( discr_scalar, discr_kind) = match & layout. variants {
746749 layout:: Variants :: Single { index } => {
747750 let discr_val = layout
748751 . ty
749752 . ty_adt_def ( )
750753 . map_or ( index. as_u32 ( ) as u128 , |def| {
751- def. discriminant_for_variant ( fx. tcx , index) . val
754+ def. discriminant_for_variant ( fx. tcx , * index) . val
752755 } ) ;
753756 return CValue :: const_val ( fx, dest_layout. ty , discr_val as u64 as i64 ) ;
754757 }
755- layout:: Variants :: Tagged { .. } | layout :: Variants :: NicheFilling { .. } => { }
756- }
758+ layout:: Variants :: Multiple { discr , discr_kind , variants : _ } => ( discr , discr_kind ) ,
759+ } ;
757760
758761 let discr = place. place_field ( fx, mir:: Field :: new ( 0 ) ) . to_cvalue ( fx) ;
759762 let discr_ty = discr. layout ( ) . ty ;
760763 let lldiscr = discr. load_scalar ( fx) ;
761- match layout. variants {
762- layout:: Variants :: Single { .. } => bug ! ( ) ,
763- layout:: Variants :: Tagged { ref tag, .. } => {
764- let signed = match tag. value {
764+ match discr_kind {
765+ layout:: DiscriminantKind :: Tag => {
766+ let signed = match discr_scalar. value {
765767 layout:: Int ( _, signed) => signed,
766768 _ => false ,
767769 } ;
768770 let val = clif_intcast ( fx, lldiscr, fx. clif_type ( dest_layout. ty ) . unwrap ( ) , signed) ;
769771 return CValue :: ByVal ( val, dest_layout) ;
770772 }
771- layout:: Variants :: NicheFilling {
773+ layout:: DiscriminantKind :: Niche {
772774 dataful_variant,
773775 ref niche_variants,
774776 niche_start,
775- ..
776777 } => {
777778 let niche_llty = fx. clif_type ( discr_ty) . unwrap ( ) ;
778779 let dest_clif_ty = fx. clif_type ( dest_layout. ty ) . unwrap ( ) ;
779780 if niche_variants. start ( ) == niche_variants. end ( ) {
780781 let b = fx
781782 . bcx
782783 . ins ( )
783- . icmp_imm ( IntCC :: Equal , lldiscr, niche_start as u64 as i64 ) ;
784+ . icmp_imm ( IntCC :: Equal , lldiscr, * niche_start as u64 as i64 ) ;
784785 let if_true = fx
785786 . bcx
786787 . ins ( )
0 commit comments