-
Notifications
You must be signed in to change notification settings - Fork 14.1k
-Zfused-futures #147129
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
Closed
Closed
-Zfused-futures #147129
Changes from all commits
Commits
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
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
46 changes: 46 additions & 0 deletions
46
tests/mir-opt/fused_futures.future-{closure#0}.coroutine_resume.0.panic-abort.mir
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,46 @@ | ||
| // MIR for `future::{closure#0}` 0 coroutine_resume | ||
| /* coroutine_layout = CoroutineLayout { | ||
| field_tys: {}, | ||
| variant_fields: { | ||
| Unresumed(0): [], | ||
| Returned (1): [], | ||
| Panicked (2): [], | ||
| }, | ||
| storage_conflicts: BitMatrix(0x0) {}, | ||
| } */ | ||
|
|
||
| fn future::{closure#0}(_1: Pin<&mut {async fn body of future()}>, _2: &mut Context<'_>) -> Poll<u32> { | ||
| debug _task_context => _2; | ||
| let mut _0: std::task::Poll<u32>; | ||
| let mut _3: u32; | ||
| let mut _4: u32; | ||
|
|
||
| bb0: { | ||
| _4 = discriminant((*(_1.0: &mut {async fn body of future()}))); | ||
| switchInt(move _4) -> [0: bb1, 1: bb4, otherwise: bb5]; | ||
| } | ||
|
|
||
| bb1: { | ||
| _3 = const 42_u32; | ||
| goto -> bb3; | ||
| } | ||
|
|
||
| bb2: { | ||
| _0 = Poll::<u32>::Ready(move _3); | ||
| discriminant((*(_1.0: &mut {async fn body of future()}))) = 1; | ||
| return; | ||
| } | ||
|
|
||
| bb3: { | ||
| goto -> bb2; | ||
| } | ||
|
|
||
| bb4: { | ||
| _0 = Poll::<u32>::Pending; | ||
| return; | ||
| } | ||
|
|
||
| bb5: { | ||
| unreachable; | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
tests/mir-opt/fused_futures.future-{closure#0}.coroutine_resume.0.panic-unwind.mir
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,46 @@ | ||
| // MIR for `future::{closure#0}` 0 coroutine_resume | ||
| /* coroutine_layout = CoroutineLayout { | ||
| field_tys: {}, | ||
| variant_fields: { | ||
| Unresumed(0): [], | ||
| Returned (1): [], | ||
| Panicked (2): [], | ||
| }, | ||
| storage_conflicts: BitMatrix(0x0) {}, | ||
| } */ | ||
|
|
||
| fn future::{closure#0}(_1: Pin<&mut {async fn body of future()}>, _2: &mut Context<'_>) -> Poll<u32> { | ||
| debug _task_context => _2; | ||
| let mut _0: std::task::Poll<u32>; | ||
| let mut _3: u32; | ||
| let mut _4: u32; | ||
|
|
||
| bb0: { | ||
| _4 = discriminant((*(_1.0: &mut {async fn body of future()}))); | ||
| switchInt(move _4) -> [0: bb1, 1: bb4, otherwise: bb5]; | ||
| } | ||
|
|
||
| bb1: { | ||
| _3 = const 42_u32; | ||
| goto -> bb3; | ||
| } | ||
|
|
||
| bb2: { | ||
| _0 = Poll::<u32>::Ready(move _3); | ||
| discriminant((*(_1.0: &mut {async fn body of future()}))) = 1; | ||
| return; | ||
| } | ||
|
|
||
| bb3: { | ||
| goto -> bb2; | ||
| } | ||
|
|
||
| bb4: { | ||
| _0 = Poll::<u32>::Pending; | ||
| return; | ||
| } | ||
|
|
||
| bb5: { | ||
| unreachable; | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
tests/mir-opt/fused_futures.main-{closure#0}.coroutine_resume.0.panic-abort.mir
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,66 @@ | ||
| // MIR for `main::{closure#0}` 0 coroutine_resume | ||
| /* coroutine_layout = CoroutineLayout { | ||
| field_tys: {}, | ||
| variant_fields: { | ||
| Unresumed(0): [], | ||
| Returned (1): [], | ||
| Panicked (2): [], | ||
| Suspend0 (3): [], | ||
| }, | ||
| storage_conflicts: BitMatrix(0x0) {}, | ||
| } */ | ||
|
|
||
| fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}>, _2: ()) -> CoroutineState<i32, &str> { | ||
| let mut _0: std::ops::CoroutineState<i32, &str>; | ||
| let mut _3: !; | ||
| let _4: (); | ||
| let mut _5: &str; | ||
| let mut _6: u32; | ||
|
|
||
| bb0: { | ||
| _6 = discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))); | ||
| switchInt(move _6) -> [0: bb1, 1: bb6, 3: bb5, otherwise: bb7]; | ||
| } | ||
|
|
||
| bb1: { | ||
| StorageLive(_4); | ||
| _0 = CoroutineState::<i32, &str>::Yielded(const 1_i32); | ||
| StorageDead(_4); | ||
| discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))) = 3; | ||
| return; | ||
| } | ||
|
|
||
| bb2: { | ||
| StorageDead(_4); | ||
| _5 = const "foo"; | ||
| goto -> bb4; | ||
| } | ||
|
|
||
| bb3: { | ||
| _0 = CoroutineState::<i32, &str>::Complete(move _5); | ||
| discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))) = 1; | ||
| return; | ||
| } | ||
|
|
||
| bb4: { | ||
| goto -> bb3; | ||
| } | ||
|
|
||
| bb5: { | ||
| StorageLive(_4); | ||
| _4 = move _2; | ||
| goto -> bb2; | ||
| } | ||
|
|
||
| bb6: { | ||
| assert(const false, "coroutine resumed after completion") -> [success: bb6, unwind unreachable]; | ||
| } | ||
|
|
||
| bb7: { | ||
| unreachable; | ||
| } | ||
| } | ||
|
|
||
| ALLOC0 (size: 3, align: 1) { | ||
| 66 6f 6f │ foo | ||
| } |
66 changes: 66 additions & 0 deletions
66
tests/mir-opt/fused_futures.main-{closure#0}.coroutine_resume.0.panic-unwind.mir
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,66 @@ | ||
| // MIR for `main::{closure#0}` 0 coroutine_resume | ||
| /* coroutine_layout = CoroutineLayout { | ||
| field_tys: {}, | ||
| variant_fields: { | ||
| Unresumed(0): [], | ||
| Returned (1): [], | ||
| Panicked (2): [], | ||
| Suspend0 (3): [], | ||
| }, | ||
| storage_conflicts: BitMatrix(0x0) {}, | ||
| } */ | ||
|
|
||
| fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}>, _2: ()) -> CoroutineState<i32, &str> { | ||
| let mut _0: std::ops::CoroutineState<i32, &str>; | ||
| let mut _3: !; | ||
| let _4: (); | ||
| let mut _5: &str; | ||
| let mut _6: u32; | ||
|
|
||
| bb0: { | ||
| _6 = discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))); | ||
| switchInt(move _6) -> [0: bb1, 1: bb6, 3: bb5, otherwise: bb7]; | ||
| } | ||
|
|
||
| bb1: { | ||
| StorageLive(_4); | ||
| _0 = CoroutineState::<i32, &str>::Yielded(const 1_i32); | ||
| StorageDead(_4); | ||
| discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))) = 3; | ||
| return; | ||
| } | ||
|
|
||
| bb2: { | ||
| StorageDead(_4); | ||
| _5 = const "foo"; | ||
| goto -> bb4; | ||
| } | ||
|
|
||
| bb3: { | ||
| _0 = CoroutineState::<i32, &str>::Complete(move _5); | ||
| discriminant((*(_1.0: &mut {coroutine@$DIR/fused_futures.rs:17:5: 17:7}))) = 1; | ||
| return; | ||
| } | ||
|
|
||
| bb4: { | ||
| goto -> bb3; | ||
| } | ||
|
|
||
| bb5: { | ||
| StorageLive(_4); | ||
| _4 = move _2; | ||
| goto -> bb2; | ||
| } | ||
|
|
||
| bb6: { | ||
| assert(const false, "coroutine resumed after completion") -> [success: bb6, unwind continue]; | ||
| } | ||
|
|
||
| bb7: { | ||
| unreachable; | ||
| } | ||
| } | ||
|
|
||
| ALLOC0 (size: 3, align: 1) { | ||
| 66 6f 6f │ foo | ||
| } |
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,21 @@ | ||
| //@ edition:2024 | ||
| //@ compile-flags: -Zfused-futures | ||
| // skip-filecheck | ||
| // EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
|
|
||
| #![feature(coroutines, stmt_expr_attributes)] | ||
| #![allow(unused)] | ||
|
|
||
| // EMIT_MIR fused_futures.future-{closure#0}.coroutine_resume.0.mir | ||
| pub async fn future() -> u32 { | ||
| 42 | ||
| } | ||
|
|
||
| // EMIT_MIR fused_futures.main-{closure#0}.coroutine_resume.0.mir | ||
| fn main() { | ||
| let mut coroutine = #[coroutine] | ||
| || { | ||
| yield 1; | ||
| return "foo"; | ||
| }; | ||
| } | ||
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,21 @@ | ||
| //@ run-pass | ||
| //@ edition: 2024 | ||
| //@ compile-flags: -Zfused-futures | ||
|
|
||
| use std::pin::pin; | ||
| use std::task::{Context, Poll, Waker}; | ||
|
|
||
| async fn foo() -> u8 { | ||
| 12 | ||
| } | ||
|
|
||
| const N: usize = 10; | ||
|
|
||
| fn main() { | ||
| let cx = &mut Context::from_waker(Waker::noop()); | ||
| let mut x = pin!(foo()); | ||
| assert_eq!(x.as_mut().poll(cx), Poll::Ready(12)); | ||
| for _ in 0..N { | ||
| assert_eq!(x.as_mut().poll(cx), Poll::Pending); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be
pub?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not