// WARNING: This output format is intended for human consumers only // and is subject to change without notice. Knock yourself out. // HINT: See also -Z dump-mir for MIR at specific points during compilation. fn ::new() -> OnePending { let mut _0: OnePending; bb0: { _0 = OnePending { ready: const false }; return; } } fn ::default() -> OnePending { let mut _0: OnePending; bb0: { _0 = OnePending::new() -> [return: bb1, unwind continue]; } bb1: { return; } } fn ::poll(_1: Pin<&mut OnePending>, _2: &mut Context<'_>) -> Poll<()> { debug self => _1; debug cx => _2; let mut _0: std::task::Poll<()>; let mut _3: bool; let mut _4: &OnePending; let mut _5: &std::pin::Pin<&mut OnePending>; let mut _6: &mut OnePending; let mut _7: &mut std::pin::Pin<&mut OnePending>; let _8: (); let _9: &std::task::Waker; let mut _10: &std::task::Context<'_>; bb0: { _5 = &_1; _4 = as Deref>::deref(move _5) -> [return: bb1, unwind continue]; } bb1: { _3 = copy ((*_4).0: bool); switchInt(move _3) -> [0: bb3, otherwise: bb2]; } bb2: { _0 = Poll::<()>::Ready(const ()); goto -> bb7; } bb3: { _7 = &mut _1; _6 = as DerefMut>::deref_mut(move _7) -> [return: bb4, unwind continue]; } bb4: { ((*_6).0: bool) = const true; _10 = &(*_2); _9 = Context::<'_>::waker(move _10) -> [return: bb5, unwind continue]; } bb5: { _8 = Waker::wake_by_ref(copy _9) -> [return: bb6, unwind continue]; } bb6: { _0 = Poll::<()>::Pending; goto -> bb7; } bb7: { return; } } fn add_after_two_steps(_1: i32) -> {async fn body of add_after_two_steps()} { debug seed => _1; let mut _0: {async fn body of add_after_two_steps()}; bb0: { _0 = {coroutine@/home/melaton/Projects/blog/examples/reverse-async/rust/src/lib.rs:35:52: 45:2 (#0)} { seed: copy _1 }; return; } } fn add_after_two_steps::{closure#0}(_1: Pin<&mut {async fn body of add_after_two_steps()}>, _2: &mut Context<'_>) -> Poll { debug _task_context => _2; debug seed => ((*_29).0: i32); let mut _0: std::task::Poll; let _3: i32; let mut _4: (i32, bool); let mut _5: OnePending; let mut _6: OnePending; let mut _7: std::task::Poll<()>; let mut _8: std::pin::Pin<&mut OnePending>; let mut _9: &mut OnePending; let mut _10: &mut std::task::Context<'_>; let mut _11: isize; let mut _13: &mut std::task::Context<'_>; let mut _14: i32; let mut _15: (i32, bool); let mut _16: OnePending; let mut _17: OnePending; let mut _18: std::task::Poll<()>; let mut _19: std::pin::Pin<&mut OnePending>; let mut _20: &mut OnePending; let mut _21: &mut std::task::Context<'_>; let mut _22: isize; let mut _24: &mut std::task::Context<'_>; let mut _25: i32; let mut _26: (i32, bool); let mut _27: i32; let mut _28: u32; let mut _29: &mut {async fn body of add_after_two_steps()}; scope 1 { debug seed => _3; scope 2 { debug local => (((*_29) as variant#3).0: i32); scope 3 { debug __awaitee => (((*_29) as variant#3).1: OnePending); let _12: (); scope 4 { debug result => _12; } } scope 5 { debug after_delay => (((*_29) as variant#4).0: i32); scope 6 { debug __awaitee => (((*_29) as variant#4).1: OnePending); let _23: (); scope 7 { debug result => _23; } } } } } bb0: { _29 = copy (_1.0: &mut {async fn body of add_after_two_steps()}); _28 = discriminant((*_29)); switchInt(move _28) -> [0: bb1, 1: bb24, 2: bb23, 3: bb21, 4: bb22, otherwise: bb8]; } bb1: { _3 = copy ((*_29).0: i32); _4 = AddWithOverflow(copy _3, const 1_i32); assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _3, const 1_i32) -> [success: bb2, unwind: bb20]; } bb2: { (((*_29) as variant#3).0: i32) = move (_4.0: i32); _6 = OnePending::new() -> [return: bb3, unwind: bb20]; } bb3: { _5 = ::into_future(move _6) -> [return: bb4, unwind: bb20]; } bb4: { (((*_29) as variant#3).1: OnePending) = move _5; goto -> bb5; } bb5: { _9 = &mut (((*_29) as variant#3).1: OnePending); _8 = Pin::<&mut OnePending>::new_unchecked(copy _9) -> [return: bb6, unwind: bb20]; } bb6: { _10 = copy _2; _7 = ::poll(move _8, copy _10) -> [return: bb7, unwind: bb20]; } bb7: { _11 = discriminant(_7); switchInt(move _11) -> [0: bb10, 1: bb9, otherwise: bb8]; } bb8: { unreachable; } bb9: { _0 = Poll::::Pending; discriminant((*_29)) = 3; return; } bb10: { _12 = copy ((_7 as Ready).0: ()); _14 = copy (((*_29) as variant#3).0: i32); _15 = MulWithOverflow(copy _14, const 2_i32); assert(!move (_15.1: bool), "attempt to compute `{} * {}`, which would overflow", move _14, const 2_i32) -> [success: bb11, unwind: bb20]; } bb11: { (((*_29) as variant#4).0: i32) = move (_15.0: i32); _17 = OnePending::new() -> [return: bb12, unwind: bb20]; } bb12: { _16 = ::into_future(move _17) -> [return: bb13, unwind: bb20]; } bb13: { (((*_29) as variant#4).1: OnePending) = move _16; goto -> bb14; } bb14: { _20 = &mut (((*_29) as variant#4).1: OnePending); _19 = Pin::<&mut OnePending>::new_unchecked(copy _20) -> [return: bb15, unwind: bb20]; } bb15: { _21 = copy _2; _18 = ::poll(move _19, copy _21) -> [return: bb16, unwind: bb20]; } bb16: { _22 = discriminant(_18); switchInt(move _22) -> [0: bb18, 1: bb17, otherwise: bb8]; } bb17: { _0 = Poll::::Pending; discriminant((*_29)) = 4; return; } bb18: { _23 = copy ((_18 as Ready).0: ()); _25 = copy (((*_29) as variant#4).0: i32); _26 = AddWithOverflow(copy _25, const 3_i32); assert(!move (_26.1: bool), "attempt to compute `{} + {}`, which would overflow", move _25, const 3_i32) -> [success: bb19, unwind: bb20]; } bb19: { _27 = move (_26.0: i32); _0 = Poll::::Ready(move _27); discriminant((*_29)) = 1; return; } bb20 (cleanup): { discriminant((*_29)) = 2; resume; } bb21: { _13 = move _2; _2 = move _13; goto -> bb5; } bb22: { _24 = move _2; _2 = move _24; goto -> bb14; } bb23: { assert(const false, "`async fn` resumed after panicking") -> [success: bb23, unwind continue]; } bb24: { assert(const false, "`async fn` resumed after completion") -> [success: bb24, unwind continue]; } } fn manual_add_new(_1: i32) -> ManualAdd { debug seed => _1; let mut _0: ManualAdd; bb0: { _0 = ManualAdd { state: const 0_u8, seed: copy _1, local: const 0_i32, after_delay: const 0_i32 }; return; } } fn manual_add_poll(_1: &mut ManualAdd) -> PollI32 { debug machine => _1; let mut _0: PollI32; let mut _2: i32; let mut _3: (i32, bool); let mut _4: i32; let mut _5: (i32, bool); let mut _6: i32; let mut _7: i32; let mut _8: (i32, bool); bb0: { switchInt(copy ((*_1).0: u8)) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; } bb1: { _0 = PollI32 { tag: const 2_u8, value: const -1_i32 }; goto -> bb8; } bb2: { ((*_1).0: u8) = const 3_u8; _7 = copy ((*_1).3: i32); _8 = AddWithOverflow(copy _7, const 3_i32); assert(!move (_8.1: bool), "attempt to compute `{} + {}`, which would overflow", move _7, const 3_i32) -> [success: bb7, unwind terminate(abi)]; } bb3: { _4 = copy ((*_1).2: i32); _5 = MulWithOverflow(copy _4, const 2_i32); assert(!move (_5.1: bool), "attempt to compute `{} * {}`, which would overflow", move _4, const 2_i32) -> [success: bb6, unwind terminate(abi)]; } bb4: { _2 = copy ((*_1).1: i32); _3 = AddWithOverflow(copy _2, const 1_i32); assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_i32) -> [success: bb5, unwind terminate(abi)]; } bb5: { ((*_1).2: i32) = move (_3.0: i32); ((*_1).0: u8) = const 1_u8; _0 = PollI32 { tag: const 0_u8, value: const 0_i32 }; goto -> bb8; } bb6: { ((*_1).3: i32) = move (_5.0: i32); ((*_1).0: u8) = const 2_u8; _0 = PollI32 { tag: const 0_u8, value: const 0_i32 }; goto -> bb8; } bb7: { _6 = move (_8.0: i32); _0 = PollI32 { tag: const 1_u8, value: move _6 }; goto -> bb8; } bb8: { return; } }