@@ -37,7 +37,7 @@ use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
37
37
use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId , CRATE_DEF_INDEX } ;
38
38
use rustc_hir:: definitions:: { DefKey , Definitions } ;
39
39
use rustc_hir:: PrimTy :: { self , Bool , Char , Float , Int , Str , Uint } ;
40
- use rustc_hir:: { GlobMap , TraitMap } ;
40
+ use rustc_hir:: TraitMap ;
41
41
use rustc_metadata:: creader:: { CStore , CrateLoader } ;
42
42
use rustc_middle:: hir:: exports:: ExportMap ;
43
43
use rustc_middle:: middle:: cstore:: { CrateStore , MetadataLoaderDyn } ;
@@ -866,7 +866,7 @@ pub struct Resolver<'a> {
866
866
label_res_map : NodeMap < NodeId > ,
867
867
868
868
/// `CrateNum` resolutions of `extern crate` items.
869
- extern_crate_map : NodeMap < CrateNum > ,
869
+ extern_crate_map : FxHashMap < LocalDefId , CrateNum > ,
870
870
export_map : ExportMap < NodeId > ,
871
871
trait_map : TraitMap < NodeId > ,
872
872
@@ -895,11 +895,11 @@ pub struct Resolver<'a> {
895
895
underscore_disambiguator : u32 ,
896
896
897
897
/// Maps glob imports to the names of items actually imported.
898
- glob_map : GlobMap ,
898
+ glob_map : FxHashMap < LocalDefId , FxHashSet < Symbol > > ,
899
899
900
900
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 ) > ,
903
903
904
904
/// Privacy errors are delayed until the end in order to deduplicate them.
905
905
privacy_errors : Vec < PrivacyError < ' a > > ,
@@ -924,7 +924,7 @@ pub struct Resolver<'a> {
924
924
dummy_ext_bang : Lrc < SyntaxExtension > ,
925
925
dummy_ext_derive : Lrc < SyntaxExtension > ,
926
926
non_macro_attrs : [ Lrc < SyntaxExtension > ; 2 ] ,
927
- local_macro_def_scopes : FxHashMap < NodeId , Module < ' a > > ,
927
+ local_macro_def_scopes : FxHashMap < LocalDefId , Module < ' a > > ,
928
928
ast_transform_scopes : FxHashMap < ExpnId , Module < ' a > > ,
929
929
unused_macros : NodeMap < Span > ,
930
930
proc_macro_stubs : NodeSet ,
@@ -1269,11 +1269,7 @@ impl<'a> Resolver<'a> {
1269
1269
1270
1270
pub fn into_outputs ( self ) -> ResolverOutputs {
1271
1271
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 ;
1277
1273
let export_map = self
1278
1274
. export_map
1279
1275
. into_iter ( )
@@ -1298,21 +1294,9 @@ impl<'a> Resolver<'a> {
1298
1294
)
1299
1295
} )
1300
1296
. 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 ;
1316
1300
ResolverOutputs {
1317
1301
definitions : definitions,
1318
1302
cstore : Box :: new ( self . crate_loader . into_cstore ( ) ) ,
@@ -1334,11 +1318,7 @@ impl<'a> Resolver<'a> {
1334
1318
ResolverOutputs {
1335
1319
definitions : self . definitions . clone ( ) ,
1336
1320
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 ( ) ,
1342
1322
export_map : self
1343
1323
. export_map
1344
1324
. iter ( )
@@ -1366,21 +1346,9 @@ impl<'a> Resolver<'a> {
1366
1346
)
1367
1347
} )
1368
1348
. 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 ( ) ,
1384
1352
extern_prelude : self
1385
1353
. extern_prelude
1386
1354
. iter ( )
@@ -1522,7 +1490,8 @@ impl<'a> Resolver<'a> {
1522
1490
#[ inline]
1523
1491
fn add_to_glob_map ( & mut self , import : & Import < ' _ > , ident : Ident ) {
1524
1492
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 ) ;
1526
1495
}
1527
1496
}
1528
1497
0 commit comments