Skip to content

Commit 88177f8

Browse files
committed
Create untracked state inside create_global_ctxt.
1 parent 75e7cf5 commit 88177f8

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

compiler/rustc_interface/src/passes.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ use rustc_ast as ast;
99
use rustc_codegen_ssa::traits::CodegenBackend;
1010
use rustc_data_structures::jobserver::Proxy;
1111
use rustc_data_structures::steal::Steal;
12-
use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, WorkerLocal};
12+
use rustc_data_structures::sync::WorkerLocal;
1313
use rustc_data_structures::{parallel, thousands};
1414
use rustc_expand::base::{ExtCtxt, LintStoreExpand};
1515
use rustc_feature::Features;
1616
use rustc_fs_util::try_canonicalize;
17-
use rustc_hir::def_id::{LOCAL_CRATE, StableCrateId, StableCrateIdMap};
18-
use rustc_hir::definitions::Definitions;
17+
use rustc_hir::def_id::{LOCAL_CRATE, StableCrateId};
1918
use rustc_incremental::setup_dep_graph;
2019
use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_store};
2120
use rustc_metadata::creader::CStore;
@@ -29,7 +28,6 @@ use rustc_parse::{
2928
use rustc_passes::{abi_test, input_stats, layout_test};
3029
use rustc_resolve::Resolver;
3130
use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
32-
use rustc_session::cstore::Untracked;
3331
use rustc_session::output::{collect_crate_types, filename_for_input};
3432
use rustc_session::parse::feature_err;
3533
use rustc_session::search_paths::PathKind;
@@ -903,13 +901,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
903901
let dep_type = DepsType { dep_names: rustc_query_impl::dep_kind_names() };
904902
let dep_graph = setup_dep_graph(sess, crate_name, &dep_type);
905903

906-
let cstore =
907-
FreezeLock::new(Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _);
908-
let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
909-
910-
let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default());
911-
let untracked =
912-
Untracked { cstore, source_span: AppendOnlyIndexVec::new(), definitions, stable_crate_ids };
904+
let cstore = Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _;
913905

914906
// We're constructing the HIR here; we don't care what we will
915907
// read, since we haven't even constructed the *input* to
@@ -952,7 +944,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
952944
stable_crate_id,
953945
arena,
954946
hir_arena,
955-
untracked,
947+
cstore,
956948
dep_graph,
957949
rustc_query_impl::query_callbacks(arena),
958950
rustc_query_impl::query_system(

compiler/rustc_middle/src/ty/context.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
2727
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2828
use rustc_data_structures::steal::Steal;
2929
use rustc_data_structures::sync::{
30-
self, DynSend, DynSync, FreezeReadGuard, Lock, RwLock, WorkerLocal,
30+
self, AppendOnlyIndexVec, DynSend, DynSync, FreezeLock, FreezeReadGuard, Lock, RwLock,
31+
WorkerLocal,
3132
};
3233
use rustc_errors::{
3334
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, LintDiagnostic, LintEmitter, MultiSpan,
@@ -48,7 +49,7 @@ use rustc_session::config::CrateType;
4849
use rustc_session::cstore::{CrateStoreDyn, Untracked};
4950
use rustc_session::lint::Lint;
5051
use rustc_session::{Limit, MetadataKind, Session};
51-
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
52+
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId, StableCrateIdMap};
5253
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
5354
use rustc_type_ir::TyKind::*;
5455
use rustc_type_ir::lang_items::TraitSolverLangItem;
@@ -1684,7 +1685,7 @@ impl<'tcx> TyCtxt<'tcx> {
16841685
stable_crate_id: StableCrateId,
16851686
arena: &'tcx WorkerLocal<Arena<'tcx>>,
16861687
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
1687-
untracked: Untracked,
1688+
cstore: Box<CrateStoreDyn>,
16881689
dep_graph: DepGraph,
16891690
query_kinds: &'tcx [DepKindStruct<'tcx>],
16901691
query_system: QuerySystem<'tcx>,
@@ -1693,6 +1694,17 @@ impl<'tcx> TyCtxt<'tcx> {
16931694
jobserver_proxy: Arc<Proxy>,
16941695
f: impl FnOnce(TyCtxt<'tcx>) -> T,
16951696
) -> T {
1697+
let cstore = FreezeLock::new(cstore);
1698+
let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
1699+
1700+
let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default());
1701+
let untracked = Untracked {
1702+
cstore,
1703+
source_span: AppendOnlyIndexVec::new(),
1704+
definitions,
1705+
stable_crate_ids,
1706+
};
1707+
16961708
let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| {
16971709
s.dcx().emit_fatal(err);
16981710
});

0 commit comments

Comments
 (0)