提交 6dbd8464 编写于 作者: M Michael Woerister

Erase/anonymize regions while computing TypeId hash.

上级 d07dd4ab
......@@ -214,6 +214,11 @@ pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 {
let mut hasher = StableHasher::new();
let mut hcx = StableHashingContext::new(self);
// We want the type_id be independent of the types free regions, so we
// erase them. The erase_regions() call will also anonymize bound
// regions, which is desirable too.
let ty = self.erase_regions(&ty);
hcx.while_hashing_spans(false, |hcx| {
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
ty.hash_stable(hcx, &mut hasher);
......
......@@ -45,6 +45,11 @@ fn main() {
assert!(g != h);
assert!(g != i);
assert!(h != i);
// Make sure lifetime anonymization handles nesting correctly
let j = TypeId::of::<fn(for<'a> fn(&'a isize) -> &'a usize)>();
let k = TypeId::of::<fn(for<'b> fn(&'b isize) -> &'b usize)>();
assert_eq!(j, k);
}
// Boxed unboxed closures
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册