Skip to content

Commit

Permalink
Rollup merge of rust-lang#91892 - compiler-errors:fix-inferty-hashtab…
Browse files Browse the repository at this point in the history
…le, r=dtolnay

Fix HashStable implementation on InferTy

HashStable impl forgot to hash the discriminant.

Fixes rust-lang#91807
  • Loading branch information
matthiaskrgr authored Dec 14, 2021
2 parents 3a42dc8 + 75729af commit d0e6bb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ impl<CTX> HashStable<CTX> for FloatTy {
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),
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/traits/vtable/issue-91807.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit d0e6bb7

Please sign in to comment.