about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-03-26 16:52:06 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-19 14:16:18 +0000
commitfbc9b94064c611f341d613ce14d321b267b3c298 (patch)
tree601c6bcb511c2c56c26a5e643701ed38ad209a28 /compiler/rustc_metadata/src/rmeta/decoder
parent10be74569ce3f3140e2d035af920ee0e78682407 (diff)
downloadrust-fbc9b94064c611f341d613ce14d321b267b3c298.tar.gz
rust-fbc9b94064c611f341d613ce14d321b267b3c298.zip
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
Diffstat (limited to 'compiler/rustc_metadata/src/rmeta/decoder')
-rw-r--r--compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
index 2935d5b8f63..531b2e05411 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
@@ -629,13 +629,6 @@ impl CrateStore for CStore {
         self.get_crate_data(cnum).root.stable_crate_id
     }
 
-    fn stable_crate_id_to_crate_num(&self, stable_crate_id: StableCrateId) -> CrateNum {
-        *self
-            .stable_crate_ids
-            .get(&stable_crate_id)
-            .unwrap_or_else(|| bug!("uninterned StableCrateId: {stable_crate_id:?}"))
-    }
-
     /// Returns the `DefKey` for a given `DefId`. This indicates the
     /// parent `DefId` as well as some idea of what kind of data the
     /// `DefId` refers to.
@@ -657,7 +650,13 @@ fn provide_cstore_hooks(providers: &mut Providers) {
         // If this is a DefPathHash from an upstream crate, let the CrateStore map
         // it to a DefId.
         let cstore = CStore::from_tcx(tcx.tcx);
-        let cnum = cstore.stable_crate_id_to_crate_num(stable_crate_id);
+        let cnum = *tcx
+            .untracked()
+            .stable_crate_ids
+            .read()
+            .get(&stable_crate_id)
+            .unwrap_or_else(|| bug!("uninterned StableCrateId: {stable_crate_id:?}"));
+        assert_ne!(cnum, LOCAL_CRATE);
         let def_index = cstore.get_crate_data(cnum).def_path_hash_to_def_index(hash);
         DefId { krate: cnum, index: def_index }
     };