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.
This commit is contained in:
Michael Woerister 2021-07-20 14:18:37 +02:00
parent 5445715c20
commit 2b60338ee9
8 changed files with 18 additions and 25 deletions

View file

@ -336,7 +336,11 @@ impl DepNodeExt for DepNode {
/// has been removed.
fn extract_def_id(&self, tcx: TyCtxt<'tcx>) -> Option<DefId> {
if self.kind.can_reconstruct_query_key() {
tcx.on_disk_cache.as_ref()?.def_path_hash_to_def_id(tcx, DefPathHash(self.hash.into()))
Some(
tcx.on_disk_cache
.as_ref()?
.def_path_hash_to_def_id(tcx, DefPathHash(self.hash.into())),
)
} else {
None
}