diff options
| -rw-r--r-- | src/librustc/ich/hcx.rs | 8 | ||||
| -rw-r--r-- | src/librustc/ich/impls_hir.rs | 25 | ||||
| -rw-r--r-- | src/librustc_hir/stable_hash_impls.rs | 6 |
3 files changed, 12 insertions, 27 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 09654478791..34b41c32dab 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::Lrc; use rustc_hir as hir; -use rustc_hir::def_id::{DefId, DefIndex}; +use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_session::Session; use rustc_span::source_map::SourceMap; use rustc_span::symbol::Symbol; @@ -124,15 +124,15 @@ impl<'a> StableHashingContext<'a> { #[inline] pub fn def_path_hash(&self, def_id: DefId) -> DefPathHash { if let Some(def_id) = def_id.as_local() { - self.definitions.def_path_hash(def_id.local_def_index) + self.local_def_path_hash(def_id) } else { self.cstore.def_path_hash(def_id) } } #[inline] - pub fn local_def_path_hash(&self, def_index: DefIndex) -> DefPathHash { - self.definitions.def_path_hash(def_index) + pub fn local_def_path_hash(&self, def_id: LocalDefId) -> DefPathHash { + self.definitions.def_path_hash(def_id.local_def_index) } #[inline] diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 205eadf227c..1722b29266a 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -6,7 +6,7 @@ use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext}; use rustc_attr as attr; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; use rustc_hir as hir; -use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; +use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX}; use smallvec::SmallVec; use std::mem; @@ -21,7 +21,7 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> { NodeIdHashingMode::HashDefPath => { let hir::HirId { owner, local_id } = hir_id; - hcx.local_def_path_hash(owner.local_def_index).hash_stable(hcx, hasher); + hcx.local_def_path_hash(owner).hash_stable(hcx, hasher); local_id.hash_stable(hcx, hasher); } } @@ -116,8 +116,8 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> { } #[inline] - fn local_def_path_hash(&self, def_index: DefIndex) -> DefPathHash { - self.local_def_path_hash(def_index) + fn local_def_path_hash(&self, def_id: LocalDefId) -> DefPathHash { + self.local_def_path_hash(def_id) } } @@ -197,21 +197,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::BodyId { } } -impl<'a> HashStable<StableHashingContext<'a>> for hir::def_id::DefIndex { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - hcx.local_def_path_hash(*self).hash_stable(hcx, hasher); - } -} - -impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::def_id::DefIndex { - type KeyType = DefPathHash; - - #[inline] - fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash { - hcx.local_def_path_hash(*self) - } -} - impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { @@ -231,7 +216,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate { let import_keys = import_ids .iter() - .map(|hir_id| (hcx.local_def_path_hash(hir_id.owner.local_def_index), hir_id.local_id)) + .map(|hir_id| (hcx.local_def_path_hash(hir_id.owner), hir_id.local_id)) .collect(); (hcx.def_path_hash(*def_id), import_keys) } diff --git a/src/librustc_hir/stable_hash_impls.rs b/src/librustc_hir/stable_hash_impls.rs index bdfdd76d1f9..996b3108969 100644 --- a/src/librustc_hir/stable_hash_impls.rs +++ b/src/librustc_hir/stable_hash_impls.rs @@ -5,7 +5,7 @@ use crate::hir::{ VisibilityKind, }; use crate::hir_id::{HirId, ItemLocalId}; -use rustc_span::def_id::{DefIndex, DefPathHash}; +use rustc_span::def_id::{DefPathHash, LocalDefId}; /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro @@ -21,7 +21,7 @@ pub trait HashStableContext: fn hash_hir_ty(&mut self, _: &Ty<'_>, hasher: &mut StableHasher); fn hash_hir_visibility_kind(&mut self, _: &VisibilityKind<'_>, hasher: &mut StableHasher); fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F); - fn local_def_path_hash(&self, def_index: DefIndex) -> DefPathHash; + fn local_def_path_hash(&self, def_id: LocalDefId) -> DefPathHash; } impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId { @@ -29,7 +29,7 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId { #[inline] fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) { - let def_path_hash = hcx.local_def_path_hash(self.owner.local_def_index); + let def_path_hash = hcx.local_def_path_hash(self.owner); (def_path_hash, self.local_id) } } |
