about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/dep_graph/dep_node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/dep_graph/dep_node.rs')
-rw-r--r--compiler/rustc_middle/src/dep_graph/dep_node.rs38
1 files changed, 6 insertions, 32 deletions
diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs
index eded3b3eedc..1fa0c6babab 100644
--- a/compiler/rustc_middle/src/dep_graph/dep_node.rs
+++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs
@@ -62,7 +62,7 @@ use crate::ty::TyCtxt;
 use rustc_data_structures::fingerprint::Fingerprint;
 use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
 use rustc_hir::definitions::DefPathHash;
-use rustc_hir::{HirId, ItemLocalId};
+use rustc_hir::HirId;
 use rustc_query_system::dep_graph::FingerprintStyle;
 use rustc_span::symbol::Symbol;
 use std::hash::Hash;
@@ -280,7 +280,7 @@ impl DepNodeExt for DepNode {
         let kind = dep_kind_from_label_string(label)?;
 
         match kind.fingerprint_style(tcx) {
-            FingerprintStyle::Opaque | FingerprintStyle::HirId => Err(()),
+            FingerprintStyle::Opaque => Err(()),
             FingerprintStyle::Unit => Ok(DepNode::new_no_params(tcx, kind)),
             FingerprintStyle::DefPathHash => {
                 Ok(DepNode::from_def_path_hash(tcx, def_path_hash, kind))
@@ -408,7 +408,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
 impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
     #[inline(always)]
     fn fingerprint_style() -> FingerprintStyle {
-        FingerprintStyle::HirId
+        FingerprintStyle::Opaque
     }
 
     // We actually would not need to specialize the implementation of this
@@ -417,36 +417,10 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
     #[inline(always)]
     fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
         let HirId { owner, local_id } = *self;
-        let def_path_hash = tcx.def_path_hash(owner.to_def_id());
-        Fingerprint::new(
-            // `owner` is local, so is completely defined by the local hash
-            def_path_hash.local_hash(),
-            local_id.as_u32().into(),
-        )
-    }
 
-    #[inline(always)]
-    fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
-        let HirId { owner, local_id } = *self;
-        format!("{}.{}", tcx.def_path_str(owner.to_def_id()), local_id.as_u32())
-    }
+        let def_path_hash = tcx.def_path_hash(owner.to_def_id());
+        let local_id = Fingerprint::from_smaller_hash(local_id.as_u32().into());
 
-    #[inline(always)]
-    fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
-        if dep_node.kind.fingerprint_style(tcx) == FingerprintStyle::HirId {
-            let (local_hash, local_id) = Fingerprint::from(dep_node.hash).as_value();
-            let def_path_hash = DefPathHash::new(tcx.sess.local_stable_crate_id(), local_hash);
-            let owner = tcx
-                .def_path_hash_to_def_id(def_path_hash, &mut || {
-                    panic!("Failed to extract HirId: {:?} {}", dep_node.kind, dep_node.hash)
-                })
-                .expect_local();
-            let local_id = local_id
-                .try_into()
-                .unwrap_or_else(|_| panic!("local id should be u32, found {:?}", local_id));
-            Some(HirId { owner, local_id: ItemLocalId::from_u32(local_id) })
-        } else {
-            None
-        }
+        def_path_hash.0.combine(local_id)
     }
 }