-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform async ResumeTy in generator transform
- 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 <#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<'_>`.
- Loading branch information
Showing
10 changed files
with
644 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,7 @@ symbols! { | |
Capture, | ||
Center, | ||
Clone, | ||
Context, | ||
Continue, | ||
Copy, | ||
Count, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// MIR for `a::{closure#0}` 0 generator_resume | ||
/* generator_layout = GeneratorLayout { | ||
field_tys: {}, | ||
variant_fields: { | ||
Unresumed(0): [], | ||
Returned (1): [], | ||
Panicked (2): [], | ||
}, | ||
storage_conflicts: BitMatrix(0x0) {}, | ||
} */ | ||
|
||
fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:10:14: 10:16]>, _2: &mut Context<'_>) -> Poll<()> { | ||
debug _task_context => _4; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
let mut _0: std::task::Poll<()>; // return place in scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
let mut _3: (); // in scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
let mut _4: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
let mut _5: u32; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
|
||
bb0: { | ||
_5 = discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:10:14: 10:16]))); // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3]; // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
} | ||
|
||
bb1: { | ||
_4 = move _2; // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
_3 = const (); // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
Deinit(_0); // scope 0 at $DIR/async_await.rs:+0:16: +0:16 | ||
((_0 as Ready).0: ()) = move _3; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 | ||
discriminant(_0) = 0; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 | ||
discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:10:14: 10:16]))) = 1; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 | ||
return; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 | ||
} | ||
|
||
bb2: { | ||
assert(const false, "`async fn` resumed after completion") -> bb2; // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
} | ||
|
||
bb3: { | ||
unreachable; // scope 0 at $DIR/async_await.rs:+0:14: +0:16 | ||
} | ||
} |
Oops, something went wrong.