@@ -37,7 +37,7 @@ use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
3737use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId , CRATE_DEF_INDEX } ;
3838use rustc_hir:: definitions:: { DefKey , Definitions } ;
3939use rustc_hir:: PrimTy :: { self , Bool , Char , Float , Int , Str , Uint } ;
40- use rustc_hir:: { GlobMap , TraitMap } ;
40+ use rustc_hir:: TraitMap ;
4141use rustc_metadata:: creader:: { CStore , CrateLoader } ;
4242use rustc_middle:: hir:: exports:: ExportMap ;
4343use rustc_middle:: middle:: cstore:: { CrateStore , MetadataLoaderDyn } ;
@@ -866,7 +866,7 @@ pub struct Resolver<'a> {
866866 label_res_map : NodeMap < NodeId > ,
867867
868868 /// `CrateNum` resolutions of `extern crate` items.
869- extern_crate_map : NodeMap < CrateNum > ,
869+ extern_crate_map : FxHashMap < LocalDefId , CrateNum > ,
870870 export_map : ExportMap < NodeId > ,
871871 trait_map : TraitMap < NodeId > ,
872872
@@ -895,11 +895,11 @@ pub struct Resolver<'a> {
895895 underscore_disambiguator : u32 ,
896896
897897 /// Maps glob imports to the names of items actually imported.
898- glob_map : GlobMap ,
898+ glob_map : FxHashMap < LocalDefId , FxHashSet < Symbol > > ,
899899
900900 used_imports : FxHashSet < ( NodeId , Namespace ) > ,
901- maybe_unused_trait_imports : NodeSet ,
902- maybe_unused_extern_crates : Vec < ( NodeId , Span ) > ,
901+ maybe_unused_trait_imports : FxHashSet < LocalDefId > ,
902+ maybe_unused_extern_crates : Vec < ( LocalDefId , Span ) > ,
903903
904904 /// Privacy errors are delayed until the end in order to deduplicate them.
905905 privacy_errors : Vec < PrivacyError < ' a > > ,
@@ -924,7 +924,7 @@ pub struct Resolver<'a> {
924924 dummy_ext_bang : Lrc < SyntaxExtension > ,
925925 dummy_ext_derive : Lrc < SyntaxExtension > ,
926926 non_macro_attrs : [ Lrc < SyntaxExtension > ; 2 ] ,
927- local_macro_def_scopes : FxHashMap < NodeId , Module < ' a > > ,
927+ local_macro_def_scopes : FxHashMap < LocalDefId , Module < ' a > > ,
928928 ast_transform_scopes : FxHashMap < ExpnId , Module < ' a > > ,
929929 unused_macros : NodeMap < Span > ,
930930 proc_macro_stubs : NodeSet ,
@@ -1269,11 +1269,7 @@ impl<'a> Resolver<'a> {
12691269
12701270 pub fn into_outputs ( self ) -> ResolverOutputs {
12711271 let definitions = self . definitions ;
1272- let extern_crate_map = self
1273- . extern_crate_map
1274- . into_iter ( )
1275- . map ( |( k, v) | ( definitions. local_def_id ( k) . to_def_id ( ) , v) )
1276- . collect ( ) ;
1272+ let extern_crate_map = self . extern_crate_map ;
12771273 let export_map = self
12781274 . export_map
12791275 . into_iter ( )
@@ -1298,21 +1294,9 @@ impl<'a> Resolver<'a> {
12981294 )
12991295 } )
13001296 . collect ( ) ;
1301- let maybe_unused_trait_imports = self
1302- . maybe_unused_trait_imports
1303- . into_iter ( )
1304- . map ( |id| definitions. local_def_id ( id) )
1305- . collect ( ) ;
1306- let maybe_unused_extern_crates = self
1307- . maybe_unused_extern_crates
1308- . into_iter ( )
1309- . map ( |( id, sp) | ( definitions. local_def_id ( id) . to_def_id ( ) , sp) )
1310- . collect ( ) ;
1311- let glob_map = self
1312- . glob_map
1313- . into_iter ( )
1314- . map ( |( id, names) | ( definitions. local_def_id ( id) , names) )
1315- . collect ( ) ;
1297+ let maybe_unused_trait_imports = self . maybe_unused_trait_imports ;
1298+ let maybe_unused_extern_crates = self . maybe_unused_extern_crates ;
1299+ let glob_map = self . glob_map ;
13161300 ResolverOutputs {
13171301 definitions : definitions,
13181302 cstore : Box :: new ( self . crate_loader . into_cstore ( ) ) ,
@@ -1334,11 +1318,7 @@ impl<'a> Resolver<'a> {
13341318 ResolverOutputs {
13351319 definitions : self . definitions . clone ( ) ,
13361320 cstore : Box :: new ( self . cstore ( ) . clone ( ) ) ,
1337- extern_crate_map : self
1338- . extern_crate_map
1339- . iter ( )
1340- . map ( |( & k, & v) | ( self . definitions . local_def_id ( k) . to_def_id ( ) , v) )
1341- . collect ( ) ,
1321+ extern_crate_map : self . extern_crate_map . clone ( ) ,
13421322 export_map : self
13431323 . export_map
13441324 . iter ( )
@@ -1366,21 +1346,9 @@ impl<'a> Resolver<'a> {
13661346 )
13671347 } )
13681348 . collect ( ) ,
1369- glob_map : self
1370- . glob_map
1371- . iter ( )
1372- . map ( |( & id, names) | ( self . definitions . local_def_id ( id) , names. clone ( ) ) )
1373- . collect ( ) ,
1374- maybe_unused_trait_imports : self
1375- . maybe_unused_trait_imports
1376- . iter ( )
1377- . map ( |& id| self . definitions . local_def_id ( id) )
1378- . collect ( ) ,
1379- maybe_unused_extern_crates : self
1380- . maybe_unused_extern_crates
1381- . iter ( )
1382- . map ( |& ( id, sp) | ( self . definitions . local_def_id ( id) . to_def_id ( ) , sp) )
1383- . collect ( ) ,
1349+ glob_map : self . glob_map . clone ( ) ,
1350+ maybe_unused_trait_imports : self . maybe_unused_trait_imports . clone ( ) ,
1351+ maybe_unused_extern_crates : self . maybe_unused_extern_crates . clone ( ) ,
13841352 extern_prelude : self
13851353 . extern_prelude
13861354 . iter ( )
@@ -1522,7 +1490,8 @@ impl<'a> Resolver<'a> {
15221490 #[ inline]
15231491 fn add_to_glob_map ( & mut self , import : & Import < ' _ > , ident : Ident ) {
15241492 if import. is_glob ( ) {
1525- self . glob_map . entry ( import. id ) . or_default ( ) . insert ( ident. name ) ;
1493+ let def_id = self . definitions . local_def_id ( import. id ) ;
1494+ self . glob_map . entry ( def_id) . or_default ( ) . insert ( ident. name ) ;
15261495 }
15271496 }
15281497
0 commit comments