Show a more informative panic message when DefPathHash does not exist

This should hopefully make it easier to debug incremental compilation
bugs like #93096 without affecting performance.
This commit is contained in:
Aaron Hill 2022-01-19 17:36:44 -05:00
parent 5e57faa78a
commit 70d36a05bc
No known key found for this signature in database
GPG key ID: B4087E510E98B164
4 changed files with 17 additions and 6 deletions

View file

@ -266,7 +266,9 @@ impl DepNodeExt for DepNode {
/// has been removed.
fn extract_def_id<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<DefId> {
if self.kind.fingerprint_style(tcx) == FingerprintStyle::DefPathHash {
Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into())))
Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into()), &mut || {
panic!("Failed to extract DefId: {:?} {}", self.kind, self.hash)
}))
} else {
None
}