Don't hash non-fresh Ty::Infer or RegionKind::Infer

This commit is contained in:
Michael Goulet 2022-10-19 00:19:28 +00:00
parent 4b8f431995
commit 91af4f5d0b
3 changed files with 9 additions and 7 deletions

View File

@ -198,9 +198,11 @@ impl<'tcx> CtxtInterners<'tcx> {
.intern(kind, |kind| { .intern(kind, |kind| {
let flags = super::flags::FlagComputation::for_kind(&kind); let flags = super::flags::FlagComputation::for_kind(&kind);
// It's impossible to hash inference regions (and will ICE), so we don't need to try to cache them. // It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
// Without incremental, we rarely stable-hash types, so let's not do it proactively. // Without incremental, we rarely stable-hash types, so let's not do it proactively.
let stable_hash = if flags.flags.intersects(TypeFlags::HAS_RE_INFER) let stable_hash = if flags
.flags
.intersects(TypeFlags::HAS_RE_INFER | TypeFlags::HAS_TY_INFER)
|| sess.opts.incremental.is_none() || sess.opts.incremental.is_none()
{ {
Fingerprint::ZERO Fingerprint::ZERO

View File

@ -675,9 +675,9 @@ impl<CTX> HashStable<CTX> for InferTy {
use InferTy::*; use InferTy::*;
discriminant(self).hash_stable(ctx, hasher); discriminant(self).hash_stable(ctx, hasher);
match self { match self {
TyVar(v) => v.as_u32().hash_stable(ctx, hasher), TyVar(_) | IntVar(_) | FloatVar(_) => {
IntVar(v) => v.index.hash_stable(ctx, hasher), panic!("inference variables should not be hashed: {self:?}")
FloatVar(v) => v.index.hash_stable(ctx, hasher), }
FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(ctx, hasher), FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(ctx, hasher),
} }
} }

View File

@ -1332,8 +1332,8 @@ where
RePlaceholder(p) => { RePlaceholder(p) => {
p.hash_stable(hcx, hasher); p.hash_stable(hcx, hasher);
} }
ReVar(reg) => { ReVar(_) => {
reg.hash_stable(hcx, hasher); panic!("region variables should not be hashed: {self:?}")
} }
} }
} }