Skip to content

Commit 930c5b4

Browse files
committed
Create untracked state inside create_global_ctxt.
1 parent 70e2b4a commit 930c5b4

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::EncodedMetadata;
@@ -30,7 +29,6 @@ use rustc_parse::{
3029
use rustc_passes::{abi_test, input_stats, layout_test};
3130
use rustc_resolve::Resolver;
3231
use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
33-
use rustc_session::cstore::Untracked;
3432
use rustc_session::output::{collect_crate_types, filename_for_input};
3533
use rustc_session::parse::feature_err;
3634
use rustc_session::search_paths::PathKind;
@@ -904,13 +902,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
904902
let dep_type = DepsType { dep_names: rustc_query_impl::dep_kind_names() };
905903
let dep_graph = setup_dep_graph(sess, crate_name, &dep_type);
906904

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

915907
// We're constructing the HIR here; we don't care what we will
916908
// read, since we haven't even constructed the *input* to
@@ -953,7 +945,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
953945
stable_crate_id,
954946
arena,
955947
hir_arena,
956-
untracked,
948+
cstore,
957949
dep_graph,
958950
rustc_query_impl::query_callbacks(arena),
959951
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,
@@ -49,7 +50,7 @@ use rustc_session::config::CrateType;
4950
use rustc_session::cstore::{CrateStoreDyn, Untracked};
5051
use rustc_session::lint::Lint;
5152
use rustc_session::{Limit, Session};
52-
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
53+
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId, StableCrateIdMap};
5354
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
5455
use rustc_type_ir::TyKind::*;
5556
use rustc_type_ir::lang_items::TraitSolverLangItem;
@@ -1688,7 +1689,7 @@ impl<'tcx> TyCtxt<'tcx> {
16881689
stable_crate_id: StableCrateId,
16891690
arena: &'tcx WorkerLocal<Arena<'tcx>>,
16901691
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
1691-
untracked: Untracked,
1692+
cstore: Box<CrateStoreDyn>,
16921693
dep_graph: DepGraph,
16931694
query_kinds: &'tcx [DepKindStruct<'tcx>],
16941695
query_system: QuerySystem<'tcx>,
@@ -1697,6 +1698,17 @@ impl<'tcx> TyCtxt<'tcx> {
16971698
jobserver_proxy: Arc<Proxy>,
16981699
f: impl FnOnce(TyCtxt<'tcx>) -> T,
16991700
) -> T {
1701+
let cstore = FreezeLock::new(cstore);
1702+
let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
1703+
1704+
let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default());
1705+
let untracked = Untracked {
1706+
cstore,
1707+
source_span: AppendOnlyIndexVec::new(),
1708+
definitions,
1709+
stable_crate_ids,
1710+
};
1711+
17001712
let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| {
17011713
s.dcx().emit_fatal(err);
17021714
});

0 commit comments

Comments
 (0)