@@ -13,7 +13,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, FreezeWriteGuard};
1313use rustc_errors:: DiagCtxt ;
1414use rustc_expand:: base:: SyntaxExtension ;
1515use 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 } ;
1717use rustc_hir:: definitions:: Definitions ;
1818use rustc_index:: IndexVec ;
1919use rustc_middle:: ty:: TyCtxt ;
@@ -62,9 +62,6 @@ pub struct CStore {
6262 /// This crate has a `#[alloc_error_handler]` item.
6363 has_alloc_error_handler : bool ,
6464
65- /// The interned [StableCrateId]s.
66- pub ( crate ) stable_crate_ids : StableCrateIdMap ,
67-
6865 /// Unused externs of the crate
6966 unused_externs : Vec < Symbol > ,
7067}
@@ -165,9 +162,15 @@ impl CStore {
165162 } )
166163 }
167164
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+ {
171174 // Check for (potential) conflicts with the local crate
172175 if existing == LOCAL_CRATE {
173176 Err ( CrateError :: SymbolConflictsCurrent ( root. name ( ) ) )
@@ -180,8 +183,8 @@ impl CStore {
180183 }
181184 } else {
182185 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) ;
185188 Ok ( num)
186189 }
187190 }
@@ -289,12 +292,7 @@ impl CStore {
289292 }
290293 }
291294
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 {
298296 CStore {
299297 metadata_loader,
300298 // We add an empty entry for LOCAL_CRATE (which maps to zero) in
@@ -307,7 +305,6 @@ impl CStore {
307305 alloc_error_handler_kind : None ,
308306 has_global_allocator : false ,
309307 has_alloc_error_handler : false ,
310- stable_crate_ids,
311308 unused_externs : Vec :: new ( ) ,
312309 }
313310 }
@@ -416,7 +413,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
416413 let private_dep = self . is_private_dep ( name. as_str ( ) , private_dep) ;
417414
418415 // 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 ) ?;
420417
421418 info ! (
422419 "register crate `{}` (cnum = {}. private_dep = {})" ,
0 commit comments