-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent caching normalization results with a cycle #80246
Prevent caching normalization results with a cycle #80246
Conversation
This avoid the hang/oom from rust-lang#79714
When normalizing a projection which results in a cycle, we would cache the result of `project_type` without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error. Fixes rust-lang#79714, a regresion from rust-lang#79305 caused by the removal of `get_paranoid_cache_value_obligation`.
@@ -90,6 +90,7 @@ impl ProjectionCacheKey<'tcx> { | |||
pub enum ProjectionCacheEntry<'tcx> { | |||
InProgress, | |||
Ambiguous, | |||
Recur, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recur, | |
Recursive, |
I had to read the doc comment on the recur
method to understand what this meant.
/// Indicates that while trying to normalize `key`, `key` was required to | ||
/// be normalized again. Selection or evaluation should eventually report | ||
/// an error here. | ||
pub fn recur(&mut self, key: ProjectionCacheKey<'tcx>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn recur(&mut self, key: ProjectionCacheKey<'tcx>) { | |
pub fn recursive(&mut self, key: ProjectionCacheKey<'tcx>) { |
@bors r+ p=5 rollup=never I would like this to get some testing on master before we promote it to beta (and in short order, beta to stable). The patch has received some amount of eyes on it. |
📌 Commit 2e92b13 has been approved by |
☀️ Test successful - checks-actions |
Backported to 1.49 in #80417, but leaving accepted for beta backport to 1.50 (this landed after that branched). |
…ulacrum [beta] backports This backports the following to 1.49: * Revert change to trait evaluation order rust-lang#80132 * Don't allow `const` to begin a nonterminal rust-lang#80135 * Prevent caching normalization results with a cycle rust-lang#80246 r? `@Mark-Simulacrum`
…ulacrum [beta] backports This backports accepted PRs and switches to bootstrapping from the released compiler: * de-stabilize unsized raw ptr methods for Weak rust-lang#80422 * Use package name for top-level directory in bare tarballs rust-lang#80397 * Prevent caching normalization results with a cycle rust-lang#80246 r? `@Mark-Simulacrum`
…=nikomatsakis Make hitting the recursion limit in projection non-fatal This change was originally made in rust-lang#80246 to avoid future (effectively) infinite loop bugs in projections, but wundergraph relies on rustc recovering here. cc rust-lang#80953 r? `@nikomatsakis`
…ikomatsakis Make hitting the recursion limit in projection non-fatal This change was originally made in rust-lang#80246 to avoid future (effectively) infinite loop bugs in projections, but wundergraph relies on rustc recovering here. cc rust-lang#80953 r? `@nikomatsakis`
…ikomatsakis Make hitting the recursion limit in projection non-fatal This change was originally made in rust-lang#80246 to avoid future (effectively) infinite loop bugs in projections, but wundergraph relies on rustc recovering here. cc rust-lang#80953 r? `@nikomatsakis`
When normalizing a projection which results in a cycle, we would cache the result of
project_type
without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error.get_paranoid_cache_value_obligation
used to add an obligation that resulted in a cycle in this case previously, but was removed by #73905.This PR makes the projection cache not cache the value of a projection if it was ever normalized in a cycle (except in a snapshot that's rolled back).
Fixes #79714.
r? @nikomatsakis