@@ -1778,29 +1778,15 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
17781778fn int_type_width_signed ( ty : Ty , cx : & CodegenCx ) -> Option < ( u64 , bool ) > {
17791779 match ty. sty {
17801780 ty:: TyInt ( t) => Some ( ( match t {
1781- ast:: IntTy :: Isize => {
1782- match & cx. tcx . sess . target . target . target_pointer_width [ ..] {
1783- "16" => 16 ,
1784- "32" => 32 ,
1785- "64" => 64 ,
1786- tws => bug ! ( "Unsupported target word size for isize: {}" , tws) ,
1787- }
1788- } ,
1781+ ast:: IntTy :: Isize => cx. tcx . sess . target . isize_ty . bit_width ( ) . unwrap ( ) as u64 ,
17891782 ast:: IntTy :: I8 => 8 ,
17901783 ast:: IntTy :: I16 => 16 ,
17911784 ast:: IntTy :: I32 => 32 ,
17921785 ast:: IntTy :: I64 => 64 ,
17931786 ast:: IntTy :: I128 => 128 ,
17941787 } , true ) ) ,
17951788 ty:: TyUint ( t) => Some ( ( match t {
1796- ast:: UintTy :: Usize => {
1797- match & cx. tcx . sess . target . target . target_pointer_width [ ..] {
1798- "16" => 16 ,
1799- "32" => 32 ,
1800- "64" => 64 ,
1801- tws => bug ! ( "Unsupported target word size for usize: {}" , tws) ,
1802- }
1803- } ,
1789+ ast:: UintTy :: Usize => cx. tcx . sess . target . usize_ty . bit_width ( ) . unwrap ( ) as u64 ,
18041790 ast:: UintTy :: U8 => 8 ,
18051791 ast:: UintTy :: U16 => 16 ,
18061792 ast:: UintTy :: U32 => 32 ,
@@ -1813,14 +1799,9 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {
18131799
18141800// Returns the width of a float TypeVariant
18151801// Returns None if the type is not a float
1816- fn float_type_width < ' tcx > ( sty : & ty:: TypeVariants < ' tcx > )
1817- -> Option < u64 > {
1818- use rustc:: ty:: TyFloat ;
1802+ fn float_type_width < ' tcx > ( sty : & ty:: TypeVariants < ' tcx > ) -> Option < u64 > {
18191803 match * sty {
1820- TyFloat ( t) => Some ( match t {
1821- ast:: FloatTy :: F32 => 32 ,
1822- ast:: FloatTy :: F64 => 64 ,
1823- } ) ,
1804+ ty:: TyFloat ( t) => Some ( t. bit_width ( ) as u64 ) ,
18241805 _ => None ,
18251806 }
18261807}
0 commit comments