@@ -11,7 +11,6 @@ use std::{slice, vec};
11
11
use rustc_ast:: attr;
12
12
use rustc_ast:: util:: comments:: beautify_doc_string;
13
13
use rustc_ast:: { self as ast, AttrStyle } ;
14
- use rustc_ast:: { FloatTy , IntTy , UintTy } ;
15
14
use rustc_attr:: { ConstStability , Deprecation , Stability , StabilityLevel } ;
16
15
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
17
16
use rustc_feature:: UnstableFeatures ;
@@ -21,7 +20,7 @@ use rustc_hir::def_id::{CrateNum, DefId};
21
20
use rustc_hir:: lang_items:: LangItem ;
22
21
use rustc_hir:: Mutability ;
23
22
use rustc_index:: vec:: IndexVec ;
24
- use rustc_middle:: ty:: TyCtxt ;
23
+ use rustc_middle:: ty:: { self , TyCtxt } ;
25
24
use rustc_session:: Session ;
26
25
use rustc_span:: hygiene:: MacroKind ;
27
26
use rustc_span:: source_map:: DUMMY_SP ;
@@ -1423,6 +1422,7 @@ impl GetDefId for Type {
1423
1422
1424
1423
impl PrimitiveType {
1425
1424
crate fn from_hir ( prim : hir:: PrimTy ) -> PrimitiveType {
1425
+ use ast:: { FloatTy , IntTy , UintTy } ;
1426
1426
match prim {
1427
1427
hir:: PrimTy :: Int ( IntTy :: Isize ) => PrimitiveType :: Isize ,
1428
1428
hir:: PrimTy :: Int ( IntTy :: I8 ) => PrimitiveType :: I8 ,
@@ -1657,6 +1657,41 @@ impl From<ast::FloatTy> for PrimitiveType {
1657
1657
}
1658
1658
}
1659
1659
1660
+ impl From < ty:: IntTy > for PrimitiveType {
1661
+ fn from ( int_ty : ty:: IntTy ) -> PrimitiveType {
1662
+ match int_ty {
1663
+ ty:: IntTy :: Isize => PrimitiveType :: Isize ,
1664
+ ty:: IntTy :: I8 => PrimitiveType :: I8 ,
1665
+ ty:: IntTy :: I16 => PrimitiveType :: I16 ,
1666
+ ty:: IntTy :: I32 => PrimitiveType :: I32 ,
1667
+ ty:: IntTy :: I64 => PrimitiveType :: I64 ,
1668
+ ty:: IntTy :: I128 => PrimitiveType :: I128 ,
1669
+ }
1670
+ }
1671
+ }
1672
+
1673
+ impl From < ty:: UintTy > for PrimitiveType {
1674
+ fn from ( uint_ty : ty:: UintTy ) -> PrimitiveType {
1675
+ match uint_ty {
1676
+ ty:: UintTy :: Usize => PrimitiveType :: Usize ,
1677
+ ty:: UintTy :: U8 => PrimitiveType :: U8 ,
1678
+ ty:: UintTy :: U16 => PrimitiveType :: U16 ,
1679
+ ty:: UintTy :: U32 => PrimitiveType :: U32 ,
1680
+ ty:: UintTy :: U64 => PrimitiveType :: U64 ,
1681
+ ty:: UintTy :: U128 => PrimitiveType :: U128 ,
1682
+ }
1683
+ }
1684
+ }
1685
+
1686
+ impl From < ty:: FloatTy > for PrimitiveType {
1687
+ fn from ( float_ty : ty:: FloatTy ) -> PrimitiveType {
1688
+ match float_ty {
1689
+ ty:: FloatTy :: F32 => PrimitiveType :: F32 ,
1690
+ ty:: FloatTy :: F64 => PrimitiveType :: F64 ,
1691
+ }
1692
+ }
1693
+ }
1694
+
1660
1695
impl From < hir:: PrimTy > for PrimitiveType {
1661
1696
fn from ( prim_ty : hir:: PrimTy ) -> PrimitiveType {
1662
1697
match prim_ty {
0 commit comments