@@ -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;
@@ -1648,16 +1649,15 @@ fn prepare_enum_metadata(
1648
1649
1649
1650
& layout:: Variants :: NicheFilling { ref niche, .. } => {
1650
1651
// Find the integer type of the correct size.
1651
- let discr_type = niche. value . to_ty ( cx. tcx ) ;
1652
- let ( size, align) = cx. size_and_align_of ( discr_type) ;
1653
-
1654
- let discr_type = ( match size. bits ( ) {
1655
- 8 => Integer :: I8 ,
1656
- 16 => Integer :: I16 ,
1657
- 32 => Integer :: I32 ,
1658
- 64 => Integer :: I64 ,
1659
- bits => bug ! ( "prepare_enum_metadata: unknown niche bit size {}" , bits) ,
1660
- } ) . to_ty ( cx. tcx , false ) ;
1652
+ let size = niche. value . size ( cx) ;
1653
+ let align = niche. value . align ( cx) ;
1654
+
1655
+ let discr_type = match niche. value {
1656
+ layout:: Int ( t, _) => t,
1657
+ layout:: Float ( layout:: FloatTy :: F32 ) => Integer :: I32 ,
1658
+ layout:: Float ( layout:: FloatTy :: F64 ) => Integer :: I64 ,
1659
+ layout:: Pointer => cx. data_layout ( ) . ptr_sized_integer ( ) ,
1660
+ } . to_ty ( cx. tcx , false ) ;
1661
1661
1662
1662
let discr_metadata = basic_type_metadata ( cx, discr_type) ;
1663
1663
unsafe {
0 commit comments