提交 a9fa8cc0 编写于 作者: B bors

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
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
use hir::def_id::{CrateNum, DefId}; use hir::def_id::{CrateNum, DefId};
use hir::map::DefPathHash; use hir::map::DefPathHash;
use hir::HirId; use hir::{HirId, ItemLocalId};
use ich::Fingerprint; use ich::Fingerprint;
use ty::{TyCtxt, Instance, InstanceDef}; use ty::{TyCtxt, Instance, InstanceDef};
...@@ -682,6 +682,25 @@ fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { ...@@ -682,6 +682,25 @@ fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (HirId,) {
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
let (HirId {
owner,
local_id: ItemLocalId(local_id),
},) = *self;
let def_path_hash = tcx.def_path_hash(DefId::local(owner));
let local_id = Fingerprint::from_smaller_hash(local_id as u64);
def_path_hash.0.combine(local_id)
}
}
/// A "work product" corresponds to a `.o` (or other) file that we /// A "work product" corresponds to a `.o` (or other) file that we
/// save in between runs. These ids do not have a DefId but rather /// save in between runs. These ids do not have a DefId but rather
/// some independent path or string that persists between runs without /// some independent path or string that persists between runs without
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册