Skip to content

Commit fffb99e

Browse files
committed
rustc: Avoid HashStable for DefIndex queries
I'm not 100% familiar with this trait and this location, but it looks like there's a default implementation of `DepNodeParams` for anything that implements `HashStable`, but types like `DefId` which have precalculated hashes bypass this default implementation for a speedier one. This commit applies what I believe is the same optimization to `DefIndex`, looking up the local hash for it rather than going through the full `HashStable` rigamarole cc #44575
1 parent 0701b37 commit fffb99e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,18 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIndex,
645645
}
646646
}
647647

648+
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIndex,) {
649+
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
650+
651+
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
652+
tcx.hir.definitions().def_path_hash(self.0).0
653+
}
654+
655+
fn to_debug_str(&self, _tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
656+
format!("{:?}", *self)
657+
}
658+
}
659+
648660
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, DefId) {
649661
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
650662

0 commit comments

Comments
 (0)