Files
rust/compiler/rustc_mir_transform
Jacob Pratt e29599472e Rollup merge of #157166 - cjgillot:retype-context-after, r=oli-obk
Change type of async context parameter after state transform.

`Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`.

In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder.

Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`.

Based on https://github.com/rust-lang/rust/pull/156875.
2026-06-09 16:52:53 -04:00
..