@@ -27,14 +27,14 @@ use rustc_ast::{self as ast, NodeId, CRATE_NODE_ID};
2727use rustc_ast:: { AngleBracketedArg , Crate , Expr , ExprKind , GenericArg , GenericArgs , LitKind , Path } ;
2828use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap , FxIndexSet } ;
2929use rustc_data_structures:: intern:: Interned ;
30- use rustc_data_structures:: sync:: { Lrc , MappedReadGuard , ReadGuard , RwLock } ;
30+ use rustc_data_structures:: sync:: { Lrc , MappedReadGuard , ReadGuard } ;
3131use rustc_errors:: { Applicability , DiagnosticBuilder , ErrorGuaranteed } ;
3232use rustc_expand:: base:: { DeriveResolutions , SyntaxExtension , SyntaxExtensionKind } ;
3333use rustc_hir:: def:: Namespace :: { self , * } ;
3434use rustc_hir:: def:: { self , CtorOf , DefKind , DocLinkResMap , LifetimeRes , PartialRes , PerNS } ;
3535use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId } ;
3636use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE } ;
37- use rustc_hir:: definitions:: { DefPathData , Definitions } ;
37+ use rustc_hir:: definitions:: DefPathData ;
3838use rustc_hir:: TraitCandidate ;
3939use rustc_index:: vec:: IndexVec ;
4040use rustc_metadata:: creader:: { CStore , CrateLoader } ;
@@ -962,7 +962,7 @@ pub struct Resolver<'a, 'tcx> {
962962
963963 local_crate_name : Symbol ,
964964 metadata_loader : Box < MetadataLoaderDyn > ,
965- untracked : Untracked ,
965+ untracked : & ' tcx Untracked ,
966966 used_extern_options : FxHashSet < Symbol > ,
967967 macro_names : FxHashSet < Ident > ,
968968 builtin_macros : FxHashMap < Symbol , BuiltinMacroState > ,
@@ -1211,6 +1211,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12111211 crate_name : Symbol ,
12121212 metadata_loader : Box < MetadataLoaderDyn > ,
12131213 arenas : & ' a ResolverArenas < ' a > ,
1214+ untracked : & ' tcx Untracked ,
12141215 ) -> Resolver < ' a , ' tcx > {
12151216 let tcx = TyCtxt { sess : session } ;
12161217
@@ -1233,8 +1234,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12331234 & mut FxHashMap :: default ( ) ,
12341235 ) ;
12351236
1236- let definitions = Definitions :: new ( session. local_stable_crate_id ( ) ) ;
1237-
12381237 let mut visibilities = FxHashMap :: default ( ) ;
12391238 visibilities. insert ( CRATE_DEF_ID , ty:: Visibility :: Public ) ;
12401239
@@ -1246,10 +1245,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12461245 let mut invocation_parents = FxHashMap :: default ( ) ;
12471246 invocation_parents. insert ( LocalExpnId :: ROOT , ( CRATE_DEF_ID , ImplTraitContext :: Existential ) ) ;
12481247
1249- let mut source_span = IndexVec :: default ( ) ;
1250- let _id = source_span. push ( krate. spans . inner_span ) ;
1251- debug_assert_eq ! ( _id, CRATE_DEF_ID ) ;
1252-
12531248 let mut extern_prelude: FxHashMap < Ident , ExternPreludeEntry < ' _ > > = session
12541249 . opts
12551250 . externs
@@ -1327,11 +1322,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13271322 metadata_loader,
13281323 local_crate_name : crate_name,
13291324 used_extern_options : Default :: default ( ) ,
1330- untracked : Untracked {
1331- cstore : RwLock :: new ( Box :: new ( CStore :: new ( session) ) ) ,
1332- source_span : RwLock :: new ( source_span) ,
1333- definitions : RwLock :: new ( definitions) ,
1334- } ,
1325+ untracked,
13351326 macro_names : FxHashSet :: default ( ) ,
13361327 builtin_macros : Default :: default ( ) ,
13371328 builtin_macro_kinds : Default :: default ( ) ,
@@ -1436,7 +1427,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14361427 let main_def = self . main_def ;
14371428 let confused_type_with_std_module = self . confused_type_with_std_module ;
14381429 let effective_visibilities = self . effective_visibilities ;
1439- let untracked = self . untracked ;
14401430 let global_ctxt = ResolverGlobalCtxt {
14411431 expn_that_defined,
14421432 visibilities,
@@ -1475,11 +1465,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14751465 builtin_macro_kinds : self . builtin_macro_kinds ,
14761466 lifetime_elision_allowed : self . lifetime_elision_allowed ,
14771467 } ;
1478- ResolverOutputs { global_ctxt, ast_lowering, untracked }
1468+ ResolverOutputs { global_ctxt, ast_lowering }
14791469 }
14801470
14811471 fn create_stable_hashing_context ( & self ) -> StableHashingContext < ' _ > {
1482- StableHashingContext :: new ( self . tcx . sess , & self . untracked )
1472+ StableHashingContext :: new ( self . tcx . sess , self . untracked )
14831473 }
14841474
14851475 fn crate_loader < T > ( & mut self , f : impl FnOnce ( & mut CrateLoader < ' _ > ) -> T ) -> T {
@@ -1543,6 +1533,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15431533 . sess
15441534 . time ( "resolve_postprocess" , || self . crate_loader ( |c| c. postprocess ( krate) ) ) ;
15451535 } ) ;
1536+
1537+ // Make sure we don't mutate the cstore from here on.
1538+ self . untracked . cstore . leak ( ) ;
15461539 }
15471540
15481541 fn traits_in_scope (
0 commit comments