@@ -11,7 +11,6 @@ use std::{slice, vec};
1111use rustc_ast:: attr;
1212use rustc_ast:: util:: comments:: beautify_doc_string;
1313use rustc_ast:: { self as ast, AttrStyle } ;
14- use rustc_ast:: { FloatTy , IntTy , UintTy } ;
1514use rustc_attr:: { ConstStability , Deprecation , Stability , StabilityLevel } ;
1615use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1716use rustc_feature:: UnstableFeatures ;
@@ -21,7 +20,7 @@ use rustc_hir::def_id::{CrateNum, DefId};
2120use rustc_hir:: lang_items:: LangItem ;
2221use rustc_hir:: Mutability ;
2322use rustc_index:: vec:: IndexVec ;
24- use rustc_middle:: ty:: TyCtxt ;
23+ use rustc_middle:: ty:: { self , TyCtxt } ;
2524use rustc_session:: Session ;
2625use rustc_span:: hygiene:: MacroKind ;
2726use rustc_span:: source_map:: DUMMY_SP ;
@@ -1423,6 +1422,7 @@ impl GetDefId for Type {
14231422
14241423impl PrimitiveType {
14251424 crate fn from_hir ( prim : hir:: PrimTy ) -> PrimitiveType {
1425+ use ast:: { FloatTy , IntTy , UintTy } ;
14261426 match prim {
14271427 hir:: PrimTy :: Int ( IntTy :: Isize ) => PrimitiveType :: Isize ,
14281428 hir:: PrimTy :: Int ( IntTy :: I8 ) => PrimitiveType :: I8 ,
@@ -1657,6 +1657,41 @@ impl From<ast::FloatTy> for PrimitiveType {
16571657 }
16581658}
16591659
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+
16601695impl From < hir:: PrimTy > for PrimitiveType {
16611696 fn from ( prim_ty : hir:: PrimTy ) -> PrimitiveType {
16621697 match prim_ty {
0 commit comments