Skip to content

Commit 97026fe

Browse files
committed
rustc: use LocalDefId instead of DefIndex in ich.
1 parent 8fb2a39 commit 97026fe

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

src/librustc/ich/hcx.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::hir;
2-
use crate::hir::def_id::{DefId, DefIndex};
2+
use crate::hir::def_id::{DefId, LocalDefId};
33
use crate::hir::map::DefPathHash;
44
use crate::hir::map::definitions::Definitions;
55
use crate::ich::{self, CachingSourceMapView, Fingerprint};
@@ -139,8 +139,8 @@ impl<'a> StableHashingContext<'a> {
139139
}
140140

141141
#[inline]
142-
pub fn local_def_path_hash(&self, def_index: DefIndex) -> DefPathHash {
143-
self.definitions.def_path_hash(def_index)
142+
pub fn local_def_path_hash(&self, def_id: LocalDefId) -> DefPathHash {
143+
self.definitions.def_path_hash(def_id.index)
144144
}
145145

146146
#[inline]
@@ -238,7 +238,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::HirId {
238238
local_id,
239239
} = *self;
240240

241-
hcx.local_def_path_hash(owner.index).hash_stable(hcx, hasher);
241+
hcx.local_def_path_hash(owner).hash_stable(hcx, hasher);
242242
local_id.hash_stable(hcx, hasher);
243243
}
244244
}
@@ -252,7 +252,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::HirId {
252252
fn to_stable_hash_key(&self,
253253
hcx: &StableHashingContext<'a>)
254254
-> (DefPathHash, hir::ItemLocalId) {
255-
let def_path_hash = hcx.local_def_path_hash(self.owner.index);
255+
let def_path_hash = hcx.local_def_path_hash(self.owner);
256256
(def_path_hash, self.local_id)
257257
}
258258
}

src/librustc/ich/impls_hir.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -327,22 +327,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::BodyId {
327327
}
328328
}
329329

330-
impl<'a> HashStable<StableHashingContext<'a>> for hir::def_id::DefIndex {
331-
332-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
333-
hcx.local_def_path_hash(*self).hash_stable(hcx, hasher);
334-
}
335-
}
336-
337-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::def_id::DefIndex {
338-
type KeyType = DefPathHash;
339-
340-
#[inline]
341-
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
342-
hcx.local_def_path_hash(*self)
343-
}
344-
}
345-
346330
impl<'a> HashStable<StableHashingContext<'a>> for crate::middle::lang_items::LangItem {
347331
fn hash_stable(&self, _: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
348332
::std::hash::Hash::hash(self, hasher);
@@ -376,7 +360,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
376360

377361
let import_keys = import_ids.iter()
378362
.map(|node_id| hcx.node_to_hir_id(*node_id))
379-
.map(|hir_id| (hcx.local_def_path_hash(hir_id.owner.index), hir_id.local_id))
363+
.map(|hir_id| (hcx.local_def_path_hash(hir_id.owner), hir_id.local_id))
380364
.collect();
381365
(hcx.def_path_hash(*def_id), import_keys)
382366
}

0 commit comments

Comments
 (0)