cases.insert(0, (UNRESUMED, BasicBlock::new(0)));
// Panic when resumed on the returned or poisoned state
- let generator_kind = body.generator_kind.unwrap();
+ let generator_kind = body.generator_kind().unwrap();
if can_unwind {
cases.insert(
impl<'tcx> MirPass<'tcx> for StateTransform {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
- let yield_ty = if let Some(yield_ty) = body.yield_ty {
+ let yield_ty = if let Some(yield_ty) = body.yield_ty() {
yield_ty
} else {
// This only applies to generators
return;
};
- assert!(body.generator_drop.is_none());
+ assert!(body.generator_drop().is_none());
// The first argument is the generator type passed by value
let gen_ty = body.local_decls.raw[1].ty;
transform.visit_body(body);
// Update our MIR struct to reflect the changes we've made
- body.yield_ty = None;
body.arg_count = 2; // self, resume arg
body.spread_arg = None;
- body.generator_layout = Some(layout);
+
+ body.generator.as_mut().unwrap().yield_ty = None;
+ body.generator.as_mut().unwrap().generator_layout = Some(layout);
// Insert `drop(generator_struct)` which is used to drop upvars for generators in
// the unresumed state.
// Create a copy of our MIR and use it to create the drop shim for the generator
let drop_shim = create_generator_drop_shim(tcx, &transform, gen_ty, body, drop_clean);
- body.generator_drop = Some(box drop_shim);
+ body.generator.as_mut().unwrap().generator_drop = Some(drop_shim);
// Create the Generator::resume function
create_generator_resume_function(tcx, transform, body, can_return);
| StatementKind::Retag(..)
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
+ | StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {}
}
}