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