Use a dyn Debug trait object instead of a closure.

Simplifies the API a bit.
This commit is contained in:
Oli Scherer
2024-03-27 08:05:24 +00:00
parent b13a71a2e7
commit 2d4b7f287d
4 changed files with 24 additions and 13 deletions

View File

@@ -194,9 +194,10 @@ impl DepNodeExt for DepNode {
/// has been removed.
fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
if tcx.fingerprint_style(self.kind) == FingerprintStyle::DefPathHash {
Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into()), &mut || {
panic!("Failed to extract DefId: {:?} {}", self.kind, self.hash)
}))
Some(tcx.def_path_hash_to_def_id(
DefPathHash(self.hash.into()),
&("Failed to extract DefId", self.kind, self.hash),
))
} else {
None
}
@@ -390,9 +391,10 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split();
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
let def_id = tcx
.def_path_hash_to_def_id(def_path_hash, &mut || {
panic!("Failed to extract HirId: {:?} {}", dep_node.kind, dep_node.hash)
})
.def_path_hash_to_def_id(
def_path_hash,
&("Failed to extract HirId", dep_node.kind, dep_node.hash),
)
.expect_local();
let local_id = local_id
.as_u64()