about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/on_disk_cache.rs
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2021-07-20 14:18:37 +0200
committerMichael Woerister <michaelwoerister@posteo>2021-09-14 13:56:33 +0200
commit2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da (patch)
tree216ec1bf1acf3a44da1cff6f545c0c903cedfc4b /compiler/rustc_query_impl/src/on_disk_cache.rs
parent5445715c20dbedbe9b14d185937ab1ebcd81118e (diff)
downloadrust-2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da.tar.gz
rust-2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da.zip
Make DefPathHash->DefId panic for if the mapping fails.
We only use this mapping for cases where we know that it must succeed.
Letting it panic otherwise makes it harder to use the API in unsupported
ways.
Diffstat (limited to 'compiler/rustc_query_impl/src/on_disk_cache.rs')
-rw-r--r--compiler/rustc_query_impl/src/on_disk_cache.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs
index 82cc81ec4c3..f9456a6f2cd 100644
--- a/compiler/rustc_query_impl/src/on_disk_cache.rs
+++ b/compiler/rustc_query_impl/src/on_disk_cache.rs
@@ -361,7 +361,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
         })
     }
 
-    fn def_path_hash_to_def_id(&self, tcx: TyCtxt<'tcx>, hash: DefPathHash) -> Option<DefId> {
+    fn def_path_hash_to_def_id(&self, tcx: TyCtxt<'tcx>, hash: DefPathHash) -> DefId {
         debug!("def_path_hash_to_def_id({:?})", hash);
 
         let stable_crate_id = hash.stable_crate_id();
@@ -369,9 +369,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
         // If this is a DefPathHash from the local crate, we can look up the
         // DefId in the tcx's `Definitions`.
         if stable_crate_id == tcx.sess.local_stable_crate_id() {
-            tcx.definitions_untracked()
-                .local_def_path_hash_to_def_id(hash)
-                .map(LocalDefId::to_def_id)
+            tcx.definitions_untracked().local_def_path_hash_to_def_id(hash).to_def_id()
         } else {
             // If this is a DefPathHash from an upstream crate, let the CrateStore map
             // it to a DefId.
@@ -779,12 +777,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId {
         // If we get to this point, then all of the query inputs were green,
         // which means that the definition with this hash is guaranteed to
         // still exist in the current compilation session.
-        Ok(d.tcx()
-            .on_disk_cache
-            .as_ref()
-            .unwrap()
-            .def_path_hash_to_def_id(d.tcx(), def_path_hash)
-            .unwrap())
+        Ok(d.tcx().on_disk_cache.as_ref().unwrap().def_path_hash_to_def_id(d.tcx(), def_path_hash))
     }
 }