@@ -33,7 +33,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
3333use rustc:: ty:: Instance ;
3434use common:: { CodegenCx , C_u64 } ;
3535use 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 } ;
3738use rustc:: session:: config;
3839use rustc:: util:: nodemap:: FxHashMap ;
3940use rustc_fs_util:: path2cstr;
@@ -1635,16 +1636,15 @@ fn prepare_enum_metadata(
16351636
16361637 & layout:: Variants :: NicheFilling { ref niche, .. } => {
16371638 // 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 ) ;
16481648
16491649 let discr_metadata = basic_type_metadata ( cx, discr_type) ;
16501650 unsafe {
0 commit comments