@@ -13,7 +13,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, FreezeWriteGuard};
13
13
use rustc_errors:: DiagCtxt ;
14
14
use rustc_expand:: base:: SyntaxExtension ;
15
15
use rustc_fs_util:: try_canonicalize;
16
- use rustc_hir:: def_id:: { CrateNum , LocalDefId , StableCrateId , StableCrateIdMap , LOCAL_CRATE } ;
16
+ use rustc_hir:: def_id:: { CrateNum , LocalDefId , StableCrateId , LOCAL_CRATE } ;
17
17
use rustc_hir:: definitions:: Definitions ;
18
18
use rustc_index:: IndexVec ;
19
19
use rustc_middle:: ty:: TyCtxt ;
@@ -62,9 +62,6 @@ pub struct CStore {
62
62
/// This crate has a `#[alloc_error_handler]` item.
63
63
has_alloc_error_handler : bool ,
64
64
65
- /// The interned [StableCrateId]s.
66
- pub ( crate ) stable_crate_ids : StableCrateIdMap ,
67
-
68
65
/// Unused externs of the crate
69
66
unused_externs : Vec < Symbol > ,
70
67
}
@@ -165,9 +162,15 @@ impl CStore {
165
162
} )
166
163
}
167
164
168
- fn intern_stable_crate_id ( & mut self , root : & CrateRoot ) -> Result < CrateNum , CrateError > {
169
- assert_eq ! ( self . metas. len( ) , self . stable_crate_ids. len( ) ) ;
170
- if let Some ( & existing) = self . stable_crate_ids . get ( & root. stable_crate_id ( ) ) {
165
+ fn intern_stable_crate_id < ' tcx > (
166
+ & mut self ,
167
+ root : & CrateRoot ,
168
+ tcx : TyCtxt < ' tcx > ,
169
+ ) -> Result < CrateNum , CrateError > {
170
+ assert_eq ! ( self . metas. len( ) , tcx. untracked( ) . stable_crate_ids. read( ) . len( ) ) ;
171
+ if let Some ( & existing) =
172
+ tcx. untracked ( ) . stable_crate_ids . read ( ) . get ( & root. stable_crate_id ( ) )
173
+ {
171
174
// Check for (potential) conflicts with the local crate
172
175
if existing == LOCAL_CRATE {
173
176
Err ( CrateError :: SymbolConflictsCurrent ( root. name ( ) ) )
@@ -180,8 +183,8 @@ impl CStore {
180
183
}
181
184
} else {
182
185
self . metas . push ( None ) ;
183
- let num = CrateNum :: new ( self . stable_crate_ids . len ( ) ) ;
184
- self . stable_crate_ids . insert ( root. stable_crate_id ( ) , num) ;
186
+ let num = CrateNum :: new ( tcx . untracked ( ) . stable_crate_ids . read ( ) . len ( ) ) ;
187
+ tcx . untracked ( ) . stable_crate_ids . write ( ) . insert ( root. stable_crate_id ( ) , num) ;
185
188
Ok ( num)
186
189
}
187
190
}
@@ -289,12 +292,7 @@ impl CStore {
289
292
}
290
293
}
291
294
292
- pub fn new (
293
- metadata_loader : Box < MetadataLoaderDyn > ,
294
- local_stable_crate_id : StableCrateId ,
295
- ) -> CStore {
296
- let mut stable_crate_ids = StableCrateIdMap :: default ( ) ;
297
- stable_crate_ids. insert ( local_stable_crate_id, LOCAL_CRATE ) ;
295
+ pub fn new ( metadata_loader : Box < MetadataLoaderDyn > ) -> CStore {
298
296
CStore {
299
297
metadata_loader,
300
298
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
@@ -307,7 +305,6 @@ impl CStore {
307
305
alloc_error_handler_kind : None ,
308
306
has_global_allocator : false ,
309
307
has_alloc_error_handler : false ,
310
- stable_crate_ids,
311
308
unused_externs : Vec :: new ( ) ,
312
309
}
313
310
}
@@ -416,7 +413,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
416
413
let private_dep = self . is_private_dep ( name. as_str ( ) , private_dep) ;
417
414
418
415
// Claim this crate number and cache it
419
- let cnum = self . cstore . intern_stable_crate_id ( & crate_root) ?;
416
+ let cnum = self . cstore . intern_stable_crate_id ( & crate_root, self . tcx ) ?;
420
417
421
418
info ! (
422
419
"register crate `{}` (cnum = {}. private_dep = {})" ,
0 commit comments