Description
I'm interested in removing the TyKind::CoroutineWitness
variant from the type system.
Coroutine witnesses are a synthetic generic arg given to coroutines to stall the computation of the "witness" types of the coroutine (which are the variables live across await points) by initially being populated with an infer var, then getting inferred to a tuple after analysis was run at the end of typeck. (We do similar things for closures, for example, for their upvars.)
However, since #101692, the tuple was replaced with a TyKind::CoroutineWitness
which defers that computation further to MIR. However, we still use an infer var to stall obligations that would rely on using these witness types (and only unify with with a CoroutineWitness
at the end of typeck), since if we try to query for the witnesses during typeck in the same body that defines the coroutine, we would encounter query cycles.
#138845 introduced a more appropriate way to stall oblgiations that rely on coroutine witnesses which is currently used in the new solver. I'd like to use this in the old solver, and eventually rip out the TyKind::CoroutineWitness
altogether, since it's redundant with TyKind::Coroutine
which stores the same def-id and args as the former.
This is a tracking issue to make sure that I follow up with the work.
Rough timeline:
- Track coroutines that must be stalled in
TypingMode
: Properly stall coroutine witnesses in new solver #138845 - Stop using infer vars to stall coroutine witnesses in old solver: Unify
CoroutineWitness
sooner in typeck, and stall coroutine obligations based off ofTypingEnv
#141762 - Fix the way we handle coroutines in drop live outlives machinery
- Remove
TyKind::CoroutineWitness
- profit