-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fix coroutine MIR saved local remapping #158655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dingxiangfei2009
wants to merge
2
commits into
rust-lang:main
Choose a base branch
from
dingxiangfei2009:fix-remapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
220 changes: 220 additions & 0 deletions
220
tests/mir-opt/coroutine/async_drop.array-{closure#0}.ElaborateDrops.diff
This file contains hidden or 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,220 @@ | ||
| - // MIR for `array::{closure#0}` before ElaborateDrops | ||
| + // MIR for `array::{closure#0}` after ElaborateDrops | ||
|
|
||
| fn array::{closure#0}(_1: {async fn body of array()}, _2: std::future::ResumeTy) -> () | ||
| yields () | ||
| { | ||
| debug _task_context => _2; | ||
| let mut _0: (); | ||
| let _3: [AsyncInt; 2]; | ||
| let mut _4: AsyncInt; | ||
| let mut _5: AsyncInt; | ||
| + let mut _6: impl std::future::Future<Output = ()>; | ||
| + let mut _7: std::future::ResumeTy; | ||
| + let mut _8: std::task::Poll<()>; | ||
| + let mut _9: isize; | ||
| + let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; | ||
| + let mut _11: &mut std::task::Context<'_>; | ||
| + let mut _12: std::future::ResumeTy; | ||
| + let mut _13: &mut impl std::future::Future<Output = ()>; | ||
| + let mut _14: std::future::ResumeTy; | ||
| + let mut _15: std::task::Poll<()>; | ||
| + let mut _16: isize; | ||
| + let mut _17: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; | ||
| + let mut _18: &mut std::task::Context<'_>; | ||
| + let mut _19: std::future::ResumeTy; | ||
| + let mut _20: &mut impl std::future::Future<Output = ()>; | ||
| + let mut _21: std::pin::Pin<&mut [AsyncInt; 2]>; | ||
| + let mut _22: &mut [AsyncInt; 2]; | ||
| scope 1 { | ||
| debug array => _3; | ||
| } | ||
|
|
||
| bb0: { | ||
| StorageLive(_3); | ||
| StorageLive(_4); | ||
| _4 = AsyncInt(const 1_i32); | ||
| StorageLive(_5); | ||
| _5 = AsyncInt(const 2_i32); | ||
| _3 = [move _4, move _5]; | ||
| - drop(_5) -> [return: bb1, unwind: bb9, drop: bb5]; | ||
| + goto -> bb1; | ||
| } | ||
|
|
||
| bb1: { | ||
| StorageDead(_5); | ||
| - drop(_4) -> [return: bb2, unwind: bb10, drop: bb6]; | ||
| + goto -> bb2; | ||
| } | ||
|
|
||
| bb2: { | ||
| StorageDead(_4); | ||
| _0 = const (); | ||
| - drop(_3) -> [return: bb3, unwind: bb11, drop: bb7]; | ||
| + goto -> bb34; | ||
| } | ||
|
|
||
| bb3: { | ||
| StorageDead(_3); | ||
| - drop(_1) -> [return: bb4, drop: bb8, unwind continue]; | ||
| + drop(_1) -> [return: bb4, unwind: bb12]; | ||
| } | ||
|
|
||
| bb4: { | ||
| return; | ||
| } | ||
|
|
||
| bb5: { | ||
| StorageDead(_5); | ||
| - drop(_4) -> [return: bb6, unwind: bb13]; | ||
| + goto -> bb6; | ||
| } | ||
|
|
||
| bb6: { | ||
| StorageDead(_4); | ||
| goto -> bb7; | ||
| } | ||
|
|
||
| bb7: { | ||
| StorageDead(_3); | ||
| - drop(_1) -> [return: bb8, unwind continue]; | ||
| + goto -> bb8; | ||
| } | ||
|
|
||
| bb8: { | ||
| coroutine_drop; | ||
| } | ||
|
|
||
| bb9 (cleanup): { | ||
| StorageDead(_5); | ||
| - drop(_4) -> [return: bb10, unwind terminate(cleanup)]; | ||
| + goto -> bb10; | ||
| } | ||
|
|
||
| bb10 (cleanup): { | ||
| StorageDead(_4); | ||
| goto -> bb11; | ||
| } | ||
|
|
||
| bb11 (cleanup): { | ||
| StorageDead(_3); | ||
| drop(_1) -> [return: bb12, unwind terminate(cleanup)]; | ||
| } | ||
|
|
||
| bb12 (cleanup): { | ||
| resume; | ||
| } | ||
|
|
||
| bb13 (cleanup): { | ||
| StorageDead(_4); | ||
| StorageDead(_3); | ||
| - drop(_1) -> [return: bb12, unwind terminate(cleanup)]; | ||
| + goto -> bb12; | ||
| + } | ||
| + | ||
| + bb14: { | ||
| + StorageDead(_6); | ||
| + goto -> bb3; | ||
| + } | ||
| + | ||
| + bb15: { | ||
| + StorageDead(_6); | ||
| + goto -> bb7; | ||
| + } | ||
| + | ||
| + bb16 (cleanup): { | ||
| + StorageDead(_6); | ||
| + goto -> bb11; | ||
| + } | ||
| + | ||
| + bb17: { | ||
| + assert(const false, "`async fn` resumed after async drop") -> [success: bb17, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb18: { | ||
| + _2 = move _7; | ||
| + StorageDead(_7); | ||
| + goto -> bb17; | ||
| + } | ||
| + | ||
| + bb19: { | ||
| + _2 = move _7; | ||
| + StorageDead(_7); | ||
| + goto -> bb25; | ||
| + } | ||
| + | ||
| + bb20: { | ||
| + StorageLive(_7); | ||
| + _7 = yield(const ()) -> [resume: bb18, drop: bb19]; | ||
| + } | ||
| + | ||
| + bb21: { | ||
| + unreachable; | ||
| + } | ||
| + | ||
| + bb22: { | ||
| + _9 = discriminant(_8); | ||
| + switchInt(move _9) -> [0: bb15, 1: bb20, otherwise: bb21]; | ||
| + } | ||
| + | ||
| + bb23: { | ||
| + _8 = <impl Future<Output = ()> as Future>::poll(move _10, move _11) -> [return: bb22, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb24: { | ||
| + _12 = move _2; | ||
| + _11 = std::future::get_context::<'_, '_>(move _12) -> [return: bb23, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb25: { | ||
| + _13 = &mut _6; | ||
| + _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _13) -> [return: bb24, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb26: { | ||
| + _2 = move _14; | ||
| + StorageDead(_14); | ||
| + goto -> bb32; | ||
| + } | ||
| + | ||
| + bb27: { | ||
| + _2 = move _14; | ||
| + StorageDead(_14); | ||
| + goto -> bb25; | ||
| + } | ||
| + | ||
| + bb28: { | ||
| + StorageLive(_14); | ||
| + _14 = yield(const ()) -> [resume: bb26, drop: bb27]; | ||
| + } | ||
| + | ||
| + bb29: { | ||
| + _16 = discriminant(_15); | ||
| + switchInt(move _16) -> [0: bb14, 1: bb28, otherwise: bb21]; | ||
| + } | ||
| + | ||
| + bb30: { | ||
| + _15 = <impl Future<Output = ()> as Future>::poll(move _17, move _18) -> [return: bb29, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb31: { | ||
| + _19 = move _2; | ||
| + _18 = std::future::get_context::<'_, '_>(move _19) -> [return: bb30, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb32: { | ||
| + _20 = &mut _6; | ||
| + _17 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _20) -> [return: bb31, unwind: bb16]; | ||
| + } | ||
| + | ||
| + bb33: { | ||
| + StorageLive(_6); | ||
| + _6 = async_drop_in_place::<[AsyncInt; 2]>(copy (_21.0: &mut [AsyncInt; 2])) -> [return: bb32, unwind: bb16]; | ||
|
dingxiangfei2009 marked this conversation as resolved.
|
||
| + } | ||
| + | ||
| + bb34: { | ||
| + _22 = &mut _3; | ||
| + _21 = Pin::<&mut [AsyncInt; 2]>::new_unchecked(move _22) -> [return: bb33, unwind: bb11]; | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.