|
50 | 50 | //! Otherwise it drops all the values in scope at the last suspension point.
|
51 | 51 |
|
52 | 52 | use rustc::hir;
|
53 |
| -use rustc::hir::{def_id::DefId, GeneratorKind}; |
| 53 | +use rustc::hir::def_id::DefId; |
54 | 54 | use rustc::mir::*;
|
55 | 55 | use rustc::mir::visit::{PlaceContext, Visitor, MutVisitor};
|
56 | 56 | use rustc::ty::{self, TyCtxt, AdtDef, Ty};
|
@@ -1056,28 +1056,17 @@ fn create_generator_resume_function<'tcx>(
|
1056 | 1056 | let mut cases = create_cases(body, &transform, |point| Some(point.resume));
|
1057 | 1057 |
|
1058 | 1058 | use rustc::mir::interpret::PanicInfo::{
|
1059 |
| - GeneratorResumedAfterPanic, |
1060 |
| - GeneratorResumedAfterReturn, |
1061 |
| - AsyncResumedAfterReturn, |
1062 |
| - AsyncResumedAfterPanic, |
| 1059 | + ResumedAfterPanic, |
| 1060 | + ResumedAfterReturn, |
1063 | 1061 | };
|
1064 | 1062 |
|
1065 | 1063 | // Jump to the entry point on the unresumed
|
1066 | 1064 | cases.insert(0, (UNRESUMED, BasicBlock::new(0)));
|
1067 | 1065 |
|
1068 | 1066 | // Panic when resumed on the returned or poisoned state
|
1069 |
| - match body.generator_kind { |
1070 |
| - Some(GeneratorKind::Async(_)) => { |
1071 |
| - cases.insert(1, (RETURNED, insert_panic_block(tcx, body, AsyncResumedAfterReturn))); |
1072 |
| - cases.insert(2, (POISONED, insert_panic_block(tcx, body, AsyncResumedAfterPanic))); |
1073 |
| - }, |
1074 |
| - Some(GeneratorKind::Gen) => { |
1075 |
| - cases.insert(1, (RETURNED, insert_panic_block(tcx, body, GeneratorResumedAfterReturn))); |
1076 |
| - cases.insert(2, (POISONED, insert_panic_block(tcx, body, GeneratorResumedAfterPanic))); |
1077 |
| - }, |
1078 |
| - None => { |
1079 |
| - // N/A because we would never create a resume function if there was no generator_kind |
1080 |
| - } |
| 1067 | + if let Some(generator_kind) = body.generator_kind { |
| 1068 | + cases.insert(1, (RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(generator_kind)))); |
| 1069 | + cases.insert(2, (POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(generator_kind)))); |
1081 | 1070 | };
|
1082 | 1071 |
|
1083 | 1072 | insert_switch(body, cases, &transform, TerminatorKind::Unreachable);
|
|
0 commit comments