@@ -6,12 +6,14 @@ use crate::rmeta::{self, encoder};
6
6
7
7
use rustc_ast as ast;
8
8
use rustc_ast:: expand:: allocator:: AllocatorKind ;
9
+ use rustc_data_structures:: stable_map:: FxHashMap ;
9
10
use rustc_data_structures:: svh:: Svh ;
10
11
use rustc_hir as hir;
11
12
use rustc_hir:: def:: DefKind ;
12
13
use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , CRATE_DEF_INDEX , LOCAL_CRATE } ;
13
14
use rustc_hir:: definitions:: { DefKey , DefPath , DefPathHash } ;
14
15
use rustc_middle:: hir:: exports:: Export ;
16
+ use rustc_middle:: middle:: cstore:: ForeignModule ;
15
17
use rustc_middle:: middle:: cstore:: { CrateSource , CrateStore , EncodedMetadata } ;
16
18
use rustc_middle:: middle:: exported_symbols:: ExportedSymbol ;
17
19
use rustc_middle:: middle:: stability:: DeprecationEntry ;
@@ -267,12 +269,10 @@ pub fn provide(providers: &mut Providers) {
267
269
Some ( id) => id,
268
270
None => return false ,
269
271
} ;
270
- tcx. foreign_modules ( id. krate )
271
- . iter ( )
272
- . find ( |m| m. def_id == fm_id)
273
- . expect ( "failed to find foreign module" )
274
- . foreign_items
275
- . contains ( & id)
272
+ let map = tcx. foreign_modules ( id. krate ) ;
273
+ let module =
274
+ tcx. prof . generic_activity ( "finding_foreign_module" ) . run ( || map. get ( & fm_id) ) ;
275
+ module. expect ( "failed to find foreign module" ) . foreign_items . contains ( & id)
276
276
} )
277
277
. map ( |l| l. kind )
278
278
} ,
@@ -282,7 +282,9 @@ pub fn provide(providers: &mut Providers) {
282
282
} ,
283
283
foreign_modules : |tcx, cnum| {
284
284
assert_eq ! ( cnum, LOCAL_CRATE ) ;
285
- & tcx. arena . alloc ( foreign_modules:: collect ( tcx) ) [ ..]
285
+ let modules: FxHashMap < DefId , ForeignModule > =
286
+ foreign_modules:: collect ( tcx) . into_iter ( ) . map ( |m| ( m. def_id , m) ) . collect ( ) ;
287
+ Lrc :: new ( modules)
286
288
} ,
287
289
link_args : |tcx, cnum| {
288
290
assert_eq ! ( cnum, LOCAL_CRATE ) ;
0 commit comments