@@ -1778,29 +1778,15 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
1778
1778
fn int_type_width_signed ( ty : Ty , cx : & CodegenCx ) -> Option < ( u64 , bool ) > {
1779
1779
match ty. sty {
1780
1780
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 ,
1789
1782
ast:: IntTy :: I8 => 8 ,
1790
1783
ast:: IntTy :: I16 => 16 ,
1791
1784
ast:: IntTy :: I32 => 32 ,
1792
1785
ast:: IntTy :: I64 => 64 ,
1793
1786
ast:: IntTy :: I128 => 128 ,
1794
1787
} , true ) ) ,
1795
1788
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 ,
1804
1790
ast:: UintTy :: U8 => 8 ,
1805
1791
ast:: UintTy :: U16 => 16 ,
1806
1792
ast:: UintTy :: U32 => 32 ,
@@ -1813,14 +1799,9 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {
1813
1799
1814
1800
// Returns the width of a float TypeVariant
1815
1801
// 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 > {
1819
1803
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 ) ,
1824
1805
_ => None ,
1825
1806
}
1826
1807
}
0 commit comments