Generalize StableHashingContext as a trait #53084
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Background
PR #52475 improves the infinite loop detection algorithm during compile time evaluation, the algorithm relies on
HashStable
to detect whether two evaluation contexts are potentially identical as an optimization to avoid unnecessarily cloning the entire evaluation context.The Problem
The current implementation of
HashStable
throughout the compiler relies on a hashing context represented byStableHashingContext
. This context however provides no way to resolveAllocId
s toAllocations
, so the implementation ofHashStable
forAllocId
relies on theglobal
TyCtxt::alloc_map
, thus bypassing the current transient allocations inMemory
. This has the inconvenient side effect of increasing the probability of hash conflicts, thus increasing the probability of unnecessarily cloning the evaluation context.The Solution
@oli-obk suggested
StableHashingContext
could be generalized as a trait that could be implemented forMemory
, which would provide a way to directly resolveAllocId
s.The text was updated successfully, but these errors were encountered: