mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
96931a787a
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
18 lines
493 B
Rust
18 lines
493 B
Rust
// This test makes sure that the generator MIR pass eliminates all calls to
|
|
// `get_context`, and that the MIR argument type for an async fn and all locals
|
|
// related to `yield` are `&mut Context`, and its return type is `Poll`.
|
|
|
|
// edition:2018
|
|
// compile-flags: -C panic=abort
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
// EMIT_MIR async_await.a-{closure#0}.generator_resume.0.mir
|
|
async fn a() {}
|
|
|
|
// EMIT_MIR async_await.b-{closure#0}.generator_resume.0.mir
|
|
pub async fn b() {
|
|
a().await;
|
|
a().await
|
|
}
|