Skip to content

Commit e88948a

Browse files
author
David Haig
committed
Fail fast if generator_kind is None
1 parent ed66492 commit e88948a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/librustc_mir/transform/generator.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1064,14 +1064,15 @@ fn create_generator_resume_function<'tcx>(
10641064
cases.insert(0, (UNRESUMED, BasicBlock::new(0)));
10651065

10661066
// Panic when resumed on the returned or poisoned state
1067-
if let Some(generator_kind) = body.generator_kind {
1068-
cases.insert(1, (RETURNED, insert_panic_block(tcx,
1069-
body,
1070-
ResumedAfterReturn(generator_kind))));
1071-
cases.insert(2, (POISONED, insert_panic_block(tcx,
1072-
body,
1073-
ResumedAfterPanic(generator_kind))));
1074-
};
1067+
let generator_kind = body.generator_kind.unwrap();
1068+
cases.insert(1, (RETURNED, insert_panic_block(
1069+
tcx,
1070+
body,
1071+
ResumedAfterReturn(generator_kind))));
1072+
cases.insert(2, (POISONED, insert_panic_block(
1073+
tcx,
1074+
body,
1075+
ResumedAfterPanic(generator_kind))));
10751076

10761077
insert_switch(body, cases, &transform, TerminatorKind::Unreachable);
10771078

0 commit comments

Comments
 (0)