Skip to content

Commit e7d7d91

Browse files
committed
Removed use of TypeIdHasher in debuginfo and replaced it with StableHasher. Also corrected erroneous mention of TypeIdHasher in implementation of HashStable trait.
1 parent 295d980 commit e7d7d91

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ for ty::RegionKind {
132132
ty::ReLateBound(..) |
133133
ty::ReVar(..) |
134134
ty::ReSkolemized(..) => {
135-
bug!("TypeIdHasher: unexpected region {:?}", *self)
135+
bug!("StableHasher: unexpected region {:?}", *self)
136136
}
137137
}
138138
}

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ use llvm::{self, ValueRef};
2323
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
2424
DICompositeType, DILexicalBlock, DIFlags};
2525

26+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2627
use rustc::hir::TransFnAttrFlags;
2728
use rustc::hir::def::CtorKind;
2829
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
29-
use rustc::ty::fold::TypeVisitor;
30-
use rustc::ty::util::TypeIdHasher;
31-
use rustc::ich::Fingerprint;
30+
use rustc::ich::{Fingerprint, NodeIdHashingMode};
3231
use rustc::ty::Instance;
3332
use common::CodegenCx;
3433
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
@@ -144,9 +143,15 @@ impl<'tcx> TypeMap<'tcx> {
144143

145144
// The hasher we are using to generate the UniqueTypeId. We want
146145
// something that provides more than the 64 bits of the DefaultHasher.
147-
let mut type_id_hasher = TypeIdHasher::<Fingerprint>::new(cx.tcx);
148-
type_id_hasher.visit_ty(type_);
149-
let unique_type_id = type_id_hasher.finish().to_hex();
146+
let mut hasher = StableHasher::<Fingerprint>::new();
147+
let mut hcx = cx.tcx.create_stable_hashing_context();
148+
let type_ = cx.tcx.erase_regions(&type_);
149+
hcx.while_hashing_spans(false, |hcx| {
150+
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
151+
type_.hash_stable(hcx, &mut hasher);
152+
});
153+
});
154+
let unique_type_id = hasher.finish().to_hex();
150155

151156
let key = self.unique_id_interner.intern(&unique_type_id);
152157
self.type_to_unique_id.insert(type_, UniqueTypeId(key));

0 commit comments

Comments
 (0)