You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid generating by-move coroutine MIR during parameter deduction
The `mir_keys` query generates additional by-move MIR bodies (that
aren't in the HIR) for coroutine-closures. However, computing such
bodies (indeed, merely determining whether such a body needs to be
generated) before typeck is complete can lead to cycles.
In order to compute a function's ABI (which happens amongst other things
during CTFE), it may be necessary to look at the function's body in
order to deduce certain codegen optimization attributes for its
indirectly-passed parameters beyond what can be determined purely from
its signature (namely today `ArgAttribute::ReadOnly` and
`ArgAttribute::CapturesNone`).
Prior to this patch, such parameter deduction is bypassed for functions
that have no body (eg in trait or extern declarations) by calling upon
the `is_mir_available` query, which in turn calls upon `mir_keys`, and
cycles can ensue. This patch breaks such cycles by using instead a new
query, `is_mir_available_for_hir`, which itself calls another new query
`mir_keys_for_hir` that only considers MIR bodies for items that exist
in the HIR (ie without generating the additional by-move MIR bodies for
coroutine closures). Clearly theis cannot change overall behaviour, as
`is_mir_available` could never have been called with the `DefId` of an
as-yet not generated item.
In order to minimize duplicated effort, the existing `mir_keys` query
reuses the result from the new `mir_keys_for_hir` query, modifying it
only if there are coroutine-closures for which by-move MIR bodies need
be generated.
0 commit comments