@@ -24,7 +24,7 @@ use rustc_arena::{DroplessArena, TypedArena};
2424use rustc_ast:: node_id:: NodeMap ;
2525use rustc_ast:: unwrap_or;
2626use rustc_ast:: visit:: { self , Visitor } ;
27- use rustc_ast:: { self as ast, FloatTy , IntTy , NodeId , UintTy } ;
27+ use rustc_ast:: { self as ast, NodeId } ;
2828use rustc_ast:: { Crate , CRATE_NODE_ID } ;
2929use rustc_ast:: { ItemKind , Path } ;
3030use rustc_ast_lowering:: ResolverAstLowering ;
@@ -38,8 +38,7 @@ use rustc_hir::def::Namespace::*;
3838use rustc_hir:: def:: { self , CtorOf , DefKind , NonMacroAttrKind , PartialRes } ;
3939use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId , CRATE_DEF_INDEX } ;
4040use rustc_hir:: definitions:: { DefKey , DefPathData , Definitions } ;
41- use rustc_hir:: PrimTy :: { self , Bool , Char , Float , Int , Str , Uint } ;
42- use rustc_hir:: TraitCandidate ;
41+ use rustc_hir:: { PrimTy , TraitCandidate } ;
4342use rustc_index:: vec:: IndexVec ;
4443use rustc_metadata:: creader:: { CStore , CrateLoader } ;
4544use rustc_middle:: hir:: exports:: ExportMap ;
@@ -833,39 +832,6 @@ impl<'a> NameBinding<'a> {
833832 }
834833}
835834
836- /// Interns the names of the primitive types.
837- ///
838- /// All other types are defined somewhere and possibly imported, but the primitive ones need
839- /// special handling, since they have no place of origin.
840- struct PrimitiveTypeTable {
841- primitive_types : FxHashMap < Symbol , PrimTy > ,
842- }
843-
844- impl PrimitiveTypeTable {
845- fn new ( ) -> PrimitiveTypeTable {
846- let mut table = FxHashMap :: default ( ) ;
847-
848- table. insert ( sym:: bool, Bool ) ;
849- table. insert ( sym:: char, Char ) ;
850- table. insert ( sym:: f32, Float ( FloatTy :: F32 ) ) ;
851- table. insert ( sym:: f64, Float ( FloatTy :: F64 ) ) ;
852- table. insert ( sym:: isize, Int ( IntTy :: Isize ) ) ;
853- table. insert ( sym:: i8, Int ( IntTy :: I8 ) ) ;
854- table. insert ( sym:: i16, Int ( IntTy :: I16 ) ) ;
855- table. insert ( sym:: i32, Int ( IntTy :: I32 ) ) ;
856- table. insert ( sym:: i64, Int ( IntTy :: I64 ) ) ;
857- table. insert ( sym:: i128, Int ( IntTy :: I128 ) ) ;
858- table. insert ( sym:: str, Str ) ;
859- table. insert ( sym:: usize, Uint ( UintTy :: Usize ) ) ;
860- table. insert ( sym:: u8, Uint ( UintTy :: U8 ) ) ;
861- table. insert ( sym:: u16, Uint ( UintTy :: U16 ) ) ;
862- table. insert ( sym:: u32, Uint ( UintTy :: U32 ) ) ;
863- table. insert ( sym:: u64, Uint ( UintTy :: U64 ) ) ;
864- table. insert ( sym:: u128, Uint ( UintTy :: U128 ) ) ;
865- Self { primitive_types : table }
866- }
867- }
868-
869835#[ derive( Debug , Default , Clone ) ]
870836pub struct ExternPreludeEntry < ' a > {
871837 extern_crate_item : Option < & ' a NameBinding < ' a > > ,
@@ -911,9 +877,6 @@ pub struct Resolver<'a> {
911877 /// "self-confirming" import resolutions during import validation.
912878 unusable_binding : Option < & ' a NameBinding < ' a > > ,
913879
914- /// The idents for the primitive types.
915- primitive_type_table : PrimitiveTypeTable ,
916-
917880 /// Resolutions for nodes that have a single resolution.
918881 partial_res_map : NodeMap < PartialRes > ,
919882 /// Resolutions for import nodes, which have multiple resolutions in different namespaces.
@@ -1283,8 +1246,6 @@ impl<'a> Resolver<'a> {
12831246 last_import_segment : false ,
12841247 unusable_binding : None ,
12851248
1286- primitive_type_table : PrimitiveTypeTable :: new ( ) ,
1287-
12881249 partial_res_map : Default :: default ( ) ,
12891250 import_res_map : Default :: default ( ) ,
12901251 label_res_map : Default :: default ( ) ,
@@ -1993,9 +1954,9 @@ impl<'a> Resolver<'a> {
19931954 }
19941955
19951956 if ns == TypeNS {
1996- if let Some ( prim_ty) = self . primitive_type_table . primitive_types . get ( & ident. name ) {
1957+ if let Some ( prim_ty) = PrimTy :: from_name ( ident. name ) {
19971958 let binding =
1998- ( Res :: PrimTy ( * prim_ty) , ty:: Visibility :: Public , DUMMY_SP , ExpnId :: root ( ) )
1959+ ( Res :: PrimTy ( prim_ty) , ty:: Visibility :: Public , DUMMY_SP , ExpnId :: root ( ) )
19991960 . to_name_binding ( self . arenas ) ;
20001961 return Some ( LexicalScopeBinding :: Item ( binding) ) ;
20011962 }
0 commit comments