Skip to content

Commit a9fa8cc

Browse files
committed
Auto merge of #44335 - arielb1:node-hashing, r=alexcrichton
Avoid hashing when creating a DepNode from a HirId Instead, combine the already-present DefPathHash with the 32-bit ItemLocalIndex. Should fix #44323. r? @alexcrichton
2 parents dee6d0f + d14ed92 commit a9fa8cc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/librustc/dep_graph/dep_node.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
6363
use hir::def_id::{CrateNum, DefId};
6464
use hir::map::DefPathHash;
65-
use hir::HirId;
65+
use hir::{HirId, ItemLocalId};
6666

6767
use ich::Fingerprint;
6868
use ty::{TyCtxt, Instance, InstanceDef};
@@ -682,6 +682,25 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIdList
682682
}
683683
}
684684

685+
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (HirId,) {
686+
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
687+
688+
// We actually would not need to specialize the implementation of this
689+
// method but it's faster to combine the hashes than to instantiate a full
690+
// hashing context and stable-hashing state.
691+
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
692+
let (HirId {
693+
owner,
694+
local_id: ItemLocalId(local_id),
695+
},) = *self;
696+
697+
let def_path_hash = tcx.def_path_hash(DefId::local(owner));
698+
let local_id = Fingerprint::from_smaller_hash(local_id as u64);
699+
700+
def_path_hash.0.combine(local_id)
701+
}
702+
}
703+
685704
/// A "work product" corresponds to a `.o` (or other) file that we
686705
/// save in between runs. These ids do not have a DefId but rather
687706
/// some independent path or string that persists between runs without

0 commit comments

Comments
 (0)