Skip to content

Properly stall coroutine witnesses in new solver#138845

Merged
bors merged 6 commits intorust-lang:masterfrom
compiler-errors:stall-generators
Apr 24, 2025
Merged

Properly stall coroutine witnesses in new solver#138845
bors merged 6 commits intorust-lang:masterfrom
compiler-errors:stall-generators

Conversation

@compiler-errors
Copy link
Contributor

@compiler-errors compiler-errors commented Mar 22, 2025

Fixes rust-lang/trait-system-refactor-initiative#82.

Using an infer var for the witness meant that if we constrain the infer var during writeback and then try to normalize during writeback, after the coroutine witness has been plugged into the coroutine type - which we do with the new solver - we may encounter a query cycle due to trying to fetch the coroutine witness types.

This PR changes the AnalysisInBody typing mode to track all coroutines being defined by the current body during typeck, and forces any auto trait and Copy obligations that would require fetching the hidden types of these coroutines to be forced ambiguous. This also introduces a new proof tree visitor which detects which obligations should be stalled due to bottoming out in one of these ambiguous obligations, so we can re-check them after borrowck (as is done with the old solver).

This PR shouldn't have functional changes, but post-mortem seems to have introduced a perf regression. Looking at the code, I don't see much of a reason why this would be the case. We don't call the new query when the old solver is active, nor should be be visiting any of this new unstalling code in the old solver.

r? lcnr

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) F-autodiff `#![feature(autodiff)]` merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalizing in writeback causes cycle errors with generators

8 participants