Skip to content

Commit d0e6bb7

Browse files
authored
Rollup merge of #91892 - compiler-errors:fix-inferty-hashtable, r=dtolnay
Fix HashStable implementation on InferTy HashStable impl forgot to hash the discriminant. Fixes #91807
2 parents 3a42dc8 + 75729af commit d0e6bb7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: compiler/rustc_type_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ impl<CTX> HashStable<CTX> for FloatTy {
559559
impl<CTX> HashStable<CTX> for InferTy {
560560
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
561561
use InferTy::*;
562+
discriminant(self).hash_stable(ctx, hasher);
562563
match self {
563564
TyVar(v) => v.as_u32().hash_stable(ctx, hasher),
564565
IntVar(v) => v.index.hash_stable(ctx, hasher),

Diff for: src/test/ui/traits/vtable/issue-91807.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
// incremental
3+
4+
struct Struct<T>(T);
5+
6+
impl<T> std::ops::Deref for Struct<T> {
7+
type Target = dyn Fn(T);
8+
fn deref(&self) -> &Self::Target {
9+
unimplemented!()
10+
}
11+
}
12+
13+
fn main() {
14+
let f = Struct(Default::default());
15+
f(0);
16+
f(0);
17+
}

0 commit comments

Comments
 (0)