From fbc9b94064c611f341d613ce14d321b267b3c298 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 26 Mar 2024 16:52:06 +0000 Subject: Move `stable_crate_ids` from `CrateStore` to `Untracked` This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes --- compiler/rustc_interface/src/queries.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_interface') diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index ee677a092e2..375a390948b 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,17 @@ 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 mut stable_crate_ids = StableCrateIdMap::default(); + stable_crate_ids.insert(stable_crate_id, LOCAL_CRATE); + let untracked = Untracked { + cstore, + source_span: AppendOnlyIndexVec::new(), + definitions, + stable_crate_ids: FreezeLock::new(stable_crate_ids), + }; let qcx = passes::create_global_ctxt( self.compiler, -- cgit 1.4.1-3-g733a5 From e9a2f8fef181a8aa0145a2665804916effb6365e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 27 Mar 2024 08:07:23 +0000 Subject: Remove `feed_local_crate` in favor of creating the `CrateNum` via `TyCtxt` --- compiler/rustc_interface/src/queries.rs | 8 ++++---- compiler/rustc_middle/src/ty/context.rs | 7 ------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_interface') diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 375a390948b..1b9165342d4 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -143,13 +143,12 @@ impl<'tcx> Queries<'tcx> { )) as _); let definitions = FreezeLock::new(Definitions::new(stable_crate_id)); - let mut stable_crate_ids = StableCrateIdMap::default(); - stable_crate_ids.insert(stable_crate_id, LOCAL_CRATE); + let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default()); let untracked = Untracked { cstore, source_span: AppendOnlyIndexVec::new(), definitions, - stable_crate_ids: FreezeLock::new(stable_crate_ids), + stable_crate_ids, }; let qcx = passes::create_global_ctxt( @@ -164,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(); diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index b5769e6fee2..65ff643ed4b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -565,13 +565,6 @@ impl<'tcx> TyCtxt<'tcx> { TyCtxtFeed { tcx: self, key: () } } - /// Can only be fed before queries are run, and is thus exempt from any - /// incremental issues. Do not use except for the initial query feeding. - pub fn feed_local_crate(self) -> TyCtxtFeed<'tcx, CrateNum> { - self.dep_graph.assert_ignored(); - TyCtxtFeed { tcx: self, key: LOCAL_CRATE } - } - /// Only used in the resolver to register the `CRATE_DEF_ID` `DefId` and feed /// some queries for it. It will panic if used twice. pub fn create_local_crate_def_id(self, span: Span) -> TyCtxtFeed<'tcx, LocalDefId> { -- cgit 1.4.1-3-g733a5