Swap inserts to keep the original ordering

This commit is contained in:
Jonas Schievink 2020-03-14 15:46:57 +01:00
parent cb58de8165
commit 38fa3783ce

View File

@ -1099,13 +1099,6 @@ fn create_generator_resume_function<'tcx>(
// Panic when resumed on the returned or poisoned state
let generator_kind = body.generator_kind.unwrap();
if can_return {
cases.insert(
1,
(RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(generator_kind))),
);
}
if can_unwind {
cases.insert(
1,
@ -1113,6 +1106,13 @@ fn create_generator_resume_function<'tcx>(
);
}
if can_return {
cases.insert(
1,
(RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(generator_kind))),
);
}
insert_switch(body, cases, &transform, TerminatorKind::Unreachable);
make_generator_state_argument_indirect(tcx, def_id, body);