@@ -33,7 +33,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
33
33
use rustc:: ty:: Instance ;
34
34
use common:: { CodegenCx , C_u64 } ;
35
35
use rustc:: ty:: { self , AdtKind , ParamEnv , Ty , TyCtxt } ;
36
- use rustc:: ty:: layout:: { self , Align , Integer , IntegerExt , LayoutOf , PrimitiveExt , Size , TyLayout } ;
36
+ use rustc:: ty:: layout:: { self , Align , HasDataLayout , Integer , IntegerExt , LayoutOf ,
37
+ PrimitiveExt , Size , TyLayout } ;
37
38
use rustc:: session:: config;
38
39
use rustc:: util:: nodemap:: FxHashMap ;
39
40
use rustc_fs_util:: path2cstr;
@@ -1635,16 +1636,15 @@ fn prepare_enum_metadata(
1635
1636
1636
1637
& layout:: Variants :: NicheFilling { ref niche, .. } => {
1637
1638
// Find the integer type of the correct size.
1638
- let discr_type = niche. value . to_ty ( cx. tcx ) ;
1639
- let ( size, align) = cx. size_and_align_of ( discr_type) ;
1640
-
1641
- let discr_type = ( match size. bits ( ) {
1642
- 8 => Integer :: I8 ,
1643
- 16 => Integer :: I16 ,
1644
- 32 => Integer :: I32 ,
1645
- 64 => Integer :: I64 ,
1646
- bits => bug ! ( "prepare_enum_metadata: unknown niche bit size {}" , bits) ,
1647
- } ) . to_ty ( cx. tcx , false ) ;
1639
+ let size = niche. value . size ( cx) ;
1640
+ let align = niche. value . align ( cx) ;
1641
+
1642
+ let discr_type = match niche. value {
1643
+ layout:: Int ( t, _) => t,
1644
+ layout:: Float ( layout:: FloatTy :: F32 ) => Integer :: I32 ,
1645
+ layout:: Float ( layout:: FloatTy :: F64 ) => Integer :: I64 ,
1646
+ layout:: Pointer => cx. data_layout ( ) . ptr_sized_integer ( ) ,
1647
+ } . to_ty ( cx. tcx , false ) ;
1648
1648
1649
1649
let discr_metadata = basic_type_metadata ( cx, discr_type) ;
1650
1650
unsafe {
0 commit comments