diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-14 10:21:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-14 10:21:07 +0100 |
| commit | d0e6bb707663d03e6cbbe3e0c5168327b138a405 (patch) | |
| tree | 4edcb38cbfe400ae93099942f82a706b0c8a9592 | |
| parent | 3a42dc8be1226740495400ce189b2db6087610ac (diff) | |
| parent | 75729afcc040f8df101baebc7eba438dfb044d72 (diff) | |
| download | rust-d0e6bb707663d03e6cbbe3e0c5168327b138a405.tar.gz rust-d0e6bb707663d03e6cbbe3e0c5168327b138a405.zip | |
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
| -rw-r--r-- | compiler/rustc_type_ir/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/traits/vtable/issue-91807.rs | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 91dbbec782f..f11c93e9339 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -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), diff --git a/src/test/ui/traits/vtable/issue-91807.rs b/src/test/ui/traits/vtable/issue-91807.rs new file mode 100644 index 00000000000..f435ff09dc3 --- /dev/null +++ b/src/test/ui/traits/vtable/issue-91807.rs @@ -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); +} |
