@@ -27,14 +27,14 @@ use rustc_ast::{self as ast, NodeId, CRATE_NODE_ID};
27
27
use rustc_ast:: { AngleBracketedArg , Crate , Expr , ExprKind , GenericArg , GenericArgs , LitKind , Path } ;
28
28
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap , FxIndexSet } ;
29
29
use rustc_data_structures:: intern:: Interned ;
30
- use rustc_data_structures:: sync:: { Lrc , MappedReadGuard , ReadGuard , RwLock } ;
30
+ use rustc_data_structures:: sync:: { Lrc , MappedReadGuard , ReadGuard } ;
31
31
use rustc_errors:: { Applicability , DiagnosticBuilder , ErrorGuaranteed } ;
32
32
use rustc_expand:: base:: { DeriveResolutions , SyntaxExtension , SyntaxExtensionKind } ;
33
33
use rustc_hir:: def:: Namespace :: { self , * } ;
34
34
use rustc_hir:: def:: { self , CtorOf , DefKind , DocLinkResMap , LifetimeRes , PartialRes , PerNS } ;
35
35
use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId } ;
36
36
use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE } ;
37
- use rustc_hir:: definitions:: { DefPathData , Definitions } ;
37
+ use rustc_hir:: definitions:: DefPathData ;
38
38
use rustc_hir:: TraitCandidate ;
39
39
use rustc_index:: vec:: IndexVec ;
40
40
use rustc_metadata:: creader:: { CStore , CrateLoader } ;
@@ -962,7 +962,7 @@ pub struct Resolver<'a, 'tcx> {
962
962
963
963
local_crate_name : Symbol ,
964
964
metadata_loader : Box < MetadataLoaderDyn > ,
965
- untracked : Untracked ,
965
+ untracked : & ' tcx Untracked ,
966
966
used_extern_options : FxHashSet < Symbol > ,
967
967
macro_names : FxHashSet < Ident > ,
968
968
builtin_macros : FxHashMap < Symbol , BuiltinMacroState > ,
@@ -1211,6 +1211,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1211
1211
crate_name : Symbol ,
1212
1212
metadata_loader : Box < MetadataLoaderDyn > ,
1213
1213
arenas : & ' a ResolverArenas < ' a > ,
1214
+ untracked : & ' tcx Untracked ,
1214
1215
) -> Resolver < ' a , ' tcx > {
1215
1216
let tcx = TyCtxt { sess : session } ;
1216
1217
@@ -1233,8 +1234,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1233
1234
& mut FxHashMap :: default ( ) ,
1234
1235
) ;
1235
1236
1236
- let definitions = Definitions :: new ( session. local_stable_crate_id ( ) ) ;
1237
-
1238
1237
let mut visibilities = FxHashMap :: default ( ) ;
1239
1238
visibilities. insert ( CRATE_DEF_ID , ty:: Visibility :: Public ) ;
1240
1239
@@ -1246,10 +1245,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1246
1245
let mut invocation_parents = FxHashMap :: default ( ) ;
1247
1246
invocation_parents. insert ( LocalExpnId :: ROOT , ( CRATE_DEF_ID , ImplTraitContext :: Existential ) ) ;
1248
1247
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
-
1253
1248
let mut extern_prelude: FxHashMap < Ident , ExternPreludeEntry < ' _ > > = session
1254
1249
. opts
1255
1250
. externs
@@ -1327,11 +1322,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1327
1322
metadata_loader,
1328
1323
local_crate_name : crate_name,
1329
1324
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,
1335
1326
macro_names : FxHashSet :: default ( ) ,
1336
1327
builtin_macros : Default :: default ( ) ,
1337
1328
builtin_macro_kinds : Default :: default ( ) ,
@@ -1436,7 +1427,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1436
1427
let main_def = self . main_def ;
1437
1428
let confused_type_with_std_module = self . confused_type_with_std_module ;
1438
1429
let effective_visibilities = self . effective_visibilities ;
1439
- let untracked = self . untracked ;
1440
1430
let global_ctxt = ResolverGlobalCtxt {
1441
1431
expn_that_defined,
1442
1432
visibilities,
@@ -1475,11 +1465,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1475
1465
builtin_macro_kinds : self . builtin_macro_kinds ,
1476
1466
lifetime_elision_allowed : self . lifetime_elision_allowed ,
1477
1467
} ;
1478
- ResolverOutputs { global_ctxt, ast_lowering, untracked }
1468
+ ResolverOutputs { global_ctxt, ast_lowering }
1479
1469
}
1480
1470
1481
1471
fn create_stable_hashing_context ( & self ) -> StableHashingContext < ' _ > {
1482
- StableHashingContext :: new ( self . tcx . sess , & self . untracked )
1472
+ StableHashingContext :: new ( self . tcx . sess , self . untracked )
1483
1473
}
1484
1474
1485
1475
fn crate_loader < T > ( & mut self , f : impl FnOnce ( & mut CrateLoader < ' _ > ) -> T ) -> T {
@@ -1543,6 +1533,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1543
1533
. sess
1544
1534
. time ( "resolve_postprocess" , || self . crate_loader ( |c| c. postprocess ( krate) ) ) ;
1545
1535
} ) ;
1536
+
1537
+ // Make sure we don't mutate the cstore from here on.
1538
+ self . untracked . cstore . leak ( ) ;
1546
1539
}
1547
1540
1548
1541
fn traits_in_scope (
0 commit comments