@@ -388,7 +388,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
388
388
layout:: Variants :: Single { index } => {
389
389
assert_eq ! ( index, * variant_index) ;
390
390
}
391
- layout:: Variants :: Tagged { .. } => {
391
+ layout:: Variants :: Multiple { discr_kind : layout :: DiscriminantKind :: Tag , .. } => {
392
392
let ptr = place. place_field ( fx, mir:: Field :: new ( 0 ) ) ;
393
393
let to = layout
394
394
. ty
@@ -399,10 +399,12 @@ fn trans_stmt<'a, 'tcx: 'a>(
399
399
let discr = CValue :: const_val ( fx, ptr. layout ( ) . ty , to as u64 as i64 ) ;
400
400
ptr. write_cvalue ( fx, discr) ;
401
401
}
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
+ } ,
406
408
..
407
409
} => {
408
410
if * variant_index != dataful_variant {
@@ -613,7 +615,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
613
615
lval. write_cvalue ( fx, CValue :: ByVal ( res, dest_layout) ) ;
614
616
}
615
617
}
616
- Rvalue :: Cast ( CastKind :: ClosureFnPointer , operand, _ty) => {
618
+ Rvalue :: Cast ( CastKind :: ClosureFnPointer ( _ ) , operand, _ty) => {
617
619
let operand = trans_operand ( fx, operand) ;
618
620
match operand. layout ( ) . ty . sty {
619
621
ty:: Closure ( def_id, substs) => {
@@ -742,45 +744,44 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
742
744
if layout. abi == layout:: Abi :: Uninhabited {
743
745
return trap_unreachable_ret_value ( fx, dest_layout) ;
744
746
}
745
- match layout. variants {
747
+
748
+ let ( discr_scalar, discr_kind) = match & layout. variants {
746
749
layout:: Variants :: Single { index } => {
747
750
let discr_val = layout
748
751
. ty
749
752
. ty_adt_def ( )
750
753
. 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
752
755
} ) ;
753
756
return CValue :: const_val ( fx, dest_layout. ty , discr_val as u64 as i64 ) ;
754
757
}
755
- layout:: Variants :: Tagged { .. } | layout :: Variants :: NicheFilling { .. } => { }
756
- }
758
+ layout:: Variants :: Multiple { discr , discr_kind , variants : _ } => ( discr , discr_kind ) ,
759
+ } ;
757
760
758
761
let discr = place. place_field ( fx, mir:: Field :: new ( 0 ) ) . to_cvalue ( fx) ;
759
762
let discr_ty = discr. layout ( ) . ty ;
760
763
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 {
765
767
layout:: Int ( _, signed) => signed,
766
768
_ => false ,
767
769
} ;
768
770
let val = clif_intcast ( fx, lldiscr, fx. clif_type ( dest_layout. ty ) . unwrap ( ) , signed) ;
769
771
return CValue :: ByVal ( val, dest_layout) ;
770
772
}
771
- layout:: Variants :: NicheFilling {
773
+ layout:: DiscriminantKind :: Niche {
772
774
dataful_variant,
773
775
ref niche_variants,
774
776
niche_start,
775
- ..
776
777
} => {
777
778
let niche_llty = fx. clif_type ( discr_ty) . unwrap ( ) ;
778
779
let dest_clif_ty = fx. clif_type ( dest_layout. ty ) . unwrap ( ) ;
779
780
if niche_variants. start ( ) == niche_variants. end ( ) {
780
781
let b = fx
781
782
. bcx
782
783
. 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 ) ;
784
785
let if_true = fx
785
786
. bcx
786
787
. ins ( )
0 commit comments