blob: 17671228295e367cc2259359fb533864bb8b84ab [file]
- // MIR for `main::{closure#0}` before StateTransform
+ // MIR for `main::{closure#0}` after StateTransform
- fn main::{closure#0}(_1: {coroutine@$DIR/coroutine.rs:19:5: 19:18}, _2: String) -> ()
- yields (&str, String, &Location<'_>)
- {
- debug arg => _2;
- let mut _0: ();
+ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine.rs:19:5: 19:18}>, _2: String) -> CoroutineState<(&str, String, &Location<'_>), ()> {
+ coroutine layout {
+ field _s0: String;
+ variant_fields = {
+ Unresumed(0): [],
+ Returned (1): [],
+ Panicked (2): [],
+ Suspend0 (3): [_s0],
+ Suspend1 (4): [_s0],
+ }
+ storage_conflicts = BitMatrix(1x1) {(_s0, _s0)}
+ }
+ debug arg => (((*_18) as variant#4).0: std::string::String);
+ coroutine debug arg => _s0;
+ let mut _0: std::ops::CoroutineState<(&str, std::string::String, &std::panic::Location<'_>), ()>;
let _3: std::string::String;
let mut _4: (&str, std::string::String, &std::panic::Location<'_>);
let mut _5: std::string::String;
let mut _6: &std::string::String;
let mut _7: &std::panic::Location<'_>;
let _8: std::string::String;
let mut _9: (&str, std::string::String, &std::panic::Location<'_>);
let mut _10: &str;
let _11: &str;
let mut _12: std::string::String;
let mut _13: &std::string::String;
let mut _14: &std::panic::Location<'_>;
let _15: &std::panic::Location<'_>;
+ let mut _16: ();
+ let mut _17: u32;
+ let mut _18: &mut {coroutine@$DIR/coroutine.rs:19:5: 19:18};
bb0: {
- StorageLive(_3);
- StorageLive(_4);
- StorageLive(_5);
- StorageLive(_6);
- _6 = &_2;
- _5 = <String as Clone>::clone(move _6) -> [return: bb1, unwind: bb31];
+ _18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:19:5: 19:18});
+ _17 = discriminant((*_18));
+ switchInt(move _17) -> [0: bb36, 1: bb34, 2: bb33, 3: bb31, 4: bb32, otherwise: bb35];
}
bb1: {
StorageDead(_6);
StorageLive(_7);
- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb30];
+ _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21];
}
bb2: {
_4 = (const "first", move _5, move _7);
StorageDead(_7);
goto -> bb3;
}
bb3: {
StorageDead(_5);
- _3 = yield(move _4) -> [resume: bb4, drop: bb18];
+ _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _4);
+ StorageDead(_3);
+ StorageDead(_4);
+ discriminant((*_18)) = 3;
+ return;
}
bb4: {
goto -> bb5;
}
bb5: {
StorageDead(_4);
- drop(_3) -> [return: bb6, unwind: bb34];
+ drop(_3) -> [return: bb6, unwind: bb25];
}
bb6: {
StorageDead(_3);
StorageLive(_8);
StorageLive(_9);
StorageLive(_10);
StorageLive(_11);
_11 = const "second";
_10 = &(*_11);
StorageLive(_12);
StorageLive(_13);
- _13 = &_2;
- _12 = <String as Clone>::clone(move _13) -> [return: bb7, unwind: bb28];
+ _13 = &(((*_18) as variant#4).0: std::string::String);
+ _12 = <String as Clone>::clone(move _13) -> [return: bb7, unwind: bb19];
}
bb7: {
StorageDead(_13);
StorageLive(_14);
StorageLive(_15);
- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb24];
+ _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb15];
}
bb8: {
_14 = &(*_15);
_9 = (move _10, move _12, move _14);
StorageDead(_14);
goto -> bb9;
}
bb9: {
StorageDead(_12);
StorageDead(_10);
- _8 = yield(move _9) -> [resume: bb10, drop: bb15];
+ _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _9);
+ StorageDead(_8);
+ StorageDead(_9);
+ StorageDead(_11);
+ StorageDead(_15);
+ discriminant((*_18)) = 4;
+ return;
}
bb10: {
goto -> bb11;
}
bb11: {
StorageDead(_9);
- drop(_8) -> [return: bb12, unwind: bb27];
+ drop(_8) -> [return: bb12, unwind: bb18];
}
bb12: {
StorageDead(_15);
StorageDead(_11);
StorageDead(_8);
- _0 = const ();
- drop(_2) -> [return: bb13, unwind: bb36];
+ _16 = const ();
+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb13, unwind: bb27];
}
bb13: {
- drop(_1) -> [return: bb14, unwind: bb37];
+ goto -> bb29;
}
bb14: {
+ _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Complete(move _16);
+ discriminant((*_18)) = 1;
return;
}
- bb15: {
- goto -> bb16;
+ bb15 (cleanup): {
+ StorageDead(_14);
+ drop(_12) -> [return: bb16, unwind terminate(cleanup)];
}
- bb16: {
- StorageDead(_9);
+ bb16 (cleanup): {
+ StorageDead(_12);
+ StorageDead(_10);
goto -> bb17;
}
- bb17: {
- StorageDead(_15);
- StorageDead(_11);
- StorageDead(_8);
- goto -> bb21;
+ bb17 (cleanup): {
+ StorageDead(_9);
+ goto -> bb18;
}
- bb18: {
- goto -> bb19;
+ bb18 (cleanup): {
+ StorageDead(_15);
+ goto -> bb20;
}
- bb19: {
- StorageDead(_4);
+ bb19 (cleanup): {
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_10);
+ StorageDead(_9);
goto -> bb20;
}
- bb20: {
- StorageDead(_3);
- goto -> bb21;
+ bb20 (cleanup): {
+ StorageDead(_11);
+ StorageDead(_8);
+ goto -> bb26;
}
- bb21: {
- drop(_2) -> [return: bb22, unwind: bb38];
+ bb21 (cleanup): {
+ StorageDead(_7);
+ drop(_5) -> [return: bb23, unwind terminate(cleanup)];
}
- bb22: {
- drop(_1) -> [return: bb23, unwind: bb37];
+ bb22 (cleanup): {
+ StorageDead(_6);
+ goto -> bb23;
}
- bb23: {
- coroutine_drop;
+ bb23 (cleanup): {
+ StorageDead(_5);
+ goto -> bb24;
}
bb24 (cleanup): {
- StorageDead(_14);
- drop(_12) -> [return: bb25, unwind terminate(cleanup)];
+ StorageDead(_4);
+ goto -> bb25;
}
bb25 (cleanup): {
- StorageDead(_12);
- StorageDead(_10);
+ StorageDead(_3);
goto -> bb26;
}
bb26 (cleanup): {
- StorageDead(_9);
- goto -> bb27;
+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb27, unwind terminate(cleanup)];
}
bb27 (cleanup): {
- StorageDead(_15);
- goto -> bb29;
+ goto -> bb28;
}
bb28 (cleanup): {
- StorageDead(_13);
- StorageDead(_12);
- StorageDead(_10);
- StorageDead(_9);
- goto -> bb29;
+ goto -> bb30;
}
- bb29 (cleanup): {
- StorageDead(_11);
- StorageDead(_8);
- goto -> bb35;
+ bb29: {
+ goto -> bb14;
}
bb30 (cleanup): {
- StorageDead(_7);
- drop(_5) -> [return: bb32, unwind terminate(cleanup)];
+ discriminant((*_18)) = 2;
+ resume;
}
- bb31 (cleanup): {
- StorageDead(_6);
- goto -> bb32;
+ bb31: {
+ StorageLive(_3);
+ StorageLive(_4);
+ _3 = move _2;
+ goto -> bb4;
}
- bb32 (cleanup): {
- StorageDead(_5);
- goto -> bb33;
+ bb32: {
+ StorageLive(_8);
+ StorageLive(_9);
+ StorageLive(_11);
+ StorageLive(_15);
+ _8 = move _2;
+ goto -> bb10;
}
- bb33 (cleanup): {
- StorageDead(_4);
- goto -> bb34;
+ bb33: {
+ assert(const false, "coroutine resumed after panicking") -> [success: bb33, unwind continue];
}
- bb34 (cleanup): {
- StorageDead(_3);
- goto -> bb35;
+ bb34: {
+ assert(const false, "coroutine resumed after completion") -> [success: bb34, unwind continue];
}
- bb35 (cleanup): {
- drop(_2) -> [return: bb36, unwind terminate(cleanup)];
+ bb35: {
+ unreachable;
}
- bb36 (cleanup): {
- drop(_1) -> [return: bb37, unwind terminate(cleanup)];
- }
-
- bb37 (cleanup): {
- resume;
- }
-
- bb38 (cleanup): {
- drop(_1) -> [return: bb37, unwind terminate(cleanup)];
+ bb36: {
+ (((*_18) as variant#4).0: std::string::String) = move _2;
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ _6 = &(((*_18) as variant#4).0: std::string::String);
+ _5 = <String as Clone>::clone(move _6) -> [return: bb1, unwind: bb22];
}
}
ALLOC0 (size: 6, align: 1) {
73 65 63 6f 6e 64 │ second
}
ALLOC1 (size: 5, align: 1) {
66 69 72 73 74 │ first
}