about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-23 20:46:48 +0000
committerbors <bors@rust-lang.org>2024-04-23 20:46:48 +0000
commit244da22fabd9fa677bbd0ac601a88e5ca6917526 (patch)
tree4027ccd0b3e983d7902e1000cb46f417df37bcea /compiler/rustc_interface/src
parent40dcd796d094b911b8b7b55a0519fb8e3d21680f (diff)
parente9a2f8fef181a8aa0145a2665804916effb6365e (diff)
downloadrust-244da22fabd9fa677bbd0ac601a88e5ca6917526.tar.gz
rust-244da22fabd9fa677bbd0ac601a88e5ca6917526.zip
Auto merge of #123126 - oli-obk:feed_crate_num, r=davidtwco
Enable `CrateNum` query feeding via `TyCtxt`

Instead of having a magic function that violates some `TyCtxtFeed` invariants, add a `create_def` equivalent for `CrateNum`s.

Note that this still isn't tracked by the query system (unlike `create_def`), and that feeding most `CrateNum` queries for crates other than the local one will likely cause performance regressions.

These things should be attempted on their own separately, but this PR should stand on its own
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/queries.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index ee677a092e2..1b9165342d4 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -8,7 +8,7 @@ use rustc_codegen_ssa::CodegenResults;
 use rustc_data_structures::steal::Steal;
 use rustc_data_structures::svh::Svh;
 use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, OnceLock, WorkerLocal};
-use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
+use rustc_hir::def_id::{StableCrateId, StableCrateIdMap, LOCAL_CRATE};
 use rustc_hir::definitions::Definitions;
 use rustc_incremental::setup_dep_graph;
 use rustc_metadata::creader::CStore;
@@ -140,11 +140,16 @@ impl<'tcx> Queries<'tcx> {
 
             let cstore = FreezeLock::new(Box::new(CStore::new(
                 self.compiler.codegen_backend.metadata_loader(),
-                stable_crate_id,
             )) as _);
             let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
-            let untracked =
-                Untracked { cstore, source_span: AppendOnlyIndexVec::new(), definitions };
+
+            let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default());
+            let untracked = Untracked {
+                cstore,
+                source_span: AppendOnlyIndexVec::new(),
+                definitions,
+                stable_crate_ids,
+            };
 
             let qcx = passes::create_global_ctxt(
                 self.compiler,
@@ -158,7 +163,8 @@ impl<'tcx> Queries<'tcx> {
             );
 
             qcx.enter(|tcx| {
-                let feed = tcx.feed_local_crate();
+                let feed = tcx.create_crate_num(stable_crate_id).unwrap();
+                assert_eq!(feed.key(), LOCAL_CRATE);
                 feed.crate_name(crate_name);
 
                 let feed = tcx.feed_unit_query();