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
This commit is contained in:
Matthias Krüger 2021-12-14 10:21:07 +01:00 committed by GitHub
commit d0e6bb7076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -559,6 +559,7 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
impl<CTX> HashStable<CTX> for InferTy {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
use InferTy::*;
discriminant(self).hash_stable(ctx, hasher);
match self {
TyVar(v) => v.as_u32().hash_stable(ctx, hasher),
IntVar(v) => v.index.hash_stable(ctx, hasher),

View File

@ -0,0 +1,17 @@
// check-pass
// incremental
struct Struct<T>(T);
impl<T> std::ops::Deref for Struct<T> {
type Target = dyn Fn(T);
fn deref(&self) -> &Self::Target {
unimplemented!()
}
}
fn main() {
let f = Struct(Default::default());
f(0);
f(0);
}