diff --git a/compiler/rustc_mir_transform/src/coroutine/drop.rs b/compiler/rustc_mir_transform/src/coroutine/drop.rs index dc58bc14d0c9b..5a5dd93852a7c 100644 --- a/compiler/rustc_mir_transform/src/coroutine/drop.rs +++ b/compiler/rustc_mir_transform/src/coroutine/drop.rs @@ -308,6 +308,10 @@ pub(super) fn create_coroutine_drop_shim_async<'tcx>( // Run derefer to fix Derefs that are not in the first place deref_finder(tcx, &mut body, false); + if transform.coroutine_kind.is_async_desugaring() { + transform_async_context(tcx, &mut body); + } + if let Some(dumper) = MirDumper::new(tcx, "coroutine_drop_async", &body) { dumper.dump_mir(&body); } @@ -320,6 +324,7 @@ pub(super) fn create_coroutine_drop_shim_async<'tcx>( pub(super) fn create_coroutine_drop_shim_proxy_async<'tcx>( tcx: TyCtxt<'tcx>, body: &Body<'tcx>, + coroutine_kind: CoroutineKind, ) -> Body<'tcx> { let mut body = body.clone(); // Take the coroutine info out of the body, since the drop shim is @@ -357,6 +362,10 @@ pub(super) fn create_coroutine_drop_shim_proxy_async<'tcx>( // Run derefer to fix Derefs that are not in the first place deref_finder(tcx, &mut body, false); + if coroutine_kind.is_async_desugaring() { + transform_async_context(tcx, &mut body); + } + if let Some(dumper) = MirDumper::new(tcx, "coroutine_drop_proxy_async", &body) { dumper.dump_mir(&body); } diff --git a/compiler/rustc_mir_transform/src/coroutine/mod.rs b/compiler/rustc_mir_transform/src/coroutine/mod.rs index 235654fd3454e..df72f199087ff 100644 --- a/compiler/rustc_mir_transform/src/coroutine/mod.rs +++ b/compiler/rustc_mir_transform/src/coroutine/mod.rs @@ -160,6 +160,7 @@ const SELF_ARG: Local = Local::arg(0); pub(crate) const CTX_ARG: Local = Local::arg(1); /// A `yield` point in the coroutine. +#[derive(Debug)] struct SuspensionPoint<'tcx> { /// State discriminant used when suspending or resuming at this point. state: usize, @@ -551,19 +552,15 @@ fn make_coroutine_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body ); } -/// Transforms the `body` of the coroutine applying the following transforms: -/// -/// - Eliminates all the `get_context` calls that async lowering created. -/// - Replace all `Local` `ResumeTy` types with `&mut Context<'_>` (`context_mut_ref`). -/// -/// The `Local`s that have their types replaced are: -/// - The `resume` argument itself. -/// - The argument to `get_context`. -/// - The yielded value of a `yield`. -/// +/// Async desugaring uses an unsafe binder type `ResumeTy` to circumvert borrow-checking. /// The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the /// `get_context` function is being used to convert that back to a `&mut Context<'_>`. /// +/// The actual should be `&mut Context<'_>`. This performs the substitution: +/// - create a new local `_r` of type `ResumeTy`; +/// - assign `ResumeTy(transmute::<&mut Context<'_>, NonNull>>(_2))` to that local; +/// - let all the code use `_r` instead of `_2`. +/// /// Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, /// but rather directly use `&mut Context<'_>`, however that would currently /// lead to higher-kinded lifetime errors. @@ -575,93 +572,90 @@ fn make_coroutine_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body #[tracing::instrument(level = "trace", skip(tcx, body), ret)] fn transform_async_context<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let context_mut_ref = Ty::new_task_context(tcx); + let resume_ty_def_id = tcx.require_lang_item(LangItem::ResumeTy, body.span); + let resume_nonnull_ty = tcx.instantiate_and_normalize_erasing_regions( + ty::GenericArgs::empty(), + body.typing_env(tcx), + tcx.type_of(tcx.adt_def(resume_ty_def_id).non_enum_variant().fields[FieldIdx::ZERO].did), + ); - // replace the type of the `resume` argument - replace_resume_ty_local(tcx, body, CTX_ARG, context_mut_ref); + // Replace all occurrences of `CTX_ARG` with `resume_local: ResumeTy`, + // and set `CTX_ARG: &mut Context<'_>`. + let resume_local = body.local_decls.push(LocalDecl::new(context_mut_ref, body.span)); + body.local_decls.swap(CTX_ARG, resume_local); + RenameLocalVisitor { from: CTX_ARG, to: resume_local, tcx }.visit_body(body); - let get_context_def_id = tcx.require_lang_item(LangItem::GetContext, body.span); + // Now `CTX_ARG` is `&mut Context` and `resume_local` is a `ResumeTy`. + // Insert a `resume_local = ResumeTy(CTX_ARG as *mut Context<'static>)` + // at the function entry to make the bridge. + let source_info = SourceInfo::outermost(body.span); + let nonnull_local = body.local_decls.push(LocalDecl::new(resume_nonnull_ty, body.span)); + let nonnull_rhs = + Rvalue::Cast(CastKind::Transmute, Operand::Move(CTX_ARG.into()), resume_nonnull_ty); + let nonnull_assign = StatementKind::Assign(Box::new((nonnull_local.into(), nonnull_rhs))); + let resume_rhs = Rvalue::Aggregate( + Box::new(AggregateKind::Adt( + resume_ty_def_id, + VariantIdx::ZERO, + ty::GenericArgs::empty(), + None, + None, + )), + indexvec![Operand::Move(nonnull_local.into())], + ); + let resume_assign = StatementKind::Assign(Box::new((resume_local.into(), resume_rhs))); + body.basic_blocks.as_mut_preserves_cfg()[START_BLOCK].statements.splice( + 0..0, + [Statement::new(source_info, nonnull_assign), Statement::new(source_info, resume_assign)], + ); +} + +/// HIR uses `get_context` to unwrap a `&mut Context<'_>` from a `ResumeTy`. +/// Both types are just a single pointer, but liveness analysis does not know that and +/// supposes that the operand and the destination are live at the same time. +/// Forcibly inline those calls to avoid this. +fn eliminate_get_context_calls<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let context_mut_ref = Ty::new_task_context(tcx); + let resume_ty_def_id = tcx.require_lang_item(LangItem::ResumeTy, body.span); + let resume_nonnull_ty = tcx.instantiate_and_normalize_erasing_regions( + ty::GenericArgs::empty(), + body.typing_env(tcx), + tcx.type_of(tcx.adt_def(resume_ty_def_id).non_enum_variant().fields[FieldIdx::ZERO].did), + ); - for bb in body.basic_blocks.indices() { - let bb_data = &body[bb]; + let get_context_def_id = tcx.require_lang_item(LangItem::GetContext, body.span); + for bb_data in body.basic_blocks.as_mut().iter_mut() { if bb_data.is_cleanup { continue; } - match &bb_data.terminator().kind { - TerminatorKind::Call { func, .. } => { - let func_ty = func.ty(body, tcx); - if let ty::FnDef(def_id, _) = *func_ty.kind() - && def_id == get_context_def_id - { - let local = eliminate_get_context_call(&mut body[bb]); - replace_resume_ty_local(tcx, body, local, context_mut_ref); - } - } - TerminatorKind::Yield { resume_arg, .. } => { - replace_resume_ty_local(tcx, body, resume_arg.local, context_mut_ref); - } - _ => {} + let terminator = bb_data.terminator_mut(); + if let TerminatorKind::Call { func, args, destination, target, .. } = &terminator.kind + && let func_ty = func.ty(&body.local_decls, tcx) + && let ty::FnDef(def_id, _) = *func_ty.kind() + && def_id == get_context_def_id + && let [arg] = &**args + && let Some(place) = arg.node.place() + { + let arg = + Rvalue::Cast( + CastKind::Transmute, + Operand::Copy(place.project_deeper( + &[PlaceElem::Field(FieldIdx::ZERO, resume_nonnull_ty)], + tcx, + )), + context_mut_ref, + ); + let assign = Statement::new( + terminator.source_info, + StatementKind::Assign(Box::new((*destination, arg))), + ); + terminator.kind = TerminatorKind::Goto { target: target.unwrap() }; + bb_data.statements.push(assign); } } } -fn eliminate_get_context_call<'tcx>(bb_data: &mut BasicBlockData<'tcx>) -> Local { - let terminator = bb_data.terminator.take().unwrap(); - let TerminatorKind::Call { args, destination, target, .. } = terminator.kind else { - bug!(); - }; - let [arg] = *Box::try_from(args).unwrap(); - let local = arg.node.place().unwrap().local; - - let arg = Rvalue::Use(arg.node, WithRetag::Yes); - let assign = - Statement::new(terminator.source_info, StatementKind::Assign(Box::new((destination, arg)))); - bb_data.statements.push(assign); - bb_data.terminator = Some(Terminator { - source_info: terminator.source_info, - kind: TerminatorKind::Goto { target: target.unwrap() }, - }); - local -} - -#[cfg_attr(not(debug_assertions), allow(unused))] -#[tracing::instrument(level = "trace", skip(tcx, body), ret)] -fn replace_resume_ty_local<'tcx>( - tcx: TyCtxt<'tcx>, - body: &mut Body<'tcx>, - local: Local, - context_mut_ref: Ty<'tcx>, -) { - let local_ty = std::mem::replace(&mut body.local_decls[local].ty, context_mut_ref); - // We have to replace the `ResumeTy` that is used for type and borrow checking - // with `&mut Context<'_>` in MIR. - #[cfg(debug_assertions)] - { - if let ty::Adt(resume_ty_adt, _) = local_ty.kind() { - let expected_adt = tcx.adt_def(tcx.require_lang_item(LangItem::ResumeTy, body.span)); - assert_eq!(*resume_ty_adt, expected_adt); - } else { - panic!("expected `ResumeTy`, found `{:?}`", local_ty); - }; - } -} - -/// Transforms the `body` of the coroutine applying the following transform: -/// -/// - Remove the `resume` argument. -/// -/// Ideally the async lowering would not add the `resume` argument. -/// -/// The async lowering step and the type / lifetime inference / checking are -/// still using the `resume` argument for the time being. After this transform, -/// the coroutine body doesn't have the `resume` argument. -fn transform_gen_context<'tcx>(body: &mut Body<'tcx>) { - // This leaves the local representing the `resume` argument in place, - // but turns it into a regular local variable. This is cheaper than - // adjusting all local references in the body after removing it. - body.arg_count = 1; -} - /// Replaces the entry point of `body` with a block that switches on the coroutine discriminant and /// dispatches to blocks according to `cases`. /// @@ -874,18 +868,27 @@ fn create_coroutine_resume_function<'tcx>( } } - // Make sure we remove dead blocks to remove - // unrelated code from the drop part of the function - simplify::remove_dead_blocks(body); - - pm::run_passes_no_validate(tcx, body, &[&abort_unwinding_calls::AbortUnwindingCalls], None); - // Run derefer to fix Derefs that are not in the first place deref_finder(tcx, body, false); + if transform.coroutine_kind.is_async_desugaring() { + transform_async_context(tcx, body); + } + if let Some(dumper) = MirDumper::new(tcx, "coroutine_resume", body) { dumper.dump_mir(body); } + + pm::run_passes_no_validate( + tcx, + body, + &[ + &crate::abort_unwinding_calls::AbortUnwindingCalls, + &crate::simplify::SimplifyCfg::PostStateTransform, + &crate::simplify::SimplifyLocals::PostStateTransform, + ], + None, + ); } /// An operation that can be performed on a coroutine. @@ -1025,12 +1028,10 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform { // (finally in open_drop_for_tuple) before async drop expansion. // Async drops, produced by this drop elaboration, will be expanded, // and corresponding futures kept in layout. - let coroutine_is_async = coroutine_kind.is_async_desugaring(); let has_async_drops = has_async_drops(body); - // Replace all occurrences of `ResumeTy` with `&mut Context<'_>` within async bodies. - if coroutine_is_async { - transform_async_context(tcx, body); + if coroutine_kind.is_async_desugaring() { + eliminate_get_context_calls(tcx, body); } let always_live_locals = always_storage_live_locals(body); @@ -1097,13 +1098,9 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform { }), ); - // Update our MIR struct to reflect the changes we've made - body.arg_count = 2; // self, resume arg - body.spread_arg = None; - // Remove the context argument within generator bodies. if matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) { - transform_gen_context(body); + body.arg_count = 1; } // The original arguments to the function are no longer arguments, mark them as such. @@ -1150,7 +1147,7 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform { body.coroutine.as_mut().unwrap().coroutine_drop = Some(drop_shim); // For coroutine with sync drop, generating async proxy for `future_drop_poll` call - let proxy_shim = create_coroutine_drop_shim_proxy_async(tcx, body); + let proxy_shim = create_coroutine_drop_shim_proxy_async(tcx, body, coroutine_kind); body.coroutine.as_mut().unwrap().coroutine_drop_proxy_async = Some(proxy_shim); } diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 331c98fc198eb..e0d027b968e49 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -107,6 +107,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } } } + TerminatorKind::Yield { .. } => self.penalty += CALL_PENALTY, TerminatorKind::Call { func, unwind, .. } => { self.penalty += if let Some((def_id, ..)) = func.const_fn_def() && self.tcx.intrinsic(def_id).is_some() @@ -163,12 +164,11 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { TerminatorKind::Unreachable => { self.bonus += INSTR_COST; } - TerminatorKind::Goto { .. } | TerminatorKind::Return => {} + TerminatorKind::Goto { .. } + | TerminatorKind::Return + | TerminatorKind::CoroutineDrop => {} TerminatorKind::UnwindTerminate(..) => {} - kind @ (TerminatorKind::FalseUnwind { .. } - | TerminatorKind::FalseEdge { .. } - | TerminatorKind::Yield { .. } - | TerminatorKind::CoroutineDrop) => { + kind @ (TerminatorKind::FalseUnwind { .. } | TerminatorKind::FalseEdge { .. }) => { bug!("{kind:?} should not be in runtime MIR"); } } diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index c7d18bd1cc92f..d992dea41e0c7 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -239,9 +239,8 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { TerminatorKind::Drop { place, .. } => { state.flood_with(place.as_ref(), &self.map, FlatSet::::BOTTOM); } - TerminatorKind::Yield { .. } => { - // They would have an effect, but are not allowed in this phase. - bug!("encountered disallowed terminator"); + TerminatorKind::Yield { resume_arg, .. } => { + state.flood_with(resume_arg.as_ref(), &self.map, FlatSet::::BOTTOM); } TerminatorKind::SwitchInt { discr, targets } => { return self.handle_switch_int(discr, targets, state); diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index d185c11452dbe..f2b5c7fcf070a 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -2062,14 +2062,18 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, '_, 'tcx> { } fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) { - if let Terminator { kind: TerminatorKind::Call { destination, .. }, .. } = terminator { - if let Some(local) = destination.as_local() - && self.ssa.is_ssa(local) - { - let ty = self.local_decls[local].ty; - let opaque = self.new_opaque(ty); - self.assign(local, opaque); - } + let destination = match terminator.kind { + TerminatorKind::Call { destination, .. } => Some(destination), + TerminatorKind::Yield { resume_arg, .. } => Some(resume_arg), + _ => None, + }; + if let Some(destination) = destination + && let Some(local) = destination.as_local() + && self.ssa.is_ssa(local) + { + let ty = self.local_decls[local].ty; + let opaque = self.new_opaque(ty); + self.assign(local, opaque); } self.super_terminator(terminator, location); } diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 6c93472245d2f..9f2bd6c24f7dd 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -650,9 +650,9 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { let term = self.body.basic_blocks[bb].terminator(); let place_to_flood = match term.kind { // Disallowed during optimizations. - TerminatorKind::FalseEdge { .. } - | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::Yield { .. } => bug!("{term:?} invalid"), + TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => { + bug!("{term:?} invalid") + } // Cannot reason about inline asm. TerminatorKind::InlineAsm { .. } => { state.active.clear(); @@ -673,6 +673,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { | TerminatorKind::Goto { .. } => None, // Flood the overwritten place, and progress through. TerminatorKind::Drop { place: destination, .. } + | TerminatorKind::Yield { resume_arg: destination, .. } | TerminatorKind::Call { destination, .. } => Some(destination), TerminatorKind::TailCall { .. } => Some(RETURN_PLACE.into()), }; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 063f0f39ee06e..62cb2c9355c49 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -79,7 +79,7 @@ pub use shim::build_drop_shim; macro_rules! declare_passes { ( $( - $vis:vis mod $mod_name:ident : $($pass_name:ident $( { $($ident:ident),* } )?),+ $(,)?; + $vis:vis mod $mod_name:ident : $($pass_name:ident $( { $($ident:ident),* $(,)? } )?),+ $(,)?; )* ) => { $( @@ -186,12 +186,14 @@ declare_passes! { PreOptimizations, Final, MakeShim, - AfterUnreachableEnumBranching + AfterUnreachableEnumBranching, + PostStateTransform, }, SimplifyLocals { BeforeConstProp, AfterGVN, - Final + Final, + PostStateTransform, }; mod simplify_branches : SimplifyConstCondition { AfterInstSimplify, @@ -647,7 +649,6 @@ fn run_runtime_lowering_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &add_moves_for_packed_drops::AddMovesForPackedDrops, &erase_deref_temps::EraseDerefTemps, &elaborate_box_derefs::ElaborateBoxDerefs, - &coroutine::StateTransform, &Lint(known_panics_lint::KnownPanicsLint), ]; pm::run_passes_no_validate(tcx, body, passes, Some(MirPhase::Runtime(RuntimePhase::Initial))); @@ -765,6 +766,7 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<' &simplify::SimplifyLocals::Final, &multiple_return_terminators::MultipleReturnTerminators, &large_enums::EnumSizeOpt { discrepancy: 128 }, + &coroutine::StateTransform, // Some cleanup necessary at least for LLVM and potentially other codegen backends. &add_call_guards::CriticalCallEdges, // Cleanup for human readability, off by default. diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index dede4a31d88fa..36e4bc144bc29 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -115,7 +115,6 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceKind<'tcx>) -> Body< tcx, &mut body, &[ - &mentioned_items::MentionedItems, &abort_unwinding_calls::AbortUnwindingCalls, &add_call_guards::CriticalCallEdges, ], diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index e9c317ecdec21..c9603ecd41a8a 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -207,6 +207,7 @@ fn build_adrop_for_coroutine_shim<'tcx>( body.source.instance = instance; body.phase = MirPhase::Runtime(RuntimePhase::Initial); body.var_debug_info.clear(); + body.mentioned_items = None; // converting `(_1: Pin<&mut CorLayout>, _2: &mut Context<'_>) -> Poll<()>` // into `(_1: Pin<&mut ProxyLayout>, _2: &mut Context<'_>) -> Poll<()>` diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 14ab4fb0e74eb..cee727d4aedf7 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -57,6 +57,8 @@ pub(super) enum SimplifyCfg { Final, MakeShim, AfterUnreachableEnumBranching, + /// Extra run introduced by `StateTransform`. + PostStateTransform, } impl SimplifyCfg { @@ -72,6 +74,7 @@ impl SimplifyCfg { SimplifyCfg::AfterUnreachableEnumBranching => { "SimplifyCfg-after-unreachable-enum-branching" } + SimplifyCfg::PostStateTransform => "SimplifyCfg-post-StateTransform", } } } @@ -416,6 +419,8 @@ pub(super) enum SimplifyLocals { BeforeConstProp, AfterGVN, Final, + /// Extra run introduced by `StateTransform`. + PostStateTransform, } impl<'tcx> crate::MirPass<'tcx> for SimplifyLocals { @@ -424,6 +429,7 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyLocals { SimplifyLocals::BeforeConstProp => "SimplifyLocals-before-const-prop", SimplifyLocals::AfterGVN => "SimplifyLocals-after-value-numbering", SimplifyLocals::Final => "SimplifyLocals-final", + SimplifyLocals::PostStateTransform => "SimplifyLocals-post-StateTransform", } } diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 3dca3f09db65d..1858a61232b47 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -449,7 +449,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { if self.body.coroutine.is_none() { self.fail(location, "`Yield` cannot appear outside coroutine bodies"); } - if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) { + if self.body.phase >= MirPhase::Runtime(RuntimePhase::Optimized) { self.fail(location, "`Yield` should have been replaced by coroutine lowering"); } self.check_edge(location, *resume, EdgeKind::Normal); @@ -487,7 +487,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { if self.body.coroutine.is_none() { self.fail(location, "`CoroutineDrop` cannot appear outside coroutine bodies"); } - if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) { + if self.body.phase >= MirPhase::Runtime(RuntimePhase::Optimized) { self.fail( location, "`CoroutineDrop` should have been replaced by coroutine lowering", diff --git a/tests/crashes/140303.rs b/tests/crashes/140303.rs deleted file mode 100644 index 43a20b5e58ed4..0000000000000 --- a/tests/crashes/140303.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #140303 -//@compile-flags: -Zvalidate-mir -use std::future::Future; -async fn a() -> impl Sized { - b(c) -} -async fn c(); // kaboom -fn b(e: d) -> impl Sized -where - d: f, -{ - || -> ::h { panic!() } -} -trait f { - type h; -} -impl f for d -where - d: Fn() -> g, - g: Future, -{ -} diff --git a/tests/mir-opt/coroutine/async_await.a-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_await.a-{closure#0}.StateTransform.diff index dddd66e73fd51..14d79998bb6ed 100644 --- a/tests/mir-opt/coroutine/async_await.a-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_await.a-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn a::{closure#0}(_1: {async fn body of a()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + variant_fields = { @@ -13,44 +15,40 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _6; + let mut _0: std::task::Poll<()>; + let mut _3: (); + let mut _4: u32; + let mut _5: &mut {async fn body of a()}; ++ let mut _6: std::future::ResumeTy; ++ let mut _7: std::ptr::NonNull>; bb0: { - _0 = const (); - drop(_1) -> [return: bb1, unwind: bb2]; ++ _7 = move _2 as std::ptr::NonNull> (Transmute); ++ _6 = std::future::ResumeTy(move _7); + _5 = copy (_1.0: &mut {async fn body of a()}); + _4 = discriminant((*_5)); -+ switchInt(move _4) -> [0: bb5, 1: bb3, otherwise: bb4]; ++ switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; } bb1: { -+ _0 = Poll::<()>::Ready(move _3); -+ discriminant((*_5)) = 1; - return; +- return; ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; } - bb2 (cleanup): { - resume; + bb2: { -+ goto -> bb1; -+ } -+ -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; -+ } -+ -+ bb4: { + unreachable; + } + -+ bb5: { ++ bb3: { + _3 = const (); -+ goto -> bb2; ++ _0 = Poll::<()>::Ready(move _3); ++ discriminant((*_5)) = 1; ++ return; } } diff --git a/tests/mir-opt/coroutine/async_await.b-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_await.b-{closure#0}.StateTransform.diff index fdbc67d51bd34..33234cf7634cc 100644 --- a/tests/mir-opt/coroutine/async_await.b-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_await.b-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn b::{closure#0}(_1: {async fn body of b()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: {async fn body of a()}; @@ -17,8 +19,7 @@ + } + storage_conflicts = BitMatrix(2x2) {(_s0, _s0), (_s1, _s1)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _40; + coroutine debug __awaitee => _s0; + coroutine debug __awaitee => _s1; + let mut _0: std::task::Poll<()>; @@ -34,12 +35,10 @@ let mut _12: &mut {async fn body of a()}; let mut _13: &mut std::task::Context<'_>; let mut _14: &mut std::task::Context<'_>; -- let mut _15: std::future::ResumeTy; -+ let mut _15: &mut std::task::Context<'_>; + let mut _15: std::future::ResumeTy; let mut _16: isize; let mut _18: !; -- let mut _19: std::future::ResumeTy; -+ let mut _19: &mut std::task::Context<'_>; + let mut _19: std::future::ResumeTy; let mut _20: (); let mut _21: {async fn body of a()}; let mut _22: {async fn body of a()}; @@ -51,16 +50,16 @@ let mut _28: &mut {async fn body of a()}; let mut _29: &mut std::task::Context<'_>; let mut _30: &mut std::task::Context<'_>; -- let mut _31: std::future::ResumeTy; -+ let mut _31: &mut std::task::Context<'_>; + let mut _31: std::future::ResumeTy; let mut _32: isize; let mut _34: !; -- let mut _35: std::future::ResumeTy; -+ let mut _35: &mut std::task::Context<'_>; + let mut _35: std::future::ResumeTy; let mut _36: (); + let mut _37: (); + let mut _38: u32; + let mut _39: &mut {async fn body of b()}; ++ let mut _40: std::future::ResumeTy; ++ let mut _41: std::ptr::NonNull>; scope 1 { - debug __awaitee => _6; + debug __awaitee => (((*_39) as variant#3).0: {async fn body of a()}); @@ -82,23 +81,23 @@ - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); -- _5 = a() -> [return: bb1, unwind: bb47]; +- _5 = a() -> [return: bb1, unwind: bb41]; ++ _41 = move _2 as std::ptr::NonNull> (Transmute); ++ _40 = std::future::ResumeTy(move _41); + _39 = copy (_1.0: &mut {async fn body of b()}); + _38 = discriminant((*_39)); -+ switchInt(move _38) -> [0: bb47, 1: bb46, 2: bb45, 3: bb43, 4: bb44, otherwise: bb7]; ++ switchInt(move _38) -> [0: bb33, 1: bb32, 2: bb31, 3: bb29, 4: bb30, otherwise: bb6]; } bb1: { -- _4 = <{async fn body of a()} as IntoFuture>::into_future(move _5) -> [return: bb2, unwind: bb46]; -+ _4 = <{async fn body of a()} as IntoFuture>::into_future(move _5) -> [return: bb2, unwind: bb36]; +- _4 = <{async fn body of a()} as IntoFuture>::into_future(move _5) -> [return: bb2, unwind: bb41]; ++ _4 = <{async fn body of a()} as IntoFuture>::into_future(move _5) -> [return: bb2, unwind: bb26]; } bb2: { StorageDead(_5); - PlaceMention(_4); - StorageLive(_6); - _6 = move _4; -+ nop; + (((*_39) as variant#3).0: {async fn body of a()}) = move _4; goto -> bb3; } @@ -112,8 +111,8 @@ - _12 = &mut _6; + _12 = &mut (((*_39) as variant#3).0: {async fn body of a()}); _11 = &mut (*_12); -- _10 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _11) -> [return: bb4, unwind: bb43]; -+ _10 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _11) -> [return: bb4, unwind: bb33]; +- _10 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _11) -> [return: bb4, unwind: bb38]; ++ _10 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _11) -> [return: bb4, unwind: bb24]; } bb4: { @@ -121,32 +120,35 @@ StorageLive(_13); StorageLive(_14); StorageLive(_15); - _15 = copy _2; -- _14 = std::future::get_context::<'_, '_>(move _15) -> [return: bb5, unwind: bb41]; -+ _14 = move _15; -+ goto -> bb5; - } - - bb5: { +- _15 = copy _2; +- _14 = std::future::get_context::<'_, '_>(move _15) -> [return: bb5, unwind: bb36]; +- } +- +- bb5: { ++ _15 = copy _40; ++ _14 = copy (_15.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _13 = &mut (*_14); StorageDead(_15); -- _9 = <{async fn body of a()} as Future>::poll(move _10, move _13) -> [return: bb6, unwind: bb42]; -+ _9 = <{async fn body of a()} as Future>::poll(move _10, move _13) -> [return: bb6, unwind: bb32]; +- _9 = <{async fn body of a()} as Future>::poll(move _10, move _13) -> [return: bb6, unwind: bb37]; ++ _9 = <{async fn body of a()} as Future>::poll(move _10, move _13) -> [return: bb5, unwind: bb23]; } - bb6: { +- bb6: { ++ bb5: { StorageDead(_13); StorageDead(_10); - PlaceMention(_9); _16 = discriminant(_9); - switchInt(move _16) -> [0: bb9, 1: bb8, otherwise: bb7]; +- switchInt(move _16) -> [0: bb9, 1: bb8, otherwise: bb7]; ++ switchInt(move _16) -> [0: bb8, 1: bb7, otherwise: bb6]; } - bb7: { +- bb7: { ++ bb6: { unreachable; } - bb8: { +- bb8: { ++ bb7: { _8 = const (); StorageDead(_14); StorageDead(_12); @@ -155,7 +157,7 @@ StorageLive(_19); StorageLive(_20); _20 = (); -- _19 = yield(move _20) -> [resume: bb10, drop: bb28]; +- _19 = yield(move _20) -> [resume: bb10, drop: bb25]; + _0 = Poll::<()>::Pending; + StorageDead(_3); + StorageDead(_4); @@ -165,7 +167,8 @@ + return; } - bb9: { +- bb9: { ++ bb8: { StorageLive(_17); _17 = copy ((_9 as Ready).0: ()); _3 = copy _17; @@ -174,49 +177,47 @@ StorageDead(_12); StorageDead(_9); StorageDead(_8); -- drop(_6) -> [return: bb11, unwind: bb45]; -+ drop((((*_39) as variant#3).0: {async fn body of a()})) -> [return: bb11, unwind: bb35]; - } - - bb10: { - StorageDead(_20); - _2 = move _19; - StorageDead(_19); - _7 = const (); - goto -> bb3; +- drop(_6) -> [return: bb11, unwind: bb40]; ++ drop((((*_39) as variant#3).0: {async fn body of a()})) -> [return: bb9, unwind: bb27]; } - bb11: { +- bb10: { +- StorageDead(_20); +- _2 = move _19; +- StorageDead(_19); +- _7 = const (); +- goto -> bb3; +- } +- +- bb11: { - StorageDead(_6); -+ nop; - goto -> bb12; - } - - bb12: { ++ bb9: { StorageDead(_4); StorageDead(_3); StorageLive(_21); StorageLive(_22); -- _22 = a() -> [return: bb13, unwind: bb39]; -+ _22 = a() -> [return: bb13, unwind: bb30]; +- _22 = a() -> [return: bb12, unwind: bb34]; ++ _22 = a() -> [return: bb10, unwind: bb21]; } - bb13: { -- _21 = <{async fn body of a()} as IntoFuture>::into_future(move _22) -> [return: bb14, unwind: bb38]; -+ _21 = <{async fn body of a()} as IntoFuture>::into_future(move _22) -> [return: bb14, unwind: bb29]; +- bb12: { +- _21 = <{async fn body of a()} as IntoFuture>::into_future(move _22) -> [return: bb13, unwind: bb34]; ++ bb10: { ++ _21 = <{async fn body of a()} as IntoFuture>::into_future(move _22) -> [return: bb11, unwind: bb21]; } - bb14: { +- bb13: { ++ bb11: { StorageDead(_22); - PlaceMention(_21); - StorageLive(_23); - _23 = move _21; -+ nop; +- goto -> bb14; + (((*_39) as variant#4).0: {async fn body of a()}) = move _21; - goto -> bb15; ++ goto -> bb12; } - bb15: { +- bb14: { ++ bb12: { StorageLive(_24); StorageLive(_25); StorageLive(_26); @@ -225,37 +226,40 @@ - _28 = &mut _23; + _28 = &mut (((*_39) as variant#4).0: {async fn body of a()}); _27 = &mut (*_28); -- _26 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _27) -> [return: bb16, unwind: bb35]; -+ _26 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _27) -> [return: bb16, unwind: bb26]; +- _26 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _27) -> [return: bb15, unwind: bb31]; ++ _26 = Pin::<&mut {async fn body of a()}>::new_unchecked(move _27) -> [return: bb13, unwind: bb19]; } - bb16: { +- bb15: { ++ bb13: { StorageDead(_27); StorageLive(_29); StorageLive(_30); StorageLive(_31); - _31 = copy _2; -- _30 = std::future::get_context::<'_, '_>(move _31) -> [return: bb17, unwind: bb33]; -+ _30 = move _31; -+ goto -> bb17; - } - - bb17: { +- _31 = copy _2; +- _30 = std::future::get_context::<'_, '_>(move _31) -> [return: bb16, unwind: bb29]; +- } +- +- bb16: { ++ _31 = copy _40; ++ _30 = copy (_31.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _29 = &mut (*_30); StorageDead(_31); -- _25 = <{async fn body of a()} as Future>::poll(move _26, move _29) -> [return: bb18, unwind: bb34]; -+ _25 = <{async fn body of a()} as Future>::poll(move _26, move _29) -> [return: bb18, unwind: bb25]; +- _25 = <{async fn body of a()} as Future>::poll(move _26, move _29) -> [return: bb17, unwind: bb30]; ++ _25 = <{async fn body of a()} as Future>::poll(move _26, move _29) -> [return: bb14, unwind: bb18]; } - bb18: { +- bb17: { ++ bb14: { StorageDead(_29); StorageDead(_26); - PlaceMention(_25); _32 = discriminant(_25); - switchInt(move _32) -> [0: bb20, 1: bb19, otherwise: bb7]; +- switchInt(move _32) -> [0: bb19, 1: bb18, otherwise: bb7]; ++ switchInt(move _32) -> [0: bb16, 1: bb15, otherwise: bb6]; } - bb19: { +- bb18: { ++ bb15: { _24 = const (); StorageDead(_30); StorageDead(_28); @@ -264,7 +268,7 @@ StorageLive(_35); StorageLive(_36); _36 = (); -- _35 = yield(move _36) -> [resume: bb21, drop: bb25]; +- _35 = yield(move _36) -> [resume: bb20, drop: bb23]; + _0 = Poll::<()>::Pending; + StorageDead(_21); + StorageDead(_35); @@ -273,7 +277,8 @@ + return; } - bb20: { +- bb19: { ++ bb16: { StorageLive(_33); _33 = copy ((_25 as Ready).0: ()); - _0 = copy _33; @@ -283,261 +288,223 @@ StorageDead(_28); StorageDead(_25); StorageDead(_24); -- drop(_23) -> [return: bb22, unwind: bb37]; -+ drop((((*_39) as variant#4).0: {async fn body of a()})) -> [return: bb22, unwind: bb28]; - } - - bb21: { - StorageDead(_36); - _2 = move _35; - StorageDead(_35); - _7 = const (); - goto -> bb15; +- drop(_23) -> [return: bb21, unwind: bb33]; ++ drop((((*_39) as variant#4).0: {async fn body of a()})) -> [return: bb17, unwind: bb22]; } - bb22: { +- bb20: { +- StorageDead(_36); +- _2 = move _35; +- StorageDead(_35); +- _7 = const (); +- goto -> bb14; +- } +- +- bb21: { - StorageDead(_23); -+ nop; - goto -> bb23; - } - - bb23: { ++ bb17: { StorageDead(_21); -- drop(_1) -> [return: bb24, unwind: bb50]; -+ goto -> bb41; - } - - bb24: { +- drop(_1) -> [return: bb22, unwind: bb44]; +- } +- +- bb22: { + _0 = Poll::<()>::Ready(move _37); + discriminant((*_39)) = 1; return; } -- bb25: { +- bb23: { - StorageDead(_36); - StorageDead(_35); -- drop(_23) -> [return: bb26, unwind: bb51]; +- drop(_23) -> [return: bb24, unwind: bb45]; - } - -- bb26: { +- bb24: { - StorageDead(_23); -- goto -> bb27; -- } -- -- bb27: { - StorageDead(_21); -- goto -> bb31; +- goto -> bb27; - } - -- bb28: { +- bb25: { - StorageDead(_20); - StorageDead(_19); -- drop(_6) -> [return: bb29, unwind: bb53]; +- drop(_6) -> [return: bb26, unwind: bb46]; - } - -- bb29: { +- bb26: { - StorageDead(_6); -- goto -> bb30; -- } -- -- bb30: { - StorageDead(_4); - StorageDead(_3); -- goto -> bb31; +- goto -> bb27; - } - -- bb31: { -- drop(_1) -> [return: bb32, unwind: bb50]; +- bb27: { +- drop(_1) -> [return: bb28, unwind: bb44]; - } - -- bb32: { +- bb28: { - coroutine_drop; - } - -- bb33 (cleanup): { +- bb29 (cleanup): { - StorageDead(_31); -- goto -> bb34; +- goto -> bb30; - } - -- bb34 (cleanup): { -+ bb25 (cleanup): { +- bb30 (cleanup): { ++ bb18 (cleanup): { StorageDead(_29); StorageDead(_26); StorageDead(_30); -- goto -> bb36; -+ goto -> bb27; +- goto -> bb32; ++ goto -> bb20; } -- bb35 (cleanup): { -+ bb26 (cleanup): { +- bb31 (cleanup): { ++ bb19 (cleanup): { StorageDead(_27); StorageDead(_26); -- goto -> bb36; -+ goto -> bb27; +- goto -> bb32; ++ goto -> bb20; } -- bb36 (cleanup): { -+ bb27 (cleanup): { +- bb32 (cleanup): { ++ bb20 (cleanup): { StorageDead(_28); StorageDead(_25); StorageDead(_24); -- drop(_23) -> [return: bb37, unwind terminate(cleanup)]; -+ drop((((*_39) as variant#4).0: {async fn body of a()})) -> [return: bb28, unwind terminate(cleanup)]; +- drop(_23) -> [return: bb33, unwind terminate(cleanup)]; ++ drop((((*_39) as variant#4).0: {async fn body of a()})) -> [return: bb22, unwind terminate(cleanup)]; } -- bb37 (cleanup): { +- bb33 (cleanup): { - StorageDead(_23); -- goto -> bb40; -+ bb28 (cleanup): { -+ nop; -+ goto -> bb31; - } - -- bb38 (cleanup): { -- goto -> bb39; -+ bb29 (cleanup): { -+ goto -> bb30; - } - -- bb39 (cleanup): { -+ bb30 (cleanup): { +- goto -> bb35; +- } +- +- bb34 (cleanup): { ++ bb21 (cleanup): { StorageDead(_22); -- goto -> bb40; -+ goto -> bb31; +- goto -> bb35; ++ goto -> bb22; } -- bb40 (cleanup): { -+ bb31 (cleanup): { +- bb35 (cleanup): { ++ bb22 (cleanup): { StorageDead(_21); -- goto -> bb49; -+ goto -> bb39; +- goto -> bb43; ++ goto -> bb28; } -- bb41 (cleanup): { +- bb36 (cleanup): { - StorageDead(_15); -- goto -> bb42; +- goto -> bb37; - } - -- bb42 (cleanup): { -+ bb32 (cleanup): { +- bb37 (cleanup): { ++ bb23 (cleanup): { StorageDead(_13); StorageDead(_10); StorageDead(_14); -- goto -> bb44; -+ goto -> bb34; +- goto -> bb39; ++ goto -> bb25; } -- bb43 (cleanup): { -+ bb33 (cleanup): { +- bb38 (cleanup): { ++ bb24 (cleanup): { StorageDead(_11); StorageDead(_10); -- goto -> bb44; -+ goto -> bb34; +- goto -> bb39; ++ goto -> bb25; } -- bb44 (cleanup): { -+ bb34 (cleanup): { +- bb39 (cleanup): { ++ bb25 (cleanup): { StorageDead(_12); StorageDead(_9); StorageDead(_8); -- drop(_6) -> [return: bb45, unwind terminate(cleanup)]; -+ drop((((*_39) as variant#3).0: {async fn body of a()})) -> [return: bb35, unwind terminate(cleanup)]; +- drop(_6) -> [return: bb40, unwind terminate(cleanup)]; ++ drop((((*_39) as variant#3).0: {async fn body of a()})) -> [return: bb27, unwind terminate(cleanup)]; } -- bb45 (cleanup): { +- bb40 (cleanup): { - StorageDead(_6); -- goto -> bb48; -+ bb35 (cleanup): { -+ nop; -+ goto -> bb38; - } - -- bb46 (cleanup): { -- goto -> bb47; -+ bb36 (cleanup): { -+ goto -> bb37; - } - -- bb47 (cleanup): { -+ bb37 (cleanup): { +- goto -> bb42; +- } +- +- bb41 (cleanup): { ++ bb26 (cleanup): { StorageDead(_5); -- goto -> bb48; -+ goto -> bb38; +- goto -> bb42; ++ goto -> bb27; } -- bb48 (cleanup): { -+ bb38 (cleanup): { +- bb42 (cleanup): { ++ bb27 (cleanup): { StorageDead(_4); StorageDead(_3); -- goto -> bb49; -+ goto -> bb39; - } - -- bb49 (cleanup): { -- drop(_1) -> [return: bb50, unwind terminate(cleanup)]; -+ bb39 (cleanup): { -+ goto -> bb40; +- goto -> bb43; ++ goto -> bb28; } -- bb50 (cleanup): { -+ bb40 (cleanup): { -+ goto -> bb42; -+ } -+ -+ bb41: { -+ goto -> bb24; -+ } -+ -+ bb42 (cleanup): { +- bb43 (cleanup): { +- drop(_1) -> [return: bb44, unwind terminate(cleanup)]; ++ bb28 (cleanup): { + discriminant((*_39)) = 2; - resume; ++ resume; } -- bb51 (cleanup): { -- StorageDead(_23); -- goto -> bb52; -+ bb43: { +- bb44 (cleanup): { +- resume; ++ bb29: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_19); + StorageLive(_20); -+ _19 = move _2; -+ goto -> bb10; ++ _19 = move _40; ++ StorageDead(_20); ++ _40 = move _19; ++ StorageDead(_19); ++ _7 = const (); ++ goto -> bb3; } -- bb52 (cleanup): { +- bb45 (cleanup): { +- StorageDead(_23); - StorageDead(_21); -- goto -> bb55; -+ bb44: { +- goto -> bb47; ++ bb30: { + StorageLive(_21); + StorageLive(_35); + StorageLive(_36); -+ _35 = move _2; -+ goto -> bb21; ++ _35 = move _40; ++ StorageDead(_36); ++ _40 = move _35; ++ StorageDead(_35); ++ _7 = const (); ++ goto -> bb12; } -- bb53 (cleanup): { +- bb46 (cleanup): { - StorageDead(_6); -- goto -> bb54; -+ bb45: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb45, unwind continue]; - } - -- bb54 (cleanup): { - StorageDead(_4); - StorageDead(_3); -- goto -> bb55; -+ bb46: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb46, unwind continue]; +- goto -> bb47; ++ bb31: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb31, unwind continue]; } -- bb55 (cleanup): { -- drop(_1) -> [return: bb50, unwind terminate(cleanup)]; -+ bb47: { +- bb47 (cleanup): { +- drop(_1) -> [return: bb44, unwind terminate(cleanup)]; ++ bb32: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb32, unwind continue]; ++ } ++ ++ bb33: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); -+ _5 = a() -> [return: bb1, unwind: bb37]; ++ _5 = a() -> [return: bb1, unwind: bb26]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff index aedc5a0e9e9c4..b07234c8094f9 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff @@ -1,60 +1,50 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ field _s0: &mut AsyncEnum; -+ field _s1: impl Future; -+ field _s2: impl Future; -+ field _s3: impl Future; -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ Suspend0 (3): [_s1], -+ Suspend1 (4): [_s2], -+ Suspend2 (5): [_s2], -+ Suspend3 (6): [_s0, _s3], -+ Suspend4 (7): [_s0, _s3], -+ } -+ storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3)} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: &mut AsyncEnum; + field _s1: impl Future; + field _s2: impl Future; + field _s3: impl Future; + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + Suspend0 (3): [_s1], + Suspend1 (4): [_s2], + Suspend2 (5): [_s2], + Suspend3 (6): [_s0, _s3], + Suspend4 (7): [_s0, _s3], + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3)} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut AsyncEnum; let mut _4: impl std::future::Future; -- let mut _5: std::future::ResumeTy; -+ let mut _5: &mut std::task::Context<'_>; + let mut _5: std::future::ResumeTy; let mut _6: std::task::Poll<()>; let mut _7: isize; let mut _8: std::pin::Pin<&mut impl std::future::Future>; let mut _9: &mut std::task::Context<'_>; -- let mut _10: std::future::ResumeTy; -+ let mut _10: &mut std::task::Context<'_>; + let mut _10: std::future::ResumeTy; let mut _11: &mut impl std::future::Future; let mut _12: std::pin::Pin<&mut AsyncInt>; let mut _13: &mut AsyncInt; let mut _14: impl std::future::Future; -- let mut _15: std::future::ResumeTy; -+ let mut _15: &mut std::task::Context<'_>; + let mut _15: std::future::ResumeTy; let mut _16: std::task::Poll<()>; let mut _17: isize; let mut _18: std::pin::Pin<&mut impl std::future::Future>; let mut _19: &mut std::task::Context<'_>; -- let mut _20: std::future::ResumeTy; -+ let mut _20: &mut std::task::Context<'_>; + let mut _20: std::future::ResumeTy; let mut _21: &mut impl std::future::Future; -- let mut _22: std::future::ResumeTy; -+ let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: std::task::Poll<()>; let mut _24: isize; let mut _25: std::pin::Pin<&mut impl std::future::Future>; let mut _26: &mut std::task::Context<'_>; -- let mut _27: std::future::ResumeTy; -+ let mut _27: &mut std::task::Context<'_>; + let mut _27: std::future::ResumeTy; let mut _28: &mut impl std::future::Future; let mut _29: std::pin::Pin<&mut AsyncInt>; let mut _30: &mut AsyncInt; @@ -62,446 +52,216 @@ let mut _32: isize; let mut _33: isize; let mut _34: impl std::future::Future; -- let mut _35: std::future::ResumeTy; -+ let mut _35: &mut std::task::Context<'_>; + let mut _35: std::future::ResumeTy; let mut _36: std::task::Poll<()>; let mut _37: isize; let mut _38: std::pin::Pin<&mut impl std::future::Future>; let mut _39: &mut std::task::Context<'_>; -- let mut _40: std::future::ResumeTy; -+ let mut _40: &mut std::task::Context<'_>; + let mut _40: std::future::ResumeTy; let mut _41: &mut impl std::future::Future; -- let mut _42: std::future::ResumeTy; -+ let mut _42: &mut std::task::Context<'_>; + let mut _42: std::future::ResumeTy; let mut _43: std::task::Poll<()>; let mut _44: isize; let mut _45: std::pin::Pin<&mut impl std::future::Future>; let mut _46: &mut std::task::Context<'_>; -- let mut _47: std::future::ResumeTy; -+ let mut _47: &mut std::task::Context<'_>; + let mut _47: std::future::ResumeTy; let mut _48: &mut impl std::future::Future; let mut _49: std::pin::Pin<&mut AsyncEnum>; let mut _50: &mut AsyncEnum; -+ let mut _51: (); -+ let mut _52: u32; -+ let mut _53: &mut {async fn body of std::future::async_drop_in_place()}; -+ let mut _54: &mut AsyncEnum; -+ let mut _55: &mut AsyncEnum; -+ let mut _56: &mut AsyncEnum; -+ let mut _57: &mut AsyncEnum; -+ let mut _58: &mut AsyncEnum; -+ let mut _59: &mut AsyncEnum; -+ let mut _60: &mut AsyncEnum; + let mut _51: (); + let mut _52: u32; + let mut _53: &mut {async fn body of std::future::async_drop_in_place()}; + let mut _54: &mut AsyncEnum; + let mut _55: &mut AsyncEnum; + let mut _56: &mut AsyncEnum; + let mut _57: &mut AsyncEnum; + let mut _58: &mut AsyncEnum; + let mut _59: &mut AsyncEnum; + let mut _60: &mut AsyncEnum; + let mut _61: &mut AsyncEnum; + let mut _62: &mut AsyncEnum; + let mut _63: &mut AsyncEnum; + let _64: std::future::ResumeTy; + let mut _65: std::ptr::NonNull>; bb0: { -- _3 = move (_1.0: &mut AsyncEnum); -- _50 = &mut (*_3); -- _49 = Pin::<&mut AsyncEnum>::new_unchecked(move _50) -> [return: bb59, unwind: bb40]; -+ _53 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _52 = discriminant((*_53)); -+ switchInt(move _52) -> [0: bb42, 1: bb41, 2: bb40, 3: bb35, 4: bb36, 5: bb37, 6: bb38, 7: bb39, otherwise: bb7]; + _65 = move _2 as std::ptr::NonNull> (Transmute); + _64 = std::future::ResumeTy(move _65); + _53 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _52 = discriminant((*_53)); + switchInt(move _52) -> [0: bb30, 1: bb29, 2: bb28, 3: bb23, 4: bb24, 5: bb25, 6: bb26, 7: bb27, otherwise: bb5]; } bb1: { -+ _0 = Poll::<()>::Ready(move _51); -+ discriminant((*_53)) = 1; + _0 = Poll::<()>::Ready(move _51); + discriminant((*_53)) = 1; return; } bb2 (cleanup): { -- resume; -+ goto -> bb34; + discriminant((*_53)) = 2; + resume; } bb3 (cleanup): { -- drop((((*_3) as A).0: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; -+ _54 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ drop((((*_54) as A).0: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; + _54 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + drop((((*_54) as A).0: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; } -- bb4: { -- StorageDead(_4); -- goto -> bb1; -+ bb4 (cleanup): { -+ nop; -+ goto -> bb2; + bb4: { + assert(const false, "`async fn` resumed after async drop") -> [success: bb4, unwind: bb2]; } -- bb5 (cleanup): { -- StorageDead(_4); -- goto -> bb2; -+ bb5: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb5, unwind: bb4]; + bb5: { + unreachable; } bb6: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb5]; -+ _2 = move _5; -+ StorageDead(_5); -+ goto -> bb5; + assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb2]; } bb7: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb6; -+ unreachable; + StorageLive(_22); + _0 = Poll::<()>::Pending; + StorageDead(_22); + discriminant((*_53)) = 5; + return; } bb8: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb14; -+ nop; -+ goto -> bb1; + _24 = discriminant(_23); + switchInt(move _24) -> [0: bb1, 1: bb7, otherwise: bb5]; } -- bb9: { -- StorageLive(_5); -- _5 = yield(const ()) -> [resume: bb7, drop: bb8]; -+ bb9 (cleanup): { -+ nop; -+ goto -> bb2; + bb9: { + _27 = move _64; + _26 = copy (_27.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _23 = as Future>::poll(move _25, move _26) -> [return: bb8, unwind: bb2]; } bb10: { -- unreachable; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb10, unwind: bb9]; + _28 = &mut (((*_53) as variant#5).0: impl std::future::Future); + _25 = Pin::<&mut impl Future>::new_unchecked(move _28) -> [return: bb9, unwind: bb2]; } bb11: { -- _7 = discriminant(_6); -- switchInt(move _7) -> [0: bb4, 1: bb9, otherwise: bb10]; -+ _2 = move _15; -+ StorageDead(_15); -+ goto -> bb10; + (((*_53) as variant#5).0: impl std::future::Future) = async_drop_in_place::(copy (_29.0: &mut AsyncInt)) -> [return: bb10, unwind: bb2]; } bb12: { -- _6 = as Future>::poll(move _8, move _9) -> [return: bb11, unwind: bb5]; -+ _2 = move _22; -+ StorageDead(_22); -+ goto -> bb17; + _56 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + _30 = &mut (((*_56) as A).0: AsyncInt); + _29 = Pin::<&mut AsyncInt>::new_unchecked(move _30) -> [return: bb11, unwind: bb2]; } - bb13: { -- _10 = move _2; -- _9 = std::future::get_context::<'_, '_>(move _10) -> [return: bb12, unwind: bb5]; -+ StorageLive(_22); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_22); -+ discriminant((*_53)) = 5; -+ return; + bb13 (cleanup): { + _57 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + drop((((*_57) as B).0: SyncInt)) -> [return: bb2, unwind terminate(cleanup)]; } bb14: { -- _11 = &mut _4; -- _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb13, unwind: bb5]; -+ _24 = discriminant(_23); -+ switchInt(move _24) -> [0: bb8, 1: bb13, otherwise: bb7]; + _59 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + drop((((*_59) as B).0: SyncInt)) -> [return: bb1, unwind: bb2]; } - bb15: { -- StorageLive(_4); -- _4 = async_drop_in_place::(copy (_12.0: &mut AsyncInt)) -> [return: bb14, unwind: bb5]; -+ _23 = as Future>::poll(move _25, move _26) -> [return: bb14, unwind: bb9]; + bb15 (cleanup): { + _60 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + _32 = discriminant((*_60)); + switchInt(move _32) -> [0: bb3, otherwise: bb13]; } bb16: { -- _13 = &mut (((*_3) as A).0: AsyncInt); -- _12 = Pin::<&mut AsyncInt>::new_unchecked(move _13) -> [return: bb15, unwind: bb2]; -+ _27 = move _2; -+ _26 = move _27; -+ goto -> bb15; + _61 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + _31 = discriminant((*_61)); + switchInt(move _31) -> [0: bb12, otherwise: bb14]; } bb17: { -- StorageDead(_14); -- goto -> bb1; -+ _28 = &mut (((*_53) as variant#5).0: impl std::future::Future); -+ _25 = Pin::<&mut impl Future>::new_unchecked(move _28) -> [return: bb16, unwind: bb9]; + assert(const false, "`async fn` resumed after async drop") -> [success: bb17, unwind: bb15]; } bb18: { -- StorageDead(_14); -- goto -> bb1; -+ nop; -+ (((*_53) as variant#5).0: impl std::future::Future) = async_drop_in_place::(copy (_29.0: &mut AsyncInt)) -> [return: bb17, unwind: bb9]; + StorageLive(_42); + _0 = Poll::<()>::Pending; + StorageDead(_42); + discriminant((*_53)) = 7; + return; } -- bb19 (cleanup): { -- StorageDead(_14); -- goto -> bb2; -+ bb19: { -+ _55 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ _30 = &mut (((*_55) as A).0: AsyncInt); -+ _29 = Pin::<&mut AsyncInt>::new_unchecked(move _30) -> [return: bb18, unwind: bb2]; + bb19: { + _44 = discriminant(_43); + switchInt(move _44) -> [0: bb16, 1: bb18, otherwise: bb5]; } -- bb20: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb20, unwind: bb19]; -+ bb20 (cleanup): { -+ _56 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ drop((((*_56) as B).0: SyncInt)) -> [return: bb2, unwind terminate(cleanup)]; + bb20: { + _47 = move _64; + _46 = copy (_47.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _43 = as Future>::poll(move _45, move _46) -> [return: bb19, unwind: bb15]; } bb21: { -- _2 = move _15; -- StorageDead(_15); -- goto -> bb20; -+ _57 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ drop((((*_57) as B).0: SyncInt)) -> [return: bb1, unwind: bb2]; + _48 = &mut (((*_53) as variant#7).1: impl std::future::Future); + _45 = Pin::<&mut impl Future>::new_unchecked(move _48) -> [return: bb20, unwind: bb15]; } -- bb22: { -- _2 = move _15; -- StorageDead(_15); -- goto -> bb27; -+ bb22 (cleanup): { -+ _58 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ _32 = discriminant((*_58)); -+ switchInt(move _32) -> [0: bb3, otherwise: bb20]; + bb22: { + (((*_53) as variant#7).1: impl std::future::Future) = ::drop(move _49) -> [return: bb21, unwind: bb15]; } bb23: { -- StorageLive(_15); -- _15 = yield(const ()) -> [resume: bb21, drop: bb22]; -+ nop; -+ _59 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ _31 = discriminant((*_59)); -+ switchInt(move _31) -> [0: bb19, otherwise: bb21]; + StorageLive(_5); + _5 = move _64; + _64 = move _5; + StorageDead(_5); + goto -> bb4; } -- bb24: { -- _17 = discriminant(_16); -- switchInt(move _17) -> [0: bb18, 1: bb23, otherwise: bb10]; -+ bb24 (cleanup): { -+ nop; -+ goto -> bb22; + bb24: { + StorageLive(_15); + _15 = move _64; + _64 = move _15; + StorageDead(_15); + goto -> bb6; } bb25: { -- _16 = as Future>::poll(move _18, move _19) -> [return: bb24, unwind: bb19]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb25, unwind: bb24]; + StorageLive(_22); + _22 = move _64; + _64 = move _22; + StorageDead(_22); + goto -> bb10; } bb26: { -- _20 = move _2; -- _19 = std::future::get_context::<'_, '_>(move _20) -> [return: bb25, unwind: bb19]; -+ _2 = move _35; -+ StorageDead(_35); -+ goto -> bb25; + StorageLive(_35); + _35 = move _64; + _64 = move _35; + StorageDead(_35); + goto -> bb17; } bb27: { -- _21 = &mut _14; -- _18 = Pin::<&mut impl Future>::new_unchecked(move _21) -> [return: bb26, unwind: bb19]; -+ _2 = move _42; -+ StorageDead(_42); -+ goto -> bb32; + StorageLive(_42); + _42 = move _64; + _64 = move _42; + StorageDead(_42); + goto -> bb21; } bb28: { -- _2 = move _22; -- StorageDead(_22); -- goto -> bb34; -+ StorageLive(_42); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_42); -+ discriminant((*_53)) = 7; -+ return; + assert(const false, "`async fn` resumed after panicking") -> [success: bb28, unwind continue]; } bb29: { -- _2 = move _22; -- StorageDead(_22); -- goto -> bb27; -+ _44 = discriminant(_43); -+ switchInt(move _44) -> [0: bb23, 1: bb28, otherwise: bb7]; + _0 = Poll::<()>::Ready(const ()); + return; } bb30: { -- StorageLive(_22); -- _22 = yield(const ()) -> [resume: bb28, drop: bb29]; -+ _43 = as Future>::poll(move _45, move _46) -> [return: bb29, unwind: bb24]; - } - - bb31: { -- _24 = discriminant(_23); -- switchInt(move _24) -> [0: bb17, 1: bb30, otherwise: bb10]; -+ _47 = move _2; -+ _46 = move _47; -+ goto -> bb30; - } - - bb32: { -- _23 = as Future>::poll(move _25, move _26) -> [return: bb31, unwind: bb19]; -+ _48 = &mut (((*_53) as variant#7).1: impl std::future::Future); -+ _45 = Pin::<&mut impl Future>::new_unchecked(move _48) -> [return: bb31, unwind: bb24]; - } - - bb33: { -- _27 = move _2; -- _26 = std::future::get_context::<'_, '_>(move _27) -> [return: bb32, unwind: bb19]; -+ nop; -+ (((*_53) as variant#7).1: impl std::future::Future) = ::drop(move _49) -> [return: bb32, unwind: bb24]; - } - -- bb34: { -- _28 = &mut _14; -- _25 = Pin::<&mut impl Future>::new_unchecked(move _28) -> [return: bb33, unwind: bb19]; -+ bb34 (cleanup): { -+ discriminant((*_53)) = 2; -+ resume; - } - - bb35: { -- StorageLive(_14); -- _14 = async_drop_in_place::(copy (_29.0: &mut AsyncInt)) -> [return: bb34, unwind: bb19]; -+ StorageLive(_5); -+ _5 = move _2; -+ goto -> bb6; - } - - bb36: { -- _30 = &mut (((*_3) as A).0: AsyncInt); -- _29 = Pin::<&mut AsyncInt>::new_unchecked(move _30) -> [return: bb35, unwind: bb2]; -+ StorageLive(_15); -+ _15 = move _2; -+ goto -> bb11; - } - -- bb37 (cleanup): { -- drop((((*_3) as B).0: SyncInt)) -> [return: bb2, unwind terminate(cleanup)]; -+ bb37: { -+ StorageLive(_22); -+ _22 = move _2; -+ goto -> bb12; - } - - bb38: { -- drop((((*_3) as B).0: SyncInt)) -> [return: bb1, unwind: bb2]; -+ StorageLive(_35); -+ _35 = move _2; -+ goto -> bb26; - } - - bb39: { -- drop((((*_3) as B).0: SyncInt)) -> [return: bb1, unwind: bb2]; -+ StorageLive(_42); -+ _42 = move _2; -+ goto -> bb27; - } - -- bb40 (cleanup): { -- _32 = discriminant((*_3)); -- switchInt(move _32) -> [0: bb3, otherwise: bb37]; -+ bb40: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb40, unwind continue]; - } - - bb41: { -- StorageDead(_34); -- _31 = discriminant((*_3)); -- switchInt(move _31) -> [0: bb36, otherwise: bb39]; -+ _0 = Poll::<()>::Ready(const ()); -+ return; - } - - bb42: { -- StorageDead(_34); -- _33 = discriminant((*_3)); -- switchInt(move _33) -> [0: bb16, otherwise: bb38]; -- } -- -- bb43 (cleanup): { -- StorageDead(_34); -- goto -> bb40; -- } -- -- bb44: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb44, unwind: bb43]; -- } -- -- bb45: { -- _2 = move _35; -- StorageDead(_35); -- goto -> bb44; -- } -- -- bb46: { -- _2 = move _35; -- StorageDead(_35); -- goto -> bb51; -- } -- -- bb47: { -- StorageLive(_35); -- _35 = yield(const ()) -> [resume: bb45, drop: bb46]; -- } -- -- bb48: { -- _37 = discriminant(_36); -- switchInt(move _37) -> [0: bb42, 1: bb47, otherwise: bb10]; -- } -- -- bb49: { -- _36 = as Future>::poll(move _38, move _39) -> [return: bb48, unwind: bb43]; -- } -- -- bb50: { -- _40 = move _2; -- _39 = std::future::get_context::<'_, '_>(move _40) -> [return: bb49, unwind: bb43]; -- } -- -- bb51: { -- _41 = &mut _34; -- _38 = Pin::<&mut impl Future>::new_unchecked(move _41) -> [return: bb50, unwind: bb43]; -- } -- -- bb52: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb58; -- } -- -- bb53: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb51; -- } -- -- bb54: { -- StorageLive(_42); -- _42 = yield(const ()) -> [resume: bb52, drop: bb53]; -- } -- -- bb55: { -- _44 = discriminant(_43); -- switchInt(move _44) -> [0: bb41, 1: bb54, otherwise: bb10]; -- } -- -- bb56: { -- _43 = as Future>::poll(move _45, move _46) -> [return: bb55, unwind: bb43]; -- } -- -- bb57: { -- _47 = move _2; -- _46 = std::future::get_context::<'_, '_>(move _47) -> [return: bb56, unwind: bb43]; -- } -- -- bb58: { -- _48 = &mut _34; -- _45 = Pin::<&mut impl Future>::new_unchecked(move _48) -> [return: bb57, unwind: bb43]; -- } -- -- bb59: { -- StorageLive(_34); -- _34 = ::drop(move _49) -> [return: bb58, unwind: bb43]; -+ (((*_53) as variant#7).0: &mut AsyncEnum) = move ((*_53).0: &mut AsyncEnum); -+ _60 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); -+ _50 = &mut (*_60); -+ _49 = Pin::<&mut AsyncEnum>::new_unchecked(move _50) -> [return: bb33, unwind: bb22]; + (((*_53) as variant#7).0: &mut AsyncEnum) = move ((*_53).0: &mut AsyncEnum); + _63 = no_retag copy (((*_53) as variant#7).0: &mut AsyncEnum); + _50 = &mut (*_63); + _49 = Pin::<&mut AsyncEnum>::new_unchecked(move _50) -> [return: bb22, unwind: bb15]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff index f3849286502ee..22b4c98913e2e 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff @@ -1,209 +1,127 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ field _s0: impl Future; -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ Suspend0 (3): [_s0], -+ Suspend1 (4): [_s0], -+ } -+ storage_conflicts = BitMatrix(1x1) {(_s0, _s0)} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: impl Future; + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + Suspend0 (3): [_s0], + Suspend1 (4): [_s0], + } + storage_conflicts = BitMatrix(1x1) {(_s0, _s0)} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut AsyncInt; let mut _4: impl std::future::Future; -- let mut _5: std::future::ResumeTy; -+ let mut _5: &mut std::task::Context<'_>; + let mut _5: std::future::ResumeTy; let mut _6: std::task::Poll<()>; let mut _7: isize; let mut _8: std::pin::Pin<&mut impl std::future::Future>; let mut _9: &mut std::task::Context<'_>; -- let mut _10: std::future::ResumeTy; -+ let mut _10: &mut std::task::Context<'_>; + let mut _10: std::future::ResumeTy; let mut _11: &mut impl std::future::Future; -- let mut _12: std::future::ResumeTy; -+ let mut _12: &mut std::task::Context<'_>; + let mut _12: std::future::ResumeTy; let mut _13: std::task::Poll<()>; let mut _14: isize; let mut _15: std::pin::Pin<&mut impl std::future::Future>; let mut _16: &mut std::task::Context<'_>; -- let mut _17: std::future::ResumeTy; -+ let mut _17: &mut std::task::Context<'_>; + let mut _17: std::future::ResumeTy; let mut _18: &mut impl std::future::Future; let mut _19: std::pin::Pin<&mut AsyncInt>; let mut _20: &mut AsyncInt; -+ let mut _21: (); -+ let mut _22: u32; -+ let mut _23: &mut {async fn body of std::future::async_drop_in_place()}; + let mut _21: (); + let mut _22: u32; + let mut _23: &mut {async fn body of std::future::async_drop_in_place()}; + let _24: std::future::ResumeTy; + let mut _25: std::ptr::NonNull>; bb0: { -- _3 = move (_1.0: &mut AsyncInt); -- _20 = &mut (*_3); -- _19 = Pin::<&mut AsyncInt>::new_unchecked(move _20) -> [return: bb22, unwind: bb2]; -+ _23 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _22 = discriminant((*_23)); -+ switchInt(move _22) -> [0: bb20, 1: bb19, 2: bb18, 3: bb16, 4: bb17, otherwise: bb7]; + _25 = move _2 as std::ptr::NonNull> (Transmute); + _24 = std::future::ResumeTy(move _25); + _23 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _22 = discriminant((*_23)); + switchInt(move _22) -> [0: bb14, 1: bb13, 2: bb12, 3: bb10, 4: bb11, otherwise: bb4]; } - bb1: { -+ _0 = Poll::<()>::Ready(move _21); -+ discriminant((*_23)) = 1; - return; + bb1 (cleanup): { + discriminant((*_23)) = 2; + resume; } - bb2 (cleanup): { -- resume; -+ goto -> bb15; + bb2: { + _0 = Poll::<()>::Ready(move _21); + discriminant((*_23)) = 1; + return; } bb3: { -- StorageDead(_4); -+ nop; - goto -> bb1; + assert(const false, "`async fn` resumed after async drop") -> [success: bb3, unwind: bb1]; } -- bb4: { -- StorageDead(_4); -- goto -> bb1; -+ bb4 (cleanup): { -+ nop; -+ goto -> bb2; + bb4: { + unreachable; } -- bb5 (cleanup): { -- StorageDead(_4); -- goto -> bb2; -+ bb5: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb5, unwind: bb4]; + bb5: { + StorageLive(_12); + _0 = Poll::<()>::Pending; + StorageDead(_12); + discriminant((*_23)) = 4; + return; } bb6: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb5]; -+ _2 = move _5; -+ StorageDead(_5); -+ goto -> bb5; + _14 = discriminant(_13); + switchInt(move _14) -> [0: bb2, 1: bb5, otherwise: bb4]; } bb7: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb6; -+ unreachable; + _17 = move _24; + _16 = copy (_17.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _13 = as Future>::poll(move _15, move _16) -> [return: bb6, unwind: bb1]; } bb8: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb14; -+ _2 = move _12; -+ StorageDead(_12); -+ goto -> bb13; + _18 = &mut (((*_23) as variant#4).0: impl std::future::Future); + _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb7, unwind: bb1]; } bb9: { -- StorageLive(_5); -- _5 = yield(const ()) -> [resume: bb7, drop: bb8]; -+ StorageLive(_12); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_12); -+ discriminant((*_23)) = 4; -+ return; + (((*_23) as variant#4).0: impl std::future::Future) = ::drop(move _19) -> [return: bb8, unwind: bb1]; } bb10: { -- unreachable; -+ _14 = discriminant(_13); -+ switchInt(move _14) -> [0: bb3, 1: bb9, otherwise: bb7]; + StorageLive(_5); + _5 = move _24; + _24 = move _5; + StorageDead(_5); + goto -> bb3; } bb11: { -- _7 = discriminant(_6); -- switchInt(move _7) -> [0: bb4, 1: bb9, otherwise: bb10]; -+ _13 = as Future>::poll(move _15, move _16) -> [return: bb10, unwind: bb4]; + StorageLive(_12); + _12 = move _24; + _24 = move _12; + StorageDead(_12); + goto -> bb8; } bb12: { -- _6 = as Future>::poll(move _8, move _9) -> [return: bb11, unwind: bb5]; -+ _17 = move _2; -+ _16 = move _17; -+ goto -> bb11; + assert(const false, "`async fn` resumed after panicking") -> [success: bb12, unwind continue]; } bb13: { -- _10 = move _2; -- _9 = std::future::get_context::<'_, '_>(move _10) -> [return: bb12, unwind: bb5]; -+ _18 = &mut (((*_23) as variant#4).0: impl std::future::Future); -+ _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb12, unwind: bb4]; + _0 = Poll::<()>::Ready(const ()); + return; } bb14: { -- _11 = &mut _4; -- _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb13, unwind: bb5]; -+ nop; -+ (((*_23) as variant#4).0: impl std::future::Future) = ::drop(move _19) -> [return: bb13, unwind: bb4]; - } - -- bb15: { -- _2 = move _12; -- StorageDead(_12); -- goto -> bb21; -+ bb15 (cleanup): { -+ discriminant((*_23)) = 2; -+ resume; - } - - bb16: { -- _2 = move _12; -- StorageDead(_12); -- goto -> bb14; -+ StorageLive(_5); -+ _5 = move _2; -+ goto -> bb6; - } - - bb17: { - StorageLive(_12); -- _12 = yield(const ()) -> [resume: bb15, drop: bb16]; -+ _12 = move _2; -+ goto -> bb8; - } - - bb18: { -- _14 = discriminant(_13); -- switchInt(move _14) -> [0: bb3, 1: bb17, otherwise: bb10]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb18, unwind continue]; - } - - bb19: { -- _13 = as Future>::poll(move _15, move _16) -> [return: bb18, unwind: bb5]; -+ _0 = Poll::<()>::Ready(const ()); -+ return; - } - - bb20: { -- _17 = move _2; -- _16 = std::future::get_context::<'_, '_>(move _17) -> [return: bb19, unwind: bb5]; -- } -- -- bb21: { -- _18 = &mut _4; -- _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb20, unwind: bb5]; -- } -- -- bb22: { -- StorageLive(_4); -- _4 = ::drop(move _19) -> [return: bb21, unwind: bb5]; -+ _3 = move ((*_23).0: &mut AsyncInt); -+ _20 = &mut (*_3); -+ _19 = Pin::<&mut AsyncInt>::new_unchecked(move _20) -> [return: bb14, unwind: bb2]; + _3 = move ((*_23).0: &mut AsyncInt); + _20 = &mut (*_3); + _19 = Pin::<&mut AsyncInt>::new_unchecked(move _20) -> [return: bb9, unwind: bb1]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff index 120028d1cabf0..eb78e586c1315 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff @@ -1,209 +1,127 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place>()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place>()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ field _s0: impl Future; -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ Suspend0 (3): [_s0], -+ Suspend1 (4): [_s0], -+ } -+ storage_conflicts = BitMatrix(1x1) {(_s0, _s0)} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place>()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: impl Future; + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + Suspend0 (3): [_s0], + Suspend1 (4): [_s0], + } + storage_conflicts = BitMatrix(1x1) {(_s0, _s0)} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut AsyncReference<'_>; let mut _4: impl std::future::Future; -- let mut _5: std::future::ResumeTy; -+ let mut _5: &mut std::task::Context<'_>; + let mut _5: std::future::ResumeTy; let mut _6: std::task::Poll<()>; let mut _7: isize; let mut _8: std::pin::Pin<&mut impl std::future::Future>; let mut _9: &mut std::task::Context<'_>; -- let mut _10: std::future::ResumeTy; -+ let mut _10: &mut std::task::Context<'_>; + let mut _10: std::future::ResumeTy; let mut _11: &mut impl std::future::Future; -- let mut _12: std::future::ResumeTy; -+ let mut _12: &mut std::task::Context<'_>; + let mut _12: std::future::ResumeTy; let mut _13: std::task::Poll<()>; let mut _14: isize; let mut _15: std::pin::Pin<&mut impl std::future::Future>; let mut _16: &mut std::task::Context<'_>; -- let mut _17: std::future::ResumeTy; -+ let mut _17: &mut std::task::Context<'_>; + let mut _17: std::future::ResumeTy; let mut _18: &mut impl std::future::Future; let mut _19: std::pin::Pin<&mut AsyncReference<'_>>; let mut _20: &mut AsyncReference<'_>; -+ let mut _21: (); -+ let mut _22: u32; -+ let mut _23: &mut {async fn body of std::future::async_drop_in_place>()}; + let mut _21: (); + let mut _22: u32; + let mut _23: &mut {async fn body of std::future::async_drop_in_place>()}; + let _24: std::future::ResumeTy; + let mut _25: std::ptr::NonNull>; bb0: { -- _3 = move (_1.0: &mut AsyncReference<'_>); -- _20 = &mut (*_3); -- _19 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _20) -> [return: bb22, unwind: bb2]; -+ _23 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place>()}); -+ _22 = discriminant((*_23)); -+ switchInt(move _22) -> [0: bb20, 1: bb19, 2: bb18, 3: bb16, 4: bb17, otherwise: bb7]; + _25 = move _2 as std::ptr::NonNull> (Transmute); + _24 = std::future::ResumeTy(move _25); + _23 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place>()}); + _22 = discriminant((*_23)); + switchInt(move _22) -> [0: bb14, 1: bb13, 2: bb12, 3: bb10, 4: bb11, otherwise: bb4]; } - bb1: { -+ _0 = Poll::<()>::Ready(move _21); -+ discriminant((*_23)) = 1; - return; + bb1 (cleanup): { + discriminant((*_23)) = 2; + resume; } - bb2 (cleanup): { -- resume; -+ goto -> bb15; + bb2: { + _0 = Poll::<()>::Ready(move _21); + discriminant((*_23)) = 1; + return; } bb3: { -- StorageDead(_4); -+ nop; - goto -> bb1; + assert(const false, "`async fn` resumed after async drop") -> [success: bb3, unwind: bb1]; } -- bb4: { -- StorageDead(_4); -- goto -> bb1; -+ bb4 (cleanup): { -+ nop; -+ goto -> bb2; + bb4: { + unreachable; } -- bb5 (cleanup): { -- StorageDead(_4); -- goto -> bb2; -+ bb5: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb5, unwind: bb4]; + bb5: { + StorageLive(_12); + _0 = Poll::<()>::Pending; + StorageDead(_12); + discriminant((*_23)) = 4; + return; } bb6: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb5]; -+ _2 = move _5; -+ StorageDead(_5); -+ goto -> bb5; + _14 = discriminant(_13); + switchInt(move _14) -> [0: bb2, 1: bb5, otherwise: bb4]; } bb7: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb6; -+ unreachable; + _17 = move _24; + _16 = copy (_17.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _13 = as Future>::poll(move _15, move _16) -> [return: bb6, unwind: bb1]; } bb8: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb14; -+ _2 = move _12; -+ StorageDead(_12); -+ goto -> bb13; + _18 = &mut (((*_23) as variant#4).0: impl std::future::Future); + _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb7, unwind: bb1]; } bb9: { -- StorageLive(_5); -- _5 = yield(const ()) -> [resume: bb7, drop: bb8]; -+ StorageLive(_12); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_12); -+ discriminant((*_23)) = 4; -+ return; + (((*_23) as variant#4).0: impl std::future::Future) = as AsyncDrop>::drop(move _19) -> [return: bb8, unwind: bb1]; } bb10: { -- unreachable; -+ _14 = discriminant(_13); -+ switchInt(move _14) -> [0: bb3, 1: bb9, otherwise: bb7]; + StorageLive(_5); + _5 = move _24; + _24 = move _5; + StorageDead(_5); + goto -> bb3; } bb11: { -- _7 = discriminant(_6); -- switchInt(move _7) -> [0: bb4, 1: bb9, otherwise: bb10]; -+ _13 = as Future>::poll(move _15, move _16) -> [return: bb10, unwind: bb4]; + StorageLive(_12); + _12 = move _24; + _24 = move _12; + StorageDead(_12); + goto -> bb8; } bb12: { -- _6 = as Future>::poll(move _8, move _9) -> [return: bb11, unwind: bb5]; -+ _17 = move _2; -+ _16 = move _17; -+ goto -> bb11; + assert(const false, "`async fn` resumed after panicking") -> [success: bb12, unwind continue]; } bb13: { -- _10 = move _2; -- _9 = std::future::get_context::<'_, '_>(move _10) -> [return: bb12, unwind: bb5]; -+ _18 = &mut (((*_23) as variant#4).0: impl std::future::Future); -+ _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb12, unwind: bb4]; + _0 = Poll::<()>::Ready(const ()); + return; } bb14: { -- _11 = &mut _4; -- _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb13, unwind: bb5]; -+ nop; -+ (((*_23) as variant#4).0: impl std::future::Future) = as AsyncDrop>::drop(move _19) -> [return: bb13, unwind: bb4]; - } - -- bb15: { -- _2 = move _12; -- StorageDead(_12); -- goto -> bb21; -+ bb15 (cleanup): { -+ discriminant((*_23)) = 2; -+ resume; - } - - bb16: { -- _2 = move _12; -- StorageDead(_12); -- goto -> bb14; -+ StorageLive(_5); -+ _5 = move _2; -+ goto -> bb6; - } - - bb17: { - StorageLive(_12); -- _12 = yield(const ()) -> [resume: bb15, drop: bb16]; -+ _12 = move _2; -+ goto -> bb8; - } - - bb18: { -- _14 = discriminant(_13); -- switchInt(move _14) -> [0: bb3, 1: bb17, otherwise: bb10]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb18, unwind continue]; - } - - bb19: { -- _13 = as Future>::poll(move _15, move _16) -> [return: bb18, unwind: bb5]; -+ _0 = Poll::<()>::Ready(const ()); -+ return; - } - - bb20: { -- _17 = move _2; -- _16 = std::future::get_context::<'_, '_>(move _17) -> [return: bb19, unwind: bb5]; -- } -- -- bb21: { -- _18 = &mut _4; -- _15 = Pin::<&mut impl Future>::new_unchecked(move _18) -> [return: bb20, unwind: bb5]; -- } -- -- bb22: { -- StorageLive(_4); -- _4 = as AsyncDrop>::drop(move _19) -> [return: bb21, unwind: bb5]; -+ _3 = move ((*_23).0: &mut AsyncReference<'_>); -+ _20 = &mut (*_3); -+ _19 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _20) -> [return: bb14, unwind: bb2]; + _3 = move ((*_23).0: &mut AsyncReference<'_>); + _20 = &mut (*_3); + _19 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _20) -> [return: bb9, unwind: bb1]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff index 0de0be9675f9b..60c4bfe802082 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff @@ -1,709 +1,342 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ field _s0: &mut AsyncStruct; -+ field _s1: impl Future; -+ field _s2: impl Future; -+ field _s3: impl Future; -+ field _s4: impl Future; -+ field _s5: impl Future; -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ Suspend0 (3): [_s1], -+ Suspend1 (4): [_s0, _s2], -+ Suspend2 (5): [_s3], -+ Suspend3 (6): [_s3], -+ Suspend4 (7): [_s0, _s4], -+ Suspend5 (8): [_s0, _s4], -+ Suspend6 (9): [_s0, _s5], -+ Suspend7 (10): [_s0, _s5], -+ } -+ storage_conflicts = BitMatrix(6x6) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s0, _s4), (_s0, _s5), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3), (_s4, _s0), (_s4, _s4), (_s5, _s0), (_s5, _s5)} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: &mut AsyncStruct; + field _s1: impl Future; + field _s2: impl Future; + field _s3: impl Future; + field _s4: impl Future; + field _s5: impl Future; + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + Suspend0 (3): [_s1], + Suspend1 (4): [_s0, _s2], + Suspend2 (5): [_s3], + Suspend3 (6): [_s3], + Suspend4 (7): [_s0, _s4], + Suspend5 (8): [_s0, _s4], + Suspend6 (9): [_s0, _s5], + Suspend7 (10): [_s0, _s5], + } + storage_conflicts = BitMatrix(6x6) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s0, _s4), (_s0, _s5), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3), (_s4, _s0), (_s4, _s4), (_s5, _s0), (_s5, _s5)} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut AsyncStruct; let mut _4: impl std::future::Future; -- let mut _5: std::future::ResumeTy; -+ let mut _5: &mut std::task::Context<'_>; + let mut _5: std::future::ResumeTy; let mut _6: std::task::Poll<()>; let mut _7: isize; let mut _8: std::pin::Pin<&mut impl std::future::Future>; let mut _9: &mut std::task::Context<'_>; -- let mut _10: std::future::ResumeTy; -+ let mut _10: &mut std::task::Context<'_>; + let mut _10: std::future::ResumeTy; let mut _11: &mut impl std::future::Future; let mut _12: std::pin::Pin<&mut AsyncInt>; let mut _13: &mut AsyncInt; let mut _14: impl std::future::Future; -- let mut _15: std::future::ResumeTy; -+ let mut _15: &mut std::task::Context<'_>; + let mut _15: std::future::ResumeTy; let mut _16: std::task::Poll<()>; let mut _17: isize; let mut _18: std::pin::Pin<&mut impl std::future::Future>; let mut _19: &mut std::task::Context<'_>; -- let mut _20: std::future::ResumeTy; -+ let mut _20: &mut std::task::Context<'_>; + let mut _20: std::future::ResumeTy; let mut _21: &mut impl std::future::Future; let mut _22: std::pin::Pin<&mut AsyncInt>; let mut _23: &mut AsyncInt; let mut _24: impl std::future::Future; -- let mut _25: std::future::ResumeTy; -+ let mut _25: &mut std::task::Context<'_>; + let mut _25: std::future::ResumeTy; let mut _26: std::task::Poll<()>; let mut _27: isize; let mut _28: std::pin::Pin<&mut impl std::future::Future>; let mut _29: &mut std::task::Context<'_>; -- let mut _30: std::future::ResumeTy; -+ let mut _30: &mut std::task::Context<'_>; + let mut _30: std::future::ResumeTy; let mut _31: &mut impl std::future::Future; -- let mut _32: std::future::ResumeTy; -+ let mut _32: &mut std::task::Context<'_>; + let mut _32: std::future::ResumeTy; let mut _33: std::task::Poll<()>; let mut _34: isize; let mut _35: std::pin::Pin<&mut impl std::future::Future>; let mut _36: &mut std::task::Context<'_>; -- let mut _37: std::future::ResumeTy; -+ let mut _37: &mut std::task::Context<'_>; + let mut _37: std::future::ResumeTy; let mut _38: &mut impl std::future::Future; let mut _39: std::pin::Pin<&mut AsyncInt>; let mut _40: &mut AsyncInt; let mut _41: impl std::future::Future; -- let mut _42: std::future::ResumeTy; -+ let mut _42: &mut std::task::Context<'_>; + let mut _42: std::future::ResumeTy; let mut _43: std::task::Poll<()>; let mut _44: isize; let mut _45: std::pin::Pin<&mut impl std::future::Future>; let mut _46: &mut std::task::Context<'_>; -- let mut _47: std::future::ResumeTy; -+ let mut _47: &mut std::task::Context<'_>; + let mut _47: std::future::ResumeTy; let mut _48: &mut impl std::future::Future; -- let mut _49: std::future::ResumeTy; -+ let mut _49: &mut std::task::Context<'_>; + let mut _49: std::future::ResumeTy; let mut _50: std::task::Poll<()>; let mut _51: isize; let mut _52: std::pin::Pin<&mut impl std::future::Future>; let mut _53: &mut std::task::Context<'_>; -- let mut _54: std::future::ResumeTy; -+ let mut _54: &mut std::task::Context<'_>; + let mut _54: std::future::ResumeTy; let mut _55: &mut impl std::future::Future; let mut _56: std::pin::Pin<&mut AsyncInt>; let mut _57: &mut AsyncInt; let mut _58: impl std::future::Future; -- let mut _59: std::future::ResumeTy; -+ let mut _59: &mut std::task::Context<'_>; + let mut _59: std::future::ResumeTy; let mut _60: std::task::Poll<()>; let mut _61: isize; let mut _62: std::pin::Pin<&mut impl std::future::Future>; let mut _63: &mut std::task::Context<'_>; -- let mut _64: std::future::ResumeTy; -+ let mut _64: &mut std::task::Context<'_>; + let mut _64: std::future::ResumeTy; let mut _65: &mut impl std::future::Future; -- let mut _66: std::future::ResumeTy; -+ let mut _66: &mut std::task::Context<'_>; + let mut _66: std::future::ResumeTy; let mut _67: std::task::Poll<()>; let mut _68: isize; let mut _69: std::pin::Pin<&mut impl std::future::Future>; let mut _70: &mut std::task::Context<'_>; -- let mut _71: std::future::ResumeTy; -+ let mut _71: &mut std::task::Context<'_>; + let mut _71: std::future::ResumeTy; let mut _72: &mut impl std::future::Future; let mut _73: std::pin::Pin<&mut AsyncStruct>; let mut _74: &mut AsyncStruct; -+ let mut _75: (); -+ let mut _76: u32; -+ let mut _77: &mut {async fn body of std::future::async_drop_in_place()}; -+ let mut _78: &mut AsyncStruct; -+ let mut _79: &mut AsyncStruct; -+ let mut _80: &mut AsyncStruct; -+ let mut _81: &mut AsyncStruct; -+ let mut _82: &mut AsyncStruct; + let mut _75: (); + let mut _76: u32; + let mut _77: &mut {async fn body of std::future::async_drop_in_place()}; + let mut _78: &mut AsyncStruct; + let mut _79: &mut AsyncStruct; + let mut _80: &mut AsyncStruct; + let mut _81: &mut AsyncStruct; + let mut _82: &mut AsyncStruct; + let mut _83: &mut AsyncStruct; + let mut _84: &mut AsyncStruct; + let _85: std::future::ResumeTy; + let mut _86: std::ptr::NonNull>; bb0: { -- _3 = move (_1.0: &mut AsyncStruct); -- _74 = &mut (*_3); -- _73 = Pin::<&mut AsyncStruct>::new_unchecked(move _74) -> [return: bb85, unwind: bb4]; -+ _77 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _76 = discriminant((*_77)); -+ switchInt(move _76) -> [0: bb56, 1: bb55, 2: bb54, 3: bb46, 4: bb47, 5: bb48, 6: bb49, 7: bb50, 8: bb51, 9: bb52, 10: bb53, otherwise: bb8]; + _86 = move _2 as std::ptr::NonNull> (Transmute); + _85 = std::future::ResumeTy(move _86); + _77 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _76 = discriminant((*_77)); + switchInt(move _76) -> [0: bb38, 1: bb37, 2: bb36, 3: bb28, 4: bb29, 5: bb30, 6: bb31, 7: bb32, 8: bb33, 9: bb34, 10: bb35, otherwise: bb5]; } - bb1: { -+ _0 = Poll::<()>::Ready(move _75); -+ discriminant((*_77)) = 1; - return; + bb1 (cleanup): { + discriminant((*_77)) = 2; + resume; } bb2 (cleanup): { -- resume; -+ goto -> bb45; + _78 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); + drop(((*_78).2: AsyncInt)) -> [return: bb1, unwind terminate(cleanup)]; } bb3 (cleanup): { -- drop(((*_3).2: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; -+ _78 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); -+ drop(((*_78).2: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; + _79 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); + drop(((*_79).1: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; } - bb4 (cleanup): { -- drop(((*_3).1: AsyncInt)) -> [return: bb3, unwind terminate(cleanup)]; -+ _79 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); -+ drop(((*_79).1: AsyncInt)) -> [return: bb3, unwind terminate(cleanup)]; + bb4: { + assert(const false, "`async fn` resumed after async drop") -> [success: bb4, unwind: bb1]; } -- bb5: { -- StorageDead(_4); -- goto -> bb1; -+ bb5 (cleanup): { -+ nop; -+ goto -> bb2; + bb5: { + unreachable; } -- bb6 (cleanup): { -- StorageDead(_4); -- goto -> bb2; -+ bb6: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb5]; + bb6: { + assert(const false, "`async fn` resumed after async drop") -> [success: bb6, unwind: bb2]; } bb7: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb7, unwind: bb6]; -+ _2 = move _5; -+ StorageDead(_5); -+ goto -> bb6; + _0 = Poll::<()>::Ready(move _75); + discriminant((*_77)) = 1; + return; } bb8: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb7; -+ unreachable; + assert(const false, "`async fn` resumed after async drop") -> [success: bb8, unwind: bb1]; } -- bb9: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb15; -+ bb9 (cleanup): { -+ nop; -+ goto -> bb3; + bb9: { + StorageLive(_32); + _0 = Poll::<()>::Pending; + StorageDead(_32); + discriminant((*_77)) = 6; + return; } bb10: { -- StorageLive(_5); -- _5 = yield(const ()) -> [resume: bb8, drop: bb9]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb10, unwind: bb9]; + _34 = discriminant(_33); + switchInt(move _34) -> [0: bb7, 1: bb9, otherwise: bb5]; } bb11: { -- unreachable; -+ _2 = move _15; -+ StorageDead(_15); -+ goto -> bb10; + _37 = move _85; + _36 = copy (_37.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _33 = as Future>::poll(move _35, move _36) -> [return: bb10, unwind: bb1]; } bb12: { -- _7 = discriminant(_6); -- switchInt(move _7) -> [0: bb5, 1: bb10, otherwise: bb11]; -+ nop; -+ goto -> bb1; + _38 = &mut (((*_77) as variant#6).0: impl std::future::Future); + _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb11, unwind: bb1]; } -- bb13: { -- _6 = as Future>::poll(move _8, move _9) -> [return: bb12, unwind: bb6]; -+ bb13 (cleanup): { -+ nop; -+ goto -> bb2; + bb13: { + (((*_77) as variant#6).0: impl std::future::Future) = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb12, unwind: bb1]; } bb14: { -- _10 = move _2; -- _9 = std::future::get_context::<'_, '_>(move _10) -> [return: bb13, unwind: bb6]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb14, unwind: bb13]; + _81 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); + _40 = &mut ((*_81).2: AsyncInt); + _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb13, unwind: bb1]; } bb15: { -- _11 = &mut _4; -- _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb14, unwind: bb6]; -+ _2 = move _25; -+ StorageDead(_25); -+ goto -> bb14; + assert(const false, "`async fn` resumed after async drop") -> [success: bb15, unwind: bb2]; } bb16: { -- StorageLive(_4); -- _4 = async_drop_in_place::(copy (_12.0: &mut AsyncInt)) -> [return: bb15, unwind: bb6]; -+ _2 = move _32; -+ StorageDead(_32); -+ goto -> bb21; + StorageLive(_49); + _0 = Poll::<()>::Pending; + StorageDead(_49); + discriminant((*_77)) = 8; + return; } bb17: { -- _13 = &mut ((*_3).2: AsyncInt); -- _12 = Pin::<&mut AsyncInt>::new_unchecked(move _13) -> [return: bb16, unwind: bb2]; -+ StorageLive(_32); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_32); -+ discriminant((*_77)) = 6; -+ return; + _51 = discriminant(_50); + switchInt(move _51) -> [0: bb14, 1: bb16, otherwise: bb5]; } bb18: { -- StorageDead(_14); -- goto -> bb17; -+ _34 = discriminant(_33); -+ switchInt(move _34) -> [0: bb12, 1: bb17, otherwise: bb8]; + _54 = move _85; + _53 = copy (_54.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _50 = as Future>::poll(move _52, move _53) -> [return: bb17, unwind: bb2]; } -- bb19 (cleanup): { -- StorageDead(_14); -- goto -> bb3; -+ bb19: { -+ _33 = as Future>::poll(move _35, move _36) -> [return: bb18, unwind: bb13]; + bb19: { + _55 = &mut (((*_77) as variant#8).1: impl std::future::Future); + _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb18, unwind: bb2]; } bb20: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb20, unwind: bb19]; -+ _37 = move _2; -+ _36 = move _37; -+ goto -> bb19; + (((*_77) as variant#8).1: impl std::future::Future) = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb19, unwind: bb2]; } bb21: { -- _2 = move _15; -- StorageDead(_15); -- goto -> bb20; -+ _38 = &mut (((*_77) as variant#6).0: impl std::future::Future); -+ _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb20, unwind: bb13]; + _82 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); + _57 = &mut ((*_82).1: AsyncInt); + _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb20, unwind: bb2]; } bb22: { -- _2 = move _15; -- StorageDead(_15); -- goto -> bb27; -+ nop; -+ (((*_77) as variant#6).0: impl std::future::Future) = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb21, unwind: bb13]; + assert(const false, "`async fn` resumed after async drop") -> [success: bb22, unwind: bb3]; } bb23: { -- StorageLive(_15); -- _15 = yield(const ()) -> [resume: bb21, drop: bb22]; -+ nop; -+ _80 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); -+ _40 = &mut ((*_80).2: AsyncInt); -+ _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb22, unwind: bb2]; + StorageLive(_66); + _0 = Poll::<()>::Pending; + StorageDead(_66); + discriminant((*_77)) = 10; + return; } -- bb24: { -- _17 = discriminant(_16); -- switchInt(move _17) -> [0: bb18, 1: bb23, otherwise: bb11]; -+ bb24 (cleanup): { -+ nop; -+ goto -> bb3; + bb24: { + _68 = discriminant(_67); + switchInt(move _68) -> [0: bb21, 1: bb23, otherwise: bb5]; } bb25: { -- _16 = as Future>::poll(move _18, move _19) -> [return: bb24, unwind: bb19]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb25, unwind: bb24]; + _71 = move _85; + _70 = copy (_71.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _67 = as Future>::poll(move _69, move _70) -> [return: bb24, unwind: bb3]; } bb26: { -- _20 = move _2; -- _19 = std::future::get_context::<'_, '_>(move _20) -> [return: bb25, unwind: bb19]; -+ _2 = move _42; -+ StorageDead(_42); -+ goto -> bb25; + _72 = &mut (((*_77) as variant#10).1: impl std::future::Future); + _69 = Pin::<&mut impl Future>::new_unchecked(move _72) -> [return: bb25, unwind: bb3]; } bb27: { -- _21 = &mut _14; -- _18 = Pin::<&mut impl Future>::new_unchecked(move _21) -> [return: bb26, unwind: bb19]; -+ _2 = move _49; -+ StorageDead(_49); -+ goto -> bb32; + (((*_77) as variant#10).1: impl std::future::Future) = ::drop(move _73) -> [return: bb26, unwind: bb3]; } bb28: { -- StorageLive(_14); -- _14 = async_drop_in_place::(copy (_22.0: &mut AsyncInt)) -> [return: bb27, unwind: bb19]; -+ StorageLive(_49); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_49); -+ discriminant((*_77)) = 8; -+ return; + StorageLive(_5); + _5 = move _85; + _85 = move _5; + StorageDead(_5); + goto -> bb4; } bb29: { -- StorageDead(_24); -- goto -> bb1; -+ _51 = discriminant(_50); -+ switchInt(move _51) -> [0: bb23, 1: bb28, otherwise: bb8]; + StorageLive(_15); + _15 = move _85; + _85 = move _15; + StorageDead(_15); + goto -> bb6; } bb30: { -- StorageDead(_24); -- goto -> bb1; -+ _50 = as Future>::poll(move _52, move _53) -> [return: bb29, unwind: bb24]; + StorageLive(_25); + _25 = move _85; + _85 = move _25; + StorageDead(_25); + goto -> bb8; } -- bb31 (cleanup): { -- StorageDead(_24); -- goto -> bb2; -+ bb31: { -+ _54 = move _2; -+ _53 = move _54; -+ goto -> bb30; + bb31: { + StorageLive(_32); + _32 = move _85; + _85 = move _32; + StorageDead(_32); + goto -> bb12; } bb32: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb32, unwind: bb31]; -+ _55 = &mut (((*_77) as variant#8).1: impl std::future::Future); -+ _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb31, unwind: bb24]; + StorageLive(_42); + _42 = move _85; + _85 = move _42; + StorageDead(_42); + goto -> bb15; } bb33: { -- _2 = move _25; -- StorageDead(_25); -- goto -> bb32; -+ nop; -+ (((*_77) as variant#8).1: impl std::future::Future) = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb32, unwind: bb24]; + StorageLive(_49); + _49 = move _85; + _85 = move _49; + StorageDead(_49); + goto -> bb19; } bb34: { -- _2 = move _25; -- StorageDead(_25); -- goto -> bb39; -+ nop; -+ _81 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); -+ _57 = &mut ((*_81).1: AsyncInt); -+ _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb33, unwind: bb3]; + StorageLive(_59); + _59 = move _85; + _85 = move _59; + StorageDead(_59); + goto -> bb22; } -- bb35: { -- StorageLive(_25); -- _25 = yield(const ()) -> [resume: bb33, drop: bb34]; -+ bb35 (cleanup): { -+ nop; -+ goto -> bb4; + bb35: { + StorageLive(_66); + _66 = move _85; + _85 = move _66; + StorageDead(_66); + goto -> bb26; } bb36: { -- _27 = discriminant(_26); -- switchInt(move _27) -> [0: bb30, 1: bb35, otherwise: bb11]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb36, unwind: bb35]; + assert(const false, "`async fn` resumed after panicking") -> [success: bb36, unwind continue]; } bb37: { -- _26 = as Future>::poll(move _28, move _29) -> [return: bb36, unwind: bb31]; -+ _2 = move _59; -+ StorageDead(_59); -+ goto -> bb36; + _0 = Poll::<()>::Ready(const ()); + return; } bb38: { -- _30 = move _2; -- _29 = std::future::get_context::<'_, '_>(move _30) -> [return: bb37, unwind: bb31]; -+ _2 = move _66; -+ StorageDead(_66); -+ goto -> bb43; - } - - bb39: { -- _31 = &mut _24; -- _28 = Pin::<&mut impl Future>::new_unchecked(move _31) -> [return: bb38, unwind: bb31]; -+ StorageLive(_66); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_66); -+ discriminant((*_77)) = 10; -+ return; - } - - bb40: { -- _2 = move _32; -- StorageDead(_32); -- goto -> bb46; -+ _68 = discriminant(_67); -+ switchInt(move _68) -> [0: bb34, 1: bb39, otherwise: bb8]; - } - - bb41: { -- _2 = move _32; -- StorageDead(_32); -- goto -> bb39; -+ _67 = as Future>::poll(move _69, move _70) -> [return: bb40, unwind: bb35]; - } - - bb42: { -- StorageLive(_32); -- _32 = yield(const ()) -> [resume: bb40, drop: bb41]; -+ _71 = move _2; -+ _70 = move _71; -+ goto -> bb41; - } - - bb43: { -- _34 = discriminant(_33); -- switchInt(move _34) -> [0: bb29, 1: bb42, otherwise: bb11]; -+ _72 = &mut (((*_77) as variant#10).1: impl std::future::Future); -+ _69 = Pin::<&mut impl Future>::new_unchecked(move _72) -> [return: bb42, unwind: bb35]; - } - - bb44: { -- _33 = as Future>::poll(move _35, move _36) -> [return: bb43, unwind: bb31]; -+ nop; -+ (((*_77) as variant#10).1: impl std::future::Future) = ::drop(move _73) -> [return: bb43, unwind: bb35]; - } - -- bb45: { -- _37 = move _2; -- _36 = std::future::get_context::<'_, '_>(move _37) -> [return: bb44, unwind: bb31]; -+ bb45 (cleanup): { -+ discriminant((*_77)) = 2; -+ resume; - } - - bb46: { -- _38 = &mut _24; -- _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb45, unwind: bb31]; -+ StorageLive(_5); -+ _5 = move _2; -+ goto -> bb7; - } - - bb47: { -- StorageLive(_24); -- _24 = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb46, unwind: bb31]; -+ StorageLive(_15); -+ _15 = move _2; -+ goto -> bb11; - } - - bb48: { -- StorageDead(_41); -- _40 = &mut ((*_3).2: AsyncInt); -- _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb47, unwind: bb2]; -+ StorageLive(_25); -+ _25 = move _2; -+ goto -> bb15; - } - - bb49: { -- StorageDead(_41); -- goto -> bb17; -+ StorageLive(_32); -+ _32 = move _2; -+ goto -> bb16; - } - -- bb50 (cleanup): { -- StorageDead(_41); -- goto -> bb3; -+ bb50: { -+ StorageLive(_42); -+ _42 = move _2; -+ goto -> bb26; - } - - bb51: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb51, unwind: bb50]; -+ StorageLive(_49); -+ _49 = move _2; -+ goto -> bb27; - } - - bb52: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb51; -+ StorageLive(_59); -+ _59 = move _2; -+ goto -> bb37; - } - - bb53: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb58; -+ StorageLive(_66); -+ _66 = move _2; -+ goto -> bb38; - } - - bb54: { -- StorageLive(_42); -- _42 = yield(const ()) -> [resume: bb52, drop: bb53]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb54, unwind continue]; - } - - bb55: { -- _44 = discriminant(_43); -- switchInt(move _44) -> [0: bb49, 1: bb54, otherwise: bb11]; -+ _0 = Poll::<()>::Ready(const ()); -+ return; - } - - bb56: { -- _43 = as Future>::poll(move _45, move _46) -> [return: bb55, unwind: bb50]; -- } -- -- bb57: { -- _47 = move _2; -- _46 = std::future::get_context::<'_, '_>(move _47) -> [return: bb56, unwind: bb50]; -- } -- -- bb58: { -- _48 = &mut _41; -- _45 = Pin::<&mut impl Future>::new_unchecked(move _48) -> [return: bb57, unwind: bb50]; -- } -- -- bb59: { -- _2 = move _49; -- StorageDead(_49); -- goto -> bb65; -- } -- -- bb60: { -- _2 = move _49; -- StorageDead(_49); -- goto -> bb58; -- } -- -- bb61: { -- StorageLive(_49); -- _49 = yield(const ()) -> [resume: bb59, drop: bb60]; -- } -- -- bb62: { -- _51 = discriminant(_50); -- switchInt(move _51) -> [0: bb48, 1: bb61, otherwise: bb11]; -- } -- -- bb63: { -- _50 = as Future>::poll(move _52, move _53) -> [return: bb62, unwind: bb50]; -- } -- -- bb64: { -- _54 = move _2; -- _53 = std::future::get_context::<'_, '_>(move _54) -> [return: bb63, unwind: bb50]; -- } -- -- bb65: { -- _55 = &mut _41; -- _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb64, unwind: bb50]; -- } -- -- bb66: { -- StorageLive(_41); -- _41 = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb65, unwind: bb50]; -- } -- -- bb67: { -- StorageDead(_58); -- _57 = &mut ((*_3).1: AsyncInt); -- _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb66, unwind: bb3]; -- } -- -- bb68: { -- StorageDead(_58); -- _23 = &mut ((*_3).1: AsyncInt); -- _22 = Pin::<&mut AsyncInt>::new_unchecked(move _23) -> [return: bb28, unwind: bb3]; -- } -- -- bb69 (cleanup): { -- StorageDead(_58); -- goto -> bb4; -- } -- -- bb70: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb70, unwind: bb69]; -- } -- -- bb71: { -- _2 = move _59; -- StorageDead(_59); -- goto -> bb70; -- } -- -- bb72: { -- _2 = move _59; -- StorageDead(_59); -- goto -> bb77; -- } -- -- bb73: { -- StorageLive(_59); -- _59 = yield(const ()) -> [resume: bb71, drop: bb72]; -- } -- -- bb74: { -- _61 = discriminant(_60); -- switchInt(move _61) -> [0: bb68, 1: bb73, otherwise: bb11]; -- } -- -- bb75: { -- _60 = as Future>::poll(move _62, move _63) -> [return: bb74, unwind: bb69]; -- } -- -- bb76: { -- _64 = move _2; -- _63 = std::future::get_context::<'_, '_>(move _64) -> [return: bb75, unwind: bb69]; -- } -- -- bb77: { -- _65 = &mut _58; -- _62 = Pin::<&mut impl Future>::new_unchecked(move _65) -> [return: bb76, unwind: bb69]; -- } -- -- bb78: { -- _2 = move _66; -- StorageDead(_66); -- goto -> bb84; -- } -- -- bb79: { -- _2 = move _66; -- StorageDead(_66); -- goto -> bb77; -- } -- -- bb80: { -- StorageLive(_66); -- _66 = yield(const ()) -> [resume: bb78, drop: bb79]; -- } -- -- bb81: { -- _68 = discriminant(_67); -- switchInt(move _68) -> [0: bb67, 1: bb80, otherwise: bb11]; -- } -- -- bb82: { -- _67 = as Future>::poll(move _69, move _70) -> [return: bb81, unwind: bb69]; -- } -- -- bb83: { -- _71 = move _2; -- _70 = std::future::get_context::<'_, '_>(move _71) -> [return: bb82, unwind: bb69]; -- } -- -- bb84: { -- _72 = &mut _58; -- _69 = Pin::<&mut impl Future>::new_unchecked(move _72) -> [return: bb83, unwind: bb69]; -- } -- -- bb85: { -- StorageLive(_58); -- _58 = ::drop(move _73) -> [return: bb84, unwind: bb69]; -+ (((*_77) as variant#10).0: &mut AsyncStruct) = move ((*_77).0: &mut AsyncStruct); -+ _82 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); -+ _74 = &mut (*_82); -+ _73 = Pin::<&mut AsyncStruct>::new_unchecked(move _74) -> [return: bb44, unwind: bb4]; + (((*_77) as variant#10).0: &mut AsyncStruct) = move ((*_77).0: &mut AsyncStruct); + _84 = no_retag copy (((*_77) as variant#10).0: &mut AsyncStruct); + _74 = &mut (*_84); + _73 = Pin::<&mut AsyncStruct>::new_unchecked(move _74) -> [return: bb27, unwind: bb3]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff index 1536d5bca0c21..46e1ae8c9020e 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff @@ -1,42 +1,42 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ } -+ storage_conflicts = BitMatrix(0x0) {} -+ } -+ let mut _0: std::task::Poll<()>; -+ let mut _3: (); -+ let mut _4: u32; -+ let mut _5: &mut {async fn body of std::future::async_drop_in_place()}; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + } + storage_conflicts = BitMatrix(0x0) {} + } + let mut _0: std::task::Poll<()>; + let mut _3: (); + let mut _4: u32; + let mut _5: &mut {async fn body of std::future::async_drop_in_place()}; + let _6: std::future::ResumeTy; + let mut _7: std::ptr::NonNull>; bb0: { -+ _5 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _4 = discriminant((*_5)); -+ switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; -+ } -+ -+ bb1: { -+ _0 = Poll::<()>::Ready(const ()); -+ return; -+ } -+ -+ bb2: { -+ unreachable; -+ } -+ -+ bb3: { -+ _0 = Poll::<()>::Ready(move _3); -+ discriminant((*_5)) = 1; + _7 = move _2 as std::ptr::NonNull> (Transmute); + _6 = std::future::ResumeTy(move _7); + _5 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _4 = discriminant((*_5)); + switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + + bb1: { + _0 = Poll::<()>::Ready(const ()); + return; + } + + bb2: { + unreachable; + } + + bb3: { + _0 = Poll::<()>::Ready(move _3); + discriminant((*_5)) = 1; return; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff index 198209a013264..5c75b0b31e2b9 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff @@ -1,60 +1,58 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ } -+ storage_conflicts = BitMatrix(0x0) {} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + } + storage_conflicts = BitMatrix(0x0) {} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut SyncInt; -+ let mut _4: (); -+ let mut _5: u32; -+ let mut _6: &mut {async fn body of std::future::async_drop_in_place()}; + let mut _4: (); + let mut _5: u32; + let mut _6: &mut {async fn body of std::future::async_drop_in_place()}; + let _7: std::future::ResumeTy; + let mut _8: std::ptr::NonNull>; bb0: { -- _3 = no_retag copy (_1.0: &mut SyncInt); -- drop((*_3)) -> [return: bb1, unwind continue]; -+ _6 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _5 = discriminant((*_6)); -+ switchInt(move _5) -> [0: bb6, 1: bb4, 2: bb3, otherwise: bb5]; + _8 = move _2 as std::ptr::NonNull> (Transmute); + _7 = std::future::ResumeTy(move _8); + _6 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _5 = discriminant((*_6)); + switchInt(move _5) -> [0: bb6, 1: bb4, 2: bb3, otherwise: bb5]; } bb1: { -+ _0 = Poll::<()>::Ready(move _4); -+ discriminant((*_6)) = 1; + _0 = Poll::<()>::Ready(move _4); + discriminant((*_6)) = 1; + return; + } + + bb2 (cleanup): { + discriminant((*_6)) = 2; + resume; + } + + bb3: { + assert(const false, "`async fn` resumed after panicking") -> [success: bb3, unwind continue]; + } + + bb4: { + _0 = Poll::<()>::Ready(const ()); return; -+ } -+ -+ bb2 (cleanup): { -+ discriminant((*_6)) = 2; -+ resume; -+ } -+ -+ bb3: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb3, unwind continue]; -+ } -+ -+ bb4: { -+ _0 = Poll::<()>::Ready(const ()); -+ return; -+ } -+ -+ bb5: { -+ unreachable; -+ } -+ -+ bb6: { -+ _3 = no_retag copy ((*_6).0: &mut SyncInt); -+ drop((*_3)) -> [return: bb1, unwind: bb2]; + } + + bb5: { + unreachable; + } + + bb6: { + _3 = no_retag copy ((*_6).0: &mut SyncInt); + drop((*_3)) -> [return: bb1, unwind: bb2]; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff index 1247a7f995101..dc67991acf66f 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff @@ -1,39 +1,33 @@ - // MIR for `std::future::async_drop_in_place::{closure#0}` before StateTransform + // MIR for `std::future::async_drop_in_place::{closure#0}` after StateTransform -- fn async_drop_in_place::{closure#0}(_1: {async fn body of async_drop_in_place()}, _2: std::future::ResumeTy) -> () -- yields () -- { -- let mut _0: (); -+ fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { -+ coroutine layout { -+ field _s0: &mut SyncThenAsync; -+ field _s1: impl Future; -+ field _s2: impl Future; -+ field _s3: impl Future; -+ variant_fields = { -+ Unresumed(0): [], -+ Returned (1): [], -+ Panicked (2): [], -+ Suspend0 (3): [_s1], -+ Suspend1 (4): [_s2], -+ Suspend2 (5): [_s2], -+ Suspend3 (6): [_s0, _s3], -+ Suspend4 (7): [_s0, _s3], -+ } -+ storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3)} -+ } -+ let mut _0: std::task::Poll<()>; + fn async_drop_in_place::{closure#0}(_1: Pin<&mut {async fn body of async_drop_in_place()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: &mut SyncThenAsync; + field _s1: impl Future; + field _s2: impl Future; + field _s3: impl Future; + variant_fields = { + Unresumed(0): [], + Returned (1): [], + Panicked (2): [], + Suspend0 (3): [_s1], + Suspend1 (4): [_s2], + Suspend2 (5): [_s2], + Suspend3 (6): [_s0, _s3], + Suspend4 (7): [_s0, _s3], + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s2, _s0), (_s2, _s2), (_s3, _s0), (_s3, _s3)} + } + let mut _0: std::task::Poll<()>; let mut _3: &mut SyncThenAsync; let mut _4: impl std::future::Future; -- let mut _5: std::future::ResumeTy; -+ let mut _5: &mut std::task::Context<'_>; + let mut _5: std::future::ResumeTy; let mut _6: std::task::Poll<()>; let mut _7: isize; let mut _8: std::pin::Pin<&mut impl std::future::Future>; let mut _9: &mut std::task::Context<'_>; -- let mut _10: std::future::ResumeTy; -+ let mut _10: &mut std::task::Context<'_>; + let mut _10: std::future::ResumeTy; let mut _11: &mut impl std::future::Future; let mut _12: std::pin::Pin<&mut AsyncInt>; let mut _13: &mut AsyncInt; @@ -48,459 +42,233 @@ let mut _22: std::pin::Pin<&mut AsyncInt>; let mut _23: &mut AsyncInt; let mut _24: impl std::future::Future; -- let mut _25: std::future::ResumeTy; -+ let mut _25: &mut std::task::Context<'_>; + let mut _25: std::future::ResumeTy; let mut _26: std::task::Poll<()>; let mut _27: isize; let mut _28: std::pin::Pin<&mut impl std::future::Future>; let mut _29: &mut std::task::Context<'_>; -- let mut _30: std::future::ResumeTy; -+ let mut _30: &mut std::task::Context<'_>; + let mut _30: std::future::ResumeTy; let mut _31: &mut impl std::future::Future; -- let mut _32: std::future::ResumeTy; -+ let mut _32: &mut std::task::Context<'_>; + let mut _32: std::future::ResumeTy; let mut _33: std::task::Poll<()>; let mut _34: isize; let mut _35: std::pin::Pin<&mut impl std::future::Future>; let mut _36: &mut std::task::Context<'_>; -- let mut _37: std::future::ResumeTy; -+ let mut _37: &mut std::task::Context<'_>; + let mut _37: std::future::ResumeTy; let mut _38: &mut impl std::future::Future; let mut _39: std::pin::Pin<&mut AsyncInt>; let mut _40: &mut AsyncInt; let mut _41: impl std::future::Future; -- let mut _42: std::future::ResumeTy; -+ let mut _42: &mut std::task::Context<'_>; + let mut _42: std::future::ResumeTy; let mut _43: std::task::Poll<()>; let mut _44: isize; let mut _45: std::pin::Pin<&mut impl std::future::Future>; let mut _46: &mut std::task::Context<'_>; -- let mut _47: std::future::ResumeTy; -+ let mut _47: &mut std::task::Context<'_>; + let mut _47: std::future::ResumeTy; let mut _48: &mut impl std::future::Future; -- let mut _49: std::future::ResumeTy; -+ let mut _49: &mut std::task::Context<'_>; + let mut _49: std::future::ResumeTy; let mut _50: std::task::Poll<()>; let mut _51: isize; let mut _52: std::pin::Pin<&mut impl std::future::Future>; let mut _53: &mut std::task::Context<'_>; -- let mut _54: std::future::ResumeTy; -+ let mut _54: &mut std::task::Context<'_>; + let mut _54: std::future::ResumeTy; let mut _55: &mut impl std::future::Future; let mut _56: std::pin::Pin<&mut AsyncInt>; let mut _57: &mut AsyncInt; let mut _58: &mut SyncThenAsync; let mut _59: (); -+ let mut _60: (); -+ let mut _61: u32; -+ let mut _62: &mut {async fn body of std::future::async_drop_in_place()}; -+ let mut _63: &mut SyncThenAsync; -+ let mut _64: &mut SyncThenAsync; -+ let mut _65: &mut SyncThenAsync; -+ let mut _66: &mut SyncThenAsync; -+ let mut _67: &mut SyncThenAsync; -+ let mut _68: &mut SyncThenAsync; -+ let mut _69: &mut SyncThenAsync; + let mut _60: (); + let mut _61: u32; + let mut _62: &mut {async fn body of std::future::async_drop_in_place()}; + let mut _63: &mut SyncThenAsync; + let mut _64: &mut SyncThenAsync; + let mut _65: &mut SyncThenAsync; + let mut _66: &mut SyncThenAsync; + let mut _67: &mut SyncThenAsync; + let mut _68: &mut SyncThenAsync; + let mut _69: &mut SyncThenAsync; + let mut _70: &mut SyncThenAsync; + let mut _71: &mut SyncThenAsync; + let _72: std::future::ResumeTy; + let mut _73: std::ptr::NonNull>; bb0: { -- _3 = move (_1.0: &mut SyncThenAsync); -- _58 = &mut (*_3); -- _59 = ::drop(move _58) -> [return: bb58, unwind: bb5]; -+ _62 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); -+ _61 = discriminant((*_62)); -+ switchInt(move _61) -> [0: bb42, 1: bb41, 2: bb40, 3: bb35, 4: bb36, 5: bb37, 6: bb38, 7: bb39, otherwise: bb9]; + _73 = move _2 as std::ptr::NonNull> (Transmute); + _72 = std::future::ResumeTy(move _73); + _62 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); + _61 = discriminant((*_62)); + switchInt(move _61) -> [0: bb30, 1: bb29, 2: bb28, 3: bb23, 4: bb24, 5: bb25, 6: bb26, 7: bb27, otherwise: bb6]; } - bb1: { -+ _0 = Poll::<()>::Ready(move _60); -+ discriminant((*_62)) = 1; - return; + bb1 (cleanup): { + discriminant((*_62)) = 2; + resume; } bb2 (cleanup): { -- resume; -+ goto -> bb34; + _63 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + drop(((*_63).3: AsyncInt)) -> [return: bb1, unwind terminate(cleanup)]; } bb3 (cleanup): { -- drop(((*_3).3: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; -+ _63 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ drop(((*_63).3: AsyncInt)) -> [return: bb2, unwind terminate(cleanup)]; + _64 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + drop(((*_64).2: SyncInt)) -> [return: bb2, unwind terminate(cleanup)]; } bb4 (cleanup): { -- drop(((*_3).2: SyncInt)) -> [return: bb3, unwind terminate(cleanup)]; -+ _64 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ drop(((*_64).2: SyncInt)) -> [return: bb3, unwind terminate(cleanup)]; + _65 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + drop(((*_65).1: AsyncInt)) -> [return: bb3, unwind terminate(cleanup)]; } - bb5 (cleanup): { -- drop(((*_3).1: AsyncInt)) -> [return: bb4, unwind terminate(cleanup)]; -+ _65 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ drop(((*_65).1: AsyncInt)) -> [return: bb4, unwind terminate(cleanup)]; + bb5: { + assert(const false, "`async fn` resumed after async drop") -> [success: bb5, unwind: bb1]; } -- bb6: { -- StorageDead(_4); -- goto -> bb1; -+ bb6 (cleanup): { -+ nop; -+ goto -> bb2; + bb6: { + unreachable; } -- bb7 (cleanup): { -- StorageDead(_4); -- goto -> bb2; -+ bb7: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb7, unwind: bb6]; + bb7: { + _0 = Poll::<()>::Ready(move _60); + discriminant((*_62)) = 1; + return; } bb8: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb8, unwind: bb7]; -+ _2 = move _5; -+ StorageDead(_5); -+ goto -> bb7; + assert(const false, "`async fn` resumed after async drop") -> [success: bb8, unwind: bb1]; } bb9: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb8; -+ unreachable; + StorageLive(_32); + _0 = Poll::<()>::Pending; + StorageDead(_32); + discriminant((*_62)) = 5; + return; } bb10: { -- _2 = move _5; -- StorageDead(_5); -- goto -> bb16; -+ nop; -+ goto -> bb1; + _34 = discriminant(_33); + switchInt(move _34) -> [0: bb7, 1: bb9, otherwise: bb6]; } -- bb11: { -- StorageLive(_5); -- _5 = yield(const ()) -> [resume: bb9, drop: bb10]; -+ bb11 (cleanup): { -+ nop; -+ goto -> bb2; + bb11: { + _37 = move _72; + _36 = copy (_37.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _33 = as Future>::poll(move _35, move _36) -> [return: bb10, unwind: bb1]; } bb12: { -- unreachable; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb12, unwind: bb11]; + _38 = &mut (((*_62) as variant#5).0: impl std::future::Future); + _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb11, unwind: bb1]; } bb13: { -- _7 = discriminant(_6); -- switchInt(move _7) -> [0: bb6, 1: bb11, otherwise: bb12]; -+ _2 = move _25; -+ StorageDead(_25); -+ goto -> bb12; + (((*_62) as variant#5).0: impl std::future::Future) = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb12, unwind: bb1]; } bb14: { -- _6 = as Future>::poll(move _8, move _9) -> [return: bb13, unwind: bb7]; -+ _2 = move _32; -+ StorageDead(_32); -+ goto -> bb19; + _67 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + _40 = &mut ((*_67).3: AsyncInt); + _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb13, unwind: bb1]; } bb15: { -- _10 = move _2; -- _9 = std::future::get_context::<'_, '_>(move _10) -> [return: bb14, unwind: bb7]; -+ StorageLive(_32); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_32); -+ discriminant((*_62)) = 5; -+ return; + _68 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + drop(((*_68).2: SyncInt)) -> [return: bb14, unwind: bb2]; } bb16: { -- _11 = &mut _4; -- _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb15, unwind: bb7]; -+ _34 = discriminant(_33); -+ switchInt(move _34) -> [0: bb10, 1: bb15, otherwise: bb9]; + assert(const false, "`async fn` resumed after async drop") -> [success: bb16, unwind: bb3]; } bb17: { -- StorageLive(_4); -- _4 = async_drop_in_place::(copy (_12.0: &mut AsyncInt)) -> [return: bb16, unwind: bb7]; -+ _33 = as Future>::poll(move _35, move _36) -> [return: bb16, unwind: bb11]; + StorageLive(_49); + _0 = Poll::<()>::Pending; + StorageDead(_49); + discriminant((*_62)) = 7; + return; } bb18: { -- _13 = &mut ((*_3).3: AsyncInt); -- _12 = Pin::<&mut AsyncInt>::new_unchecked(move _13) -> [return: bb17, unwind: bb2]; -+ _37 = move _2; -+ _36 = move _37; -+ goto -> bb17; + _51 = discriminant(_50); + switchInt(move _51) -> [0: bb15, 1: bb17, otherwise: bb6]; } bb19: { -- StorageDead(_24); -- goto -> bb1; -+ _38 = &mut (((*_62) as variant#5).0: impl std::future::Future); -+ _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb18, unwind: bb11]; + _54 = move _72; + _53 = copy (_54.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _50 = as Future>::poll(move _52, move _53) -> [return: bb18, unwind: bb3]; } bb20: { -- StorageDead(_24); -- goto -> bb1; -+ nop; -+ (((*_62) as variant#5).0: impl std::future::Future) = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb19, unwind: bb11]; + _55 = &mut (((*_62) as variant#7).1: impl std::future::Future); + _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb19, unwind: bb3]; } -- bb21 (cleanup): { -- StorageDead(_24); -- goto -> bb2; -+ bb21: { -+ _66 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ _40 = &mut ((*_66).3: AsyncInt); -+ _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb20, unwind: bb2]; + bb21: { + (((*_62) as variant#7).1: impl std::future::Future) = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb20, unwind: bb3]; } bb22: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb22, unwind: bb21]; -+ nop; -+ _67 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ drop(((*_67).2: SyncInt)) -> [return: bb21, unwind: bb3]; + _70 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + _57 = &mut ((*_70).1: AsyncInt); + _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb21, unwind: bb3]; } -- bb23: { -- _2 = move _25; -- StorageDead(_25); -- goto -> bb22; -+ bb23 (cleanup): { -+ nop; -+ goto -> bb4; + bb23: { + StorageLive(_5); + _5 = move _72; + _72 = move _5; + StorageDead(_5); + goto -> bb5; } bb24: { -- _2 = move _25; -- StorageDead(_25); -- goto -> bb29; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb24, unwind: bb23]; + StorageLive(_25); + _25 = move _72; + _72 = move _25; + StorageDead(_25); + goto -> bb8; } bb25: { -- StorageLive(_25); -- _25 = yield(const ()) -> [resume: bb23, drop: bb24]; -+ _2 = move _42; -+ StorageDead(_42); -+ goto -> bb24; + StorageLive(_32); + _32 = move _72; + _72 = move _32; + StorageDead(_32); + goto -> bb12; } bb26: { -- _27 = discriminant(_26); -- switchInt(move _27) -> [0: bb20, 1: bb25, otherwise: bb12]; -+ _2 = move _49; -+ StorageDead(_49); -+ goto -> bb31; + StorageLive(_42); + _42 = move _72; + _72 = move _42; + StorageDead(_42); + goto -> bb16; } bb27: { -- _26 = as Future>::poll(move _28, move _29) -> [return: bb26, unwind: bb21]; -+ StorageLive(_49); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_49); -+ discriminant((*_62)) = 7; -+ return; + StorageLive(_49); + _49 = move _72; + _72 = move _49; + StorageDead(_49); + goto -> bb20; } bb28: { -- _30 = move _2; -- _29 = std::future::get_context::<'_, '_>(move _30) -> [return: bb27, unwind: bb21]; -+ _51 = discriminant(_50); -+ switchInt(move _51) -> [0: bb22, 1: bb27, otherwise: bb9]; + assert(const false, "`async fn` resumed after panicking") -> [success: bb28, unwind continue]; } bb29: { -- _31 = &mut _24; -- _28 = Pin::<&mut impl Future>::new_unchecked(move _31) -> [return: bb28, unwind: bb21]; -+ _50 = as Future>::poll(move _52, move _53) -> [return: bb28, unwind: bb23]; + _0 = Poll::<()>::Ready(const ()); + return; } bb30: { -- _2 = move _32; -- StorageDead(_32); -- goto -> bb36; -+ _54 = move _2; -+ _53 = move _54; -+ goto -> bb29; - } - - bb31: { -- _2 = move _32; -- StorageDead(_32); -- goto -> bb29; -+ _55 = &mut (((*_62) as variant#7).1: impl std::future::Future); -+ _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb30, unwind: bb23]; - } - - bb32: { -- StorageLive(_32); -- _32 = yield(const ()) -> [resume: bb30, drop: bb31]; -+ nop; -+ (((*_62) as variant#7).1: impl std::future::Future) = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb31, unwind: bb23]; - } - - bb33: { -- _34 = discriminant(_33); -- switchInt(move _34) -> [0: bb19, 1: bb32, otherwise: bb12]; -+ _68 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ _57 = &mut ((*_68).1: AsyncInt); -+ _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb32, unwind: bb4]; - } - -- bb34: { -- _33 = as Future>::poll(move _35, move _36) -> [return: bb33, unwind: bb21]; -+ bb34 (cleanup): { -+ discriminant((*_62)) = 2; -+ resume; - } - - bb35: { -- _37 = move _2; -- _36 = std::future::get_context::<'_, '_>(move _37) -> [return: bb34, unwind: bb21]; -+ StorageLive(_5); -+ _5 = move _2; -+ goto -> bb8; - } - - bb36: { -- _38 = &mut _24; -- _35 = Pin::<&mut impl Future>::new_unchecked(move _38) -> [return: bb35, unwind: bb21]; -+ StorageLive(_25); -+ _25 = move _2; -+ goto -> bb13; - } - - bb37: { -- StorageLive(_24); -- _24 = async_drop_in_place::(copy (_39.0: &mut AsyncInt)) -> [return: bb36, unwind: bb21]; -+ StorageLive(_32); -+ _32 = move _2; -+ goto -> bb14; - } - - bb38: { -- _40 = &mut ((*_3).3: AsyncInt); -- _39 = Pin::<&mut AsyncInt>::new_unchecked(move _40) -> [return: bb37, unwind: bb2]; -+ StorageLive(_42); -+ _42 = move _2; -+ goto -> bb25; - } - - bb39: { -- StorageDead(_41); -- drop(((*_3).2: SyncInt)) -> [return: bb38, unwind: bb3]; -+ StorageLive(_49); -+ _49 = move _2; -+ goto -> bb26; - } - - bb40: { -- StorageDead(_41); -- drop(((*_3).2: SyncInt)) -> [return: bb18, unwind: bb3]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb40, unwind continue]; - } - -- bb41 (cleanup): { -- StorageDead(_41); -- goto -> bb4; -+ bb41: { -+ _0 = Poll::<()>::Ready(const ()); -+ return; - } - - bb42: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb42, unwind: bb41]; -- } -- -- bb43: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb42; -- } -- -- bb44: { -- _2 = move _42; -- StorageDead(_42); -- goto -> bb49; -- } -- -- bb45: { -- StorageLive(_42); -- _42 = yield(const ()) -> [resume: bb43, drop: bb44]; -- } -- -- bb46: { -- _44 = discriminant(_43); -- switchInt(move _44) -> [0: bb40, 1: bb45, otherwise: bb12]; -- } -- -- bb47: { -- _43 = as Future>::poll(move _45, move _46) -> [return: bb46, unwind: bb41]; -- } -- -- bb48: { -- _47 = move _2; -- _46 = std::future::get_context::<'_, '_>(move _47) -> [return: bb47, unwind: bb41]; -- } -- -- bb49: { -- _48 = &mut _41; -- _45 = Pin::<&mut impl Future>::new_unchecked(move _48) -> [return: bb48, unwind: bb41]; -- } -- -- bb50: { -- _2 = move _49; -- StorageDead(_49); -- goto -> bb56; -- } -- -- bb51: { -- _2 = move _49; -- StorageDead(_49); -- goto -> bb49; -- } -- -- bb52: { -- StorageLive(_49); -- _49 = yield(const ()) -> [resume: bb50, drop: bb51]; -- } -- -- bb53: { -- _51 = discriminant(_50); -- switchInt(move _51) -> [0: bb39, 1: bb52, otherwise: bb12]; -- } -- -- bb54: { -- _50 = as Future>::poll(move _52, move _53) -> [return: bb53, unwind: bb41]; -- } -- -- bb55: { -- _54 = move _2; -- _53 = std::future::get_context::<'_, '_>(move _54) -> [return: bb54, unwind: bb41]; -- } -- -- bb56: { -- _55 = &mut _41; -- _52 = Pin::<&mut impl Future>::new_unchecked(move _55) -> [return: bb55, unwind: bb41]; -- } -- -- bb57: { -- StorageLive(_41); -- _41 = async_drop_in_place::(copy (_56.0: &mut AsyncInt)) -> [return: bb56, unwind: bb41]; -- } -- -- bb58: { -- _57 = &mut ((*_3).1: AsyncInt); -- _56 = Pin::<&mut AsyncInt>::new_unchecked(move _57) -> [return: bb57, unwind: bb4]; -+ (((*_62) as variant#7).0: &mut SyncThenAsync) = move ((*_62).0: &mut SyncThenAsync); -+ _69 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); -+ _58 = &mut (*_69); -+ _59 = ::drop(move _58) -> [return: bb33, unwind: bb5]; + (((*_62) as variant#7).0: &mut SyncThenAsync) = move ((*_62).0: &mut SyncThenAsync); + _71 = no_retag copy (((*_62) as variant#7).0: &mut SyncThenAsync); + _58 = &mut (*_71); + _59 = ::drop(move _58) -> [return: bb22, unwind: bb4]; } } diff --git a/tests/mir-opt/coroutine/async_drop.double-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.double-{closure#0}.StateTransform.diff index b59d810d5366a..89b30ef98bba7 100644 --- a/tests/mir-opt/coroutine/async_drop.double-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.double-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn double::{closure#0}(_1: {async fn body of double()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn double::{closure#0}(_1: Pin<&mut {async fn body of double()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: (); @@ -23,56 +25,49 @@ + } + storage_conflicts = BitMatrix(6x6) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s0, _s4), (_s0, _s5), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s1, _s4), (_s1, _s5), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s2, _s4), (_s2, _s5), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3), (_s3, _s4), (_s4, _s0), (_s4, _s1), (_s4, _s2), (_s4, _s3), (_s4, _s4), (_s5, _s0), (_s5, _s1), (_s5, _s2), (_s5, _s5)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _43; + coroutine debug sync_int => _s1; + let mut _0: std::task::Poll<()>; let _3: SyncInt; let mut _6: impl std::future::Future; -- let mut _7: std::future::ResumeTy; -+ let mut _7: &mut std::task::Context<'_>; + let mut _7: std::future::ResumeTy; let mut _8: std::task::Poll<()>; let mut _9: isize; let mut _10: std::pin::Pin<&mut impl std::future::Future>; let mut _11: &mut std::task::Context<'_>; -- let mut _12: std::future::ResumeTy; -+ let mut _12: &mut std::task::Context<'_>; + let mut _12: std::future::ResumeTy; let mut _13: &mut impl std::future::Future; -- let mut _14: std::future::ResumeTy; -+ let mut _14: &mut std::task::Context<'_>; + let mut _14: std::future::ResumeTy; let mut _15: std::task::Poll<()>; let mut _16: isize; let mut _17: std::pin::Pin<&mut impl std::future::Future>; let mut _18: &mut std::task::Context<'_>; -- let mut _19: std::future::ResumeTy; -+ let mut _19: &mut std::task::Context<'_>; + let mut _19: std::future::ResumeTy; let mut _20: &mut impl std::future::Future; let mut _21: std::pin::Pin<&mut AsyncInt>; let mut _22: &mut AsyncInt; let mut _23: impl std::future::Future; -- let mut _24: std::future::ResumeTy; -+ let mut _24: &mut std::task::Context<'_>; + let mut _24: std::future::ResumeTy; let mut _25: std::task::Poll<()>; let mut _26: isize; let mut _27: std::pin::Pin<&mut impl std::future::Future>; let mut _28: &mut std::task::Context<'_>; -- let mut _29: std::future::ResumeTy; -+ let mut _29: &mut std::task::Context<'_>; + let mut _29: std::future::ResumeTy; let mut _30: &mut impl std::future::Future; -- let mut _31: std::future::ResumeTy; -+ let mut _31: &mut std::task::Context<'_>; + let mut _31: std::future::ResumeTy; let mut _32: std::task::Poll<()>; let mut _33: isize; let mut _34: std::pin::Pin<&mut impl std::future::Future>; let mut _35: &mut std::task::Context<'_>; -- let mut _36: std::future::ResumeTy; -+ let mut _36: &mut std::task::Context<'_>; + let mut _36: std::future::ResumeTy; let mut _37: &mut impl std::future::Future; let mut _38: std::pin::Pin<&mut AsyncInt>; let mut _39: &mut AsyncInt; + let mut _40: (); + let mut _41: u32; + let mut _42: &mut {async fn body of double()}; ++ let mut _43: std::future::ResumeTy; ++ let mut _44: std::ptr::NonNull>; scope 1 { - debug sync_int => _3; + debug sync_int => (((*_42) as variant#6).1: SyncInt); @@ -98,380 +93,321 @@ - StorageLive(_5); - _5 = AsyncInt(const 0_i32); - _0 = const (); -- goto -> bb33; +- _22 = &mut _5; +- _21 = Pin::<&mut AsyncInt>::new_unchecked(move _22) -> [return: bb27, unwind: bb4]; ++ _44 = move _2 as std::ptr::NonNull> (Transmute); ++ _43 = std::future::ResumeTy(move _44); + _42 = copy (_1.0: &mut {async fn body of double()}); + _41 = discriminant((*_42)); -+ switchInt(move _41) -> [0: bb42, 1: bb41, 2: bb40, 3: bb36, 4: bb37, 5: bb38, 6: bb39, otherwise: bb13]; ++ switchInt(move _41) -> [0: bb26, 1: bb25, 2: bb24, 3: bb20, 4: bb21, 5: bb22, 6: bb23, otherwise: bb6]; } bb1: { -- StorageDead(_5); -- goto -> bb53; -+ nop; -+ goto -> bb33; - } - - bb2: { -- StorageDead(_4); -- drop(_3) -> [return: bb3, unwind: bb11]; -+ nop; -+ drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb3, unwind: bb7]; - } - - bb3: { - StorageDead(_3); -- drop(_1) -> [return: bb4, unwind: bb12]; -+ nop; -+ goto -> bb34; - } - - bb4: { +- drop(_1) -> [return: bb2, unwind: bb7]; + _0 = Poll::<()>::Ready(move (((*_42) as variant#6).0: ())); + discriminant((*_42)) = 1; - return; ++ return; } -- bb5: { -- StorageDead(_5); -- goto -> bb6; -+ bb5 (cleanup): { -+ nop; -+ drop((((*_42) as variant#6).2: AsyncInt)) -> [return: bb6, unwind terminate(cleanup)]; +- bb2: { +- return; ++ bb2 (cleanup): { ++ drop((((*_42) as variant#6).2: AsyncInt)) -> [return: bb3, unwind terminate(cleanup)]; } -- bb6: { +- bb3: { - StorageDead(_4); -- goto -> bb7; -+ bb6 (cleanup): { -+ nop; -+ drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb7, unwind terminate(cleanup)]; - } - -- bb7: { - StorageDead(_3); -+ bb7 (cleanup): { -+ nop; - goto -> bb8; - } - -- bb8: { - coroutine_drop; -+ bb8 (cleanup): { -+ goto -> bb35; ++ bb3 (cleanup): { ++ drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb19, unwind terminate(cleanup)]; } -- bb9 (cleanup): { +- bb4 (cleanup): { - StorageDead(_5); -- drop(_4) -> [return: bb10, unwind terminate(cleanup)]; -+ bb9: { -+ nop; -+ goto -> bb1; +- drop(_4) -> [return: bb5, unwind terminate(cleanup)]; ++ bb4: { ++ _39 = &mut (((*_42) as variant#6).2: AsyncInt); ++ _38 = Pin::<&mut AsyncInt>::new_unchecked(move _39) -> [return: bb18, unwind: bb3]; } - bb10 (cleanup): { +- bb5 (cleanup): { - StorageDead(_4); -- drop(_3) -> [return: bb11, unwind terminate(cleanup)]; -+ nop; -+ goto -> bb5; +- drop(_3) -> [return: bb6, unwind terminate(cleanup)]; ++ bb5: { ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb5, unwind: bb2]; } -- bb11 (cleanup): { +- bb6 (cleanup): { - StorageDead(_3); -- drop(_1) -> [return: bb12, unwind terminate(cleanup)]; -+ bb11: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb11, unwind: bb10]; +- drop(_1) -> [return: bb7, unwind terminate(cleanup)]; ++ bb6: { ++ unreachable; } -- bb12 (cleanup): { +- bb7 (cleanup): { - resume; -+ bb12: { -+ _2 = move _7; -+ StorageDead(_7); -+ goto -> bb11; ++ bb7: { ++ StorageLive(_14); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_14); ++ discriminant((*_42)) = 4; ++ return; } - bb13: { + bb8: { - StorageDead(_6); -- goto -> bb1; -+ unreachable; +- StorageDead(_5); +- _39 = &mut _4; +- _38 = Pin::<&mut AsyncInt>::new_unchecked(move _39) -> [return: bb46, unwind: bb5]; ++ _16 = discriminant(_15); ++ switchInt(move _16) -> [0: bb4, 1: bb7, otherwise: bb6]; } - bb14: { + bb9: { - StorageDead(_6); -- goto -> bb5; -+ _2 = move _14; -+ StorageDead(_14); -+ goto -> bb19; +- StorageDead(_5); +- goto -> bb3; ++ _19 = move _43; ++ _18 = copy (_19.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _15 = as Future>::poll(move _17, move _18) -> [return: bb8, unwind: bb2]; } -- bb15 (cleanup): { +- bb10 (cleanup): { - StorageDead(_6); -- goto -> bb9; -+ bb15: { -+ StorageLive(_14); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_14); -+ discriminant((*_42)) = 4; -+ return; +- goto -> bb4; ++ bb10: { ++ _20 = &mut (((*_42) as variant#4).4: impl std::future::Future); ++ _17 = Pin::<&mut impl Future>::new_unchecked(move _20) -> [return: bb9, unwind: bb2]; } - bb16: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb16, unwind: bb15]; -+ _16 = discriminant(_15); -+ switchInt(move _16) -> [0: bb9, 1: bb15, otherwise: bb13]; + bb11: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb11, unwind: bb10]; ++ (((*_42) as variant#4).4: impl std::future::Future) = async_drop_in_place::(copy (_21.0: &mut AsyncInt)) -> [return: bb10, unwind: bb2]; } - bb17: { + bb12: { - _2 = move _7; - StorageDead(_7); -- goto -> bb16; -+ _15 = as Future>::poll(move _17, move _18) -> [return: bb16, unwind: bb10]; +- goto -> bb11; ++ drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb1, unwind: bb19]; } - bb18: { + bb13: { - _2 = move _7; - StorageDead(_7); -- goto -> bb24; -+ _19 = move _2; -+ _18 = move _19; -+ goto -> bb17; +- goto -> bb19; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb13, unwind: bb3]; } - bb19: { + bb14: { - StorageLive(_7); -- _7 = yield(const ()) -> [resume: bb17, drop: bb18]; -+ _20 = &mut (((*_42) as variant#4).4: impl std::future::Future); -+ _17 = Pin::<&mut impl Future>::new_unchecked(move _20) -> [return: bb18, unwind: bb10]; +- _7 = yield(const ()) -> [resume: bb12, drop: bb13]; ++ StorageLive(_31); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_31); ++ discriminant((*_42)) = 6; ++ return; } - bb20: { + bb15: { - unreachable; -+ nop; -+ (((*_42) as variant#4).4: impl std::future::Future) = async_drop_in_place::(copy (_21.0: &mut AsyncInt)) -> [return: bb19, unwind: bb10]; ++ _33 = discriminant(_32); ++ switchInt(move _33) -> [0: bb12, 1: bb14, otherwise: bb6]; } - bb21: { + bb16: { - _9 = discriminant(_8); -- switchInt(move _9) -> [0: bb14, 1: bb19, otherwise: bb20]; -+ _22 = &mut (((*_42) as variant#4).3: AsyncInt); -+ _21 = Pin::<&mut AsyncInt>::new_unchecked(move _22) -> [return: bb20, unwind: bb5]; +- switchInt(move _9) -> [0: bb9, 1: bb14, otherwise: bb15]; ++ _36 = move _43; ++ _35 = copy (_36.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _32 = as Future>::poll(move _34, move _35) -> [return: bb15, unwind: bb3]; } - bb22: { -- _8 = as Future>::poll(move _10, move _11) -> [return: bb21, unwind: bb15]; -+ nop; -+ goto -> bb2; + bb17: { +- _8 = as Future>::poll(move _10, move _11) -> [return: bb16, unwind: bb10]; ++ _37 = &mut (((*_42) as variant#6).3: impl std::future::Future); ++ _34 = Pin::<&mut impl Future>::new_unchecked(move _37) -> [return: bb16, unwind: bb3]; } -- bb23: { + bb18: { - _12 = move _2; -- _11 = std::future::get_context::<'_, '_>(move _12) -> [return: bb22, unwind: bb15]; -+ bb23 (cleanup): { -+ nop; -+ goto -> bb6; +- _11 = std::future::get_context::<'_, '_>(move _12) -> [return: bb17, unwind: bb10]; ++ (((*_42) as variant#6).3: impl std::future::Future) = async_drop_in_place::(copy (_38.0: &mut AsyncInt)) -> [return: bb17, unwind: bb3]; } - bb24: { +- bb19: { - _13 = &mut _6; -- _10 = Pin::<&mut impl Future>::new_unchecked(move _13) -> [return: bb23, unwind: bb15]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb24, unwind: bb23]; +- _10 = Pin::<&mut impl Future>::new_unchecked(move _13) -> [return: bb18, unwind: bb10]; ++ bb19 (cleanup): { ++ discriminant((*_42)) = 2; ++ resume; } - bb25: { + bb20: { - _2 = move _14; - StorageDead(_14); -- goto -> bb31; -+ _2 = move _24; -+ StorageDead(_24); -+ goto -> bb24; +- goto -> bb26; ++ StorageLive(_7); ++ _7 = move _43; ++ _43 = move _7; ++ StorageDead(_7); ++ goto -> bb5; } - bb26: { + bb21: { - _2 = move _14; -- StorageDead(_14); -- goto -> bb24; -+ _2 = move _31; -+ StorageDead(_31); -+ goto -> bb31; ++ StorageLive(_14); ++ _14 = move _43; ++ _43 = move _14; + StorageDead(_14); +- goto -> bb19; ++ goto -> bb10; } - bb27: { + bb22: { - StorageLive(_14); -- _14 = yield(const ()) -> [resume: bb25, drop: bb26]; -+ StorageLive(_31); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_31); -+ discriminant((*_42)) = 6; -+ return; +- _14 = yield(const ()) -> [resume: bb20, drop: bb21]; ++ StorageLive(_24); ++ _24 = move _43; ++ _43 = move _24; ++ StorageDead(_24); ++ goto -> bb13; } - bb28: { + bb23: { - _16 = discriminant(_15); -- switchInt(move _16) -> [0: bb13, 1: bb27, otherwise: bb20]; -+ _33 = discriminant(_32); -+ switchInt(move _33) -> [0: bb22, 1: bb27, otherwise: bb13]; +- switchInt(move _16) -> [0: bb8, 1: bb22, otherwise: bb15]; ++ StorageLive(_31); ++ _31 = move _43; ++ _43 = move _31; ++ StorageDead(_31); ++ goto -> bb17; } - bb29: { -- _15 = as Future>::poll(move _17, move _18) -> [return: bb28, unwind: bb15]; -+ _32 = as Future>::poll(move _34, move _35) -> [return: bb28, unwind: bb23]; + bb24: { +- _15 = as Future>::poll(move _17, move _18) -> [return: bb23, unwind: bb10]; ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb24, unwind continue]; } - bb30: { + bb25: { - _19 = move _2; -- _18 = std::future::get_context::<'_, '_>(move _19) -> [return: bb29, unwind: bb15]; -+ _36 = move _2; -+ _35 = move _36; -+ goto -> bb29; +- _18 = std::future::get_context::<'_, '_>(move _19) -> [return: bb24, unwind: bb10]; ++ assert(const false, "`async fn` resumed after completion") -> [success: bb25, unwind continue]; } - bb31: { + bb26: { - _20 = &mut _6; -- _17 = Pin::<&mut impl Future>::new_unchecked(move _20) -> [return: bb30, unwind: bb15]; -+ _37 = &mut (((*_42) as variant#6).3: impl std::future::Future); -+ _34 = Pin::<&mut impl Future>::new_unchecked(move _37) -> [return: bb30, unwind: bb23]; - } - - bb32: { +- _17 = Pin::<&mut impl Future>::new_unchecked(move _20) -> [return: bb25, unwind: bb10]; +- } +- +- bb27: { - StorageLive(_6); -- _6 = async_drop_in_place::(copy (_21.0: &mut AsyncInt)) -> [return: bb31, unwind: bb15]; -+ nop; -+ (((*_42) as variant#6).3: impl std::future::Future) = async_drop_in_place::(copy (_38.0: &mut AsyncInt)) -> [return: bb31, unwind: bb23]; - } - - bb33: { -- _22 = &mut _5; -- _21 = Pin::<&mut AsyncInt>::new_unchecked(move _22) -> [return: bb32, unwind: bb9]; -+ _39 = &mut (((*_42) as variant#6).2: AsyncInt); -+ _38 = Pin::<&mut AsyncInt>::new_unchecked(move _39) -> [return: bb32, unwind: bb6]; - } - - bb34: { +- _6 = async_drop_in_place::(copy (_21.0: &mut AsyncInt)) -> [return: bb26, unwind: bb10]; +- } +- +- bb28: { - StorageDead(_23); -- goto -> bb2; -+ goto -> bb4; - } - -- bb35: { +- StorageDead(_4); +- drop(_3) -> [return: bb1, unwind: bb6]; +- } +- +- bb29: { - StorageDead(_23); -- goto -> bb6; -+ bb35 (cleanup): { -+ discriminant((*_42)) = 2; -+ resume; - } - -- bb36 (cleanup): { +- goto -> bb3; +- } +- +- bb30 (cleanup): { - StorageDead(_23); -- goto -> bb10; -+ bb36: { -+ StorageLive(_7); -+ _7 = move _2; -+ goto -> bb12; - } - - bb37: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb37, unwind: bb36]; -+ StorageLive(_14); -+ _14 = move _2; -+ goto -> bb14; - } - - bb38: { +- goto -> bb5; +- } +- +- bb31: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb31, unwind: bb30]; +- } +- +- bb32: { - _2 = move _24; - StorageDead(_24); -- goto -> bb37; -+ StorageLive(_24); -+ _24 = move _2; -+ goto -> bb25; - } - - bb39: { +- goto -> bb31; +- } +- +- bb33: { - _2 = move _24; - StorageDead(_24); -- goto -> bb44; -+ StorageLive(_31); -+ _31 = move _2; -+ goto -> bb26; - } - - bb40: { +- goto -> bb38; +- } +- +- bb34: { - StorageLive(_24); -- _24 = yield(const ()) -> [resume: bb38, drop: bb39]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb40, unwind continue]; - } - - bb41: { +- _24 = yield(const ()) -> [resume: bb32, drop: bb33]; +- } +- +- bb35: { - _26 = discriminant(_25); -- switchInt(move _26) -> [0: bb35, 1: bb40, otherwise: bb20]; -+ assert(const false, "`async fn` resumed after completion") -> [success: bb41, unwind continue]; - } - - bb42: { -- _25 = as Future>::poll(move _27, move _28) -> [return: bb41, unwind: bb36]; +- switchInt(move _26) -> [0: bb29, 1: bb34, otherwise: bb15]; - } - -- bb43: { +- bb36: { +- _25 = as Future>::poll(move _27, move _28) -> [return: bb35, unwind: bb30]; +- } +- +- bb37: { - _29 = move _2; -- _28 = std::future::get_context::<'_, '_>(move _29) -> [return: bb42, unwind: bb36]; +- _28 = std::future::get_context::<'_, '_>(move _29) -> [return: bb36, unwind: bb30]; - } - -- bb44: { +- bb38: { - _30 = &mut _23; -- _27 = Pin::<&mut impl Future>::new_unchecked(move _30) -> [return: bb43, unwind: bb36]; +- _27 = Pin::<&mut impl Future>::new_unchecked(move _30) -> [return: bb37, unwind: bb30]; - } - -- bb45: { +- bb39: { - _2 = move _31; - StorageDead(_31); -- goto -> bb51; +- goto -> bb45; - } - -- bb46: { +- bb40: { - _2 = move _31; - StorageDead(_31); -- goto -> bb44; +- goto -> bb38; - } - -- bb47: { +- bb41: { - StorageLive(_31); -- _31 = yield(const ()) -> [resume: bb45, drop: bb46]; +- _31 = yield(const ()) -> [resume: bb39, drop: bb40]; - } - -- bb48: { +- bb42: { - _33 = discriminant(_32); -- switchInt(move _33) -> [0: bb34, 1: bb47, otherwise: bb20]; +- switchInt(move _33) -> [0: bb28, 1: bb41, otherwise: bb15]; - } - -- bb49: { -- _32 = as Future>::poll(move _34, move _35) -> [return: bb48, unwind: bb36]; +- bb43: { +- _32 = as Future>::poll(move _34, move _35) -> [return: bb42, unwind: bb30]; - } - -- bb50: { +- bb44: { - _36 = move _2; -- _35 = std::future::get_context::<'_, '_>(move _36) -> [return: bb49, unwind: bb36]; +- _35 = std::future::get_context::<'_, '_>(move _36) -> [return: bb43, unwind: bb30]; - } - -- bb51: { +- bb45: { - _37 = &mut _23; -- _34 = Pin::<&mut impl Future>::new_unchecked(move _37) -> [return: bb50, unwind: bb36]; +- _34 = Pin::<&mut impl Future>::new_unchecked(move _37) -> [return: bb44, unwind: bb30]; - } - -- bb52: { +- bb46: { - StorageLive(_23); -- _23 = async_drop_in_place::(copy (_38.0: &mut AsyncInt)) -> [return: bb51, unwind: bb36]; -- } -- -- bb53: { -- _39 = &mut _4; -- _38 = Pin::<&mut AsyncInt>::new_unchecked(move _39) -> [return: bb52, unwind: bb10]; -+ nop; +- _23 = async_drop_in_place::(copy (_38.0: &mut AsyncInt)) -> [return: bb45, unwind: bb30]; + (((*_42) as variant#6).1: SyncInt) = SyncInt(const 0_i32); -+ nop; + (((*_42) as variant#6).2: AsyncInt) = AsyncInt(const 0_i32); -+ nop; + (((*_42) as variant#4).3: AsyncInt) = AsyncInt(const 0_i32); + (((*_42) as variant#6).0: ()) = const (); -+ goto -> bb21; ++ _22 = &mut (((*_42) as variant#4).3: AsyncInt); ++ _21 = Pin::<&mut AsyncInt>::new_unchecked(move _22) -> [return: bb11, unwind: bb2]; } } diff --git a/tests/mir-opt/coroutine/async_drop.double-{closure#0}.coroutine_drop_async.0.mir b/tests/mir-opt/coroutine/async_drop.double-{closure#0}.coroutine_drop_async.0.mir index acd022800f84c..f48a7fd8eb877 100644 --- a/tests/mir-opt/coroutine/async_drop.double-{closure#0}.coroutine_drop_async.0.mir +++ b/tests/mir-opt/coroutine/async_drop.double-{closure#0}.coroutine_drop_async.0.mir @@ -1,46 +1,48 @@ // MIR for `double::{closure#0}` 0 coroutine_drop_async fn double::{closure#0}(_1: Pin<&mut {async fn body of double()}>, _2: &mut Context<'_>) -> Poll<()> { - debug _task_context => _2; + debug _task_context => _43; let mut _0: std::task::Poll<()>; let _3: SyncInt; let mut _6: impl std::future::Future; - let mut _7: &mut std::task::Context<'_>; + let mut _7: std::future::ResumeTy; let mut _8: std::task::Poll<()>; let mut _9: isize; let mut _10: std::pin::Pin<&mut impl std::future::Future>; let mut _11: &mut std::task::Context<'_>; - let mut _12: &mut std::task::Context<'_>; + let mut _12: std::future::ResumeTy; let mut _13: &mut impl std::future::Future; - let mut _14: &mut std::task::Context<'_>; + let mut _14: std::future::ResumeTy; let mut _15: std::task::Poll<()>; let mut _16: isize; let mut _17: std::pin::Pin<&mut impl std::future::Future>; let mut _18: &mut std::task::Context<'_>; - let mut _19: &mut std::task::Context<'_>; + let mut _19: std::future::ResumeTy; let mut _20: &mut impl std::future::Future; let mut _21: std::pin::Pin<&mut AsyncInt>; let mut _22: &mut AsyncInt; let mut _23: impl std::future::Future; - let mut _24: &mut std::task::Context<'_>; + let mut _24: std::future::ResumeTy; let mut _25: std::task::Poll<()>; let mut _26: isize; let mut _27: std::pin::Pin<&mut impl std::future::Future>; let mut _28: &mut std::task::Context<'_>; - let mut _29: &mut std::task::Context<'_>; + let mut _29: std::future::ResumeTy; let mut _30: &mut impl std::future::Future; - let mut _31: &mut std::task::Context<'_>; + let mut _31: std::future::ResumeTy; let mut _32: std::task::Poll<()>; let mut _33: isize; let mut _34: std::pin::Pin<&mut impl std::future::Future>; let mut _35: &mut std::task::Context<'_>; - let mut _36: &mut std::task::Context<'_>; + let mut _36: std::future::ResumeTy; let mut _37: &mut impl std::future::Future; let mut _38: std::pin::Pin<&mut AsyncInt>; let mut _39: &mut AsyncInt; let mut _40: (); let mut _41: u32; let mut _42: &mut {async fn body of double()}; + let mut _43: std::future::ResumeTy; + let mut _44: std::ptr::NonNull>; scope 1 { debug sync_int => (((*_42) as variant#6).1: SyncInt); let _4: AsyncInt; @@ -54,67 +56,57 @@ fn double::{closure#0}(_1: Pin<&mut {async fn body of double()}>, _2: &mut Conte } bb0: { + _44 = move _2 as std::ptr::NonNull> (Transmute); + _43 = std::future::ResumeTy(move _44); _42 = copy (_1.0: &mut {async fn body of double()}); _41 = discriminant((*_42)); - switchInt(move _41) -> [0: bb29, 2: bb36, 3: bb32, 4: bb33, 5: bb34, 6: bb35, otherwise: bb37]; + switchInt(move _41) -> [0: bb26, 2: bb33, 3: bb29, 4: bb30, 5: bb31, 6: bb32, otherwise: bb34]; } bb1: { nop; - goto -> bb2; - } - - bb2: { - nop; - goto -> bb3; - } - - bb3: { nop; - goto -> bb4; - } - - bb4: { _0 = Poll::<()>::Ready(const ()); return; } - bb5 (cleanup): { + bb2 (cleanup): { nop; - drop((((*_42) as variant#6).2: AsyncInt)) -> [return: bb6, unwind terminate(cleanup)]; + drop((((*_42) as variant#6).2: AsyncInt)) -> [return: bb3, unwind terminate(cleanup)]; } - bb6 (cleanup): { + bb3 (cleanup): { nop; - drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb7, unwind terminate(cleanup)]; + drop((((*_42) as variant#6).1: SyncInt)) -> [return: bb4, unwind terminate(cleanup)]; } - bb7 (cleanup): { + bb4 (cleanup): { nop; - goto -> bb8; + goto -> bb5; } - bb8 (cleanup): { - goto -> bb31; + bb5 (cleanup): { + goto -> bb28; } - bb9: { + bb6: { + nop; nop; goto -> bb1; } - bb10 (cleanup): { + bb7 (cleanup): { nop; - goto -> bb5; + goto -> bb2; } - bb11: { - _2 = move _7; + bb8: { + _43 = move _7; StorageDead(_7); - goto -> bb17; + goto -> bb14; } - bb12: { + bb9: { StorageLive(_7); _0 = Poll::<()>::Pending; StorageDead(_7); @@ -122,53 +114,53 @@ fn double::{closure#0}(_1: Pin<&mut {async fn body of double()}>, _2: &mut Conte return; } - bb13: { + bb10: { unreachable; } - bb14: { + bb11: { _9 = discriminant(_8); - switchInt(move _9) -> [0: bb9, 1: bb12, otherwise: bb13]; + switchInt(move _9) -> [0: bb6, 1: bb9, otherwise: bb10]; } - bb15: { - _8 = as Future>::poll(move _10, move _11) -> [return: bb14, unwind: bb10]; + bb12: { + _8 = as Future>::poll(move _10, move _11) -> [return: bb11, unwind: bb7]; } - bb16: { - _12 = move _2; - _11 = move _12; - goto -> bb15; + bb13: { + _12 = move _43; + _11 = copy (_12.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + goto -> bb12; } - bb17: { + bb14: { _13 = &mut (((*_42) as variant#4).4: impl std::future::Future); - _10 = Pin::<&mut impl Future>::new_unchecked(move _13) -> [return: bb16, unwind: bb10]; + _10 = Pin::<&mut impl Future>::new_unchecked(move _13) -> [return: bb13, unwind: bb7]; } - bb18: { - _2 = move _14; + bb15: { + _43 = move _14; StorageDead(_14); - goto -> bb17; + goto -> bb14; } - bb19: { + bb16: { nop; - goto -> bb2; + goto -> bb1; } - bb20 (cleanup): { + bb17 (cleanup): { nop; - goto -> bb6; + goto -> bb3; } - bb21: { - _2 = move _24; + bb18: { + _43 = move _24; StorageDead(_24); - goto -> bb26; + goto -> bb23; } - bb22: { + bb19: { StorageLive(_24); _0 = Poll::<()>::Pending; StorageDead(_24); @@ -176,79 +168,79 @@ fn double::{closure#0}(_1: Pin<&mut {async fn body of double()}>, _2: &mut Conte return; } - bb23: { + bb20: { _26 = discriminant(_25); - switchInt(move _26) -> [0: bb19, 1: bb22, otherwise: bb13]; + switchInt(move _26) -> [0: bb16, 1: bb19, otherwise: bb10]; } - bb24: { - _25 = as Future>::poll(move _27, move _28) -> [return: bb23, unwind: bb20]; + bb21: { + _25 = as Future>::poll(move _27, move _28) -> [return: bb20, unwind: bb17]; } - bb25: { - _29 = move _2; - _28 = move _29; - goto -> bb24; + bb22: { + _29 = move _43; + _28 = copy (_29.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + goto -> bb21; } - bb26: { + bb23: { _30 = &mut (((*_42) as variant#6).3: impl std::future::Future); - _27 = Pin::<&mut impl Future>::new_unchecked(move _30) -> [return: bb25, unwind: bb20]; + _27 = Pin::<&mut impl Future>::new_unchecked(move _30) -> [return: bb22, unwind: bb17]; } - bb27: { - _2 = move _31; + bb24: { + _43 = move _31; StorageDead(_31); - goto -> bb26; + goto -> bb23; } - bb28: { + bb25: { _0 = Poll::<()>::Ready(const ()); return; } - bb29: { - goto -> bb30; + bb26: { + goto -> bb27; } - bb30: { - goto -> bb28; + bb27: { + goto -> bb25; } - bb31 (cleanup): { + bb28 (cleanup): { discriminant((*_42)) = 2; resume; } - bb32: { + bb29: { StorageLive(_7); - _7 = move _2; - goto -> bb11; + _7 = move _43; + goto -> bb8; } - bb33: { + bb30: { StorageLive(_14); - _14 = move _2; - goto -> bb18; + _14 = move _43; + goto -> bb15; } - bb34: { + bb31: { StorageLive(_24); - _24 = move _2; - goto -> bb21; + _24 = move _43; + goto -> bb18; } - bb35: { + bb32: { StorageLive(_31); - _31 = move _2; - goto -> bb27; + _31 = move _43; + goto -> bb24; } - bb36: { - assert(const false, "`async fn` resumed after panicking") -> [success: bb36, unwind continue]; + bb33: { + assert(const false, "`async fn` resumed after panicking") -> [success: bb33, unwind continue]; } - bb37: { + bb34: { _0 = Poll::<()>::Ready(const ()); return; } diff --git a/tests/mir-opt/coroutine/async_drop.elaborate_drops-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.elaborate_drops-{closure#0}.StateTransform.diff index b0e6100e78fe0..7907e539dd69c 100644 --- a/tests/mir-opt/coroutine/async_drop.elaborate_drops-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.elaborate_drops-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn elaborate_drops::{closure#0}(_1: {async fn body of elaborate_drops()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn elaborate_drops::{closure#0}(_1: Pin<&mut {async fn body of elaborate_drops()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: (); @@ -51,8 +53,7 @@ + } + storage_conflicts = BitMatrix(20x20) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s0, _s4), (_s0, _s5), (_s0, _s6), (_s0, _s7), (_s0, _s8), (_s0, _s9), (_s0, _s10), (_s0, _s11), (_s0, _s12), (_s0, _s13), (_s0, _s14), (_s0, _s15), (_s0, _s16), (_s0, _s17), (_s0, _s18), (_s0, _s19), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s1, _s4), (_s1, _s5), (_s1, _s6), (_s1, _s7), (_s1, _s8), (_s1, _s9), (_s1, _s10), (_s1, _s11), (_s1, _s12), (_s1, _s13), (_s1, _s14), (_s1, _s15), (_s1, _s16), (_s1, _s17), (_s1, _s18), (_s1, _s19), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s2, _s4), (_s2, _s5), (_s2, _s6), (_s2, _s7), (_s2, _s8), (_s2, _s9), (_s2, _s10), (_s2, _s11), (_s2, _s12), (_s2, _s13), (_s2, _s14), (_s2, _s15), (_s2, _s16), (_s2, _s17), (_s2, _s18), (_s2, _s19), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3), (_s3, _s4), (_s3, _s5), (_s3, _s6), (_s3, _s7), (_s3, _s8), (_s3, _s9), (_s3, _s10), (_s3, _s11), (_s3, _s12), (_s3, _s13), (_s3, _s14), (_s3, _s15), (_s3, _s16), (_s3, _s17), (_s3, _s18), (_s4, _s0), (_s4, _s1), (_s4, _s2), (_s4, _s3), (_s4, _s4), (_s4, _s5), (_s4, _s6), (_s4, _s7), (_s4, _s8), (_s4, _s9), (_s4, _s10), (_s4, _s11), (_s4, _s12), (_s4, _s13), (_s4, _s14), (_s4, _s15), (_s4, _s16), (_s4, _s17), (_s5, _s0), (_s5, _s1), (_s5, _s2), (_s5, _s3), (_s5, _s4), (_s5, _s5), (_s5, _s6), (_s5, _s7), (_s5, _s8), (_s5, _s9), (_s5, _s10), (_s5, _s11), (_s5, _s12), (_s5, _s13), (_s5, _s14), (_s5, _s15), (_s5, _s16), (_s6, _s0), (_s6, _s1), (_s6, _s2), (_s6, _s3), (_s6, _s4), (_s6, _s5), (_s6, _s6), (_s6, _s7), (_s6, _s8), (_s6, _s9), (_s6, _s10), (_s6, _s11), (_s6, _s12), (_s6, _s13), (_s6, _s14), (_s6, _s15), (_s7, _s0), (_s7, _s1), (_s7, _s2), (_s7, _s3), (_s7, _s4), (_s7, _s5), (_s7, _s6), (_s7, _s7), (_s7, _s8), (_s7, _s9), (_s7, _s10), (_s7, _s11), (_s7, _s12), (_s7, _s13), (_s7, _s14), (_s8, _s0), (_s8, _s1), (_s8, _s2), (_s8, _s3), (_s8, _s4), (_s8, _s5), (_s8, _s6), (_s8, _s7), (_s8, _s8), (_s8, _s9), (_s8, _s10), (_s8, _s11), (_s8, _s12), (_s8, _s13), (_s9, _s0), (_s9, _s1), (_s9, _s2), (_s9, _s3), (_s9, _s4), (_s9, _s5), (_s9, _s6), (_s9, _s7), (_s9, _s8), (_s9, _s9), (_s9, _s10), (_s9, _s11), (_s9, _s12), (_s10, _s0), (_s10, _s1), (_s10, _s2), (_s10, _s3), (_s10, _s4), (_s10, _s5), (_s10, _s6), (_s10, _s7), (_s10, _s8), (_s10, _s9), (_s10, _s10), (_s10, _s11), (_s11, _s0), (_s11, _s1), (_s11, _s2), (_s11, _s3), (_s11, _s4), (_s11, _s5), (_s11, _s6), (_s11, _s7), (_s11, _s8), (_s11, _s9), (_s11, _s10), (_s11, _s11), (_s12, _s0), (_s12, _s1), (_s12, _s2), (_s12, _s3), (_s12, _s4), (_s12, _s5), (_s12, _s6), (_s12, _s7), (_s12, _s8), (_s12, _s9), (_s12, _s12), (_s13, _s0), (_s13, _s1), (_s13, _s2), (_s13, _s3), (_s13, _s4), (_s13, _s5), (_s13, _s6), (_s13, _s7), (_s13, _s8), (_s13, _s13), (_s14, _s0), (_s14, _s1), (_s14, _s2), (_s14, _s3), (_s14, _s4), (_s14, _s5), (_s14, _s6), (_s14, _s7), (_s14, _s14), (_s15, _s0), (_s15, _s1), (_s15, _s2), (_s15, _s3), (_s15, _s4), (_s15, _s5), (_s15, _s6), (_s15, _s15), (_s16, _s0), (_s16, _s1), (_s16, _s2), (_s16, _s3), (_s16, _s4), (_s16, _s5), (_s16, _s16), (_s17, _s0), (_s17, _s1), (_s17, _s2), (_s17, _s3), (_s17, _s4), (_s17, _s17), (_s18, _s0), (_s18, _s1), (_s18, _s2), (_s18, _s3), (_s18, _s18), (_s19, _s0), (_s19, _s1), (_s19, _s2), (_s19, _s19)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _183; + coroutine debug sync_int => _s1; + let mut _0: std::task::Poll<()>; let _3: SyncInt; @@ -68,197 +69,163 @@ let mut _21: &AsyncInt; let _22: &AsyncInt; let mut _27: impl std::future::Future; -- let mut _28: std::future::ResumeTy; -+ let mut _28: &mut std::task::Context<'_>; + let mut _28: std::future::ResumeTy; let mut _29: std::task::Poll<()>; let mut _30: isize; let mut _31: std::pin::Pin<&mut impl std::future::Future>; let mut _32: &mut std::task::Context<'_>; -- let mut _33: std::future::ResumeTy; -+ let mut _33: &mut std::task::Context<'_>; + let mut _33: std::future::ResumeTy; let mut _34: &mut impl std::future::Future; -- let mut _35: std::future::ResumeTy; -+ let mut _35: &mut std::task::Context<'_>; + let mut _35: std::future::ResumeTy; let mut _36: std::task::Poll<()>; let mut _37: isize; let mut _38: std::pin::Pin<&mut impl std::future::Future>; let mut _39: &mut std::task::Context<'_>; -- let mut _40: std::future::ResumeTy; -+ let mut _40: &mut std::task::Context<'_>; + let mut _40: std::future::ResumeTy; let mut _41: &mut impl std::future::Future; let mut _42: std::pin::Pin<&mut {async closure@$DIR/async_drop.rs:78:27: 78:35}>; let mut _43: &mut {async closure@$DIR/async_drop.rs:78:27: 78:35}; let mut _44: impl std::future::Future; -- let mut _45: std::future::ResumeTy; -+ let mut _45: &mut std::task::Context<'_>; + let mut _45: std::future::ResumeTy; let mut _46: std::task::Poll<()>; let mut _47: isize; let mut _48: std::pin::Pin<&mut impl std::future::Future>; let mut _49: &mut std::task::Context<'_>; -- let mut _50: std::future::ResumeTy; -+ let mut _50: &mut std::task::Context<'_>; + let mut _50: std::future::ResumeTy; let mut _51: &mut impl std::future::Future; -- let mut _52: std::future::ResumeTy; -+ let mut _52: &mut std::task::Context<'_>; + let mut _52: std::future::ResumeTy; let mut _53: std::task::Poll<()>; let mut _54: isize; let mut _55: std::pin::Pin<&mut impl std::future::Future>; let mut _56: &mut std::task::Context<'_>; -- let mut _57: std::future::ResumeTy; -+ let mut _57: &mut std::task::Context<'_>; + let mut _57: std::future::ResumeTy; let mut _58: &mut impl std::future::Future; let mut _59: std::pin::Pin<&mut {closure@$DIR/async_drop.rs:70:25: 70:27}>; let mut _60: &mut {closure@$DIR/async_drop.rs:70:25: 70:27}; let mut _61: impl std::future::Future; -- let mut _62: std::future::ResumeTy; -+ let mut _62: &mut std::task::Context<'_>; + let mut _62: std::future::ResumeTy; let mut _63: std::task::Poll<()>; let mut _64: isize; let mut _65: std::pin::Pin<&mut impl std::future::Future>; let mut _66: &mut std::task::Context<'_>; -- let mut _67: std::future::ResumeTy; -+ let mut _67: &mut std::task::Context<'_>; + let mut _67: std::future::ResumeTy; let mut _68: &mut impl std::future::Future; -- let mut _69: std::future::ResumeTy; -+ let mut _69: &mut std::task::Context<'_>; + let mut _69: std::future::ResumeTy; let mut _70: std::task::Poll<()>; let mut _71: isize; let mut _72: std::pin::Pin<&mut impl std::future::Future>; let mut _73: &mut std::task::Context<'_>; -- let mut _74: std::future::ResumeTy; -+ let mut _74: &mut std::task::Context<'_>; + let mut _74: std::future::ResumeTy; let mut _75: &mut impl std::future::Future; let mut _76: std::pin::Pin<&mut AsyncReference<'_>>; let mut _77: &mut AsyncReference<'_>; let mut _78: impl std::future::Future; -- let mut _79: std::future::ResumeTy; -+ let mut _79: &mut std::task::Context<'_>; + let mut _79: std::future::ResumeTy; let mut _80: std::task::Poll<()>; let mut _81: isize; let mut _82: std::pin::Pin<&mut impl std::future::Future>; let mut _83: &mut std::task::Context<'_>; -- let mut _84: std::future::ResumeTy; -+ let mut _84: &mut std::task::Context<'_>; + let mut _84: std::future::ResumeTy; let mut _85: &mut impl std::future::Future; -- let mut _86: std::future::ResumeTy; -+ let mut _86: &mut std::task::Context<'_>; + let mut _86: std::future::ResumeTy; let mut _87: std::task::Poll<()>; let mut _88: isize; let mut _89: std::pin::Pin<&mut impl std::future::Future>; let mut _90: &mut std::task::Context<'_>; -- let mut _91: std::future::ResumeTy; -+ let mut _91: &mut std::task::Context<'_>; + let mut _91: std::future::ResumeTy; let mut _92: &mut impl std::future::Future; let mut _93: std::pin::Pin<&mut AsyncInt>; let mut _94: &mut AsyncInt; let mut _95: impl std::future::Future; -- let mut _96: std::future::ResumeTy; -+ let mut _96: &mut std::task::Context<'_>; + let mut _96: std::future::ResumeTy; let mut _97: std::task::Poll<()>; let mut _98: isize; let mut _99: std::pin::Pin<&mut impl std::future::Future>; let mut _100: &mut std::task::Context<'_>; -- let mut _101: std::future::ResumeTy; -+ let mut _101: &mut std::task::Context<'_>; + let mut _101: std::future::ResumeTy; let mut _102: &mut impl std::future::Future; -- let mut _103: std::future::ResumeTy; -+ let mut _103: &mut std::task::Context<'_>; + let mut _103: std::future::ResumeTy; let mut _104: std::task::Poll<()>; let mut _105: isize; let mut _106: std::pin::Pin<&mut impl std::future::Future>; let mut _107: &mut std::task::Context<'_>; -- let mut _108: std::future::ResumeTy; -+ let mut _108: &mut std::task::Context<'_>; + let mut _108: std::future::ResumeTy; let mut _109: &mut impl std::future::Future; let mut _110: std::pin::Pin<&mut AsyncEnum>; let mut _111: &mut AsyncEnum; let mut _112: impl std::future::Future; -- let mut _113: std::future::ResumeTy; -+ let mut _113: &mut std::task::Context<'_>; + let mut _113: std::future::ResumeTy; let mut _114: std::task::Poll<()>; let mut _115: isize; let mut _116: std::pin::Pin<&mut impl std::future::Future>; let mut _117: &mut std::task::Context<'_>; -- let mut _118: std::future::ResumeTy; -+ let mut _118: &mut std::task::Context<'_>; + let mut _118: std::future::ResumeTy; let mut _119: &mut impl std::future::Future; -- let mut _120: std::future::ResumeTy; -+ let mut _120: &mut std::task::Context<'_>; + let mut _120: std::future::ResumeTy; let mut _121: std::task::Poll<()>; let mut _122: isize; let mut _123: std::pin::Pin<&mut impl std::future::Future>; let mut _124: &mut std::task::Context<'_>; -- let mut _125: std::future::ResumeTy; -+ let mut _125: &mut std::task::Context<'_>; + let mut _125: std::future::ResumeTy; let mut _126: &mut impl std::future::Future; let mut _127: std::pin::Pin<&mut SyncThenAsync>; let mut _128: &mut SyncThenAsync; let mut _129: impl std::future::Future; -- let mut _130: std::future::ResumeTy; -+ let mut _130: &mut std::task::Context<'_>; + let mut _130: std::future::ResumeTy; let mut _131: std::task::Poll<()>; let mut _132: isize; let mut _133: std::pin::Pin<&mut impl std::future::Future>; let mut _134: &mut std::task::Context<'_>; -- let mut _135: std::future::ResumeTy; -+ let mut _135: &mut std::task::Context<'_>; + let mut _135: std::future::ResumeTy; let mut _136: &mut impl std::future::Future; -- let mut _137: std::future::ResumeTy; -+ let mut _137: &mut std::task::Context<'_>; + let mut _137: std::future::ResumeTy; let mut _138: std::task::Poll<()>; let mut _139: isize; let mut _140: std::pin::Pin<&mut impl std::future::Future>; let mut _141: &mut std::task::Context<'_>; -- let mut _142: std::future::ResumeTy; -+ let mut _142: &mut std::task::Context<'_>; + let mut _142: std::future::ResumeTy; let mut _143: &mut impl std::future::Future; let mut _144: std::pin::Pin<&mut AsyncStruct>; let mut _145: &mut AsyncStruct; let mut _146: impl std::future::Future; -- let mut _147: std::future::ResumeTy; -+ let mut _147: &mut std::task::Context<'_>; + let mut _147: std::future::ResumeTy; let mut _148: std::task::Poll<()>; let mut _149: isize; let mut _150: std::pin::Pin<&mut impl std::future::Future>; let mut _151: &mut std::task::Context<'_>; -- let mut _152: std::future::ResumeTy; -+ let mut _152: &mut std::task::Context<'_>; + let mut _152: std::future::ResumeTy; let mut _153: &mut impl std::future::Future; -- let mut _154: std::future::ResumeTy; -+ let mut _154: &mut std::task::Context<'_>; + let mut _154: std::future::ResumeTy; let mut _155: std::task::Poll<()>; let mut _156: isize; let mut _157: std::pin::Pin<&mut impl std::future::Future>; let mut _158: &mut std::task::Context<'_>; -- let mut _159: std::future::ResumeTy; -+ let mut _159: &mut std::task::Context<'_>; + let mut _159: std::future::ResumeTy; let mut _160: &mut impl std::future::Future; let mut _161: std::pin::Pin<&mut [AsyncInt; 2]>; let mut _162: &mut [AsyncInt; 2]; let mut _163: impl std::future::Future; -- let mut _164: std::future::ResumeTy; -+ let mut _164: &mut std::task::Context<'_>; + let mut _164: std::future::ResumeTy; let mut _165: std::task::Poll<()>; let mut _166: isize; let mut _167: std::pin::Pin<&mut impl std::future::Future>; let mut _168: &mut std::task::Context<'_>; -- let mut _169: std::future::ResumeTy; -+ let mut _169: &mut std::task::Context<'_>; + let mut _169: std::future::ResumeTy; let mut _170: &mut impl std::future::Future; -- let mut _171: std::future::ResumeTy; -+ let mut _171: &mut std::task::Context<'_>; + let mut _171: std::future::ResumeTy; let mut _172: std::task::Poll<()>; let mut _173: isize; let mut _174: std::pin::Pin<&mut impl std::future::Future>; let mut _175: &mut std::task::Context<'_>; -- let mut _176: std::future::ResumeTy; -+ let mut _176: &mut std::task::Context<'_>; + let mut _176: std::future::ResumeTy; let mut _177: &mut impl std::future::Future; let mut _178: std::pin::Pin<&mut AsyncInt>; let mut _179: &mut AsyncInt; + let mut _180: (); + let mut _181: u32; + let mut _182: &mut {async fn body of elaborate_drops()}; ++ let mut _183: std::future::ResumeTy; ++ let mut _184: std::ptr::NonNull>; scope 1 { - debug sync_int => _3; + debug sync_int => (((*_182) as variant#20).1: SyncInt); @@ -341,88 +308,49 @@ - StorageLive(_7); - _7 = AsyncInt(const 2_i32); - _5 = [move _6, move _7]; -- goto -> bb1; -+ _182 = copy (_1.0: &mut {async fn body of elaborate_drops()}); -+ _181 = discriminant((*_182)); -+ switchInt(move _181) -> [0: bb170, 1: bb169, 2: bb168, 3: bb150, 4: bb151, 5: bb152, 6: bb153, 7: bb154, 8: bb155, 9: bb156, 10: bb157, 11: bb158, 12: bb159, 13: bb160, 14: bb161, 15: bb162, 16: bb163, 17: bb164, 18: bb165, 19: bb166, 20: bb167, otherwise: bb43]; - } - - bb1: { - StorageDead(_7); - goto -> bb2; - } - - bb2: { - StorageDead(_6); +- StorageDead(_7); +- StorageDead(_6); - StorageLive(_8); -+ nop; - StorageLive(_9); - _9 = AsyncInt(const 5_i32); - StorageLive(_10); - _10 = AsyncInt(const 4_i32); +- StorageLive(_9); +- _9 = AsyncInt(const 5_i32); +- StorageLive(_10); +- _10 = AsyncInt(const 4_i32); - _8 = AsyncStruct { i: const 3_i32, a: move _10, b: move _9 }; -+ (((*_182) as variant#16).4: AsyncStruct) = AsyncStruct { i: const 3_i32, a: move _10, b: move _9 }; - goto -> bb3; - } - - bb3: { - StorageDead(_10); - goto -> bb4; - } - - bb4: { - StorageDead(_9); +- StorageDead(_10); +- StorageDead(_9); - StorageLive(_11); -+ nop; - StorageLive(_12); - _12 = AsyncInt(const 7_i32); - StorageLive(_13); - _13 = SyncInt(const 8_i32); - StorageLive(_14); - _14 = AsyncInt(const 9_i32); +- StorageLive(_12); +- _12 = AsyncInt(const 7_i32); +- StorageLive(_13); +- _13 = SyncInt(const 8_i32); +- StorageLive(_14); +- _14 = AsyncInt(const 9_i32); - _11 = SyncThenAsync { i: const 6_i32, a: move _12, b: move _13, c: move _14 }; -+ (((*_182) as variant#14).5: SyncThenAsync) = SyncThenAsync { i: const 6_i32, a: move _12, b: move _13, c: move _14 }; - goto -> bb5; - } - - bb5: { - StorageDead(_14); - goto -> bb6; - } - - bb6: { - StorageDead(_13); - goto -> bb7; - } - - bb7: { - StorageDead(_12); +- StorageDead(_14); +- StorageDead(_13); +- StorageDead(_12); - StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = AsyncInt(const 10_i32); +- StorageLive(_16); +- _16 = AsyncInt(const 10_i32); - _15 = AsyncEnum::A(move _16); -+ (((*_182) as variant#12).6: AsyncEnum) = AsyncEnum::A(move _16); - goto -> bb8; - } - - bb8: { - StorageDead(_16); - StorageLive(_17); - StorageLive(_18); - _18 = AsyncInt(const 11_i32); -- _17 = ManuallyDrop::::new(move _18) -> [return: bb9, unwind: bb42]; -+ _17 = ManuallyDrop::::new(move _18) -> [return: bb9, unwind: bb29]; +- StorageDead(_16); +- StorageLive(_17); +- StorageLive(_18); +- _18 = AsyncInt(const 11_i32); +- _17 = ManuallyDrop::::new(move _18) -> [return: bb1, unwind: bb16]; ++ _184 = move _2 as std::ptr::NonNull> (Transmute); ++ _183 = std::future::ResumeTy(move _184); ++ _182 = copy (_1.0: &mut {async fn body of elaborate_drops()}); ++ _181 = discriminant((*_182)); ++ switchInt(move _181) -> [0: bb98, 1: bb97, 2: bb96, 3: bb78, 4: bb79, 5: bb80, 6: bb81, 7: bb82, 8: bb83, 9: bb84, 10: bb85, 11: bb86, 12: bb87, 13: bb88, 14: bb89, 15: bb90, 16: bb91, 17: bb92, 18: bb93, 19: bb94, 20: bb95, otherwise: bb15]; } - bb9: { + bb1: { StorageDead(_18); - StorageLive(_19); - _19 = AsyncInt(const 12_i32); - StorageLive(_20); -+ nop; + (((*_182) as variant#10).7: AsyncInt) = AsyncInt(const 12_i32); -+ nop; StorageLive(_21); StorageLive(_22); - _22 = &_19; @@ -436,274 +364,130 @@ _23 = AsyncInt(const 14_i32); - StorageLive(_24); - _24 = {closure@$DIR/async_drop.rs:70:25: 70:27} { foo: move _23 }; -+ nop; + (((*_182) as variant#6).9: {closure@$DIR/async_drop.rs:70:25: 70:27}) = {closure@$DIR/async_drop.rs:70:25: 70:27} { foo: move _23 }; StorageLive(_25); _25 = AsyncInt(const 15_i32); - StorageLive(_26); - _26 = {closure@$DIR/async_drop.rs:78:27: 78:35} { foo: move _25 }; - _0 = const (); -- goto -> bb72; -+ nop; +- _43 = &mut _26; +- _42 = Pin::<&mut {async closure@$DIR/async_drop.rs:78:27: 78:35}>::new_unchecked(move _43) -> [return: bb44, unwind: bb12]; + (((*_182) as variant#4).10: {async closure@$DIR/async_drop.rs:78:27: 78:35}) = {closure@$DIR/async_drop.rs:78:27: 78:35} { foo: move _25 }; + (((*_182) as variant#20).0: ()) = const (); -+ goto -> bb51; - } - - bb10: { -- StorageDead(_26); -+ nop; - goto -> bb11; - } - - bb11: { - StorageDead(_25); -- goto -> bb92; -+ goto -> bb63; - } - - bb12: { -- StorageDead(_24); -+ nop; - goto -> bb13; - } - - bb13: { - StorageDead(_23); -- goto -> bb112; -+ goto -> bb75; - } - - bb14: { -- StorageDead(_20); -- goto -> bb132; -+ nop; -+ goto -> bb87; - } - - bb15: { -- StorageDead(_19); -+ nop; - StorageDead(_17); -- goto -> bb152; -+ goto -> bb99; - } - - bb16: { -- StorageDead(_15); -- goto -> bb172; -+ nop; -+ goto -> bb111; - } - - bb17: { -- StorageDead(_11); -- goto -> bb192; -+ nop; -+ goto -> bb123; - } - - bb18: { -- StorageDead(_8); -- goto -> bb212; -+ nop; -+ goto -> bb135; - } - - bb19: { -- StorageDead(_5); -- goto -> bb232; -+ nop; -+ goto -> bb147; - } - - bb20: { -- StorageDead(_4); -- drop(_3) -> [return: bb21, unwind: bb50]; -+ nop; -+ drop((((*_182) as variant#20).1: SyncInt)) -> [return: bb21, unwind: bb37]; ++ _43 = &mut (((*_182) as variant#4).10: {async closure@$DIR/async_drop.rs:78:27: 78:35}); ++ _42 = Pin::<&mut {async closure@$DIR/async_drop.rs:78:27: 78:35}>::new_unchecked(move _43) -> [return: bb20, unwind: bb3]; } - bb21: { + bb2: { - StorageDead(_3); -- drop(_1) -> [return: bb22, unwind: bb51]; -+ nop; -+ goto -> bb148; - } - - bb22: { +- drop(_1) -> [return: bb3, unwind: bb24]; + _0 = Poll::<()>::Ready(move (((*_182) as variant#20).0: ())); + discriminant((*_182)) = 1; - return; - } - -- bb23: { -- StorageDead(_26); -+ bb23 (cleanup): { -+ nop; - goto -> bb24; ++ return; } -- bb24: { -+ bb24 (cleanup): { - StorageDead(_25); -- goto -> bb25; -+ drop((((*_182) as variant#6).9: {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb25, unwind terminate(cleanup)]; +- bb3: { +- return; ++ bb3 (cleanup): { ++ StorageDead(_25); ++ drop((((*_182) as variant#6).9: {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb4, unwind terminate(cleanup)]; } -- bb25: { +- bb4: { - StorageDead(_24); -+ bb25 (cleanup): { -+ nop; - goto -> bb26; - } - -- bb26: { -+ bb26 (cleanup): { ++ bb4 (cleanup): { StorageDead(_23); -- goto -> bb27; -+ drop((((*_182) as variant#8).8: AsyncReference<'_>)) -> [return: bb27, unwind terminate(cleanup)]; +- goto -> bb5; ++ drop((((*_182) as variant#8).8: AsyncReference<'_>)) -> [return: bb5, unwind terminate(cleanup)]; } -- bb27: { +- bb5: { - StorageDead(_20); -- goto -> bb28; -+ bb27 (cleanup): { -+ nop; -+ drop((((*_182) as variant#10).7: AsyncInt)) -> [return: bb28, unwind terminate(cleanup)]; +- goto -> bb6; ++ bb5 (cleanup): { ++ drop((((*_182) as variant#10).7: AsyncInt)) -> [return: bb7, unwind terminate(cleanup)]; } -- bb28: { +- bb6: { - StorageDead(_19); - StorageDead(_17); -- goto -> bb29; -+ bb28 (cleanup): { -+ nop; -+ goto -> bb31; ++ bb6 (cleanup): { ++ StorageDead(_18); + goto -> bb7; } -- bb29: { +- bb7: { - StorageDead(_15); -+ bb29 (cleanup): { - goto -> bb30; +- goto -> bb8; ++ bb7 (cleanup): { ++ StorageDead(_17); ++ drop((((*_182) as variant#12).6: AsyncEnum)) -> [return: bb8, unwind terminate(cleanup)]; } -- bb30: { +- bb8: { - StorageDead(_11); -+ bb30 (cleanup): { -+ StorageDead(_18); - goto -> bb31; +- goto -> bb9; ++ bb8 (cleanup): { ++ drop((((*_182) as variant#14).5: SyncThenAsync)) -> [return: bb9, unwind terminate(cleanup)]; } -- bb31: { +- bb9: { - StorageDead(_8); -- goto -> bb32; -+ bb31 (cleanup): { -+ StorageDead(_17); -+ drop((((*_182) as variant#12).6: AsyncEnum)) -> [return: bb32, unwind terminate(cleanup)]; +- goto -> bb10; ++ bb9 (cleanup): { ++ drop((((*_182) as variant#16).4: AsyncStruct)) -> [return: bb10, unwind terminate(cleanup)]; } -- bb32: { +- bb10: { - StorageDead(_5); -- goto -> bb33; -+ bb32 (cleanup): { -+ nop; -+ drop((((*_182) as variant#14).5: SyncThenAsync)) -> [return: bb33, unwind terminate(cleanup)]; +- goto -> bb11; ++ bb10 (cleanup): { ++ drop((((*_182) as variant#18).3: [AsyncInt; 2])) -> [return: bb11, unwind terminate(cleanup)]; } -- bb33: { +- bb11: { - StorageDead(_4); -- goto -> bb34; -+ bb33 (cleanup): { -+ nop; -+ drop((((*_182) as variant#16).4: AsyncStruct)) -> [return: bb34, unwind terminate(cleanup)]; - } - -- bb34: { - StorageDead(_3); -- goto -> bb35; -+ bb34 (cleanup): { -+ nop; -+ drop((((*_182) as variant#18).3: [AsyncInt; 2])) -> [return: bb35, unwind terminate(cleanup)]; - } - -- bb35: { - coroutine_drop; -+ bb35 (cleanup): { -+ nop; -+ drop((((*_182) as variant#20).2: AsyncInt)) -> [return: bb36, unwind terminate(cleanup)]; ++ bb11 (cleanup): { ++ drop((((*_182) as variant#20).2: AsyncInt)) -> [return: bb12, unwind terminate(cleanup)]; } - bb36 (cleanup): { + bb12 (cleanup): { - StorageDead(_26); -- goto -> bb37; -+ nop; -+ drop((((*_182) as variant#20).1: SyncInt)) -> [return: bb37, unwind terminate(cleanup)]; - } - - bb37 (cleanup): { - StorageDead(_25); -- drop(_24) -> [return: bb38, unwind terminate(cleanup)]; -+ nop; -+ goto -> bb38; +- drop(_24) -> [return: bb13, unwind terminate(cleanup)]; ++ drop((((*_182) as variant#20).1: SyncInt)) -> [return: bb77, unwind terminate(cleanup)]; } - bb38 (cleanup): { +- bb13 (cleanup): { - StorageDead(_24); -- goto -> bb39; -+ goto -> bb149; - } - -- bb39 (cleanup): { - StorageDead(_23); -- drop(_20) -> [return: bb40, unwind terminate(cleanup)]; -+ bb39: { -+ nop; -+ goto -> bb10; +- drop(_20) -> [return: bb14, unwind terminate(cleanup)]; ++ bb13: { ++ StorageDead(_25); ++ _60 = &mut (((*_182) as variant#6).9: {closure@$DIR/async_drop.rs:70:25: 70:27}); ++ _59 = Pin::<&mut {closure@$DIR/async_drop.rs:70:25: 70:27}>::new_unchecked(move _60) -> [return: bb27, unwind: bb4]; } - bb40 (cleanup): { +- bb14 (cleanup): { - StorageDead(_20); -- drop(_19) -> [return: bb41, unwind terminate(cleanup)]; -+ nop; -+ goto -> bb23; +- drop(_19) -> [return: bb15, unwind terminate(cleanup)]; ++ bb14: { ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb14, unwind: bb3]; } -- bb41 (cleanup): { +- bb15 (cleanup): { - StorageDead(_19); -- goto -> bb44; -+ bb41: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb41, unwind: bb40]; - } - -- bb42 (cleanup): { -- goto -> bb43; -+ bb42: { -+ _2 = move _28; -+ StorageDead(_28); -+ goto -> bb41; - } - -- bb43 (cleanup): { -- StorageDead(_18); -- goto -> bb44; -+ bb43: { +- goto -> bb17; ++ bb15: { + unreachable; } -- bb44 (cleanup): { -- StorageDead(_17); -- drop(_15) -> [return: bb45, unwind terminate(cleanup)]; -+ bb44: { -+ _2 = move _35; -+ StorageDead(_35); -+ goto -> bb49; - } - -- bb45 (cleanup): { -- StorageDead(_15); -- drop(_11) -> [return: bb46, unwind terminate(cleanup)]; -+ bb45: { +- bb16 (cleanup): { +- StorageDead(_18); +- goto -> bb17; ++ bb16: { + StorageLive(_35); + _0 = Poll::<()>::Pending; + StorageDead(_17); @@ -714,1291 +498,1229 @@ + return; } -- bb46 (cleanup): { -- StorageDead(_11); -- drop(_8) -> [return: bb47, unwind terminate(cleanup)]; -+ bb46: { +- bb17 (cleanup): { +- StorageDead(_17); +- drop(_15) -> [return: bb18, unwind terminate(cleanup)]; ++ bb17: { + _37 = discriminant(_36); -+ switchInt(move _37) -> [0: bb39, 1: bb45, otherwise: bb43]; ++ switchInt(move _37) -> [0: bb13, 1: bb16, otherwise: bb15]; } -- bb47 (cleanup): { +- bb18 (cleanup): { +- StorageDead(_15); +- drop(_11) -> [return: bb19, unwind terminate(cleanup)]; ++ bb18: { ++ _40 = move _183; ++ _39 = copy (_40.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _36 = as Future>::poll(move _38, move _39) -> [return: bb17, unwind: bb3]; + } + +- bb19 (cleanup): { +- StorageDead(_11); +- drop(_8) -> [return: bb20, unwind terminate(cleanup)]; ++ bb19: { ++ _41 = &mut (((*_182) as variant#4).11: impl std::future::Future); ++ _38 = Pin::<&mut impl Future>::new_unchecked(move _41) -> [return: bb18, unwind: bb3]; + } + +- bb20 (cleanup): { - StorageDead(_8); -- drop(_5) -> [return: bb48, unwind terminate(cleanup)]; -+ bb47: { -+ _36 = as Future>::poll(move _38, move _39) -> [return: bb46, unwind: bb40]; +- drop(_5) -> [return: bb21, unwind terminate(cleanup)]; ++ bb20: { ++ (((*_182) as variant#4).11: impl std::future::Future) = async_drop_in_place::<{async closure@$DIR/async_drop.rs:78:27: 78:35}>(copy (_42.0: &mut {async closure@$DIR/async_drop.rs:78:27: 78:35})) -> [return: bb19, unwind: bb3]; } -- bb48 (cleanup): { +- bb21 (cleanup): { - StorageDead(_5); -- drop(_4) -> [return: bb49, unwind terminate(cleanup)]; -+ bb48: { -+ _40 = move _2; -+ _39 = move _40; -+ goto -> bb47; +- drop(_4) -> [return: bb22, unwind terminate(cleanup)]; ++ bb21: { ++ StorageDead(_23); ++ _77 = &mut (((*_182) as variant#8).8: AsyncReference<'_>); ++ _76 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _77) -> [return: bb34, unwind: bb5]; } -- bb49 (cleanup): { +- bb22 (cleanup): { - StorageDead(_4); -- drop(_3) -> [return: bb50, unwind terminate(cleanup)]; -+ bb49: { -+ _41 = &mut (((*_182) as variant#4).11: impl std::future::Future); -+ _38 = Pin::<&mut impl Future>::new_unchecked(move _41) -> [return: bb48, unwind: bb40]; +- drop(_3) -> [return: bb23, unwind terminate(cleanup)]; ++ bb22: { ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb22, unwind: bb4]; } -- bb50 (cleanup): { +- bb23 (cleanup): { - StorageDead(_3); -- drop(_1) -> [return: bb51, unwind terminate(cleanup)]; -+ bb50: { -+ nop; -+ (((*_182) as variant#4).11: impl std::future::Future) = async_drop_in_place::<{async closure@$DIR/async_drop.rs:78:27: 78:35}>(copy (_42.0: &mut {async closure@$DIR/async_drop.rs:78:27: 78:35})) -> [return: bb49, unwind: bb40]; +- drop(_1) -> [return: bb24, unwind terminate(cleanup)]; ++ bb23: { ++ StorageLive(_52); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_17); ++ StorageDead(_23); ++ StorageDead(_52); ++ discriminant((*_182)) = 6; ++ return; } -- bb51 (cleanup): { +- bb24 (cleanup): { - resume; -+ bb51: { -+ _43 = &mut (((*_182) as variant#4).10: {async closure@$DIR/async_drop.rs:78:27: 78:35}); -+ _42 = Pin::<&mut {async closure@$DIR/async_drop.rs:78:27: 78:35}>::new_unchecked(move _43) -> [return: bb50, unwind: bb23]; ++ bb24: { ++ _54 = discriminant(_53); ++ switchInt(move _54) -> [0: bb21, 1: bb23, otherwise: bb15]; } - bb52: { + bb25: { - StorageDead(_27); -- goto -> bb10; -+ nop; -+ goto -> bb12; +- StorageDead(_26); +- StorageDead(_25); +- _60 = &mut _24; +- _59 = Pin::<&mut {closure@$DIR/async_drop.rs:70:25: 70:27}>::new_unchecked(move _60) -> [return: bb63, unwind: bb13]; ++ _57 = move _183; ++ _56 = copy (_57.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _53 = as Future>::poll(move _55, move _56) -> [return: bb24, unwind: bb4]; } -- bb53: { + bb26: { - StorageDead(_27); -- goto -> bb23; -+ bb53 (cleanup): { -+ nop; -+ goto -> bb25; +- StorageDead(_26); +- StorageDead(_25); +- goto -> bb4; ++ _58 = &mut (((*_182) as variant#6).10: impl std::future::Future); ++ _55 = Pin::<&mut impl Future>::new_unchecked(move _58) -> [return: bb25, unwind: bb4]; } -- bb54 (cleanup): { +- bb27 (cleanup): { - StorageDead(_27); -- goto -> bb36; -+ bb54: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb54, unwind: bb53]; +- goto -> bb12; ++ bb27: { ++ (((*_182) as variant#6).10: impl std::future::Future) = async_drop_in_place::<{closure@$DIR/async_drop.rs:70:25: 70:27}>(copy (_59.0: &mut {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb26, unwind: bb4]; } - bb55: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb55, unwind: bb54]; -+ _2 = move _45; -+ StorageDead(_45); -+ goto -> bb54; + bb28: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb28, unwind: bb27]; ++ _94 = &mut (((*_182) as variant#10).7: AsyncInt); ++ _93 = Pin::<&mut AsyncInt>::new_unchecked(move _94) -> [return: bb41, unwind: bb7]; } - bb56: { + bb29: { - _2 = move _28; - StorageDead(_28); -- goto -> bb55; -+ _2 = move _52; -+ StorageDead(_52); -+ goto -> bb61; +- goto -> bb28; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb29, unwind: bb5]; } - bb57: { + bb30: { - _2 = move _28; - StorageDead(_28); -- goto -> bb63; -+ StorageLive(_52); +- goto -> bb36; ++ StorageLive(_69); + _0 = Poll::<()>::Pending; + StorageDead(_17); -+ StorageDead(_23); -+ StorageDead(_52); -+ discriminant((*_182)) = 6; ++ StorageDead(_69); ++ discriminant((*_182)) = 8; + return; } - bb58: { + bb31: { - StorageLive(_28); -- _28 = yield(const ()) -> [resume: bb56, drop: bb57]; -+ _54 = discriminant(_53); -+ switchInt(move _54) -> [0: bb52, 1: bb57, otherwise: bb43]; +- _28 = yield(const ()) -> [resume: bb29, drop: bb30]; ++ _71 = discriminant(_70); ++ switchInt(move _71) -> [0: bb28, 1: bb30, otherwise: bb15]; } - bb59: { + bb32: { - unreachable; -+ _53 = as Future>::poll(move _55, move _56) -> [return: bb58, unwind: bb53]; ++ _74 = move _183; ++ _73 = copy (_74.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _70 = as Future>::poll(move _72, move _73) -> [return: bb31, unwind: bb5]; } - bb60: { + bb33: { - _30 = discriminant(_29); -- switchInt(move _30) -> [0: bb53, 1: bb58, otherwise: bb59]; -+ _57 = move _2; -+ _56 = move _57; -+ goto -> bb59; +- switchInt(move _30) -> [0: bb26, 1: bb31, otherwise: bb32]; ++ _75 = &mut (((*_182) as variant#8).9: impl std::future::Future); ++ _72 = Pin::<&mut impl Future>::new_unchecked(move _75) -> [return: bb32, unwind: bb5]; } - bb61: { -- _29 = as Future>::poll(move _31, move _32) -> [return: bb60, unwind: bb54]; -+ _58 = &mut (((*_182) as variant#6).10: impl std::future::Future); -+ _55 = Pin::<&mut impl Future>::new_unchecked(move _58) -> [return: bb60, unwind: bb53]; + bb34: { +- _29 = as Future>::poll(move _31, move _32) -> [return: bb33, unwind: bb27]; ++ (((*_182) as variant#8).9: impl std::future::Future) = async_drop_in_place::>(copy (_76.0: &mut AsyncReference<'_>)) -> [return: bb33, unwind: bb5]; } - bb62: { + bb35: { - _33 = move _2; -- _32 = std::future::get_context::<'_, '_>(move _33) -> [return: bb61, unwind: bb54]; -+ nop; -+ (((*_182) as variant#6).10: impl std::future::Future) = async_drop_in_place::<{closure@$DIR/async_drop.rs:70:25: 70:27}>(copy (_59.0: &mut {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb61, unwind: bb53]; +- _32 = std::future::get_context::<'_, '_>(move _33) -> [return: bb34, unwind: bb27]; ++ StorageDead(_17); ++ _111 = &mut (((*_182) as variant#12).6: AsyncEnum); ++ _110 = Pin::<&mut AsyncEnum>::new_unchecked(move _111) -> [return: bb48, unwind: bb8]; } - bb63: { + bb36: { - _34 = &mut _27; -- _31 = Pin::<&mut impl Future>::new_unchecked(move _34) -> [return: bb62, unwind: bb54]; -+ _60 = &mut (((*_182) as variant#6).9: {closure@$DIR/async_drop.rs:70:25: 70:27}); -+ _59 = Pin::<&mut {closure@$DIR/async_drop.rs:70:25: 70:27}>::new_unchecked(move _60) -> [return: bb62, unwind: bb25]; +- _31 = Pin::<&mut impl Future>::new_unchecked(move _34) -> [return: bb35, unwind: bb27]; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb36, unwind: bb7]; } - bb64: { + bb37: { - _2 = move _35; - StorageDead(_35); -- goto -> bb70; -+ nop; -+ goto -> bb14; +- goto -> bb43; ++ StorageLive(_86); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_17); ++ StorageDead(_86); ++ discriminant((*_182)) = 10; ++ return; } -- bb65: { + bb38: { - _2 = move _35; - StorageDead(_35); -- goto -> bb63; -+ bb65 (cleanup): { -+ nop; -+ goto -> bb27; +- goto -> bb36; ++ _88 = discriminant(_87); ++ switchInt(move _88) -> [0: bb35, 1: bb37, otherwise: bb15]; } - bb66: { + bb39: { - StorageLive(_35); -- _35 = yield(const ()) -> [resume: bb64, drop: bb65]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb66, unwind: bb65]; +- _35 = yield(const ()) -> [resume: bb37, drop: bb38]; ++ _91 = move _183; ++ _90 = copy (_91.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _87 = as Future>::poll(move _89, move _90) -> [return: bb38, unwind: bb7]; } - bb67: { + bb40: { - _37 = discriminant(_36); -- switchInt(move _37) -> [0: bb52, 1: bb66, otherwise: bb59]; -+ _2 = move _62; -+ StorageDead(_62); -+ goto -> bb66; +- switchInt(move _37) -> [0: bb25, 1: bb39, otherwise: bb32]; ++ _92 = &mut (((*_182) as variant#10).8: impl std::future::Future); ++ _89 = Pin::<&mut impl Future>::new_unchecked(move _92) -> [return: bb39, unwind: bb7]; } - bb68: { -- _36 = as Future>::poll(move _38, move _39) -> [return: bb67, unwind: bb54]; -+ _2 = move _69; -+ StorageDead(_69); -+ goto -> bb73; + bb41: { +- _36 = as Future>::poll(move _38, move _39) -> [return: bb40, unwind: bb27]; ++ (((*_182) as variant#10).8: impl std::future::Future) = async_drop_in_place::(copy (_93.0: &mut AsyncInt)) -> [return: bb40, unwind: bb7]; } - bb69: { + bb42: { - _40 = move _2; -- _39 = std::future::get_context::<'_, '_>(move _40) -> [return: bb68, unwind: bb54]; -+ StorageLive(_69); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_17); -+ StorageDead(_69); -+ discriminant((*_182)) = 8; -+ return; +- _39 = std::future::get_context::<'_, '_>(move _40) -> [return: bb41, unwind: bb27]; ++ _128 = &mut (((*_182) as variant#14).5: SyncThenAsync); ++ _127 = Pin::<&mut SyncThenAsync>::new_unchecked(move _128) -> [return: bb55, unwind: bb9]; } - bb70: { + bb43: { - _41 = &mut _27; -- _38 = Pin::<&mut impl Future>::new_unchecked(move _41) -> [return: bb69, unwind: bb54]; -+ _71 = discriminant(_70); -+ switchInt(move _71) -> [0: bb64, 1: bb69, otherwise: bb43]; +- _38 = Pin::<&mut impl Future>::new_unchecked(move _41) -> [return: bb42, unwind: bb27]; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb43, unwind: bb8]; } - bb71: { + bb44: { - StorageLive(_27); -- _27 = async_drop_in_place::<{async closure@$DIR/async_drop.rs:78:27: 78:35}>(copy (_42.0: &mut {async closure@$DIR/async_drop.rs:78:27: 78:35})) -> [return: bb70, unwind: bb54]; -+ _70 = as Future>::poll(move _72, move _73) -> [return: bb70, unwind: bb65]; - } - - bb72: { -- _43 = &mut _26; -- _42 = Pin::<&mut {async closure@$DIR/async_drop.rs:78:27: 78:35}>::new_unchecked(move _43) -> [return: bb71, unwind: bb36]; -+ _74 = move _2; -+ _73 = move _74; -+ goto -> bb71; +- _27 = async_drop_in_place::<{async closure@$DIR/async_drop.rs:78:27: 78:35}>(copy (_42.0: &mut {async closure@$DIR/async_drop.rs:78:27: 78:35})) -> [return: bb43, unwind: bb27]; ++ StorageLive(_103); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_103); ++ discriminant((*_182)) = 12; ++ return; } - bb73: { + bb45: { - StorageDead(_44); -- goto -> bb12; -+ _75 = &mut (((*_182) as variant#8).9: impl std::future::Future); -+ _72 = Pin::<&mut impl Future>::new_unchecked(move _75) -> [return: bb72, unwind: bb65]; +- StorageDead(_24); +- StorageDead(_23); +- _77 = &mut _20; +- _76 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _77) -> [return: bb82, unwind: bb14]; ++ _105 = discriminant(_104); ++ switchInt(move _105) -> [0: bb42, 1: bb44, otherwise: bb15]; } - bb74: { + bb46: { - StorageDead(_44); -- goto -> bb25; -+ nop; -+ (((*_182) as variant#8).9: impl std::future::Future) = async_drop_in_place::>(copy (_76.0: &mut AsyncReference<'_>)) -> [return: bb73, unwind: bb65]; +- goto -> bb4; ++ _108 = move _183; ++ _107 = copy (_108.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _104 = as Future>::poll(move _106, move _107) -> [return: bb45, unwind: bb8]; } -- bb75 (cleanup): { +- bb47 (cleanup): { - StorageDead(_44); -- goto -> bb38; -+ bb75: { -+ _77 = &mut (((*_182) as variant#8).8: AsyncReference<'_>); -+ _76 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _77) -> [return: bb74, unwind: bb27]; +- goto -> bb13; ++ bb47: { ++ _109 = &mut (((*_182) as variant#12).7: impl std::future::Future); ++ _106 = Pin::<&mut impl Future>::new_unchecked(move _109) -> [return: bb46, unwind: bb8]; } - bb76: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb76, unwind: bb75]; -+ nop; -+ goto -> bb15; + bb48: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb48, unwind: bb47]; ++ (((*_182) as variant#12).7: impl std::future::Future) = async_drop_in_place::(copy (_110.0: &mut AsyncEnum)) -> [return: bb47, unwind: bb8]; } -- bb77: { + bb49: { - _2 = move _45; - StorageDead(_45); -- goto -> bb76; -+ bb77 (cleanup): { -+ nop; -+ goto -> bb28; +- goto -> bb48; ++ _145 = &mut (((*_182) as variant#16).4: AsyncStruct); ++ _144 = Pin::<&mut AsyncStruct>::new_unchecked(move _145) -> [return: bb62, unwind: bb10]; } - bb78: { + bb50: { - _2 = move _45; - StorageDead(_45); -- goto -> bb83; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb78, unwind: bb77]; +- goto -> bb55; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb50, unwind: bb9]; } - bb79: { + bb51: { - StorageLive(_45); -- _45 = yield(const ()) -> [resume: bb77, drop: bb78]; -+ _2 = move _79; -+ StorageDead(_79); -+ goto -> bb78; +- _45 = yield(const ()) -> [resume: bb49, drop: bb50]; ++ StorageLive(_120); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_120); ++ discriminant((*_182)) = 14; ++ return; } - bb80: { + bb52: { - _47 = discriminant(_46); -- switchInt(move _47) -> [0: bb74, 1: bb79, otherwise: bb59]; -+ _2 = move _86; -+ StorageDead(_86); -+ goto -> bb85; +- switchInt(move _47) -> [0: bb46, 1: bb51, otherwise: bb32]; ++ _122 = discriminant(_121); ++ switchInt(move _122) -> [0: bb49, 1: bb51, otherwise: bb15]; } - bb81: { -- _46 = as Future>::poll(move _48, move _49) -> [return: bb80, unwind: bb75]; -+ StorageLive(_86); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_17); -+ StorageDead(_86); -+ discriminant((*_182)) = 10; -+ return; + bb53: { +- _46 = as Future>::poll(move _48, move _49) -> [return: bb52, unwind: bb47]; ++ _125 = move _183; ++ _124 = copy (_125.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _121 = as Future>::poll(move _123, move _124) -> [return: bb52, unwind: bb9]; } - bb82: { + bb54: { - _50 = move _2; -- _49 = std::future::get_context::<'_, '_>(move _50) -> [return: bb81, unwind: bb75]; -+ _88 = discriminant(_87); -+ switchInt(move _88) -> [0: bb76, 1: bb81, otherwise: bb43]; +- _49 = std::future::get_context::<'_, '_>(move _50) -> [return: bb53, unwind: bb47]; ++ _126 = &mut (((*_182) as variant#14).6: impl std::future::Future); ++ _123 = Pin::<&mut impl Future>::new_unchecked(move _126) -> [return: bb53, unwind: bb9]; } - bb83: { + bb55: { - _51 = &mut _44; -- _48 = Pin::<&mut impl Future>::new_unchecked(move _51) -> [return: bb82, unwind: bb75]; -+ _87 = as Future>::poll(move _89, move _90) -> [return: bb82, unwind: bb77]; +- _48 = Pin::<&mut impl Future>::new_unchecked(move _51) -> [return: bb54, unwind: bb47]; ++ (((*_182) as variant#14).6: impl std::future::Future) = async_drop_in_place::(copy (_127.0: &mut SyncThenAsync)) -> [return: bb54, unwind: bb9]; } - bb84: { + bb56: { - _2 = move _52; - StorageDead(_52); -- goto -> bb90; -+ _91 = move _2; -+ _90 = move _91; -+ goto -> bb83; +- goto -> bb62; ++ _162 = &mut (((*_182) as variant#18).3: [AsyncInt; 2]); ++ _161 = Pin::<&mut [AsyncInt; 2]>::new_unchecked(move _162) -> [return: bb69, unwind: bb11]; } - bb85: { + bb57: { - _2 = move _52; - StorageDead(_52); -- goto -> bb83; -+ _92 = &mut (((*_182) as variant#10).8: impl std::future::Future); -+ _89 = Pin::<&mut impl Future>::new_unchecked(move _92) -> [return: bb84, unwind: bb77]; +- goto -> bb55; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb57, unwind: bb10]; } - bb86: { + bb58: { - StorageLive(_52); -- _52 = yield(const ()) -> [resume: bb84, drop: bb85]; -+ nop; -+ (((*_182) as variant#10).8: impl std::future::Future) = async_drop_in_place::(copy (_93.0: &mut AsyncInt)) -> [return: bb85, unwind: bb77]; +- _52 = yield(const ()) -> [resume: bb56, drop: bb57]; ++ StorageLive(_137); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_137); ++ discriminant((*_182)) = 16; ++ return; } - bb87: { + bb59: { - _54 = discriminant(_53); -- switchInt(move _54) -> [0: bb73, 1: bb86, otherwise: bb59]; -+ _94 = &mut (((*_182) as variant#10).7: AsyncInt); -+ _93 = Pin::<&mut AsyncInt>::new_unchecked(move _94) -> [return: bb86, unwind: bb28]; +- switchInt(move _54) -> [0: bb45, 1: bb58, otherwise: bb32]; ++ _139 = discriminant(_138); ++ switchInt(move _139) -> [0: bb56, 1: bb58, otherwise: bb15]; } - bb88: { -- _53 = as Future>::poll(move _55, move _56) -> [return: bb87, unwind: bb75]; -+ nop; -+ goto -> bb16; + bb60: { +- _53 = as Future>::poll(move _55, move _56) -> [return: bb59, unwind: bb47]; ++ _142 = move _183; ++ _141 = copy (_142.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _138 = as Future>::poll(move _140, move _141) -> [return: bb59, unwind: bb10]; } -- bb89: { + bb61: { - _57 = move _2; -- _56 = std::future::get_context::<'_, '_>(move _57) -> [return: bb88, unwind: bb75]; -+ bb89 (cleanup): { -+ nop; -+ goto -> bb32; +- _56 = std::future::get_context::<'_, '_>(move _57) -> [return: bb60, unwind: bb47]; ++ _143 = &mut (((*_182) as variant#16).5: impl std::future::Future); ++ _140 = Pin::<&mut impl Future>::new_unchecked(move _143) -> [return: bb60, unwind: bb10]; } - bb90: { + bb62: { - _58 = &mut _44; -- _55 = Pin::<&mut impl Future>::new_unchecked(move _58) -> [return: bb89, unwind: bb75]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb90, unwind: bb89]; +- _55 = Pin::<&mut impl Future>::new_unchecked(move _58) -> [return: bb61, unwind: bb47]; ++ (((*_182) as variant#16).5: impl std::future::Future) = async_drop_in_place::(copy (_144.0: &mut AsyncStruct)) -> [return: bb61, unwind: bb10]; } - bb91: { + bb63: { - StorageLive(_44); -- _44 = async_drop_in_place::<{closure@$DIR/async_drop.rs:70:25: 70:27}>(copy (_59.0: &mut {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb90, unwind: bb75]; -+ _2 = move _96; -+ StorageDead(_96); -+ goto -> bb90; +- _44 = async_drop_in_place::<{closure@$DIR/async_drop.rs:70:25: 70:27}>(copy (_59.0: &mut {closure@$DIR/async_drop.rs:70:25: 70:27})) -> [return: bb62, unwind: bb47]; ++ _179 = &mut (((*_182) as variant#20).2: AsyncInt); ++ _178 = Pin::<&mut AsyncInt>::new_unchecked(move _179) -> [return: bb76, unwind: bb12]; } - bb92: { -- _60 = &mut _24; -- _59 = Pin::<&mut {closure@$DIR/async_drop.rs:70:25: 70:27}>::new_unchecked(move _60) -> [return: bb91, unwind: bb38]; -+ _2 = move _103; -+ StorageDead(_103); -+ goto -> bb97; + bb64: { +- StorageDead(_61); +- StorageDead(_20); +- _94 = &mut _19; +- _93 = Pin::<&mut AsyncInt>::new_unchecked(move _94) -> [return: bb101, unwind: bb15]; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb64, unwind: bb11]; } - bb93: { + bb65: { - StorageDead(_61); -- goto -> bb14; -+ StorageLive(_103); +- goto -> bb5; ++ StorageLive(_154); + _0 = Poll::<()>::Pending; -+ StorageDead(_103); -+ discriminant((*_182)) = 12; ++ StorageDead(_154); ++ discriminant((*_182)) = 18; + return; } - bb94: { -- StorageDead(_61); -- goto -> bb27; -+ _105 = discriminant(_104); -+ switchInt(move _105) -> [0: bb88, 1: bb93, otherwise: bb43]; - } - -- bb95 (cleanup): { +- bb66 (cleanup): { - StorageDead(_61); -- goto -> bb40; -+ bb95: { -+ _104 = as Future>::poll(move _106, move _107) -> [return: bb94, unwind: bb89]; +- goto -> bb14; ++ bb66: { ++ _156 = discriminant(_155); ++ switchInt(move _156) -> [0: bb63, 1: bb65, otherwise: bb15]; } - bb96: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb96, unwind: bb95]; -+ _108 = move _2; -+ _107 = move _108; -+ goto -> bb95; + bb67: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb67, unwind: bb66]; ++ _159 = move _183; ++ _158 = copy (_159.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _155 = as Future>::poll(move _157, move _158) -> [return: bb66, unwind: bb11]; } - bb97: { + bb68: { - _2 = move _62; - StorageDead(_62); -- goto -> bb96; -+ _109 = &mut (((*_182) as variant#12).7: impl std::future::Future); -+ _106 = Pin::<&mut impl Future>::new_unchecked(move _109) -> [return: bb96, unwind: bb89]; +- goto -> bb67; ++ _160 = &mut (((*_182) as variant#18).4: impl std::future::Future); ++ _157 = Pin::<&mut impl Future>::new_unchecked(move _160) -> [return: bb67, unwind: bb11]; } - bb98: { + bb69: { - _2 = move _62; - StorageDead(_62); -- goto -> bb103; -+ nop; -+ (((*_182) as variant#12).7: impl std::future::Future) = async_drop_in_place::(copy (_110.0: &mut AsyncEnum)) -> [return: bb97, unwind: bb89]; +- goto -> bb74; ++ (((*_182) as variant#18).4: impl std::future::Future) = async_drop_in_place::<[AsyncInt; 2]>(copy (_161.0: &mut [AsyncInt; 2])) -> [return: bb68, unwind: bb11]; } - bb99: { + bb70: { - StorageLive(_62); -- _62 = yield(const ()) -> [resume: bb97, drop: bb98]; -+ _111 = &mut (((*_182) as variant#12).6: AsyncEnum); -+ _110 = Pin::<&mut AsyncEnum>::new_unchecked(move _111) -> [return: bb98, unwind: bb32]; +- _62 = yield(const ()) -> [resume: bb68, drop: bb69]; ++ drop((((*_182) as variant#20).1: SyncInt)) -> [return: bb2, unwind: bb77]; } - bb100: { + bb71: { - _64 = discriminant(_63); -- switchInt(move _64) -> [0: bb94, 1: bb99, otherwise: bb59]; -+ nop; -+ goto -> bb17; +- switchInt(move _64) -> [0: bb65, 1: bb70, otherwise: bb32]; ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb71, unwind: bb12]; } -- bb101: { -- _63 = as Future>::poll(move _65, move _66) -> [return: bb100, unwind: bb95]; -+ bb101 (cleanup): { -+ nop; -+ goto -> bb33; + bb72: { +- _63 = as Future>::poll(move _65, move _66) -> [return: bb71, unwind: bb66]; ++ StorageLive(_171); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_171); ++ discriminant((*_182)) = 20; ++ return; } - bb102: { + bb73: { - _67 = move _2; -- _66 = std::future::get_context::<'_, '_>(move _67) -> [return: bb101, unwind: bb95]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb102, unwind: bb101]; +- _66 = std::future::get_context::<'_, '_>(move _67) -> [return: bb72, unwind: bb66]; ++ _173 = discriminant(_172); ++ switchInt(move _173) -> [0: bb70, 1: bb72, otherwise: bb15]; } - bb103: { + bb74: { - _68 = &mut _61; -- _65 = Pin::<&mut impl Future>::new_unchecked(move _68) -> [return: bb102, unwind: bb95]; -+ _2 = move _113; -+ StorageDead(_113); -+ goto -> bb102; +- _65 = Pin::<&mut impl Future>::new_unchecked(move _68) -> [return: bb73, unwind: bb66]; ++ _176 = move _183; ++ _175 = copy (_176.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _172 = as Future>::poll(move _174, move _175) -> [return: bb73, unwind: bb12]; } - bb104: { + bb75: { - _2 = move _69; - StorageDead(_69); -- goto -> bb110; -+ _2 = move _120; -+ StorageDead(_120); -+ goto -> bb109; +- goto -> bb81; ++ _177 = &mut (((*_182) as variant#20).3: impl std::future::Future); ++ _174 = Pin::<&mut impl Future>::new_unchecked(move _177) -> [return: bb74, unwind: bb12]; } - bb105: { + bb76: { - _2 = move _69; - StorageDead(_69); -- goto -> bb103; -+ StorageLive(_120); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_120); -+ discriminant((*_182)) = 14; -+ return; +- goto -> bb74; ++ (((*_182) as variant#20).3: impl std::future::Future) = async_drop_in_place::(copy (_178.0: &mut AsyncInt)) -> [return: bb75, unwind: bb12]; } - bb106: { +- bb77: { - StorageLive(_69); -- _69 = yield(const ()) -> [resume: bb104, drop: bb105]; -+ _122 = discriminant(_121); -+ switchInt(move _122) -> [0: bb100, 1: bb105, otherwise: bb43]; +- _69 = yield(const ()) -> [resume: bb75, drop: bb76]; ++ bb77 (cleanup): { ++ discriminant((*_182)) = 2; ++ resume; } - bb107: { + bb78: { - _71 = discriminant(_70); -- switchInt(move _71) -> [0: bb93, 1: bb106, otherwise: bb59]; -+ _121 = as Future>::poll(move _123, move _124) -> [return: bb106, unwind: bb101]; +- switchInt(move _71) -> [0: bb64, 1: bb77, otherwise: bb32]; ++ StorageLive(_17); ++ StorageLive(_23); ++ StorageLive(_25); ++ StorageLive(_28); ++ _28 = move _183; ++ _183 = move _28; ++ StorageDead(_28); ++ goto -> bb14; } - bb108: { -- _70 = as Future>::poll(move _72, move _73) -> [return: bb107, unwind: bb95]; -+ _125 = move _2; -+ _124 = move _125; -+ goto -> bb107; + bb79: { +- _70 = as Future>::poll(move _72, move _73) -> [return: bb78, unwind: bb66]; ++ StorageLive(_17); ++ StorageLive(_23); ++ StorageLive(_25); ++ StorageLive(_35); ++ _35 = move _183; ++ _183 = move _35; ++ StorageDead(_35); ++ goto -> bb19; } - bb109: { + bb80: { - _74 = move _2; -- _73 = std::future::get_context::<'_, '_>(move _74) -> [return: bb108, unwind: bb95]; -+ _126 = &mut (((*_182) as variant#14).6: impl std::future::Future); -+ _123 = Pin::<&mut impl Future>::new_unchecked(move _126) -> [return: bb108, unwind: bb101]; +- _73 = std::future::get_context::<'_, '_>(move _74) -> [return: bb79, unwind: bb66]; ++ StorageLive(_17); ++ StorageLive(_23); ++ StorageLive(_45); ++ _45 = move _183; ++ _183 = move _45; ++ StorageDead(_45); ++ goto -> bb22; } - bb110: { + bb81: { - _75 = &mut _61; -- _72 = Pin::<&mut impl Future>::new_unchecked(move _75) -> [return: bb109, unwind: bb95]; -+ nop; -+ (((*_182) as variant#14).6: impl std::future::Future) = async_drop_in_place::(copy (_127.0: &mut SyncThenAsync)) -> [return: bb109, unwind: bb101]; +- _72 = Pin::<&mut impl Future>::new_unchecked(move _75) -> [return: bb80, unwind: bb66]; ++ StorageLive(_17); ++ StorageLive(_23); ++ StorageLive(_52); ++ _52 = move _183; ++ _183 = move _52; ++ StorageDead(_52); ++ goto -> bb26; } - bb111: { + bb82: { - StorageLive(_61); -- _61 = async_drop_in_place::>(copy (_76.0: &mut AsyncReference<'_>)) -> [return: bb110, unwind: bb95]; -+ _128 = &mut (((*_182) as variant#14).5: SyncThenAsync); -+ _127 = Pin::<&mut SyncThenAsync>::new_unchecked(move _128) -> [return: bb110, unwind: bb33]; - } - - bb112: { -- _77 = &mut _20; -- _76 = Pin::<&mut AsyncReference<'_>>::new_unchecked(move _77) -> [return: bb111, unwind: bb40]; -+ nop; -+ goto -> bb18; +- _61 = async_drop_in_place::>(copy (_76.0: &mut AsyncReference<'_>)) -> [return: bb81, unwind: bb66]; ++ StorageLive(_17); ++ StorageLive(_62); ++ _62 = move _183; ++ _183 = move _62; ++ StorageDead(_62); ++ goto -> bb29; } -- bb113: { + bb83: { - StorageDead(_78); -- goto -> bb15; -+ bb113 (cleanup): { -+ nop; -+ goto -> bb34; +- StorageDead(_19); +- StorageDead(_17); +- _111 = &mut _15; +- _110 = Pin::<&mut AsyncEnum>::new_unchecked(move _111) -> [return: bb120, unwind: bb18]; ++ StorageLive(_17); ++ StorageLive(_69); ++ _69 = move _183; ++ _183 = move _69; ++ StorageDead(_69); ++ goto -> bb33; } - bb114: { + bb84: { - StorageDead(_78); -- goto -> bb28; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb114, unwind: bb113]; +- goto -> bb6; ++ StorageLive(_17); ++ StorageLive(_79); ++ _79 = move _183; ++ _183 = move _79; ++ StorageDead(_79); ++ goto -> bb36; } -- bb115 (cleanup): { +- bb85 (cleanup): { - StorageDead(_78); -- goto -> bb41; -+ bb115: { -+ _2 = move _130; -+ StorageDead(_130); -+ goto -> bb114; +- goto -> bb15; ++ bb85: { ++ StorageLive(_17); ++ StorageLive(_86); ++ _86 = move _183; ++ _183 = move _86; ++ StorageDead(_86); ++ goto -> bb40; } - bb116: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb116, unwind: bb115]; -+ _2 = move _137; -+ StorageDead(_137); -+ goto -> bb121; + bb86: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb86, unwind: bb85]; ++ StorageLive(_96); ++ _96 = move _183; ++ _183 = move _96; ++ StorageDead(_96); ++ goto -> bb43; } - bb117: { + bb87: { - _2 = move _79; - StorageDead(_79); -- goto -> bb116; -+ StorageLive(_137); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_137); -+ discriminant((*_182)) = 16; -+ return; +- goto -> bb86; ++ StorageLive(_103); ++ _103 = move _183; ++ _183 = move _103; ++ StorageDead(_103); ++ goto -> bb47; } - bb118: { + bb88: { - _2 = move _79; - StorageDead(_79); -- goto -> bb123; -+ _139 = discriminant(_138); -+ switchInt(move _139) -> [0: bb112, 1: bb117, otherwise: bb43]; +- goto -> bb93; ++ StorageLive(_113); ++ _113 = move _183; ++ _183 = move _113; ++ StorageDead(_113); ++ goto -> bb50; } - bb119: { + bb89: { - StorageLive(_79); -- _79 = yield(const ()) -> [resume: bb117, drop: bb118]; -+ _138 = as Future>::poll(move _140, move _141) -> [return: bb118, unwind: bb113]; +- _79 = yield(const ()) -> [resume: bb87, drop: bb88]; ++ StorageLive(_120); ++ _120 = move _183; ++ _183 = move _120; ++ StorageDead(_120); ++ goto -> bb54; } - bb120: { + bb90: { - _81 = discriminant(_80); -- switchInt(move _81) -> [0: bb114, 1: bb119, otherwise: bb59]; -+ _142 = move _2; -+ _141 = move _142; -+ goto -> bb119; +- switchInt(move _81) -> [0: bb84, 1: bb89, otherwise: bb32]; ++ StorageLive(_130); ++ _130 = move _183; ++ _183 = move _130; ++ StorageDead(_130); ++ goto -> bb57; } - bb121: { -- _80 = as Future>::poll(move _82, move _83) -> [return: bb120, unwind: bb115]; -+ _143 = &mut (((*_182) as variant#16).5: impl std::future::Future); -+ _140 = Pin::<&mut impl Future>::new_unchecked(move _143) -> [return: bb120, unwind: bb113]; + bb91: { +- _80 = as Future>::poll(move _82, move _83) -> [return: bb90, unwind: bb85]; ++ StorageLive(_137); ++ _137 = move _183; ++ _183 = move _137; ++ StorageDead(_137); ++ goto -> bb61; } - bb122: { + bb92: { - _84 = move _2; -- _83 = std::future::get_context::<'_, '_>(move _84) -> [return: bb121, unwind: bb115]; -+ nop; -+ (((*_182) as variant#16).5: impl std::future::Future) = async_drop_in_place::(copy (_144.0: &mut AsyncStruct)) -> [return: bb121, unwind: bb113]; +- _83 = std::future::get_context::<'_, '_>(move _84) -> [return: bb91, unwind: bb85]; ++ StorageLive(_147); ++ _147 = move _183; ++ _183 = move _147; ++ StorageDead(_147); ++ goto -> bb64; } - bb123: { + bb93: { - _85 = &mut _78; -- _82 = Pin::<&mut impl Future>::new_unchecked(move _85) -> [return: bb122, unwind: bb115]; -+ _145 = &mut (((*_182) as variant#16).4: AsyncStruct); -+ _144 = Pin::<&mut AsyncStruct>::new_unchecked(move _145) -> [return: bb122, unwind: bb34]; +- _82 = Pin::<&mut impl Future>::new_unchecked(move _85) -> [return: bb92, unwind: bb85]; ++ StorageLive(_154); ++ _154 = move _183; ++ _183 = move _154; ++ StorageDead(_154); ++ goto -> bb68; } - bb124: { + bb94: { - _2 = move _86; - StorageDead(_86); -- goto -> bb130; -+ nop; -+ goto -> bb19; +- goto -> bb100; ++ StorageLive(_164); ++ _164 = move _183; ++ _183 = move _164; ++ StorageDead(_164); ++ goto -> bb71; } -- bb125: { + bb95: { - _2 = move _86; - StorageDead(_86); -- goto -> bb123; -+ bb125 (cleanup): { -+ nop; -+ goto -> bb35; +- goto -> bb93; ++ StorageLive(_171); ++ _171 = move _183; ++ _183 = move _171; ++ StorageDead(_171); ++ goto -> bb75; } - bb126: { + bb96: { - StorageLive(_86); -- _86 = yield(const ()) -> [resume: bb124, drop: bb125]; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb126, unwind: bb125]; +- _86 = yield(const ()) -> [resume: bb94, drop: bb95]; ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb96, unwind continue]; } - bb127: { + bb97: { - _88 = discriminant(_87); -- switchInt(move _88) -> [0: bb113, 1: bb126, otherwise: bb59]; -+ _2 = move _147; -+ StorageDead(_147); -+ goto -> bb126; - } - - bb128: { -- _87 = as Future>::poll(move _89, move _90) -> [return: bb127, unwind: bb115]; -+ _2 = move _154; -+ StorageDead(_154); -+ goto -> bb133; +- switchInt(move _88) -> [0: bb83, 1: bb96, otherwise: bb32]; ++ assert(const false, "`async fn` resumed after completion") -> [success: bb97, unwind continue]; } - bb129: { + bb98: { +- _87 = as Future>::poll(move _89, move _90) -> [return: bb97, unwind: bb85]; +- } +- +- bb99: { - _91 = move _2; -- _90 = std::future::get_context::<'_, '_>(move _91) -> [return: bb128, unwind: bb115]; -+ StorageLive(_154); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_154); -+ discriminant((*_182)) = 18; -+ return; - } - - bb130: { +- _90 = std::future::get_context::<'_, '_>(move _91) -> [return: bb98, unwind: bb85]; +- } +- +- bb100: { - _92 = &mut _78; -- _89 = Pin::<&mut impl Future>::new_unchecked(move _92) -> [return: bb129, unwind: bb115]; -+ _156 = discriminant(_155); -+ switchInt(move _156) -> [0: bb124, 1: bb129, otherwise: bb43]; - } - - bb131: { +- _89 = Pin::<&mut impl Future>::new_unchecked(move _92) -> [return: bb99, unwind: bb85]; +- } +- +- bb101: { - StorageLive(_78); -- _78 = async_drop_in_place::(copy (_93.0: &mut AsyncInt)) -> [return: bb130, unwind: bb115]; -+ _155 = as Future>::poll(move _157, move _158) -> [return: bb130, unwind: bb125]; - } - - bb132: { -- _94 = &mut _19; -- _93 = Pin::<&mut AsyncInt>::new_unchecked(move _94) -> [return: bb131, unwind: bb41]; -+ _159 = move _2; -+ _158 = move _159; -+ goto -> bb131; - } - - bb133: { +- _78 = async_drop_in_place::(copy (_93.0: &mut AsyncInt)) -> [return: bb100, unwind: bb85]; +- } +- +- bb102: { - StorageDead(_95); -- goto -> bb16; -+ _160 = &mut (((*_182) as variant#18).4: impl std::future::Future); -+ _157 = Pin::<&mut impl Future>::new_unchecked(move _160) -> [return: bb132, unwind: bb125]; - } - - bb134: { +- StorageDead(_15); +- _128 = &mut _11; +- _127 = Pin::<&mut SyncThenAsync>::new_unchecked(move _128) -> [return: bb139, unwind: bb19]; +- } +- +- bb103: { - StorageDead(_95); -- goto -> bb29; -+ nop; -+ (((*_182) as variant#18).4: impl std::future::Future) = async_drop_in_place::<[AsyncInt; 2]>(copy (_161.0: &mut [AsyncInt; 2])) -> [return: bb133, unwind: bb125]; - } - -- bb135 (cleanup): { +- goto -> bb7; +- } +- +- bb104 (cleanup): { - StorageDead(_95); -- goto -> bb45; -+ bb135: { -+ _162 = &mut (((*_182) as variant#18).3: [AsyncInt; 2]); -+ _161 = Pin::<&mut [AsyncInt; 2]>::new_unchecked(move _162) -> [return: bb134, unwind: bb35]; - } - - bb136: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb136, unwind: bb135]; -+ nop; -+ goto -> bb20; - } - -- bb137: { +- goto -> bb18; +- } +- +- bb105: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb105, unwind: bb104]; +- } +- +- bb106: { - _2 = move _96; - StorageDead(_96); -- goto -> bb136; -+ bb137 (cleanup): { -+ nop; -+ goto -> bb36; - } - - bb138: { +- goto -> bb105; +- } +- +- bb107: { - _2 = move _96; - StorageDead(_96); -- goto -> bb143; -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb138, unwind: bb137]; - } - - bb139: { +- goto -> bb112; +- } +- +- bb108: { - StorageLive(_96); -- _96 = yield(const ()) -> [resume: bb137, drop: bb138]; -+ _2 = move _164; -+ StorageDead(_164); -+ goto -> bb138; - } - - bb140: { +- _96 = yield(const ()) -> [resume: bb106, drop: bb107]; +- } +- +- bb109: { - _98 = discriminant(_97); -- switchInt(move _98) -> [0: bb134, 1: bb139, otherwise: bb59]; -+ _2 = move _171; -+ StorageDead(_171); -+ goto -> bb145; - } - - bb141: { -- _97 = as Future>::poll(move _99, move _100) -> [return: bb140, unwind: bb135]; -+ StorageLive(_171); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_171); -+ discriminant((*_182)) = 20; -+ return; - } - - bb142: { +- switchInt(move _98) -> [0: bb103, 1: bb108, otherwise: bb32]; +- } +- +- bb110: { +- _97 = as Future>::poll(move _99, move _100) -> [return: bb109, unwind: bb104]; +- } +- +- bb111: { - _101 = move _2; -- _100 = std::future::get_context::<'_, '_>(move _101) -> [return: bb141, unwind: bb135]; -+ _173 = discriminant(_172); -+ switchInt(move _173) -> [0: bb136, 1: bb141, otherwise: bb43]; - } - - bb143: { +- _100 = std::future::get_context::<'_, '_>(move _101) -> [return: bb110, unwind: bb104]; +- } +- +- bb112: { - _102 = &mut _95; -- _99 = Pin::<&mut impl Future>::new_unchecked(move _102) -> [return: bb142, unwind: bb135]; -+ _172 = as Future>::poll(move _174, move _175) -> [return: bb142, unwind: bb137]; - } - - bb144: { +- _99 = Pin::<&mut impl Future>::new_unchecked(move _102) -> [return: bb111, unwind: bb104]; +- } +- +- bb113: { - _2 = move _103; - StorageDead(_103); -- goto -> bb150; -+ _176 = move _2; -+ _175 = move _176; -+ goto -> bb143; - } - - bb145: { +- goto -> bb119; +- } +- +- bb114: { - _2 = move _103; - StorageDead(_103); -- goto -> bb143; -+ _177 = &mut (((*_182) as variant#20).3: impl std::future::Future); -+ _174 = Pin::<&mut impl Future>::new_unchecked(move _177) -> [return: bb144, unwind: bb137]; - } - - bb146: { +- goto -> bb112; +- } +- +- bb115: { - StorageLive(_103); -- _103 = yield(const ()) -> [resume: bb144, drop: bb145]; -+ nop; -+ (((*_182) as variant#20).3: impl std::future::Future) = async_drop_in_place::(copy (_178.0: &mut AsyncInt)) -> [return: bb145, unwind: bb137]; - } - - bb147: { +- _103 = yield(const ()) -> [resume: bb113, drop: bb114]; +- } +- +- bb116: { - _105 = discriminant(_104); -- switchInt(move _105) -> [0: bb133, 1: bb146, otherwise: bb59]; -+ _179 = &mut (((*_182) as variant#20).2: AsyncInt); -+ _178 = Pin::<&mut AsyncInt>::new_unchecked(move _179) -> [return: bb146, unwind: bb36]; - } - - bb148: { -- _104 = as Future>::poll(move _106, move _107) -> [return: bb147, unwind: bb135]; -+ goto -> bb22; - } - -- bb149: { +- switchInt(move _105) -> [0: bb102, 1: bb115, otherwise: bb32]; +- } +- +- bb117: { +- _104 = as Future>::poll(move _106, move _107) -> [return: bb116, unwind: bb104]; +- } +- +- bb118: { - _108 = move _2; -- _107 = std::future::get_context::<'_, '_>(move _108) -> [return: bb148, unwind: bb135]; -+ bb149 (cleanup): { -+ discriminant((*_182)) = 2; -+ resume; - } - - bb150: { +- _107 = std::future::get_context::<'_, '_>(move _108) -> [return: bb117, unwind: bb104]; +- } +- +- bb119: { - _109 = &mut _95; -- _106 = Pin::<&mut impl Future>::new_unchecked(move _109) -> [return: bb149, unwind: bb135]; -+ StorageLive(_17); -+ StorageLive(_23); -+ StorageLive(_25); -+ StorageLive(_28); -+ _28 = move _2; -+ goto -> bb42; - } - - bb151: { +- _106 = Pin::<&mut impl Future>::new_unchecked(move _109) -> [return: bb118, unwind: bb104]; +- } +- +- bb120: { - StorageLive(_95); -- _95 = async_drop_in_place::(copy (_110.0: &mut AsyncEnum)) -> [return: bb150, unwind: bb135]; -+ StorageLive(_17); -+ StorageLive(_23); -+ StorageLive(_25); -+ StorageLive(_35); -+ _35 = move _2; -+ goto -> bb44; - } - - bb152: { -- _111 = &mut _15; -- _110 = Pin::<&mut AsyncEnum>::new_unchecked(move _111) -> [return: bb151, unwind: bb45]; -+ StorageLive(_17); -+ StorageLive(_23); -+ StorageLive(_45); -+ _45 = move _2; -+ goto -> bb55; - } - - bb153: { +- _95 = async_drop_in_place::(copy (_110.0: &mut AsyncEnum)) -> [return: bb119, unwind: bb104]; +- } +- +- bb121: { - StorageDead(_112); -- goto -> bb17; -+ StorageLive(_17); -+ StorageLive(_23); -+ StorageLive(_52); -+ _52 = move _2; -+ goto -> bb56; - } - - bb154: { +- StorageDead(_11); +- _145 = &mut _8; +- _144 = Pin::<&mut AsyncStruct>::new_unchecked(move _145) -> [return: bb158, unwind: bb20]; +- } +- +- bb122: { - StorageDead(_112); -- goto -> bb30; -+ StorageLive(_17); -+ StorageLive(_62); -+ _62 = move _2; -+ goto -> bb67; - } - -- bb155 (cleanup): { +- goto -> bb8; +- } +- +- bb123 (cleanup): { - StorageDead(_112); -- goto -> bb46; -+ bb155: { -+ StorageLive(_17); -+ StorageLive(_69); -+ _69 = move _2; -+ goto -> bb68; - } - - bb156: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb156, unwind: bb155]; -+ StorageLive(_17); -+ StorageLive(_79); -+ _79 = move _2; -+ goto -> bb79; - } - - bb157: { +- goto -> bb19; +- } +- +- bb124: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb124, unwind: bb123]; +- } +- +- bb125: { - _2 = move _113; - StorageDead(_113); -- goto -> bb156; -+ StorageLive(_17); -+ StorageLive(_86); -+ _86 = move _2; -+ goto -> bb80; - } - - bb158: { +- goto -> bb124; +- } +- +- bb126: { - _2 = move _113; - StorageDead(_113); -- goto -> bb163; -+ StorageLive(_96); -+ _96 = move _2; -+ goto -> bb91; - } - - bb159: { +- goto -> bb131; +- } +- +- bb127: { - StorageLive(_113); -- _113 = yield(const ()) -> [resume: bb157, drop: bb158]; -+ StorageLive(_103); -+ _103 = move _2; -+ goto -> bb92; - } - - bb160: { +- _113 = yield(const ()) -> [resume: bb125, drop: bb126]; +- } +- +- bb128: { - _115 = discriminant(_114); -- switchInt(move _115) -> [0: bb154, 1: bb159, otherwise: bb59]; -+ StorageLive(_113); -+ _113 = move _2; -+ goto -> bb103; - } - - bb161: { -- _114 = as Future>::poll(move _116, move _117) -> [return: bb160, unwind: bb155]; -+ StorageLive(_120); -+ _120 = move _2; -+ goto -> bb104; - } - - bb162: { +- switchInt(move _115) -> [0: bb122, 1: bb127, otherwise: bb32]; +- } +- +- bb129: { +- _114 = as Future>::poll(move _116, move _117) -> [return: bb128, unwind: bb123]; +- } +- +- bb130: { - _118 = move _2; -- _117 = std::future::get_context::<'_, '_>(move _118) -> [return: bb161, unwind: bb155]; -+ StorageLive(_130); -+ _130 = move _2; -+ goto -> bb115; - } - - bb163: { +- _117 = std::future::get_context::<'_, '_>(move _118) -> [return: bb129, unwind: bb123]; +- } +- +- bb131: { - _119 = &mut _112; -- _116 = Pin::<&mut impl Future>::new_unchecked(move _119) -> [return: bb162, unwind: bb155]; -+ StorageLive(_137); -+ _137 = move _2; -+ goto -> bb116; - } - - bb164: { +- _116 = Pin::<&mut impl Future>::new_unchecked(move _119) -> [return: bb130, unwind: bb123]; +- } +- +- bb132: { - _2 = move _120; - StorageDead(_120); -- goto -> bb170; -+ StorageLive(_147); -+ _147 = move _2; -+ goto -> bb127; - } - - bb165: { +- goto -> bb138; +- } +- +- bb133: { - _2 = move _120; - StorageDead(_120); -- goto -> bb163; -+ StorageLive(_154); -+ _154 = move _2; -+ goto -> bb128; - } - - bb166: { +- goto -> bb131; +- } +- +- bb134: { - StorageLive(_120); -- _120 = yield(const ()) -> [resume: bb164, drop: bb165]; -+ StorageLive(_164); -+ _164 = move _2; -+ goto -> bb139; - } - - bb167: { +- _120 = yield(const ()) -> [resume: bb132, drop: bb133]; +- } +- +- bb135: { - _122 = discriminant(_121); -- switchInt(move _122) -> [0: bb153, 1: bb166, otherwise: bb59]; -+ StorageLive(_171); -+ _171 = move _2; -+ goto -> bb140; - } - - bb168: { -- _121 = as Future>::poll(move _123, move _124) -> [return: bb167, unwind: bb155]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb168, unwind continue]; - } - - bb169: { +- switchInt(move _122) -> [0: bb121, 1: bb134, otherwise: bb32]; +- } +- +- bb136: { +- _121 = as Future>::poll(move _123, move _124) -> [return: bb135, unwind: bb123]; +- } +- +- bb137: { - _125 = move _2; -- _124 = std::future::get_context::<'_, '_>(move _125) -> [return: bb168, unwind: bb155]; -+ assert(const false, "`async fn` resumed after completion") -> [success: bb169, unwind continue]; - } - - bb170: { -- _126 = &mut _112; -- _123 = Pin::<&mut impl Future>::new_unchecked(move _126) -> [return: bb169, unwind: bb155]; +- _124 = std::future::get_context::<'_, '_>(move _125) -> [return: bb136, unwind: bb123]; - } - -- bb171: { -- StorageLive(_112); -- _112 = async_drop_in_place::(copy (_127.0: &mut SyncThenAsync)) -> [return: bb170, unwind: bb155]; +- bb138: { +- _126 = &mut _112; +- _123 = Pin::<&mut impl Future>::new_unchecked(move _126) -> [return: bb137, unwind: bb123]; - } - -- bb172: { -- _128 = &mut _11; -- _127 = Pin::<&mut SyncThenAsync>::new_unchecked(move _128) -> [return: bb171, unwind: bb46]; +- bb139: { +- StorageLive(_112); +- _112 = async_drop_in_place::(copy (_127.0: &mut SyncThenAsync)) -> [return: bb138, unwind: bb123]; - } - -- bb173: { +- bb140: { - StorageDead(_129); -- goto -> bb18; +- StorageDead(_8); +- _162 = &mut _5; +- _161 = Pin::<&mut [AsyncInt; 2]>::new_unchecked(move _162) -> [return: bb177, unwind: bb21]; - } - -- bb174: { +- bb141: { - StorageDead(_129); -- goto -> bb31; +- goto -> bb9; - } - -- bb175 (cleanup): { +- bb142 (cleanup): { - StorageDead(_129); -- goto -> bb47; +- goto -> bb20; - } - -- bb176: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb176, unwind: bb175]; +- bb143: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb143, unwind: bb142]; - } - -- bb177: { +- bb144: { - _2 = move _130; - StorageDead(_130); -- goto -> bb176; +- goto -> bb143; - } - -- bb178: { +- bb145: { - _2 = move _130; - StorageDead(_130); -- goto -> bb183; +- goto -> bb150; - } - -- bb179: { +- bb146: { - StorageLive(_130); -- _130 = yield(const ()) -> [resume: bb177, drop: bb178]; +- _130 = yield(const ()) -> [resume: bb144, drop: bb145]; - } - -- bb180: { +- bb147: { - _132 = discriminant(_131); -- switchInt(move _132) -> [0: bb174, 1: bb179, otherwise: bb59]; +- switchInt(move _132) -> [0: bb141, 1: bb146, otherwise: bb32]; - } - -- bb181: { -- _131 = as Future>::poll(move _133, move _134) -> [return: bb180, unwind: bb175]; +- bb148: { +- _131 = as Future>::poll(move _133, move _134) -> [return: bb147, unwind: bb142]; - } - -- bb182: { +- bb149: { - _135 = move _2; -- _134 = std::future::get_context::<'_, '_>(move _135) -> [return: bb181, unwind: bb175]; +- _134 = std::future::get_context::<'_, '_>(move _135) -> [return: bb148, unwind: bb142]; - } - -- bb183: { +- bb150: { - _136 = &mut _129; -- _133 = Pin::<&mut impl Future>::new_unchecked(move _136) -> [return: bb182, unwind: bb175]; +- _133 = Pin::<&mut impl Future>::new_unchecked(move _136) -> [return: bb149, unwind: bb142]; - } - -- bb184: { +- bb151: { - _2 = move _137; - StorageDead(_137); -- goto -> bb190; +- goto -> bb157; - } - -- bb185: { +- bb152: { - _2 = move _137; - StorageDead(_137); -- goto -> bb183; +- goto -> bb150; - } - -- bb186: { +- bb153: { - StorageLive(_137); -- _137 = yield(const ()) -> [resume: bb184, drop: bb185]; +- _137 = yield(const ()) -> [resume: bb151, drop: bb152]; - } - -- bb187: { +- bb154: { - _139 = discriminant(_138); -- switchInt(move _139) -> [0: bb173, 1: bb186, otherwise: bb59]; +- switchInt(move _139) -> [0: bb140, 1: bb153, otherwise: bb32]; - } - -- bb188: { -- _138 = as Future>::poll(move _140, move _141) -> [return: bb187, unwind: bb175]; +- bb155: { +- _138 = as Future>::poll(move _140, move _141) -> [return: bb154, unwind: bb142]; - } - -- bb189: { +- bb156: { - _142 = move _2; -- _141 = std::future::get_context::<'_, '_>(move _142) -> [return: bb188, unwind: bb175]; +- _141 = std::future::get_context::<'_, '_>(move _142) -> [return: bb155, unwind: bb142]; - } - -- bb190: { +- bb157: { - _143 = &mut _129; -- _140 = Pin::<&mut impl Future>::new_unchecked(move _143) -> [return: bb189, unwind: bb175]; +- _140 = Pin::<&mut impl Future>::new_unchecked(move _143) -> [return: bb156, unwind: bb142]; - } - -- bb191: { +- bb158: { - StorageLive(_129); -- _129 = async_drop_in_place::(copy (_144.0: &mut AsyncStruct)) -> [return: bb190, unwind: bb175]; +- _129 = async_drop_in_place::(copy (_144.0: &mut AsyncStruct)) -> [return: bb157, unwind: bb142]; - } - -- bb192: { -- _145 = &mut _8; -- _144 = Pin::<&mut AsyncStruct>::new_unchecked(move _145) -> [return: bb191, unwind: bb47]; -- } -- -- bb193: { +- bb159: { - StorageDead(_146); -- goto -> bb19; +- StorageDead(_5); +- _179 = &mut _4; +- _178 = Pin::<&mut AsyncInt>::new_unchecked(move _179) -> [return: bb196, unwind: bb22]; - } - -- bb194: { +- bb160: { - StorageDead(_146); -- goto -> bb32; +- goto -> bb10; - } - -- bb195 (cleanup): { +- bb161 (cleanup): { - StorageDead(_146); -- goto -> bb48; +- goto -> bb21; - } - -- bb196: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb196, unwind: bb195]; +- bb162: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb162, unwind: bb161]; - } - -- bb197: { +- bb163: { - _2 = move _147; - StorageDead(_147); -- goto -> bb196; +- goto -> bb162; - } - -- bb198: { +- bb164: { - _2 = move _147; - StorageDead(_147); -- goto -> bb203; +- goto -> bb169; - } - -- bb199: { +- bb165: { - StorageLive(_147); -- _147 = yield(const ()) -> [resume: bb197, drop: bb198]; +- _147 = yield(const ()) -> [resume: bb163, drop: bb164]; - } - -- bb200: { +- bb166: { - _149 = discriminant(_148); -- switchInt(move _149) -> [0: bb194, 1: bb199, otherwise: bb59]; +- switchInt(move _149) -> [0: bb160, 1: bb165, otherwise: bb32]; - } - -- bb201: { -- _148 = as Future>::poll(move _150, move _151) -> [return: bb200, unwind: bb195]; +- bb167: { +- _148 = as Future>::poll(move _150, move _151) -> [return: bb166, unwind: bb161]; - } - -- bb202: { +- bb168: { - _152 = move _2; -- _151 = std::future::get_context::<'_, '_>(move _152) -> [return: bb201, unwind: bb195]; +- _151 = std::future::get_context::<'_, '_>(move _152) -> [return: bb167, unwind: bb161]; - } - -- bb203: { +- bb169: { - _153 = &mut _146; -- _150 = Pin::<&mut impl Future>::new_unchecked(move _153) -> [return: bb202, unwind: bb195]; +- _150 = Pin::<&mut impl Future>::new_unchecked(move _153) -> [return: bb168, unwind: bb161]; - } - -- bb204: { +- bb170: { - _2 = move _154; - StorageDead(_154); -- goto -> bb210; +- goto -> bb176; - } - -- bb205: { +- bb171: { - _2 = move _154; - StorageDead(_154); -- goto -> bb203; +- goto -> bb169; - } - -- bb206: { +- bb172: { - StorageLive(_154); -- _154 = yield(const ()) -> [resume: bb204, drop: bb205]; +- _154 = yield(const ()) -> [resume: bb170, drop: bb171]; - } - -- bb207: { +- bb173: { - _156 = discriminant(_155); -- switchInt(move _156) -> [0: bb193, 1: bb206, otherwise: bb59]; +- switchInt(move _156) -> [0: bb159, 1: bb172, otherwise: bb32]; - } - -- bb208: { -- _155 = as Future>::poll(move _157, move _158) -> [return: bb207, unwind: bb195]; +- bb174: { +- _155 = as Future>::poll(move _157, move _158) -> [return: bb173, unwind: bb161]; - } - -- bb209: { +- bb175: { - _159 = move _2; -- _158 = std::future::get_context::<'_, '_>(move _159) -> [return: bb208, unwind: bb195]; +- _158 = std::future::get_context::<'_, '_>(move _159) -> [return: bb174, unwind: bb161]; - } - -- bb210: { +- bb176: { - _160 = &mut _146; -- _157 = Pin::<&mut impl Future>::new_unchecked(move _160) -> [return: bb209, unwind: bb195]; +- _157 = Pin::<&mut impl Future>::new_unchecked(move _160) -> [return: bb175, unwind: bb161]; - } - -- bb211: { +- bb177: { - StorageLive(_146); -- _146 = async_drop_in_place::<[AsyncInt; 2]>(copy (_161.0: &mut [AsyncInt; 2])) -> [return: bb210, unwind: bb195]; -- } -- -- bb212: { -- _162 = &mut _5; -- _161 = Pin::<&mut [AsyncInt; 2]>::new_unchecked(move _162) -> [return: bb211, unwind: bb48]; +- _146 = async_drop_in_place::<[AsyncInt; 2]>(copy (_161.0: &mut [AsyncInt; 2])) -> [return: bb176, unwind: bb161]; - } - -- bb213: { +- bb178: { - StorageDead(_163); -- goto -> bb20; +- StorageDead(_4); +- drop(_3) -> [return: bb2, unwind: bb23]; - } - -- bb214: { +- bb179: { - StorageDead(_163); -- goto -> bb33; +- goto -> bb11; - } - -- bb215 (cleanup): { +- bb180 (cleanup): { - StorageDead(_163); -- goto -> bb49; +- goto -> bb22; - } - -- bb216: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb216, unwind: bb215]; +- bb181: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb181, unwind: bb180]; - } - -- bb217: { +- bb182: { - _2 = move _164; - StorageDead(_164); -- goto -> bb216; +- goto -> bb181; - } - -- bb218: { +- bb183: { - _2 = move _164; - StorageDead(_164); -- goto -> bb223; +- goto -> bb188; - } - -- bb219: { +- bb184: { - StorageLive(_164); -- _164 = yield(const ()) -> [resume: bb217, drop: bb218]; +- _164 = yield(const ()) -> [resume: bb182, drop: bb183]; - } - -- bb220: { +- bb185: { - _166 = discriminant(_165); -- switchInt(move _166) -> [0: bb214, 1: bb219, otherwise: bb59]; +- switchInt(move _166) -> [0: bb179, 1: bb184, otherwise: bb32]; - } - -- bb221: { -- _165 = as Future>::poll(move _167, move _168) -> [return: bb220, unwind: bb215]; +- bb186: { +- _165 = as Future>::poll(move _167, move _168) -> [return: bb185, unwind: bb180]; - } - -- bb222: { +- bb187: { - _169 = move _2; -- _168 = std::future::get_context::<'_, '_>(move _169) -> [return: bb221, unwind: bb215]; +- _168 = std::future::get_context::<'_, '_>(move _169) -> [return: bb186, unwind: bb180]; - } - -- bb223: { +- bb188: { - _170 = &mut _163; -- _167 = Pin::<&mut impl Future>::new_unchecked(move _170) -> [return: bb222, unwind: bb215]; +- _167 = Pin::<&mut impl Future>::new_unchecked(move _170) -> [return: bb187, unwind: bb180]; - } - -- bb224: { +- bb189: { - _2 = move _171; - StorageDead(_171); -- goto -> bb230; +- goto -> bb195; - } - -- bb225: { +- bb190: { - _2 = move _171; - StorageDead(_171); -- goto -> bb223; +- goto -> bb188; - } - -- bb226: { +- bb191: { - StorageLive(_171); -- _171 = yield(const ()) -> [resume: bb224, drop: bb225]; +- _171 = yield(const ()) -> [resume: bb189, drop: bb190]; - } - -- bb227: { +- bb192: { - _173 = discriminant(_172); -- switchInt(move _173) -> [0: bb213, 1: bb226, otherwise: bb59]; +- switchInt(move _173) -> [0: bb178, 1: bb191, otherwise: bb32]; - } - -- bb228: { -- _172 = as Future>::poll(move _174, move _175) -> [return: bb227, unwind: bb215]; +- bb193: { +- _172 = as Future>::poll(move _174, move _175) -> [return: bb192, unwind: bb180]; - } - -- bb229: { +- bb194: { - _176 = move _2; -- _175 = std::future::get_context::<'_, '_>(move _176) -> [return: bb228, unwind: bb215]; +- _175 = std::future::get_context::<'_, '_>(move _176) -> [return: bb193, unwind: bb180]; - } - -- bb230: { +- bb195: { - _177 = &mut _163; -- _174 = Pin::<&mut impl Future>::new_unchecked(move _177) -> [return: bb229, unwind: bb215]; +- _174 = Pin::<&mut impl Future>::new_unchecked(move _177) -> [return: bb194, unwind: bb180]; - } - -- bb231: { +- bb196: { - StorageLive(_163); -- _163 = async_drop_in_place::(copy (_178.0: &mut AsyncInt)) -> [return: bb230, unwind: bb215]; -- } -- -- bb232: { -- _179 = &mut _4; -- _178 = Pin::<&mut AsyncInt>::new_unchecked(move _179) -> [return: bb231, unwind: bb49]; -+ nop; +- _163 = async_drop_in_place::(copy (_178.0: &mut AsyncInt)) -> [return: bb195, unwind: bb180]; + (((*_182) as variant#20).1: SyncInt) = SyncInt(const 0_i32); -+ nop; + (((*_182) as variant#20).2: AsyncInt) = AsyncInt(const 0_i32); -+ nop; + StorageLive(_6); + _6 = AsyncInt(const 1_i32); + StorageLive(_7); + _7 = AsyncInt(const 2_i32); + (((*_182) as variant#18).3: [AsyncInt; 2]) = [move _6, move _7]; -+ goto -> bb1; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageLive(_9); ++ _9 = AsyncInt(const 5_i32); ++ StorageLive(_10); ++ _10 = AsyncInt(const 4_i32); ++ (((*_182) as variant#16).4: AsyncStruct) = AsyncStruct { i: const 3_i32, a: move _10, b: move _9 }; ++ StorageDead(_10); ++ StorageDead(_9); ++ StorageLive(_12); ++ _12 = AsyncInt(const 7_i32); ++ StorageLive(_13); ++ _13 = SyncInt(const 8_i32); ++ StorageLive(_14); ++ _14 = AsyncInt(const 9_i32); ++ (((*_182) as variant#14).5: SyncThenAsync) = SyncThenAsync { i: const 6_i32, a: move _12, b: move _13, c: move _14 }; ++ StorageDead(_14); ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageLive(_16); ++ _16 = AsyncInt(const 10_i32); ++ (((*_182) as variant#12).6: AsyncEnum) = AsyncEnum::A(move _16); ++ StorageDead(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ _18 = AsyncInt(const 11_i32); ++ _17 = ManuallyDrop::::new(move _18) -> [return: bb1, unwind: bb6]; } } diff --git a/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.StateTransform.diff index 0f2b3ab13ec58..b2805af2a34ad 100644 --- a/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn simple::{closure#0}(_1: {async fn body of simple()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn simple::{closure#0}(_1: Pin<&mut {async fn body of simple()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: (); @@ -19,35 +21,32 @@ + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _25; + coroutine debug sync_int => _s1; + let mut _0: std::task::Poll<()>; let _3: SyncInt; let mut _5: impl std::future::Future; -- let mut _6: std::future::ResumeTy; -+ let mut _6: &mut std::task::Context<'_>; + let mut _6: std::future::ResumeTy; let mut _7: std::task::Poll<()>; let mut _8: isize; let mut _9: std::pin::Pin<&mut impl std::future::Future>; let mut _10: &mut std::task::Context<'_>; -- let mut _11: std::future::ResumeTy; -+ let mut _11: &mut std::task::Context<'_>; + let mut _11: std::future::ResumeTy; let mut _12: &mut impl std::future::Future; -- let mut _13: std::future::ResumeTy; -+ let mut _13: &mut std::task::Context<'_>; + let mut _13: std::future::ResumeTy; let mut _14: std::task::Poll<()>; let mut _15: isize; let mut _16: std::pin::Pin<&mut impl std::future::Future>; let mut _17: &mut std::task::Context<'_>; -- let mut _18: std::future::ResumeTy; -+ let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: &mut impl std::future::Future; let mut _20: std::pin::Pin<&mut AsyncInt>; let mut _21: &mut AsyncInt; + let mut _22: (); + let mut _23: u32; + let mut _24: &mut {async fn body of simple()}; ++ let mut _25: std::future::ResumeTy; ++ let mut _26: std::ptr::NonNull>; scope 1 { - debug sync_int => _3; + debug sync_int => (((*_24) as variant#4).1: SyncInt); @@ -65,220 +64,183 @@ - StorageLive(_4); - _4 = AsyncInt(const 0_i32); - _0 = const (); -- goto -> bb30; +- _21 = &mut _4; +- _20 = Pin::<&mut AsyncInt>::new_unchecked(move _21) -> [return: bb25, unwind: bb3]; ++ _26 = move _2 as std::ptr::NonNull> (Transmute); ++ _25 = std::future::ResumeTy(move _26); + _24 = copy (_1.0: &mut {async fn body of simple()}); + _23 = discriminant((*_24)); -+ switchInt(move _23) -> [0: bb26, 1: bb25, 2: bb24, 3: bb22, 4: bb23, otherwise: bb11]; ++ switchInt(move _23) -> [0: bb16, 1: bb15, 2: bb14, 3: bb12, 4: bb13, otherwise: bb5]; } bb1: { -- StorageDead(_4); -- drop(_3) -> [return: bb2, unwind: bb8]; -+ nop; -+ drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb2, unwind: bb5]; - } - - bb2: { - StorageDead(_3); -- drop(_1) -> [return: bb3, unwind: bb9]; -+ nop; -+ goto -> bb20; - } - - bb3: { +- drop(_1) -> [return: bb2, unwind: bb5]; + _0 = Poll::<()>::Ready(move (((*_24) as variant#4).0: ())); + discriminant((*_24)) = 1; - return; - } - -- bb4: { -- StorageDead(_4); -- goto -> bb5; -+ bb4 (cleanup): { -+ nop; -+ drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb5, unwind terminate(cleanup)]; - } - -- bb5: { -- StorageDead(_3); -+ bb5 (cleanup): { -+ nop; - goto -> bb6; ++ return; } -- bb6: { -- coroutine_drop; -+ bb6 (cleanup): { -+ goto -> bb21; +- bb2: { +- return; ++ bb2 (cleanup): { ++ drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb11, unwind terminate(cleanup)]; } -- bb7 (cleanup): { +- bb3 (cleanup): { - StorageDead(_4); -- drop(_3) -> [return: bb8, unwind terminate(cleanup)]; -+ bb7: { -+ nop; -+ goto -> bb1; +- drop(_3) -> [return: bb4, unwind terminate(cleanup)]; ++ bb3: { ++ drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb1, unwind: bb11]; } - bb8 (cleanup): { +- bb4 (cleanup): { - StorageDead(_3); -- drop(_1) -> [return: bb9, unwind terminate(cleanup)]; -+ nop; -+ goto -> bb4; +- drop(_1) -> [return: bb5, unwind terminate(cleanup)]; ++ bb4: { ++ assert(const false, "`async fn` resumed after async drop") -> [success: bb4, unwind: bb2]; } -- bb9 (cleanup): { +- bb5 (cleanup): { - resume; -+ bb9: { -+ assert(const false, "`async fn` resumed after async drop") -> [success: bb9, unwind: bb8]; ++ bb5: { ++ unreachable; } - bb10: { + bb6: { - StorageDead(_5); -- goto -> bb1; -+ _2 = move _6; -+ StorageDead(_6); -+ goto -> bb9; +- StorageDead(_4); +- drop(_3) -> [return: bb1, unwind: bb4]; ++ StorageLive(_13); ++ _0 = Poll::<()>::Pending; ++ StorageDead(_13); ++ discriminant((*_24)) = 4; ++ return; } - bb11: { + bb7: { - StorageDead(_5); -- goto -> bb4; -+ unreachable; +- StorageDead(_4); +- StorageDead(_3); +- coroutine_drop; ++ _15 = discriminant(_14); ++ switchInt(move _15) -> [0: bb3, 1: bb6, otherwise: bb5]; } -- bb12 (cleanup): { +- bb8 (cleanup): { - StorageDead(_5); -- goto -> bb7; -+ bb12: { -+ _2 = move _13; -+ StorageDead(_13); -+ goto -> bb17; +- goto -> bb3; ++ bb8: { ++ _18 = move _25; ++ _17 = copy (_18.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); ++ _14 = as Future>::poll(move _16, move _17) -> [return: bb7, unwind: bb2]; } - bb13: { -- assert(const false, "`async fn` resumed after async drop") -> [success: bb13, unwind: bb12]; -+ StorageLive(_13); -+ _0 = Poll::<()>::Pending; -+ StorageDead(_13); -+ discriminant((*_24)) = 4; -+ return; + bb9: { +- assert(const false, "`async fn` resumed after async drop") -> [success: bb9, unwind: bb8]; ++ _19 = &mut (((*_24) as variant#4).3: impl std::future::Future); ++ _16 = Pin::<&mut impl Future>::new_unchecked(move _19) -> [return: bb8, unwind: bb2]; } - bb14: { + bb10: { - _2 = move _6; - StorageDead(_6); -- goto -> bb13; -+ _15 = discriminant(_14); -+ switchInt(move _15) -> [0: bb7, 1: bb13, otherwise: bb11]; +- goto -> bb9; ++ (((*_24) as variant#4).3: impl std::future::Future) = async_drop_in_place::(copy (_20.0: &mut AsyncInt)) -> [return: bb9, unwind: bb2]; } - bb15: { +- bb11: { - _2 = move _6; - StorageDead(_6); -- goto -> bb21; -+ _14 = as Future>::poll(move _16, move _17) -> [return: bb14, unwind: bb8]; +- goto -> bb17; ++ bb11 (cleanup): { ++ discriminant((*_24)) = 2; ++ resume; } - bb16: { -- StorageLive(_6); -- _6 = yield(const ()) -> [resume: bb14, drop: bb15]; -+ _18 = move _2; -+ _17 = move _18; -+ goto -> bb15; + bb12: { + StorageLive(_6); +- _6 = yield(const ()) -> [resume: bb10, drop: bb11]; ++ _6 = move _25; ++ _25 = move _6; ++ StorageDead(_6); ++ goto -> bb4; } - bb17: { + bb13: { - unreachable; -+ _19 = &mut (((*_24) as variant#4).3: impl std::future::Future); -+ _16 = Pin::<&mut impl Future>::new_unchecked(move _19) -> [return: bb16, unwind: bb8]; ++ StorageLive(_13); ++ _13 = move _25; ++ _25 = move _13; ++ StorageDead(_13); ++ goto -> bb9; } - bb18: { + bb14: { - _8 = discriminant(_7); -- switchInt(move _8) -> [0: bb11, 1: bb16, otherwise: bb17]; -+ nop; -+ (((*_24) as variant#4).3: impl std::future::Future) = async_drop_in_place::(copy (_20.0: &mut AsyncInt)) -> [return: bb17, unwind: bb8]; +- switchInt(move _8) -> [0: bb7, 1: bb12, otherwise: bb13]; ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb14, unwind continue]; } - bb19: { -- _7 = as Future>::poll(move _9, move _10) -> [return: bb18, unwind: bb12]; -+ _21 = &mut (((*_24) as variant#4).2: AsyncInt); -+ _20 = Pin::<&mut AsyncInt>::new_unchecked(move _21) -> [return: bb18, unwind: bb4]; + bb15: { +- _7 = as Future>::poll(move _9, move _10) -> [return: bb14, unwind: bb8]; ++ assert(const false, "`async fn` resumed after completion") -> [success: bb15, unwind continue]; } - bb20: { + bb16: { - _11 = move _2; -- _10 = std::future::get_context::<'_, '_>(move _11) -> [return: bb19, unwind: bb12]; -+ goto -> bb3; - } - -- bb21: { +- _10 = std::future::get_context::<'_, '_>(move _11) -> [return: bb15, unwind: bb8]; +- } +- +- bb17: { - _12 = &mut _5; -- _9 = Pin::<&mut impl Future>::new_unchecked(move _12) -> [return: bb20, unwind: bb12]; -+ bb21 (cleanup): { -+ discriminant((*_24)) = 2; -+ resume; - } - - bb22: { +- _9 = Pin::<&mut impl Future>::new_unchecked(move _12) -> [return: bb16, unwind: bb8]; +- } +- +- bb18: { - _2 = move _13; - StorageDead(_13); -- goto -> bb28; -+ StorageLive(_6); -+ _6 = move _2; -+ goto -> bb10; - } - - bb23: { +- goto -> bb24; +- } +- +- bb19: { - _2 = move _13; - StorageDead(_13); -- goto -> bb21; -+ StorageLive(_13); -+ _13 = move _2; -+ goto -> bb12; - } - - bb24: { +- goto -> bb17; +- } +- +- bb20: { - StorageLive(_13); -- _13 = yield(const ()) -> [resume: bb22, drop: bb23]; -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb24, unwind continue]; - } - - bb25: { +- _13 = yield(const ()) -> [resume: bb18, drop: bb19]; +- } +- +- bb21: { - _15 = discriminant(_14); -- switchInt(move _15) -> [0: bb10, 1: bb24, otherwise: bb17]; -+ assert(const false, "`async fn` resumed after completion") -> [success: bb25, unwind continue]; - } - - bb26: { -- _14 = as Future>::poll(move _16, move _17) -> [return: bb25, unwind: bb12]; +- switchInt(move _15) -> [0: bb6, 1: bb20, otherwise: bb13]; - } - -- bb27: { +- bb22: { +- _14 = as Future>::poll(move _16, move _17) -> [return: bb21, unwind: bb8]; +- } +- +- bb23: { - _18 = move _2; -- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb26, unwind: bb12]; +- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb22, unwind: bb8]; - } - -- bb28: { +- bb24: { - _19 = &mut _5; -- _16 = Pin::<&mut impl Future>::new_unchecked(move _19) -> [return: bb27, unwind: bb12]; +- _16 = Pin::<&mut impl Future>::new_unchecked(move _19) -> [return: bb23, unwind: bb8]; - } - -- bb29: { +- bb25: { - StorageLive(_5); -- _5 = async_drop_in_place::(copy (_20.0: &mut AsyncInt)) -> [return: bb28, unwind: bb12]; -- } -- -- bb30: { -- _21 = &mut _4; -- _20 = Pin::<&mut AsyncInt>::new_unchecked(move _21) -> [return: bb29, unwind: bb7]; -+ nop; +- _5 = async_drop_in_place::(copy (_20.0: &mut AsyncInt)) -> [return: bb24, unwind: bb8]; + (((*_24) as variant#4).1: SyncInt) = SyncInt(const 0_i32); -+ nop; + (((*_24) as variant#4).2: AsyncInt) = AsyncInt(const 0_i32); + (((*_24) as variant#4).0: ()) = const (); -+ goto -> bb19; ++ _21 = &mut (((*_24) as variant#4).2: AsyncInt); ++ _20 = Pin::<&mut AsyncInt>::new_unchecked(move _21) -> [return: bb10, unwind: bb2]; } } diff --git a/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.coroutine_drop_async.0.mir b/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.coroutine_drop_async.0.mir index bc3def602a09e..3cd90f264ce64 100644 --- a/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.coroutine_drop_async.0.mir +++ b/tests/mir-opt/coroutine/async_drop.simple-{closure#0}.coroutine_drop_async.0.mir @@ -1,29 +1,31 @@ // MIR for `simple::{closure#0}` 0 coroutine_drop_async fn simple::{closure#0}(_1: Pin<&mut {async fn body of simple()}>, _2: &mut Context<'_>) -> Poll<()> { - debug _task_context => _2; + debug _task_context => _25; let mut _0: std::task::Poll<()>; let _3: SyncInt; let mut _5: impl std::future::Future; - let mut _6: &mut std::task::Context<'_>; + let mut _6: std::future::ResumeTy; let mut _7: std::task::Poll<()>; let mut _8: isize; let mut _9: std::pin::Pin<&mut impl std::future::Future>; let mut _10: &mut std::task::Context<'_>; - let mut _11: &mut std::task::Context<'_>; + let mut _11: std::future::ResumeTy; let mut _12: &mut impl std::future::Future; - let mut _13: &mut std::task::Context<'_>; + let mut _13: std::future::ResumeTy; let mut _14: std::task::Poll<()>; let mut _15: isize; let mut _16: std::pin::Pin<&mut impl std::future::Future>; let mut _17: &mut std::task::Context<'_>; - let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: &mut impl std::future::Future; let mut _20: std::pin::Pin<&mut AsyncInt>; let mut _21: &mut AsyncInt; let mut _22: (); let mut _23: u32; let mut _24: &mut {async fn body of simple()}; + let mut _25: std::future::ResumeTy; + let mut _26: std::ptr::NonNull>; scope 1 { debug sync_int => (((*_24) as variant#4).1: SyncInt); let _4: AsyncInt; @@ -33,57 +35,47 @@ fn simple::{closure#0}(_1: Pin<&mut {async fn body of simple()}>, _2: &mut Conte } bb0: { + _26 = move _2 as std::ptr::NonNull> (Transmute); + _25 = std::future::ResumeTy(move _26); _24 = copy (_1.0: &mut {async fn body of simple()}); _23 = discriminant((*_24)); - switchInt(move _23) -> [0: bb18, 2: bb23, 3: bb21, 4: bb22, otherwise: bb24]; + switchInt(move _23) -> [0: bb15, 2: bb20, 3: bb18, 4: bb19, otherwise: bb21]; } - bb1: { + bb1 (cleanup): { nop; - goto -> bb2; + drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb2, unwind terminate(cleanup)]; } - bb2: { + bb2 (cleanup): { nop; goto -> bb3; } - bb3: { - _0 = Poll::<()>::Ready(const ()); - return; + bb3 (cleanup): { + goto -> bb17; } - bb4 (cleanup): { + bb4: { nop; - drop((((*_24) as variant#4).1: SyncInt)) -> [return: bb5, unwind terminate(cleanup)]; - } - - bb5 (cleanup): { nop; - goto -> bb6; - } - - bb6 (cleanup): { - goto -> bb20; - } - - bb7: { nop; - goto -> bb1; + _0 = Poll::<()>::Ready(const ()); + return; } - bb8 (cleanup): { + bb5 (cleanup): { nop; - goto -> bb4; + goto -> bb1; } - bb9: { - _2 = move _6; + bb6: { + _25 = move _6; StorageDead(_6); - goto -> bb15; + goto -> bb12; } - bb10: { + bb7: { StorageLive(_6); _0 = Poll::<()>::Pending; StorageDead(_6); @@ -91,71 +83,71 @@ fn simple::{closure#0}(_1: Pin<&mut {async fn body of simple()}>, _2: &mut Conte return; } - bb11: { + bb8: { unreachable; } - bb12: { + bb9: { _8 = discriminant(_7); - switchInt(move _8) -> [0: bb7, 1: bb10, otherwise: bb11]; + switchInt(move _8) -> [0: bb4, 1: bb7, otherwise: bb8]; } - bb13: { - _7 = as Future>::poll(move _9, move _10) -> [return: bb12, unwind: bb8]; + bb10: { + _7 = as Future>::poll(move _9, move _10) -> [return: bb9, unwind: bb5]; } - bb14: { - _11 = move _2; - _10 = move _11; - goto -> bb13; + bb11: { + _11 = move _25; + _10 = copy (_11.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + goto -> bb10; } - bb15: { + bb12: { _12 = &mut (((*_24) as variant#4).3: impl std::future::Future); - _9 = Pin::<&mut impl Future>::new_unchecked(move _12) -> [return: bb14, unwind: bb8]; + _9 = Pin::<&mut impl Future>::new_unchecked(move _12) -> [return: bb11, unwind: bb5]; } - bb16: { - _2 = move _13; + bb13: { + _25 = move _13; StorageDead(_13); - goto -> bb15; + goto -> bb12; } - bb17: { + bb14: { _0 = Poll::<()>::Ready(const ()); return; } - bb18: { - goto -> bb19; + bb15: { + goto -> bb16; } - bb19: { - goto -> bb17; + bb16: { + goto -> bb14; } - bb20 (cleanup): { + bb17 (cleanup): { discriminant((*_24)) = 2; resume; } - bb21: { + bb18: { StorageLive(_6); - _6 = move _2; - goto -> bb9; + _6 = move _25; + goto -> bb6; } - bb22: { + bb19: { StorageLive(_13); - _13 = move _2; - goto -> bb16; + _13 = move _25; + goto -> bb13; } - bb23: { - assert(const false, "`async fn` resumed after panicking") -> [success: bb23, unwind continue]; + bb20: { + assert(const false, "`async fn` resumed after panicking") -> [success: bb20, unwind continue]; } - bb24: { + bb21: { _0 = Poll::<()>::Ready(const ()); return; } diff --git a/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir b/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir index 1790b350c7b49..0c8cf43e8c04e 100644 --- a/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir +++ b/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir @@ -1,129 +1,110 @@ // MIR for `a::{closure#0}` 0 coroutine_drop_async fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { - debug _task_context => _2; - debug x => ((*_23).0: T); + debug _task_context => _20; + debug x => ((*_19).0: T); let mut _0: std::task::Poll<()>; let _3: T; let mut _4: impl std::future::Future; - let mut _5: &mut std::task::Context<'_>; - let mut _6: std::task::Poll<()>; - let mut _7: isize; - let mut _8: std::pin::Pin<&mut impl std::future::Future>; - let mut _9: &mut std::task::Context<'_>; - let mut _10: &mut std::task::Context<'_>; - let mut _11: &mut impl std::future::Future; - let mut _12: &mut std::task::Context<'_>; - let mut _13: std::task::Poll<()>; - let mut _14: isize; - let mut _15: std::pin::Pin<&mut impl std::future::Future>; - let mut _16: &mut std::task::Context<'_>; - let mut _17: &mut std::task::Context<'_>; - let mut _18: &mut impl std::future::Future; - let mut _19: std::pin::Pin<&mut T>; - let mut _20: &mut T; - let mut _21: (); - let mut _22: u32; - let mut _23: &mut {async fn body of a()}; + let mut _5: std::task::Poll<()>; + let mut _6: isize; + let mut _7: std::pin::Pin<&mut impl std::future::Future>; + let mut _8: &mut std::task::Context<'_>; + let mut _9: &mut impl std::future::Future; + let mut _10: std::task::Poll<()>; + let mut _11: isize; + let mut _12: std::pin::Pin<&mut impl std::future::Future>; + let mut _13: &mut std::task::Context<'_>; + let mut _14: &mut impl std::future::Future; + let mut _15: std::pin::Pin<&mut T>; + let mut _16: &mut T; + let mut _17: (); + let mut _18: u32; + let mut _19: &mut {async fn body of a()}; + let mut _20: std::future::ResumeTy; + let mut _21: std::ptr::NonNull>; scope 1 { - debug x => (((*_23) as variant#4).1: T); + debug x => (((*_19) as variant#4).1: T); } bb0: { - _23 = copy (_1.0: &mut {async fn body of a()}); - _22 = discriminant((*_23)); - switchInt(move _22) -> [0: bb13, 3: bb16, 4: bb17, otherwise: bb18]; + _21 = move _2 as std::ptr::NonNull> (Transmute); + _20 = std::future::ResumeTy(move _21); + _19 = copy (_1.0: &mut {async fn body of a()}); + _18 = discriminant((*_19)); + switchInt(move _18) -> [0: bb11, 3: bb14, 4: bb15, otherwise: bb16]; } bb1: { nop; - goto -> bb2; + nop; + _0 = Poll::<()>::Ready(const ()); + return; } bb2: { - _0 = Poll::<()>::Ready(const ()); - return; + goto -> bb8; } bb3: { - nop; - goto -> bb1; + _0 = Poll::<()>::Pending; + discriminant((*_19)) = 3; + return; } bb4: { - _2 = move _5; - StorageDead(_5); - goto -> bb10; + unreachable; } bb5: { - StorageLive(_5); - _0 = Poll::<()>::Pending; - StorageDead(_5); - discriminant((*_23)) = 3; - return; + _6 = discriminant(_5); + switchInt(move _6) -> [0: bb1, 1: bb3, otherwise: bb4]; } bb6: { - unreachable; + _5 = as Future>::poll(move _7, move _8) -> [return: bb5, unwind unreachable]; } bb7: { - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb3, 1: bb5, otherwise: bb6]; + _8 = copy (_20.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + goto -> bb6; } bb8: { - _6 = as Future>::poll(move _8, move _9) -> [return: bb7, unwind unreachable]; + _9 = &mut (((*_19) as variant#4).2: impl std::future::Future); + _7 = Pin::<&mut impl Future>::new_unchecked(move _9) -> [return: bb7, unwind unreachable]; } bb9: { - _10 = move _2; - _9 = move _10; goto -> bb8; } bb10: { - _11 = &mut (((*_23) as variant#4).2: impl std::future::Future); - _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb9, unwind unreachable]; + _0 = Poll::<()>::Ready(const ()); + return; } bb11: { - _2 = move _12; - StorageDead(_12); - goto -> bb10; + goto -> bb13; } bb12: { - _0 = Poll::<()>::Ready(const ()); - return; + goto -> bb10; } bb13: { - goto -> bb15; + drop(((*_19).0: T)) -> [return: bb12, unwind unreachable]; } bb14: { - goto -> bb12; + goto -> bb2; } bb15: { - drop(((*_23).0: T)) -> [return: bb14, unwind unreachable]; + goto -> bb9; } bb16: { - StorageLive(_5); - _5 = move _2; - goto -> bb4; - } - - bb17: { - StorageLive(_12); - _12 = move _2; - goto -> bb11; - } - - bb18: { _0 = Poll::<()>::Ready(const ()); return; } diff --git a/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir b/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir index 83bfc3992b93b..02decd690744b 100644 --- a/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir +++ b/tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir @@ -1,156 +1,123 @@ // MIR for `a::{closure#0}` 0 coroutine_drop_async fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) -> Poll<()> { - debug _task_context => _2; - debug x => ((*_23).0: T); + debug _task_context => _20; + debug x => ((*_19).0: T); let mut _0: std::task::Poll<()>; let _3: T; let mut _4: impl std::future::Future; - let mut _5: &mut std::task::Context<'_>; - let mut _6: std::task::Poll<()>; - let mut _7: isize; - let mut _8: std::pin::Pin<&mut impl std::future::Future>; - let mut _9: &mut std::task::Context<'_>; - let mut _10: &mut std::task::Context<'_>; - let mut _11: &mut impl std::future::Future; - let mut _12: &mut std::task::Context<'_>; - let mut _13: std::task::Poll<()>; - let mut _14: isize; - let mut _15: std::pin::Pin<&mut impl std::future::Future>; - let mut _16: &mut std::task::Context<'_>; - let mut _17: &mut std::task::Context<'_>; - let mut _18: &mut impl std::future::Future; - let mut _19: std::pin::Pin<&mut T>; - let mut _20: &mut T; - let mut _21: (); - let mut _22: u32; - let mut _23: &mut {async fn body of a()}; + let mut _5: std::task::Poll<()>; + let mut _6: isize; + let mut _7: std::pin::Pin<&mut impl std::future::Future>; + let mut _8: &mut std::task::Context<'_>; + let mut _9: &mut impl std::future::Future; + let mut _10: std::task::Poll<()>; + let mut _11: isize; + let mut _12: std::pin::Pin<&mut impl std::future::Future>; + let mut _13: &mut std::task::Context<'_>; + let mut _14: &mut impl std::future::Future; + let mut _15: std::pin::Pin<&mut T>; + let mut _16: &mut T; + let mut _17: (); + let mut _18: u32; + let mut _19: &mut {async fn body of a()}; + let mut _20: std::future::ResumeTy; + let mut _21: std::ptr::NonNull>; scope 1 { - debug x => (((*_23) as variant#4).1: T); + debug x => (((*_19) as variant#4).1: T); } bb0: { - _23 = copy (_1.0: &mut {async fn body of a()}); - _22 = discriminant((*_23)); - switchInt(move _22) -> [0: bb17, 2: bb23, 3: bb21, 4: bb22, otherwise: bb24]; + _21 = move _2 as std::ptr::NonNull> (Transmute); + _20 = std::future::ResumeTy(move _21); + _19 = copy (_1.0: &mut {async fn body of a()}); + _18 = discriminant((*_19)); + switchInt(move _18) -> [0: bb11, 2: bb18, 3: bb16, 4: bb17, otherwise: bb19]; } bb1: { nop; - goto -> bb2; + nop; + _0 = Poll::<()>::Ready(const ()); + return; } bb2: { - _0 = Poll::<()>::Ready(const ()); - return; + goto -> bb8; } - bb3 (cleanup): { - nop; - goto -> bb15; + bb3: { + _0 = Poll::<()>::Pending; + discriminant((*_19)) = 3; + return; } - bb4 (cleanup): { - goto -> bb20; + bb4: { + unreachable; } bb5: { - nop; - goto -> bb1; + _6 = discriminant(_5); + switchInt(move _6) -> [0: bb1, 1: bb3, otherwise: bb4]; } - bb6 (cleanup): { - nop; - goto -> bb3; + bb6: { + _5 = as Future>::poll(move _7, move _8) -> [return: bb5, unwind: bb15]; } bb7: { - _2 = move _5; - StorageDead(_5); - goto -> bb13; + _8 = copy (_20.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + goto -> bb6; } bb8: { - StorageLive(_5); - _0 = Poll::<()>::Pending; - StorageDead(_5); - discriminant((*_23)) = 3; - return; + _9 = &mut (((*_19) as variant#4).2: impl std::future::Future); + _7 = Pin::<&mut impl Future>::new_unchecked(move _9) -> [return: bb7, unwind: bb15]; } bb9: { - unreachable; + goto -> bb8; } bb10: { - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb5, 1: bb8, otherwise: bb9]; + _0 = Poll::<()>::Ready(const ()); + return; } bb11: { - _6 = as Future>::poll(move _8, move _9) -> [return: bb10, unwind: bb6]; + goto -> bb14; } - bb12: { - _10 = move _2; - _9 = move _10; - goto -> bb11; + bb12 (cleanup): { + goto -> bb15; } bb13: { - _11 = &mut (((*_23) as variant#4).2: impl std::future::Future); - _8 = Pin::<&mut impl Future>::new_unchecked(move _11) -> [return: bb12, unwind: bb6]; + goto -> bb10; } bb14: { - _2 = move _12; - StorageDead(_12); - goto -> bb13; + drop(((*_19).0: T)) -> [return: bb13, unwind: bb12]; } bb15 (cleanup): { - goto -> bb4; + discriminant((*_19)) = 2; + resume; } bb16: { - _0 = Poll::<()>::Ready(const ()); - return; + goto -> bb2; } bb17: { - goto -> bb19; + goto -> bb9; } bb18: { - goto -> bb16; + assert(const false, "`async fn` resumed after panicking") -> [success: bb18, unwind continue]; } bb19: { - drop(((*_23).0: T)) -> [return: bb18, unwind: bb4]; - } - - bb20 (cleanup): { - discriminant((*_23)) = 2; - resume; - } - - bb21: { - StorageLive(_5); - _5 = move _2; - goto -> bb7; - } - - bb22: { - StorageLive(_12); - _12 = move _2; - goto -> bb14; - } - - bb23: { - assert(const false, "`async fn` resumed after panicking") -> [success: bb23, unwind continue]; - } - - bb24: { _0 = Poll::<()>::Ready(const ()); return; } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.StateTransform.diff index 3619637baa1f4..e2b374d417daa 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.StateTransform.diff @@ -4,6 +4,10 @@ - fn add::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:34:13: 34:18}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (*(_1.0: &u32)); +- debug y => (*(_1.1: &u32)); +- let mut _0: u32; + fn add::{closure#0}::{closure#0}(_1: Pin<&mut {async block@$DIR/async_fn.rs:34:13: 34:18}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + variant_fields = { @@ -13,10 +17,7 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- debug x => (*(_1.0: &u32)); -- debug y => (*(_1.1: &u32)); -- let mut _0: u32; ++ debug _task_context => _10; + debug x => (*((*_9).0: &u32)); + debug y => (*((*_9).1: &u32)); + let mut _0: std::task::Poll; @@ -27,54 +28,49 @@ + let mut _7: u32; + let mut _8: u32; + let mut _9: &mut {async block@$DIR/async_fn.rs:34:13: 34:18}; ++ let mut _10: std::future::ResumeTy; ++ let mut _11: std::ptr::NonNull>; bb0: { -- StorageLive(_3); -- _5 = no_retag copy (_1.0: &u32); -- _3 = copy (*_5); -- StorageLive(_4); -- _6 = no_retag copy (_1.1: &u32); -- _4 = copy (*_6); -- _0 = Add(move _3, move _4); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb1, unwind: bb2]; ++ _11 = move _2 as std::ptr::NonNull> (Transmute); ++ _10 = std::future::ResumeTy(move _11); + _9 = copy (_1.0: &mut {async block@$DIR/async_fn.rs:34:13: 34:18}); + _8 = discriminant((*_9)); -+ switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; - } - - bb1: { -+ _0 = Poll::::Ready(move _7); -+ discriminant((*_9)) = 1; - return; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { -+ goto -> bb1; ++ switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; ++ bb1: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; + } + -+ bb4: { ++ bb2: { + unreachable; + } + -+ bb5: { -+ StorageLive(_3); ++ bb3: { + StorageLive(_3); +- _5 = no_retag copy (_1.0: &u32); + _5 = no_retag copy ((*_9).0: &u32); -+ _3 = copy (*_5); -+ StorageLive(_4); + _3 = copy (*_5); + StorageLive(_4); +- _6 = no_retag copy (_1.1: &u32); + _6 = no_retag copy ((*_9).1: &u32); -+ _4 = copy (*_6); + _4 = copy (*_6); +- _0 = Add(move _3, move _4); + _7 = Add(move _3, move _4); -+ StorageDead(_4); -+ StorageDead(_3); -+ goto -> bb2; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { ++ _0 = Poll::::Ready(move _7); ++ discriminant((*_9)) = 1; + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir index 0439d4c682755..bc31fc3498c81 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -5,7 +5,7 @@ fn add::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs:34:13: 3 debug x => (*((*_1).0: &u32)); debug y => (*((*_1).1: &u32)); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let mut _3: u32; let mut _4: u32; let mut _5: &u32; diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir index 0c8f25df081aa..a4154615eca6c 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,8 +2,12 @@ fn add::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:34:13: 34:18}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.StateTransform.diff index 472d469984170..f8614dffccba1 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.StateTransform.diff @@ -4,6 +4,10 @@ - fn add::{closure#0}(_1: {async fn body of add()}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (_1.0: u32); +- debug y => (_1.1: u32); +- let mut _0: u32; + fn add::{closure#0}(_1: Pin<&mut {async fn body of add()}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + field _s0: u32; @@ -17,10 +21,7 @@ + } + storage_conflicts = BitMatrix(3x3) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s2, _s0), (_s2, _s1), (_s2, _s2)} + } - debug _task_context => _2; -- debug x => (_1.0: u32); -- debug y => (_1.1: u32); -- let mut _0: u32; ++ debug _task_context => _28; + debug x => ((*_27).0: u32); + debug y => ((*_27).1: u32); + coroutine debug x => _s0; @@ -38,16 +39,16 @@ let mut _16: &mut {async block@$DIR/async_fn.rs:34:13: 34:18}; let mut _17: &mut std::task::Context<'_>; let mut _18: &mut std::task::Context<'_>; -- let mut _19: std::future::ResumeTy; -+ let mut _19: &mut std::task::Context<'_>; + let mut _19: std::future::ResumeTy; let mut _20: isize; let mut _22: !; -- let mut _23: std::future::ResumeTy; -+ let mut _23: &mut std::task::Context<'_>; + let mut _23: std::future::ResumeTy; let mut _24: (); + let mut _25: u32; + let mut _26: u32; + let mut _27: &mut {async fn body of add()}; ++ let mut _28: std::future::ResumeTy; ++ let mut _29: std::ptr::NonNull>; scope 1 { - debug x => _3; + debug x => (((*_27) as variant#3).0: u32); @@ -89,18 +90,18 @@ - StorageLive(_8); - StorageLive(_9); - _9 = move _5; -- _8 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as IntoFuture>::into_future(move _9) -> [return: bb1, unwind: bb24]; +- _8 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as IntoFuture>::into_future(move _9) -> [return: bb1, unwind: bb20]; ++ _29 = move _2 as std::ptr::NonNull> (Transmute); ++ _28 = std::future::ResumeTy(move _29); + _27 = copy (_1.0: &mut {async fn body of add()}); + _26 = discriminant((*_27)); -+ switchInt(move _26) -> [0: bb28, 1: bb27, 2: bb26, 3: bb25, otherwise: bb6]; ++ switchInt(move _26) -> [0: bb17, 1: bb16, 2: bb15, 3: bb14, otherwise: bb5]; } bb1: { StorageDead(_9); - PlaceMention(_8); - StorageLive(_10); - _10 = move _8; -+ nop; + (((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18}) = move _8; goto -> bb2; } @@ -114,8 +115,8 @@ - _16 = &mut _10; + _16 = &mut (((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18}); _15 = &mut (*_16); -- _14 = Pin::<&mut {async block@$DIR/async_fn.rs:34:13: 34:18}>::new_unchecked(move _15) -> [return: bb3, unwind: bb21]; -+ _14 = Pin::<&mut {async block@$DIR/async_fn.rs:34:13: 34:18}>::new_unchecked(move _15) -> [return: bb3, unwind: bb15]; +- _14 = Pin::<&mut {async block@$DIR/async_fn.rs:34:13: 34:18}>::new_unchecked(move _15) -> [return: bb3, unwind: bb17]; ++ _14 = Pin::<&mut {async block@$DIR/async_fn.rs:34:13: 34:18}>::new_unchecked(move _15) -> [return: bb3, unwind: bb10]; } bb3: { @@ -123,41 +124,44 @@ StorageLive(_17); StorageLive(_18); StorageLive(_19); - _19 = copy _2; -- _18 = std::future::get_context::<'_, '_>(move _19) -> [return: bb4, unwind: bb19]; -+ _18 = move _19; -+ goto -> bb4; - } - - bb4: { +- _19 = copy _2; +- _18 = std::future::get_context::<'_, '_>(move _19) -> [return: bb4, unwind: bb15]; +- } +- +- bb4: { ++ _19 = copy _28; ++ _18 = copy (_19.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _17 = &mut (*_18); StorageDead(_19); -- _13 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as Future>::poll(move _14, move _17) -> [return: bb5, unwind: bb20]; -+ _13 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as Future>::poll(move _14, move _17) -> [return: bb5, unwind: bb14]; +- _13 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as Future>::poll(move _14, move _17) -> [return: bb5, unwind: bb16]; ++ _13 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as Future>::poll(move _14, move _17) -> [return: bb4, unwind: bb9]; } - bb5: { +- bb5: { ++ bb4: { StorageDead(_18); StorageDead(_17); StorageDead(_16); StorageDead(_14); - PlaceMention(_13); _20 = discriminant(_13); - switchInt(move _20) -> [0: bb8, 1: bb7, otherwise: bb6]; +- switchInt(move _20) -> [0: bb8, 1: bb7, otherwise: bb6]; ++ switchInt(move _20) -> [0: bb7, 1: bb6, otherwise: bb5]; } - bb6: { +- bb6: { ++ bb5: { unreachable; } - bb7: { +- bb7: { ++ bb6: { _12 = const (); StorageDead(_13); StorageDead(_12); StorageLive(_23); StorageLive(_24); _24 = (); -- _23 = yield(move _24) -> [resume: bb9, drop: bb14]; +- _23 = yield(move _24) -> [resume: bb9, drop: bb12]; + _0 = Poll::::Pending; + StorageDead(_5); + StorageDead(_8); @@ -167,7 +171,8 @@ + return; } - bb8: { +- bb8: { ++ bb7: { StorageLive(_21); _21 = copy ((_13 as Ready).0: u32); - _0 = copy _21; @@ -175,184 +180,138 @@ StorageDead(_21); StorageDead(_13); StorageDead(_12); -- drop(_10) -> [return: bb10, unwind: bb23]; -+ drop((((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb10, unwind: bb17]; - } - - bb9: { - StorageDead(_24); - _2 = move _23; - StorageDead(_23); - _11 = const (); - goto -> bb2; +- drop(_10) -> [return: bb10, unwind: bb19]; ++ drop((((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb8, unwind: bb13]; } - bb10: { +- bb9: { +- StorageDead(_24); +- _2 = move _23; +- StorageDead(_23); +- _11 = const (); +- goto -> bb2; +- } +- +- bb10: { - StorageDead(_10); -+ nop; - goto -> bb11; - } - - bb11: { ++ bb8: { StorageDead(_8); - goto -> bb12; - } - - bb12: { StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb13, unwind: bb28]; -+ nop; -+ nop; -+ goto -> bb23; - } - - bb13: { +- drop(_1) -> [return: bb11, unwind: bb22]; +- } +- +- bb11: { + _0 = Poll::::Ready(move _25); + discriminant((*_27)) = 1; return; } -- bb14: { +- bb12: { - StorageDead(_24); - StorageDead(_23); -- drop(_10) -> [return: bb15, unwind: bb29]; -+ bb14 (cleanup): { -+ StorageDead(_18); -+ StorageDead(_17); -+ goto -> bb16; - } - -- bb15: { +- drop(_10) -> [return: bb13, unwind: bb23]; +- } +- +- bb13: { - StorageDead(_10); -+ bb15 (cleanup): { -+ StorageDead(_15); - goto -> bb16; - } - -- bb16: { - StorageDead(_8); -- goto -> bb17; -+ bb16 (cleanup): { -+ StorageDead(_16); -+ StorageDead(_14); -+ StorageDead(_13); -+ StorageDead(_12); -+ drop((((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb17, unwind terminate(cleanup)]; - } - -- bb17: { - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb18, unwind: bb28]; -+ bb17 (cleanup): { -+ nop; -+ goto -> bb20; - } - -- bb18: { +- drop(_1) -> [return: bb14, unwind: bb22]; +- } +- +- bb14: { - coroutine_drop; -+ bb18 (cleanup): { -+ goto -> bb19; - } - - bb19 (cleanup): { +- } +- +- bb15 (cleanup): { - StorageDead(_19); -+ StorageDead(_9); - goto -> bb20; - } - - bb20 (cleanup): { -- StorageDead(_18); -- StorageDead(_17); -- goto -> bb22; -+ StorageDead(_8); -+ goto -> bb21; +- goto -> bb16; +- } +- +- bb16 (cleanup): { ++ bb9 (cleanup): { + StorageDead(_18); + StorageDead(_17); +- goto -> bb18; ++ goto -> bb11; } - bb21 (cleanup): { -- StorageDead(_15); -+ StorageDead(_5); -+ nop; -+ nop; - goto -> bb22; +- bb17 (cleanup): { ++ bb10 (cleanup): { + StorageDead(_15); +- goto -> bb18; ++ goto -> bb11; } - bb22 (cleanup): { -- StorageDead(_16); -- StorageDead(_14); -- StorageDead(_13); -- StorageDead(_12); -- drop(_10) -> [return: bb23, unwind terminate(cleanup)]; -+ goto -> bb24; +- bb18 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_16); + StorageDead(_14); + StorageDead(_13); + StorageDead(_12); +- drop(_10) -> [return: bb19, unwind terminate(cleanup)]; ++ drop((((*_27) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb13, unwind terminate(cleanup)]; } -- bb23 (cleanup): { +- bb19 (cleanup): { - StorageDead(_10); -- goto -> bb26; -+ bb23: { +- goto -> bb21; +- } +- +- bb20 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_9); +- goto -> bb21; + goto -> bb13; } - bb24 (cleanup): { -- goto -> bb25; +- bb21 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_8); + StorageDead(_5); +- StorageDead(_4); +- StorageDead(_3); +- drop(_1) -> [return: bb22, unwind terminate(cleanup)]; + discriminant((*_27)) = 2; + resume; } -- bb25 (cleanup): { -- StorageDead(_9); -- goto -> bb26; -+ bb25: { +- bb22 (cleanup): { +- resume; ++ bb14: { + StorageLive(_5); + StorageLive(_8); + StorageLive(_23); + StorageLive(_24); -+ _23 = move _2; -+ goto -> bb9; - } - -- bb26 (cleanup): { -- StorageDead(_8); -- goto -> bb27; -+ bb26: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb26, unwind continue]; - } - -- bb27 (cleanup): { -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb28, unwind terminate(cleanup)]; -+ bb27: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb27, unwind continue]; ++ _23 = move _28; ++ StorageDead(_24); ++ _28 = move _23; ++ StorageDead(_23); ++ _11 = const (); ++ goto -> bb2; } -- bb28 (cleanup): { -- resume; -- } -- -- bb29 (cleanup): { +- bb23 (cleanup): { - StorageDead(_10); -- goto -> bb30; -- } -- -- bb30 (cleanup): { - StorageDead(_8); -- goto -> bb31; -- } -- -- bb31 (cleanup): { - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb28, unwind terminate(cleanup)]; -+ bb28: { -+ nop; +- drop(_1) -> [return: bb22, unwind terminate(cleanup)]; ++ bb15: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb15, unwind continue]; ++ } ++ ++ bb16: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb16, unwind continue]; ++ } ++ ++ bb17: { + (((*_27) as variant#3).0: u32) = copy ((*_27).0: u32); -+ nop; + (((*_27) as variant#3).1: u32) = copy ((*_27).1: u32); + StorageLive(_5); + StorageLive(_6); @@ -365,7 +324,7 @@ + StorageLive(_8); + StorageLive(_9); + _9 = move _5; -+ _8 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as IntoFuture>::into_future(move _9) -> [return: bb1, unwind: bb18]; ++ _8 = <{async block@$DIR/async_fn.rs:34:13: 34:18} as IntoFuture>::into_future(move _9) -> [return: bb1, unwind: bb12]; } } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir index ecff837e4436f..4edd8f87078ba 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir @@ -5,7 +5,7 @@ fn add::{closure#0}(_1: &mut {async fn body of add()}) -> () { debug x => ((*_1).0: u32); debug y => ((*_1).1: u32); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: u32; let mut _6: &u32; let mut _7: &u32; @@ -19,10 +19,10 @@ fn add::{closure#0}(_1: &mut {async fn body of add()}) -> () { let mut _16: &mut {async block@$DIR/async_fn.rs:34:13: 34:18}; let mut _17: &mut std::task::Context<'_>; let mut _18: &mut std::task::Context<'_>; - let mut _19: &mut std::task::Context<'_>; + let mut _19: std::future::ResumeTy; let mut _20: isize; let mut _22: !; - let mut _23: &mut std::task::Context<'_>; + let mut _23: std::future::ResumeTy; let mut _24: (); let mut _25: u32; let mut _26: u32; @@ -48,74 +48,58 @@ fn add::{closure#0}(_1: &mut {async fn body of add()}) -> () { bb0: { _26 = discriminant((*_1)); - switchInt(move _26) -> [0: bb11, 3: bb14, otherwise: bb15]; + switchInt(move _26) -> [0: bb7, 3: bb10, otherwise: bb11]; } bb1: { StorageDead(_24); StorageDead(_23); - drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb2, unwind: bb7]; + drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:34:13: 34:18})) -> [return: bb2, unwind: bb5]; } bb2: { nop; - goto -> bb3; - } - - bb3: { StorageDead(_8); - goto -> bb4; - } - - bb4: { StorageDead(_5); nop; nop; - goto -> bb12; + goto -> bb8; } - bb5: { + bb3: { return; } - bb6 (cleanup): { + bb4 (cleanup): { resume; } - bb7 (cleanup): { + bb5 (cleanup): { nop; - goto -> bb8; - } - - bb8 (cleanup): { StorageDead(_8); - goto -> bb9; - } - - bb9 (cleanup): { StorageDead(_5); nop; nop; - goto -> bb6; + goto -> bb4; } - bb10: { + bb6: { return; } - bb11: { - goto -> bb13; + bb7: { + goto -> bb9; } - bb12: { - goto -> bb5; + bb8: { + goto -> bb3; } - bb13: { - goto -> bb10; + bb9: { + goto -> bb6; } - bb14: { + bb10: { StorageLive(_5); StorageLive(_8); StorageLive(_23); @@ -123,7 +107,7 @@ fn add::{closure#0}(_1: &mut {async fn body of add()}) -> () { goto -> bb1; } - bb15: { + bb11: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop_proxy_async.0.mir index c86391c4f729e..f398c48c3b8cc 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn add::{closure#0}(_1: {async fn body of add()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -14,6 +16,8 @@ fn add::{closure#0}(_1: {async fn body of add()}, _2: &mut Context<'_>) -> Poll< } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.StateTransform.diff index 9a644309798be..d99c6a39b32be 100644 --- a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.StateTransform.diff @@ -4,6 +4,12 @@ - fn build_aggregate::{closure#0}(_1: {async fn body of build_aggregate()}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug a => (_1.0: u32); +- debug b => (_1.1: u32); +- debug c => (_1.2: u32); +- debug d => (_1.3: u32); +- let mut _0: u32; + fn build_aggregate::{closure#0}(_1: Pin<&mut {async fn body of build_aggregate()}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + field _s0: u32; @@ -20,12 +26,7 @@ + } + storage_conflicts = BitMatrix(5x5) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s0, _s4), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s1, _s4), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s2, _s4), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3), (_s4, _s0), (_s4, _s1), (_s4, _s2), (_s4, _s4)} + } - debug _task_context => _2; -- debug a => (_1.0: u32); -- debug b => (_1.1: u32); -- debug c => (_1.2: u32); -- debug d => (_1.3: u32); -- let mut _0: u32; ++ debug _task_context => _52; + debug a => ((*_51).0: u32); + debug b => ((*_51).1: u32); + debug c => ((*_51).2: u32); @@ -45,12 +46,10 @@ let mut _19: &mut {async fn body of add()}; let mut _20: &mut std::task::Context<'_>; let mut _21: &mut std::task::Context<'_>; -- let mut _22: std::future::ResumeTy; -+ let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: isize; let mut _25: !; -- let mut _26: std::future::ResumeTy; -+ let mut _26: &mut std::task::Context<'_>; + let mut _26: std::future::ResumeTy; let mut _27: (); let mut _28: u32; let mut _29: {async fn body of add()}; @@ -64,18 +63,18 @@ let mut _38: &mut {async fn body of add()}; let mut _39: &mut std::task::Context<'_>; let mut _40: &mut std::task::Context<'_>; -- let mut _41: std::future::ResumeTy; -+ let mut _41: &mut std::task::Context<'_>; + let mut _41: std::future::ResumeTy; let mut _42: isize; let mut _44: !; -- let mut _45: std::future::ResumeTy; -+ let mut _45: &mut std::task::Context<'_>; + let mut _45: std::future::ResumeTy; let mut _46: (); let mut _47: u32; let mut _48: u32; + let mut _49: u32; + let mut _50: u32; + let mut _51: &mut {async fn body of build_aggregate()}; ++ let mut _52: std::future::ResumeTy; ++ let mut _53: std::ptr::NonNull>; scope 1 { debug a => _3; let _4: u32; @@ -137,25 +136,25 @@ - _11 = copy _3; - StorageLive(_12); - _12 = copy _4; -- _10 = add(move _11, move _12) -> [return: bb1, unwind: bb49]; +- _10 = add(move _11, move _12) -> [return: bb1, unwind: bb42]; ++ _53 = move _2 as std::ptr::NonNull> (Transmute); ++ _52 = std::future::ResumeTy(move _53); + _51 = copy (_1.0: &mut {async fn body of build_aggregate()}); + _50 = discriminant((*_51)); -+ switchInt(move _50) -> [0: bb49, 1: bb48, 2: bb47, 3: bb45, 4: bb46, otherwise: bb7]; ++ switchInt(move _50) -> [0: bb35, 1: bb34, 2: bb33, 3: bb31, 4: bb32, otherwise: bb6]; } bb1: { StorageDead(_12); StorageDead(_11); -- _9 = <{async fn body of add()} as IntoFuture>::into_future(move _10) -> [return: bb2, unwind: bb48]; -+ _9 = <{async fn body of add()} as IntoFuture>::into_future(move _10) -> [return: bb2, unwind: bb38]; +- _9 = <{async fn body of add()} as IntoFuture>::into_future(move _10) -> [return: bb2, unwind: bb43]; ++ _9 = <{async fn body of add()} as IntoFuture>::into_future(move _10) -> [return: bb2, unwind: bb29]; } bb2: { StorageDead(_10); - PlaceMention(_9); - StorageLive(_13); - _13 = move _9; -+ nop; + (((*_51) as variant#3).2: {async fn body of add()}) = move _9; goto -> bb3; } @@ -169,8 +168,8 @@ - _19 = &mut _13; + _19 = &mut (((*_51) as variant#3).2: {async fn body of add()}); _18 = &mut (*_19); -- _17 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _18) -> [return: bb4, unwind: bb44]; -+ _17 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _18) -> [return: bb4, unwind: bb34]; +- _17 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _18) -> [return: bb4, unwind: bb39]; ++ _17 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _18) -> [return: bb4, unwind: bb26]; } bb4: { @@ -178,41 +177,44 @@ StorageLive(_20); StorageLive(_21); StorageLive(_22); - _22 = copy _2; -- _21 = std::future::get_context::<'_, '_>(move _22) -> [return: bb5, unwind: bb42]; -+ _21 = move _22; -+ goto -> bb5; - } - - bb5: { +- _22 = copy _2; +- _21 = std::future::get_context::<'_, '_>(move _22) -> [return: bb5, unwind: bb37]; +- } +- +- bb5: { ++ _22 = copy _52; ++ _21 = copy (_22.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _20 = &mut (*_21); StorageDead(_22); -- _16 = <{async fn body of add()} as Future>::poll(move _17, move _20) -> [return: bb6, unwind: bb43]; -+ _16 = <{async fn body of add()} as Future>::poll(move _17, move _20) -> [return: bb6, unwind: bb33]; +- _16 = <{async fn body of add()} as Future>::poll(move _17, move _20) -> [return: bb6, unwind: bb38]; ++ _16 = <{async fn body of add()} as Future>::poll(move _17, move _20) -> [return: bb5, unwind: bb25]; } - bb6: { +- bb6: { ++ bb5: { StorageDead(_21); StorageDead(_20); StorageDead(_19); StorageDead(_17); - PlaceMention(_16); _23 = discriminant(_16); - switchInt(move _23) -> [0: bb9, 1: bb8, otherwise: bb7]; +- switchInt(move _23) -> [0: bb9, 1: bb8, otherwise: bb7]; ++ switchInt(move _23) -> [0: bb8, 1: bb7, otherwise: bb6]; } - bb7: { +- bb7: { ++ bb6: { unreachable; } - bb8: { +- bb8: { ++ bb7: { _15 = const (); StorageDead(_16); StorageDead(_15); StorageLive(_26); StorageLive(_27); _27 = (); -- _26 = yield(move _27) -> [resume: bb10, drop: bb28]; +- _26 = yield(move _27) -> [resume: bb10, drop: bb25]; + _0 = Poll::::Pending; + StorageDead(_3); + StorageDead(_4); @@ -224,7 +226,8 @@ + return; } - bb9: { +- bb9: { ++ bb8: { StorageLive(_24); _24 = copy ((_16 as Ready).0: u32); - _8 = copy _24; @@ -232,21 +235,21 @@ StorageDead(_24); StorageDead(_16); StorageDead(_15); -- drop(_13) -> [return: bb11, unwind: bb46]; -+ drop((((*_51) as variant#3).2: {async fn body of add()})) -> [return: bb11, unwind: bb36]; +- drop(_13) -> [return: bb11, unwind: bb41]; ++ drop((((*_51) as variant#3).2: {async fn body of add()})) -> [return: bb9, unwind: bb30]; } - bb10: { - StorageDead(_27); - _2 = move _26; - StorageDead(_26); - _14 = const (); - goto -> bb3; - } - - bb11: { +- bb10: { +- StorageDead(_27); +- _2 = move _26; +- StorageDead(_26); +- _14 = const (); +- goto -> bb3; +- } +- +- bb11: { - StorageDead(_13); -+ nop; ++ bb9: { StorageLive(_28); StorageLive(_29); StorageLive(_30); @@ -255,29 +258,31 @@ + _31 = copy (((*_51) as variant#3).0: u32); StorageLive(_32); - _32 = copy _6; -- _30 = add(move _31, move _32) -> [return: bb12, unwind: bb39]; +- _30 = add(move _31, move _32) -> [return: bb12, unwind: bb34]; + _32 = copy (((*_51) as variant#3).1: u32); -+ _30 = add(move _31, move _32) -> [return: bb12, unwind: bb30]; ++ _30 = add(move _31, move _32) -> [return: bb10, unwind: bb22]; } - bb12: { +- bb12: { ++ bb10: { StorageDead(_32); StorageDead(_31); -- _29 = <{async fn body of add()} as IntoFuture>::into_future(move _30) -> [return: bb13, unwind: bb38]; -+ _29 = <{async fn body of add()} as IntoFuture>::into_future(move _30) -> [return: bb13, unwind: bb29]; +- _29 = <{async fn body of add()} as IntoFuture>::into_future(move _30) -> [return: bb13, unwind: bb35]; ++ _29 = <{async fn body of add()} as IntoFuture>::into_future(move _30) -> [return: bb11, unwind: bb23]; } - bb13: { +- bb13: { ++ bb11: { StorageDead(_30); - PlaceMention(_29); - StorageLive(_33); - _33 = move _29; -+ nop; +- goto -> bb14; + (((*_51) as variant#4).1: {async fn body of add()}) = move _29; - goto -> bb14; ++ goto -> bb12; } - bb14: { +- bb14: { ++ bb12: { StorageLive(_34); StorageLive(_35); StorageLive(_36); @@ -286,46 +291,49 @@ - _38 = &mut _33; + _38 = &mut (((*_51) as variant#4).1: {async fn body of add()}); _37 = &mut (*_38); -- _36 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _37) -> [return: bb15, unwind: bb35]; -+ _36 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _37) -> [return: bb15, unwind: bb26]; +- _36 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _37) -> [return: bb15, unwind: bb31]; ++ _36 = Pin::<&mut {async fn body of add()}>::new_unchecked(move _37) -> [return: bb13, unwind: bb19]; } - bb15: { +- bb15: { ++ bb13: { StorageDead(_37); StorageLive(_39); StorageLive(_40); StorageLive(_41); - _41 = copy _2; -- _40 = std::future::get_context::<'_, '_>(move _41) -> [return: bb16, unwind: bb33]; -+ _40 = move _41; -+ goto -> bb16; - } - - bb16: { +- _41 = copy _2; +- _40 = std::future::get_context::<'_, '_>(move _41) -> [return: bb16, unwind: bb29]; +- } +- +- bb16: { ++ _41 = copy _52; ++ _40 = copy (_41.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _39 = &mut (*_40); StorageDead(_41); -- _35 = <{async fn body of add()} as Future>::poll(move _36, move _39) -> [return: bb17, unwind: bb34]; -+ _35 = <{async fn body of add()} as Future>::poll(move _36, move _39) -> [return: bb17, unwind: bb25]; +- _35 = <{async fn body of add()} as Future>::poll(move _36, move _39) -> [return: bb17, unwind: bb30]; ++ _35 = <{async fn body of add()} as Future>::poll(move _36, move _39) -> [return: bb14, unwind: bb18]; } - bb17: { +- bb17: { ++ bb14: { StorageDead(_40); StorageDead(_39); StorageDead(_38); StorageDead(_36); - PlaceMention(_35); _42 = discriminant(_35); - switchInt(move _42) -> [0: bb19, 1: bb18, otherwise: bb7]; +- switchInt(move _42) -> [0: bb19, 1: bb18, otherwise: bb7]; ++ switchInt(move _42) -> [0: bb16, 1: bb15, otherwise: bb6]; } - bb18: { +- bb18: { ++ bb15: { _34 = const (); StorageDead(_35); StorageDead(_34); StorageLive(_45); StorageLive(_46); _46 = (); -- _45 = yield(move _46) -> [resume: bb20, drop: bb25]; +- _45 = yield(move _46) -> [resume: bb20, drop: bb23]; + _0 = Poll::::Pending; + StorageDead(_3); + StorageDead(_4); @@ -339,42 +347,34 @@ + return; } - bb19: { +- bb19: { ++ bb16: { StorageLive(_43); _43 = copy ((_35 as Ready).0: u32); _28 = copy _43; StorageDead(_43); StorageDead(_35); StorageDead(_34); -- drop(_33) -> [return: bb21, unwind: bb37]; -+ drop((((*_51) as variant#4).1: {async fn body of add()})) -> [return: bb21, unwind: bb28]; - } - - bb20: { - StorageDead(_46); - _2 = move _45; - StorageDead(_45); - _14 = const (); - goto -> bb14; +- drop(_33) -> [return: bb21, unwind: bb33]; ++ drop((((*_51) as variant#4).1: {async fn body of add()})) -> [return: bb17, unwind: bb21]; } - bb21: { +- bb20: { +- StorageDead(_46); +- _2 = move _45; +- StorageDead(_45); +- _14 = const (); +- goto -> bb14; +- } +- +- bb21: { - StorageDead(_33); - _7 = (move _8, move _28); -+ nop; ++ bb17: { + _7 = (move (((*_51) as variant#4).0: u32), move _28); StorageDead(_28); - StorageDead(_8); -+ nop; - goto -> bb22; - } - - bb22: { StorageDead(_29); - goto -> bb23; - } - - bb23: { StorageDead(_9); StorageLive(_47); _47 = copy (_7.0: u32); @@ -387,257 +387,209 @@ StorageDead(_7); - StorageDead(_6); - StorageDead(_5); -+ nop; -+ nop; StorageDead(_4); StorageDead(_3); -- drop(_1) -> [return: bb24, unwind: bb52]; -+ goto -> bb43; - } - - bb24: { +- drop(_1) -> [return: bb22, unwind: bb45]; +- } +- +- bb22: { + _0 = Poll::::Ready(move _49); + discriminant((*_51)) = 1; return; } -- bb25: { +- bb23: { - StorageDead(_46); - StorageDead(_45); -- drop(_33) -> [return: bb26, unwind: bb53]; +- drop(_33) -> [return: bb24, unwind: bb46]; - } - -- bb26: { +- bb24: { - StorageDead(_33); - StorageDead(_28); - StorageDead(_8); -- goto -> bb27; -- } -- -- bb27: { - StorageDead(_29); -- goto -> bb30; +- goto -> bb27; - } - -- bb28: { +- bb25: { - StorageDead(_27); - StorageDead(_26); -- drop(_13) -> [return: bb29, unwind: bb55]; +- drop(_13) -> [return: bb26, unwind: bb47]; - } - -- bb29: { +- bb26: { - StorageDead(_13); - StorageDead(_8); -- goto -> bb30; -- } -- -- bb30: { -- goto -> bb31; +- goto -> bb27; - } - -- bb31: { +- bb27: { - StorageDead(_9); - StorageDead(_7); - StorageDead(_6); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb32, unwind: bb52]; +- drop(_1) -> [return: bb28, unwind: bb45]; - } - -- bb32: { +- bb28: { - coroutine_drop; - } - -- bb33 (cleanup): { +- bb29 (cleanup): { - StorageDead(_41); -- goto -> bb34; +- goto -> bb30; - } - -- bb34 (cleanup): { -+ bb25 (cleanup): { +- bb30 (cleanup): { ++ bb18 (cleanup): { StorageDead(_40); StorageDead(_39); -- goto -> bb36; -+ goto -> bb27; +- goto -> bb32; ++ goto -> bb20; } -- bb35 (cleanup): { -+ bb26 (cleanup): { +- bb31 (cleanup): { ++ bb19 (cleanup): { StorageDead(_37); -- goto -> bb36; -+ goto -> bb27; +- goto -> bb32; ++ goto -> bb20; } -- bb36 (cleanup): { -+ bb27 (cleanup): { +- bb32 (cleanup): { ++ bb20 (cleanup): { StorageDead(_38); StorageDead(_36); StorageDead(_35); StorageDead(_34); -- drop(_33) -> [return: bb37, unwind terminate(cleanup)]; -+ drop((((*_51) as variant#4).1: {async fn body of add()})) -> [return: bb28, unwind terminate(cleanup)]; +- drop(_33) -> [return: bb33, unwind terminate(cleanup)]; ++ drop((((*_51) as variant#4).1: {async fn body of add()})) -> [return: bb21, unwind terminate(cleanup)]; } -- bb37 (cleanup): { +- bb33 (cleanup): { - StorageDead(_33); -+ bb28 (cleanup): { -+ nop; ++ bb21 (cleanup): { StorageDead(_28); - StorageDead(_8); -- goto -> bb41; -+ nop; -+ goto -> bb32; - } - -- bb38 (cleanup): { -- goto -> bb40; -+ bb29 (cleanup): { -+ goto -> bb31; +- goto -> bb36; ++ goto -> bb24; } -- bb39 (cleanup): { -+ bb30 (cleanup): { +- bb34 (cleanup): { ++ bb22 (cleanup): { StorageDead(_32); StorageDead(_31); -- goto -> bb40; -+ goto -> bb31; +- goto -> bb35; ++ goto -> bb23; } -- bb40 (cleanup): { -+ bb31 (cleanup): { +- bb35 (cleanup): { ++ bb23 (cleanup): { StorageDead(_30); StorageDead(_28); - StorageDead(_8); -- goto -> bb41; -+ nop; -+ goto -> bb32; +- goto -> bb36; ++ goto -> bb24; } -- bb41 (cleanup): { -+ bb32 (cleanup): { +- bb36 (cleanup): { ++ bb24 (cleanup): { StorageDead(_29); -- goto -> bb47; -+ goto -> bb37; +- goto -> bb44; ++ goto -> bb30; } -- bb42 (cleanup): { +- bb37 (cleanup): { - StorageDead(_22); -- goto -> bb43; +- goto -> bb38; - } - -- bb43 (cleanup): { -+ bb33 (cleanup): { +- bb38 (cleanup): { ++ bb25 (cleanup): { StorageDead(_21); StorageDead(_20); -- goto -> bb45; -+ goto -> bb35; +- goto -> bb40; ++ goto -> bb27; } -- bb44 (cleanup): { -+ bb34 (cleanup): { +- bb39 (cleanup): { ++ bb26 (cleanup): { StorageDead(_18); -- goto -> bb45; -+ goto -> bb35; +- goto -> bb40; ++ goto -> bb27; } -- bb45 (cleanup): { -+ bb35 (cleanup): { +- bb40 (cleanup): { ++ bb27 (cleanup): { StorageDead(_19); StorageDead(_17); StorageDead(_16); StorageDead(_15); -- drop(_13) -> [return: bb46, unwind terminate(cleanup)]; -+ drop((((*_51) as variant#3).2: {async fn body of add()})) -> [return: bb36, unwind terminate(cleanup)]; +- drop(_13) -> [return: bb41, unwind terminate(cleanup)]; ++ drop((((*_51) as variant#3).2: {async fn body of add()})) -> [return: bb30, unwind terminate(cleanup)]; } -- bb46 (cleanup): { +- bb41 (cleanup): { - StorageDead(_13); - StorageDead(_8); -- goto -> bb47; -+ bb36 (cleanup): { -+ nop; -+ nop; -+ goto -> bb37; - } - -- bb47 (cleanup): { -- goto -> bb51; -+ bb37 (cleanup): { -+ goto -> bb41; - } - -- bb48 (cleanup): { -- goto -> bb50; -+ bb38 (cleanup): { -+ goto -> bb40; - } - -- bb49 (cleanup): { -+ bb39 (cleanup): { +- goto -> bb44; +- } +- +- bb42 (cleanup): { ++ bb28 (cleanup): { StorageDead(_12); StorageDead(_11); -- goto -> bb50; -+ goto -> bb40; +- goto -> bb43; ++ goto -> bb29; } -- bb50 (cleanup): { -+ bb40 (cleanup): { +- bb43 (cleanup): { ++ bb29 (cleanup): { StorageDead(_10); - StorageDead(_8); -- goto -> bb51; -+ nop; -+ goto -> bb41; +- goto -> bb44; ++ goto -> bb30; } -- bb51 (cleanup): { -+ bb41 (cleanup): { +- bb44 (cleanup): { ++ bb30 (cleanup): { StorageDead(_9); StorageDead(_7); - StorageDead(_6); - StorageDead(_5); -+ nop; -+ nop; StorageDead(_4); StorageDead(_3); -- drop(_1) -> [return: bb52, unwind terminate(cleanup)]; -+ goto -> bb42; - } - -- bb52 (cleanup): { -+ bb42 (cleanup): { -+ goto -> bb44; -+ } -+ -+ bb43: { -+ goto -> bb24; -+ } -+ -+ bb44 (cleanup): { +- drop(_1) -> [return: bb45, unwind terminate(cleanup)]; + discriminant((*_51)) = 2; - resume; ++ resume; } -- bb53 (cleanup): { -- StorageDead(_33); -- StorageDead(_28); -- StorageDead(_8); -- goto -> bb54; -+ bb45: { +- bb45 (cleanup): { +- resume; ++ bb31: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_7); + StorageLive(_9); + StorageLive(_26); + StorageLive(_27); -+ _26 = move _2; -+ goto -> bb10; ++ _26 = move _52; ++ StorageDead(_27); ++ _52 = move _26; ++ StorageDead(_26); ++ _14 = const (); ++ goto -> bb3; } -- bb54 (cleanup): { +- bb46 (cleanup): { +- StorageDead(_33); +- StorageDead(_28); +- StorageDead(_8); - StorageDead(_29); -- goto -> bb56; -+ bb46: { +- goto -> bb48; ++ bb32: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_7); @@ -646,50 +598,49 @@ + StorageLive(_29); + StorageLive(_45); + StorageLive(_46); -+ _45 = move _2; -+ goto -> bb20; ++ _45 = move _52; ++ StorageDead(_46); ++ _52 = move _45; ++ StorageDead(_45); ++ _14 = const (); ++ goto -> bb12; } -- bb55 (cleanup): { +- bb47 (cleanup): { - StorageDead(_13); - StorageDead(_8); -- goto -> bb56; -+ bb47: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb47, unwind continue]; +- goto -> bb48; ++ bb33: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb33, unwind continue]; } -- bb56 (cleanup): { -- goto -> bb57; -+ bb48: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb48, unwind continue]; - } - -- bb57 (cleanup): { +- bb48 (cleanup): { - StorageDead(_9); - StorageDead(_7); - StorageDead(_6); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb52, unwind terminate(cleanup)]; -+ bb49: { +- drop(_1) -> [return: bb45, unwind terminate(cleanup)]; ++ bb34: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb34, unwind continue]; ++ } ++ ++ bb35: { + StorageLive(_3); + _3 = copy ((*_51).0: u32); + StorageLive(_4); + _4 = copy ((*_51).1: u32); -+ nop; + (((*_51) as variant#3).0: u32) = copy ((*_51).2: u32); -+ nop; + (((*_51) as variant#3).1: u32) = copy ((*_51).3: u32); + StorageLive(_7); -+ nop; + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _11 = copy _3; + StorageLive(_12); + _12 = copy _4; -+ _10 = add(move _11, move _12) -> [return: bb1, unwind: bb39]; ++ _10 = add(move _11, move _12) -> [return: bb1, unwind: bb28]; } } diff --git a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir index bd5fea383b50d..cfd8eeb157e50 100644 --- a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir @@ -7,7 +7,7 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - debug c => ((*_1).2: u32); debug d => ((*_1).3: u32); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: u32; let mut _8: u32; let mut _9: {async fn body of add()}; @@ -22,10 +22,10 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - let mut _19: &mut {async fn body of add()}; let mut _20: &mut std::task::Context<'_>; let mut _21: &mut std::task::Context<'_>; - let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: isize; let mut _25: !; - let mut _26: &mut std::task::Context<'_>; + let mut _26: std::future::ResumeTy; let mut _27: (); let mut _28: u32; let mut _29: {async fn body of add()}; @@ -39,10 +39,10 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - let mut _38: &mut {async fn body of add()}; let mut _39: &mut std::task::Context<'_>; let mut _40: &mut std::task::Context<'_>; - let mut _41: &mut std::task::Context<'_>; + let mut _41: std::future::ResumeTy; let mut _42: isize; let mut _44: !; - let mut _45: &mut std::task::Context<'_>; + let mut _45: std::future::ResumeTy; let mut _46: (); let mut _47: u32; let mut _48: u32; @@ -86,120 +86,104 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - bb0: { _50 = discriminant((*_1)); - switchInt(move _50) -> [0: bb16, 3: bb19, 4: bb20, otherwise: bb21]; + switchInt(move _50) -> [0: bb12, 3: bb15, 4: bb16, otherwise: bb17]; } bb1: { StorageDead(_46); StorageDead(_45); - drop((((*_1) as variant#4).1: {async fn body of add()})) -> [return: bb2, unwind: bb10]; + drop((((*_1) as variant#4).1: {async fn body of add()})) -> [return: bb2, unwind: bb8]; } bb2: { nop; StorageDead(_28); nop; - goto -> bb3; - } - - bb3: { StorageDead(_29); - goto -> bb6; + goto -> bb5; } - bb4: { + bb3: { StorageDead(_27); StorageDead(_26); - drop((((*_1) as variant#3).2: {async fn body of add()})) -> [return: bb5, unwind: bb12]; + drop((((*_1) as variant#3).2: {async fn body of add()})) -> [return: bb4, unwind: bb9]; } - bb5: { + bb4: { nop; nop; - goto -> bb6; + goto -> bb5; } - bb6: { - goto -> bb7; - } - - bb7: { + bb5: { StorageDead(_9); StorageDead(_7); nop; nop; StorageDead(_4); StorageDead(_3); - goto -> bb17; + goto -> bb13; } - bb8: { + bb6: { return; } - bb9 (cleanup): { + bb7 (cleanup): { resume; } - bb10 (cleanup): { + bb8 (cleanup): { nop; StorageDead(_28); nop; - goto -> bb11; - } - - bb11 (cleanup): { StorageDead(_29); - goto -> bb13; + goto -> bb10; } - bb12 (cleanup): { + bb9 (cleanup): { nop; nop; - goto -> bb13; + goto -> bb10; } - bb13 (cleanup): { - goto -> bb14; - } - - bb14 (cleanup): { + bb10 (cleanup): { StorageDead(_9); StorageDead(_7); nop; nop; StorageDead(_4); StorageDead(_3); - goto -> bb9; + goto -> bb7; } - bb15: { + bb11: { return; } - bb16: { - goto -> bb18; + bb12: { + goto -> bb14; } - bb17: { - goto -> bb8; + bb13: { + goto -> bb6; } - bb18: { - goto -> bb15; + bb14: { + goto -> bb11; } - bb19: { + bb15: { StorageLive(_3); StorageLive(_4); StorageLive(_7); StorageLive(_9); StorageLive(_26); StorageLive(_27); - goto -> bb4; + goto -> bb3; } - bb20: { + bb16: { StorageLive(_3); StorageLive(_4); StorageLive(_7); @@ -211,7 +195,7 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - goto -> bb1; } - bb21: { + bb17: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop_proxy_async.0.mir index 9f06ae9272bad..68b809e50f7b3 100644 --- a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn build_aggregate::{closure#0}(_1: {async fn body of build_aggregate()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -22,6 +24,8 @@ fn build_aggregate::{closure#0}(_1: {async fn body of build_aggregate()}, _2: &m } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.StateTransform.diff index b902c7c048048..05ba3f9613b8e 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.StateTransform.diff @@ -4,6 +4,10 @@ - fn foo::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:21:13: 21:18}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug y => (*(_1.0: &u32)); +- debug z => (*(_1.1: &u32)); +- let mut _0: u32; + fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async block@$DIR/async_fn.rs:21:13: 21:18}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + variant_fields = { @@ -13,10 +17,7 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- debug y => (*(_1.0: &u32)); -- debug z => (*(_1.1: &u32)); -- let mut _0: u32; ++ debug _task_context => _10; + debug y => (*((*_9).0: &u32)); + debug z => (*((*_9).1: &u32)); + let mut _0: std::task::Poll; @@ -27,54 +28,49 @@ + let mut _7: u32; + let mut _8: u32; + let mut _9: &mut {async block@$DIR/async_fn.rs:21:13: 21:18}; ++ let mut _10: std::future::ResumeTy; ++ let mut _11: std::ptr::NonNull>; bb0: { -- StorageLive(_3); -- _5 = no_retag copy (_1.0: &u32); -- _3 = copy (*_5); -- StorageLive(_4); -- _6 = no_retag copy (_1.1: &u32); -- _4 = copy (*_6); -- _0 = Add(move _3, move _4); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb1, unwind: bb2]; ++ _11 = move _2 as std::ptr::NonNull> (Transmute); ++ _10 = std::future::ResumeTy(move _11); + _9 = copy (_1.0: &mut {async block@$DIR/async_fn.rs:21:13: 21:18}); + _8 = discriminant((*_9)); -+ switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; - } - - bb1: { -+ _0 = Poll::::Ready(move _7); -+ discriminant((*_9)) = 1; - return; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { -+ goto -> bb1; ++ switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; ++ bb1: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; + } + -+ bb4: { ++ bb2: { + unreachable; + } + -+ bb5: { -+ StorageLive(_3); ++ bb3: { + StorageLive(_3); +- _5 = no_retag copy (_1.0: &u32); + _5 = no_retag copy ((*_9).0: &u32); -+ _3 = copy (*_5); -+ StorageLive(_4); + _3 = copy (*_5); + StorageLive(_4); +- _6 = no_retag copy (_1.1: &u32); + _6 = no_retag copy ((*_9).1: &u32); -+ _4 = copy (*_6); + _4 = copy (*_6); +- _0 = Add(move _3, move _4); + _7 = Add(move _3, move _4); -+ StorageDead(_4); -+ StorageDead(_3); -+ goto -> bb2; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { ++ _0 = Poll::::Ready(move _7); ++ discriminant((*_9)) = 1; + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir index c22d1ca1ca132..97b9a7098b5ec 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -5,7 +5,7 @@ fn foo::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs:21:13: 2 debug y => (*((*_1).0: &u32)); debug z => (*((*_1).1: &u32)); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let mut _3: u32; let mut _4: u32; let mut _5: &u32; diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir index 19fe75de78cb5..b15cd698a68d1 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,8 +2,12 @@ fn foo::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:21:13: 21:18}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.StateTransform.diff index 86cac4aad150d..dd79f0a17f83b 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.StateTransform.diff @@ -4,6 +4,10 @@ - fn foo::{closure#0}(_1: {async fn body of foo()}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (_1.0: &u32); +- debug y => (_1.1: u32); +- let mut _0: u32; + fn foo::{closure#0}(_1: Pin<&mut {async fn body of foo()}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + field _s0: &u32; @@ -18,10 +22,7 @@ + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3)} + } - debug _task_context => _2; -- debug x => (_1.0: &u32); -- debug y => (_1.1: u32); -- let mut _0: u32; ++ debug _task_context => _38; + debug x => ((*_36).0: &u32); + debug y => ((*_36).1: u32); + coroutine debug x => _s0; @@ -39,12 +40,10 @@ let mut _19: &mut {async block@$DIR/async_fn.rs:21:13: 21:18}; let mut _20: &mut std::task::Context<'_>; let mut _21: &mut std::task::Context<'_>; -- let mut _22: std::future::ResumeTy; -+ let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: isize; let mut _25: !; -- let mut _26: std::future::ResumeTy; -+ let mut _26: &mut std::task::Context<'_>; + let mut _26: std::future::ResumeTy; let mut _27: (); let mut _30: u32; let mut _31: u32; @@ -54,6 +53,8 @@ + let mut _35: u32; + let mut _36: &mut {async fn body of foo()}; + let mut _37: &u32; ++ let mut _38: std::future::ResumeTy; ++ let mut _39: std::ptr::NonNull>; scope 1 { - debug x => _3; + debug x => (((*_36) as variant#3).0: &u32); @@ -122,18 +123,18 @@ - _10 = {coroutine@$DIR/async_fn.rs:21:13: 21:18 (#0)} { y: move _11, z: move _12 }; - StorageDead(_12); - StorageDead(_11); -- _9 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as IntoFuture>::into_future(move _10) -> [return: bb1, unwind: bb22]; +- _9 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as IntoFuture>::into_future(move _10) -> [return: bb1, unwind: bb20]; ++ _39 = move _2 as std::ptr::NonNull> (Transmute); ++ _38 = std::future::ResumeTy(move _39); + _36 = copy (_1.0: &mut {async fn body of foo()}); + _35 = discriminant((*_36)); -+ switchInt(move _35) -> [0: bb26, 1: bb25, 2: bb24, 3: bb23, otherwise: bb6]; ++ switchInt(move _35) -> [0: bb17, 1: bb16, 2: bb15, 3: bb14, otherwise: bb5]; } bb1: { StorageDead(_10); - PlaceMention(_9); - StorageLive(_13); - _13 = move _9; -+ nop; + (((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18}) = move _9; goto -> bb2; } @@ -147,8 +148,8 @@ - _19 = &mut _13; + _19 = &mut (((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18}); _18 = &mut (*_19); -- _17 = Pin::<&mut {async block@$DIR/async_fn.rs:21:13: 21:18}>::new_unchecked(move _18) -> [return: bb3, unwind: bb19]; -+ _17 = Pin::<&mut {async block@$DIR/async_fn.rs:21:13: 21:18}>::new_unchecked(move _18) -> [return: bb3, unwind: bb14]; +- _17 = Pin::<&mut {async block@$DIR/async_fn.rs:21:13: 21:18}>::new_unchecked(move _18) -> [return: bb3, unwind: bb17]; ++ _17 = Pin::<&mut {async block@$DIR/async_fn.rs:21:13: 21:18}>::new_unchecked(move _18) -> [return: bb3, unwind: bb10]; } bb3: { @@ -156,41 +157,44 @@ StorageLive(_20); StorageLive(_21); StorageLive(_22); - _22 = copy _2; -- _21 = std::future::get_context::<'_, '_>(move _22) -> [return: bb4, unwind: bb17]; -+ _21 = move _22; -+ goto -> bb4; - } - - bb4: { +- _22 = copy _2; +- _21 = std::future::get_context::<'_, '_>(move _22) -> [return: bb4, unwind: bb15]; +- } +- +- bb4: { ++ _22 = copy _38; ++ _21 = copy (_22.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _20 = &mut (*_21); StorageDead(_22); -- _16 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as Future>::poll(move _17, move _20) -> [return: bb5, unwind: bb18]; -+ _16 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as Future>::poll(move _17, move _20) -> [return: bb5, unwind: bb13]; +- _16 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as Future>::poll(move _17, move _20) -> [return: bb5, unwind: bb16]; ++ _16 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as Future>::poll(move _17, move _20) -> [return: bb4, unwind: bb9]; } - bb5: { +- bb5: { ++ bb4: { StorageDead(_21); StorageDead(_20); StorageDead(_19); StorageDead(_17); - PlaceMention(_16); _23 = discriminant(_16); - switchInt(move _23) -> [0: bb8, 1: bb7, otherwise: bb6]; +- switchInt(move _23) -> [0: bb8, 1: bb7, otherwise: bb6]; ++ switchInt(move _23) -> [0: bb7, 1: bb6, otherwise: bb5]; } - bb6: { +- bb6: { ++ bb5: { unreachable; } - bb7: { +- bb7: { ++ bb6: { _15 = const (); StorageDead(_16); StorageDead(_15); StorageLive(_26); StorageLive(_27); _27 = (); -- _26 = yield(move _27) -> [resume: bb9, drop: bb13]; +- _26 = yield(move _27) -> [resume: bb9, drop: bb12]; + _0 = Poll::::Pending; + StorageDead(_5); + StorageDead(_7); @@ -202,32 +206,29 @@ + return; } - bb8: { +- bb8: { ++ bb7: { StorageLive(_24); _24 = copy ((_16 as Ready).0: u32); _8 = copy _24; StorageDead(_24); StorageDead(_16); StorageDead(_15); -- drop(_13) -> [return: bb10, unwind: bb21]; -+ drop((((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb10, unwind: bb16]; +- drop(_13) -> [return: bb10, unwind: bb19]; ++ drop((((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb8, unwind: bb13]; } - bb9: { - StorageDead(_27); - _2 = move _26; - StorageDead(_26); - _14 = const (); - goto -> bb2; - } - - bb10: { +- bb9: { +- StorageDead(_27); +- _2 = move _26; +- StorageDead(_26); +- _14 = const (); +- goto -> bb2; +- } +- +- bb10: { - StorageDead(_13); -+ nop; - goto -> bb11; - } - - bb11: { ++ bb8: { StorageDead(_9); StorageLive(_28); _28 = const 10_u32; @@ -254,40 +255,26 @@ StorageDead(_8); StorageDead(_7); - StorageDead(_6); -+ nop; StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb12, unwind: bb25]; -+ nop; -+ nop; -+ goto -> bb21; - } - - bb12: { +- drop(_1) -> [return: bb11, unwind: bb22]; +- } +- +- bb11: { + _0 = Poll::::Ready(move _34); + discriminant((*_36)) = 1; return; } -- bb13: { +- bb12: { - StorageDead(_27); - StorageDead(_26); -- drop(_13) -> [return: bb14, unwind: bb26]; -+ bb13 (cleanup): { -+ StorageDead(_21); -+ StorageDead(_20); -+ goto -> bb15; - } - -- bb14: { +- drop(_13) -> [return: bb13, unwind: bb23]; +- } +- +- bb13: { - StorageDead(_13); -+ bb14 (cleanup): { -+ StorageDead(_18); - goto -> bb15; - } - -- bb15: { - StorageDead(_9); - StorageDead(_8); - StorageDead(_7); @@ -295,108 +282,88 @@ - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb16, unwind: bb25]; -+ bb15 (cleanup): { -+ StorageDead(_19); -+ StorageDead(_17); -+ StorageDead(_16); -+ StorageDead(_15); -+ drop((((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb16, unwind terminate(cleanup)]; - } - -- bb16: { +- drop(_1) -> [return: bb14, unwind: bb22]; +- } +- +- bb14: { - coroutine_drop; -+ bb16 (cleanup): { -+ nop; -+ goto -> bb19; - } - - bb17 (cleanup): { +- } +- +- bb15 (cleanup): { - StorageDead(_22); - goto -> bb18; - } - - bb18 (cleanup): { -- StorageDead(_21); -- StorageDead(_20); -- goto -> bb20; -+ StorageDead(_10); -+ goto -> bb19; +- goto -> bb16; +- } +- +- bb16 (cleanup): { ++ bb9 (cleanup): { + StorageDead(_21); + StorageDead(_20); +- goto -> bb18; ++ goto -> bb11; } - bb19 (cleanup): { -- StorageDead(_18); -+ StorageDead(_9); -+ StorageDead(_8); -+ StorageDead(_7); -+ nop; -+ StorageDead(_5); -+ nop; -+ nop; - goto -> bb20; +- bb17 (cleanup): { ++ bb10 (cleanup): { + StorageDead(_18); +- goto -> bb18; ++ goto -> bb11; } - bb20 (cleanup): { -- StorageDead(_19); -- StorageDead(_17); -- StorageDead(_16); -- StorageDead(_15); -- drop(_13) -> [return: bb21, unwind terminate(cleanup)]; -+ goto -> bb22; +- bb18 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_19); + StorageDead(_17); + StorageDead(_16); + StorageDead(_15); +- drop(_13) -> [return: bb19, unwind terminate(cleanup)]; ++ drop((((*_36) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb13, unwind terminate(cleanup)]; } -- bb21 (cleanup): { +- bb19 (cleanup): { - StorageDead(_13); -- goto -> bb24; -+ bb21: { -+ goto -> bb12; +- goto -> bb21; +- } +- +- bb20 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_10); +- goto -> bb21; ++ goto -> bb13; } - bb22 (cleanup): { -- goto -> bb23; +- bb21 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); +- StorageDead(_6); + StorageDead(_5); +- StorageDead(_4); +- StorageDead(_3); +- drop(_1) -> [return: bb22, unwind terminate(cleanup)]; + discriminant((*_36)) = 2; + resume; } -- bb23 (cleanup): { -- StorageDead(_10); -- goto -> bb24; -+ bb23: { +- bb22 (cleanup): { +- resume; ++ bb14: { + StorageLive(_5); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + StorageLive(_26); + StorageLive(_27); -+ _26 = move _2; -+ goto -> bb9; - } - -- bb24 (cleanup): { -- StorageDead(_9); -- StorageDead(_8); -- StorageDead(_7); -- StorageDead(_6); -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb25, unwind terminate(cleanup)]; -+ bb24: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb24, unwind continue]; - } - -- bb25 (cleanup): { -- resume; -+ bb25: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb25, unwind continue]; ++ _26 = move _38; ++ StorageDead(_27); ++ _38 = move _26; ++ StorageDead(_26); ++ _14 = const (); ++ goto -> bb2; } -- bb26 (cleanup): { +- bb23 (cleanup): { - StorageDead(_13); -- goto -> bb27; -- } -- -- bb27 (cleanup): { - StorageDead(_9); - StorageDead(_8); - StorageDead(_7); @@ -404,15 +371,20 @@ - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb25, unwind terminate(cleanup)]; -+ bb26: { -+ nop; +- drop(_1) -> [return: bb22, unwind terminate(cleanup)]; ++ bb15: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb15, unwind continue]; ++ } ++ ++ bb16: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb16, unwind continue]; ++ } ++ ++ bb17: { + (((*_36) as variant#3).0: &u32) = copy ((*_36).0: &u32); -+ nop; + (((*_36) as variant#3).1: u32) = copy ((*_36).1: u32); + StorageLive(_5); + _5 = &(((*_36) as variant#3).1: u32); -+ nop; + (((*_36) as variant#3).2: u32) = const 9_u32; + StorageLive(_7); + _7 = &(((*_36) as variant#3).2: u32); @@ -426,7 +398,7 @@ + _10 = {coroutine@$DIR/async_fn.rs:21:13: 21:18 (#0)} { y: move _11, z: move _12 }; + StorageDead(_12); + StorageDead(_11); -+ _9 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as IntoFuture>::into_future(move _10) -> [return: bb1, unwind: bb17]; ++ _9 = <{async block@$DIR/async_fn.rs:21:13: 21:18} as IntoFuture>::into_future(move _10) -> [return: bb1, unwind: bb12]; } } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir index 1ce52d353af34..e756ab348997a 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir @@ -5,7 +5,7 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { debug x => ((*_1).0: &u32); debug y => ((*_1).1: u32); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: &u32; let mut _9: {async block@$DIR/async_fn.rs:21:13: 21:18}; let mut _10: {async block@$DIR/async_fn.rs:21:13: 21:18}; @@ -19,10 +19,10 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { let mut _19: &mut {async block@$DIR/async_fn.rs:21:13: 21:18}; let mut _20: &mut std::task::Context<'_>; let mut _21: &mut std::task::Context<'_>; - let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: isize; let mut _25: !; - let mut _26: &mut std::task::Context<'_>; + let mut _26: std::future::ResumeTy; let mut _27: (); let mut _30: u32; let mut _31: u32; @@ -72,21 +72,17 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { bb0: { _35 = discriminant((*_1)); - switchInt(move _35) -> [0: bb9, 3: bb12, otherwise: bb13]; + switchInt(move _35) -> [0: bb7, 3: bb10, otherwise: bb11]; } bb1: { StorageDead(_27); StorageDead(_26); - drop((((*_1) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb2, unwind: bb6]; + drop((((*_1) as variant#3).3: {async block@$DIR/async_fn.rs:21:13: 21:18})) -> [return: bb2, unwind: bb5]; } bb2: { nop; - goto -> bb3; - } - - bb3: { StorageDead(_9); StorageDead(_8); StorageDead(_7); @@ -94,23 +90,19 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { StorageDead(_5); nop; nop; - goto -> bb10; + goto -> bb8; } - bb4: { + bb3: { return; } - bb5 (cleanup): { + bb4 (cleanup): { resume; } - bb6 (cleanup): { + bb5 (cleanup): { nop; - goto -> bb7; - } - - bb7 (cleanup): { StorageDead(_9); StorageDead(_8); StorageDead(_7); @@ -118,26 +110,26 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { StorageDead(_5); nop; nop; - goto -> bb5; + goto -> bb4; } - bb8: { + bb6: { return; } - bb9: { - goto -> bb11; + bb7: { + goto -> bb9; } - bb10: { - goto -> bb4; + bb8: { + goto -> bb3; } - bb11: { - goto -> bb8; + bb9: { + goto -> bb6; } - bb12: { + bb10: { StorageLive(_5); StorageLive(_7); StorageLive(_8); @@ -147,7 +139,7 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { goto -> bb1; } - bb13: { + bb11: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop_proxy_async.0.mir index f7038fc83baad..3eba8934af246 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn foo::{closure#0}(_1: {async fn body of foo()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -24,6 +26,8 @@ fn foo::{closure#0}(_1: {async fn body of foo()}, _2: &mut Context<'_>) -> Poll< } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.StateTransform.diff index fbbec5a970b73..01666cb6847cf 100644 --- a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn hello_world::{closure#0}(_1: {async fn body of hello_world()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn hello_world::{closure#0}(_1: Pin<&mut {async fn body of hello_world()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: [u8; 1]; @@ -18,8 +20,7 @@ + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s0, _s3), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s1, _s3), (_s2, _s0), (_s2, _s1), (_s2, _s2), (_s2, _s3), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _36; + coroutine debug data => _s0; + let mut _0: std::task::Poll<()>; let _3: [u8; 1]; @@ -43,16 +44,16 @@ let mut _24: &mut {async fn body of read_exact()}; let mut _25: &mut std::task::Context<'_>; let mut _26: &mut std::task::Context<'_>; -- let mut _27: std::future::ResumeTy; -+ let mut _27: &mut std::task::Context<'_>; + let mut _27: std::future::ResumeTy; let mut _28: isize; let mut _30: !; -- let mut _31: std::future::ResumeTy; -+ let mut _31: &mut std::task::Context<'_>; + let mut _31: std::future::ResumeTy; let mut _32: (); + let mut _33: (); + let mut _34: u32; + let mut _35: &mut {async fn body of hello_world()}; ++ let mut _36: std::future::ResumeTy; ++ let mut _37: std::ptr::NonNull>; scope 1 { - debug data => _3; + debug data => (((*_35) as variant#3).0: [u8; 1]); @@ -89,10 +90,12 @@ - _6 = &_3; - StorageLive(_7); - _7 = RangeFull; -- _5 = <[u8; 1] as Index>::index(move _6, move _7) -> [return: bb1, unwind: bb30]; +- _5 = <[u8; 1] as Index>::index(move _6, move _7) -> [return: bb1, unwind: bb27]; ++ _37 = move _2 as std::ptr::NonNull> (Transmute); ++ _36 = std::future::ResumeTy(move _37); + _35 = copy (_1.0: &mut {async fn body of hello_world()}); + _34 = discriminant((*_35)); -+ switchInt(move _34) -> [0: bb33, 1: bb32, 2: bb31, 3: bb30, otherwise: bb8]; ++ switchInt(move _34) -> [0: bb24, 1: bb23, 2: bb22, 3: bb21, otherwise: bb7]; } bb1: { @@ -102,7 +105,6 @@ - StorageLive(_8); - _8 = [const 0_u8; 1]; + (((*_35) as variant#3).1: &[u8]) = &(*_5); -+ nop; + (((*_35) as variant#3).2: [u8; 1]) = [const 0_u8; 1]; StorageLive(_9); StorageLive(_10); @@ -121,23 +123,21 @@ _16 = &mut (*_17); _15 = move _16 as &mut [u8] (PointerCoercion(Unsize, Implicit)); StorageDead(_16); -- _12 = read_exact(move _13, move _15) -> [return: bb2, unwind: bb27]; -+ _12 = read_exact(move _13, move _15) -> [return: bb2, unwind: bb22]; +- _12 = read_exact(move _13, move _15) -> [return: bb2, unwind: bb24]; ++ _12 = read_exact(move _13, move _15) -> [return: bb2, unwind: bb16]; } bb2: { StorageDead(_15); StorageDead(_13); -- _11 = <{async fn body of read_exact()} as IntoFuture>::into_future(move _12) -> [return: bb3, unwind: bb26]; -+ _11 = <{async fn body of read_exact()} as IntoFuture>::into_future(move _12) -> [return: bb3, unwind: bb21]; +- _11 = <{async fn body of read_exact()} as IntoFuture>::into_future(move _12) -> [return: bb3, unwind: bb25]; ++ _11 = <{async fn body of read_exact()} as IntoFuture>::into_future(move _12) -> [return: bb3, unwind: bb17]; } bb3: { StorageDead(_12); - PlaceMention(_11); - StorageLive(_18); - _18 = move _11; -+ nop; + (((*_35) as variant#3).3: {async fn body of read_exact()}) = move _11; goto -> bb4; } @@ -151,8 +151,8 @@ - _24 = &mut _18; + _24 = &mut (((*_35) as variant#3).3: {async fn body of read_exact()}); _23 = &mut (*_24); -- _22 = Pin::<&mut {async fn body of read_exact()}>::new_unchecked(move _23) -> [return: bb5, unwind: bb22]; -+ _22 = Pin::<&mut {async fn body of read_exact()}>::new_unchecked(move _23) -> [return: bb5, unwind: bb17]; +- _22 = Pin::<&mut {async fn body of read_exact()}>::new_unchecked(move _23) -> [return: bb5, unwind: bb20]; ++ _22 = Pin::<&mut {async fn body of read_exact()}>::new_unchecked(move _23) -> [return: bb5, unwind: bb13]; } bb5: { @@ -160,41 +160,44 @@ StorageLive(_25); StorageLive(_26); StorageLive(_27); - _27 = copy _2; -- _26 = std::future::get_context::<'_, '_>(move _27) -> [return: bb6, unwind: bb20]; -+ _26 = move _27; -+ goto -> bb6; - } - - bb6: { +- _27 = copy _2; +- _26 = std::future::get_context::<'_, '_>(move _27) -> [return: bb6, unwind: bb18]; +- } +- +- bb6: { ++ _27 = copy _36; ++ _26 = copy (_27.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _25 = &mut (*_26); StorageDead(_27); -- _21 = <{async fn body of read_exact()} as Future>::poll(move _22, move _25) -> [return: bb7, unwind: bb21]; -+ _21 = <{async fn body of read_exact()} as Future>::poll(move _22, move _25) -> [return: bb7, unwind: bb16]; +- _21 = <{async fn body of read_exact()} as Future>::poll(move _22, move _25) -> [return: bb7, unwind: bb19]; ++ _21 = <{async fn body of read_exact()} as Future>::poll(move _22, move _25) -> [return: bb6, unwind: bb12]; } - bb7: { +- bb7: { ++ bb6: { StorageDead(_26); StorageDead(_25); StorageDead(_24); StorageDead(_22); - PlaceMention(_21); _28 = discriminant(_21); - switchInt(move _28) -> [0: bb10, 1: bb9, otherwise: bb8]; +- switchInt(move _28) -> [0: bb10, 1: bb9, otherwise: bb8]; ++ switchInt(move _28) -> [0: bb9, 1: bb8, otherwise: bb7]; } - bb8: { +- bb8: { ++ bb7: { unreachable; } - bb9: { +- bb9: { ++ bb8: { _20 = const (); StorageDead(_21); StorageDead(_20); StorageLive(_31); StorageLive(_32); _32 = (); -- _31 = yield(move _32) -> [resume: bb11, drop: bb16]; +- _31 = yield(move _32) -> [resume: bb11, drop: bb15]; + _0 = Poll::<()>::Pending; + StorageDead(_5); + StorageDead(_9); @@ -208,38 +211,36 @@ + return; } - bb10: { +- bb10: { ++ bb9: { StorageLive(_29); _29 = copy ((_21 as Ready).0: std::option::Option<()>); _10 = copy _29; StorageDead(_29); StorageDead(_21); StorageDead(_20); -- drop(_18) -> [return: bb12, unwind: bb24]; -+ drop((((*_35) as variant#3).3: {async fn body of read_exact()})) -> [return: bb12, unwind: bb19]; +- drop(_18) -> [return: bb12, unwind: bb22]; ++ drop((((*_35) as variant#3).3: {async fn body of read_exact()})) -> [return: bb10, unwind: bb15]; } - bb11: { - StorageDead(_32); - _2 = move _31; - StorageDead(_31); - _19 = const (); - goto -> bb4; +- bb11: { +- StorageDead(_32); +- _2 = move _31; +- StorageDead(_31); +- _19 = const (); +- goto -> bb4; ++ bb10: { ++ _9 = Option::<()>::unwrap(move _10) -> [return: bb11, unwind: bb15]; } - bb12: { +- bb12: { - StorageDead(_18); -- _9 = Option::<()>::unwrap(move _10) -> [return: bb13, unwind: bb25]; -+ nop; -+ _9 = Option::<()>::unwrap(move _10) -> [return: bb13, unwind: bb20]; - } - - bb13: { +- _9 = Option::<()>::unwrap(move _10) -> [return: bb13, unwind: bb23]; +- } +- +- bb13: { ++ bb11: { StorageDead(_10); - goto -> bb14; - } - - bb14: { StorageDead(_17); StorageDead(_14); StorageDead(_11); @@ -247,35 +248,27 @@ - _0 = const (); - StorageDead(_8); + _33 = const (); -+ nop; StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb15, unwind: bb32]; -+ nop; -+ nop; -+ goto -> bb28; - } - - bb15: { +- drop(_1) -> [return: bb14, unwind: bb29]; +- } +- +- bb14: { + _0 = Poll::<()>::Ready(move _33); + discriminant((*_35)) = 1; return; } -- bb16: { +- bb15: { - StorageDead(_32); - StorageDead(_31); -- drop(_18) -> [return: bb17, unwind: bb33]; +- drop(_18) -> [return: bb16, unwind: bb30]; - } - -- bb17: { +- bb16: { - StorageDead(_18); - StorageDead(_10); -- goto -> bb18; -- } -- -- bb18: { - StorageDead(_17); - StorageDead(_14); - StorageDead(_11); @@ -284,130 +277,103 @@ - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb19, unwind: bb32]; +- drop(_1) -> [return: bb17, unwind: bb29]; - } - -- bb19: { +- bb17: { - coroutine_drop; - } - -- bb20 (cleanup): { +- bb18 (cleanup): { - StorageDead(_27); -- goto -> bb21; +- goto -> bb19; - } - -- bb21 (cleanup): { -+ bb16 (cleanup): { +- bb19 (cleanup): { ++ bb12 (cleanup): { StorageDead(_26); StorageDead(_25); -- goto -> bb23; -+ goto -> bb18; +- goto -> bb21; ++ goto -> bb14; } -- bb22 (cleanup): { -+ bb17 (cleanup): { +- bb20 (cleanup): { ++ bb13 (cleanup): { StorageDead(_23); -- goto -> bb23; -+ goto -> bb18; +- goto -> bb21; ++ goto -> bb14; } -- bb23 (cleanup): { -+ bb18 (cleanup): { +- bb21 (cleanup): { ++ bb14 (cleanup): { StorageDead(_24); StorageDead(_22); StorageDead(_21); StorageDead(_20); -- drop(_18) -> [return: bb24, unwind terminate(cleanup)]; -+ drop((((*_35) as variant#3).3: {async fn body of read_exact()})) -> [return: bb19, unwind terminate(cleanup)]; +- drop(_18) -> [return: bb22, unwind terminate(cleanup)]; ++ drop((((*_35) as variant#3).3: {async fn body of read_exact()})) -> [return: bb15, unwind terminate(cleanup)]; } -- bb24 (cleanup): { +- bb22 (cleanup): { - StorageDead(_18); -- goto -> bb25; -+ bb19 (cleanup): { -+ nop; -+ goto -> bb20; - } - -- bb25 (cleanup): { -+ bb20 (cleanup): { +- goto -> bb23; +- } +- +- bb23 (cleanup): { ++ bb15 (cleanup): { StorageDead(_10); -- goto -> bb29; -+ goto -> bb24; - } - -- bb26 (cleanup): { -- goto -> bb28; -+ bb21 (cleanup): { -+ goto -> bb23; +- goto -> bb26; ++ goto -> bb18; } -- bb27 (cleanup): { -+ bb22 (cleanup): { +- bb24 (cleanup): { ++ bb16 (cleanup): { StorageDead(_15); StorageDead(_13); -- goto -> bb28; -+ goto -> bb23; +- goto -> bb25; ++ goto -> bb17; } -- bb28 (cleanup): { -+ bb23 (cleanup): { +- bb25 (cleanup): { ++ bb17 (cleanup): { StorageDead(_12); StorageDead(_10); -- goto -> bb29; -+ goto -> bb24; +- goto -> bb26; ++ goto -> bb18; } -- bb29 (cleanup): { -+ bb24 (cleanup): { +- bb26 (cleanup): { ++ bb18 (cleanup): { StorageDead(_17); StorageDead(_14); StorageDead(_11); StorageDead(_9); - StorageDead(_8); -- goto -> bb31; -+ nop; -+ goto -> bb26; +- goto -> bb28; ++ goto -> bb20; } -- bb30 (cleanup): { -+ bb25 (cleanup): { +- bb27 (cleanup): { ++ bb19 (cleanup): { StorageDead(_7); StorageDead(_6); -- goto -> bb31; -+ goto -> bb26; +- goto -> bb28; ++ goto -> bb20; } -- bb31 (cleanup): { -+ bb26 (cleanup): { +- bb28 (cleanup): { ++ bb20 (cleanup): { StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb32, unwind terminate(cleanup)]; -+ nop; -+ nop; -+ goto -> bb27; - } - -- bb32 (cleanup): { -+ bb27 (cleanup): { -+ goto -> bb29; -+ } -+ -+ bb28: { -+ goto -> bb15; -+ } -+ -+ bb29 (cleanup): { +- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; + discriminant((*_35)) = 2; - resume; ++ resume; } -- bb33 (cleanup): { -- StorageDead(_18); -- StorageDead(_10); -- goto -> bb34; -+ bb30: { +- bb29 (cleanup): { +- resume; ++ bb21: { + StorageLive(_5); + StorageLive(_9); + StorageLive(_10); @@ -416,11 +382,17 @@ + StorageLive(_17); + StorageLive(_31); + StorageLive(_32); -+ _31 = move _2; -+ goto -> bb11; ++ _31 = move _36; ++ StorageDead(_32); ++ _36 = move _31; ++ StorageDead(_31); ++ _19 = const (); ++ goto -> bb4; } -- bb34 (cleanup): { +- bb30 (cleanup): { +- StorageDead(_18); +- StorageDead(_10); - StorageDead(_17); - StorageDead(_14); - StorageDead(_11); @@ -429,25 +401,23 @@ - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb32, unwind terminate(cleanup)]; -+ bb31: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb31, unwind continue]; +- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; ++ bb22: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb22, unwind continue]; + } + -+ bb32: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb32, unwind continue]; ++ bb23: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb23, unwind continue]; + } + -+ bb33: { -+ nop; ++ bb24: { + (((*_35) as variant#3).0: [u8; 1]) = [const 0_u8; 1]; -+ nop; + StorageLive(_5); + StorageLive(_6); + _6 = &(((*_35) as variant#3).0: [u8; 1]); + StorageLive(_7); + _7 = RangeFull; -+ _5 = <[u8; 1] as Index>::index(move _6, move _7) -> [return: bb1, unwind: bb25]; ++ _5 = <[u8; 1] as Index>::index(move _6, move _7) -> [return: bb1, unwind: bb19]; } } diff --git a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir index 2fd801f42122c..dcf3fae03a420 100644 --- a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir @@ -3,7 +3,7 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { debug _task_context => _2; let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: [u8; 1]; let _5: &[u8]; let mut _6: &[u8; 1]; @@ -25,10 +25,10 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { let mut _24: &mut {async fn body of read_exact()}; let mut _25: &mut std::task::Context<'_>; let mut _26: &mut std::task::Context<'_>; - let mut _27: &mut std::task::Context<'_>; + let mut _27: std::future::ResumeTy; let mut _28: isize; let mut _30: !; - let mut _31: &mut std::task::Context<'_>; + let mut _31: std::future::ResumeTy; let mut _32: (); let mut _33: (); let mut _34: u32; @@ -54,22 +54,18 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { bb0: { _34 = discriminant((*_1)); - switchInt(move _34) -> [0: bb9, 3: bb12, otherwise: bb13]; + switchInt(move _34) -> [0: bb7, 3: bb10, otherwise: bb11]; } bb1: { StorageDead(_32); StorageDead(_31); - drop((((*_1) as variant#3).3: {async fn body of read_exact()})) -> [return: bb2, unwind: bb6]; + drop((((*_1) as variant#3).3: {async fn body of read_exact()})) -> [return: bb2, unwind: bb5]; } bb2: { nop; StorageDead(_10); - goto -> bb3; - } - - bb3: { StorageDead(_17); StorageDead(_14); StorageDead(_11); @@ -78,24 +74,20 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { StorageDead(_5); nop; nop; - goto -> bb10; + goto -> bb8; } - bb4: { + bb3: { return; } - bb5 (cleanup): { + bb4 (cleanup): { resume; } - bb6 (cleanup): { + bb5 (cleanup): { nop; StorageDead(_10); - goto -> bb7; - } - - bb7 (cleanup): { StorageDead(_17); StorageDead(_14); StorageDead(_11); @@ -104,26 +96,26 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { StorageDead(_5); nop; nop; - goto -> bb5; + goto -> bb4; } - bb8: { + bb6: { return; } - bb9: { - goto -> bb11; + bb7: { + goto -> bb9; } - bb10: { - goto -> bb4; + bb8: { + goto -> bb3; } - bb11: { - goto -> bb8; + bb9: { + goto -> bb6; } - bb12: { + bb10: { StorageLive(_5); StorageLive(_9); StorageLive(_10); @@ -135,7 +127,7 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { goto -> bb1; } - bb13: { + bb11: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop_proxy_async.0.mir index f611658c30174..891d350d6c32d 100644 --- a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn hello_world::{closure#0}(_1: {async fn body of hello_world()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -14,6 +16,8 @@ fn hello_world::{closure#0}(_1: {async fn body of hello_world()}, _2: &mut Conte } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.StateTransform.diff index 00bddd77b6ced..5d791e4377257 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.StateTransform.diff @@ -4,6 +4,9 @@ - fn includes_never::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:61:18: 61:23}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (*(_1.0: &u32)); +- let mut _0: u32; + fn includes_never::{closure#0}::{closure#0}(_1: Pin<&mut {async block@$DIR/async_fn.rs:61:18: 61:23}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + variant_fields = { @@ -13,9 +16,7 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- debug x => (*(_1.0: &u32)); -- let mut _0: u32; ++ debug _task_context => _10; + debug x => (*((*_9).0: &u32)); + let mut _0: std::task::Poll; let mut _3: u32; @@ -25,54 +26,49 @@ + let mut _7: u32; + let mut _8: u32; + let mut _9: &mut {async block@$DIR/async_fn.rs:61:18: 61:23}; ++ let mut _10: std::future::ResumeTy; ++ let mut _11: std::ptr::NonNull>; bb0: { -- StorageLive(_3); -- _5 = no_retag copy (_1.0: &u32); -- _3 = copy (*_5); -- StorageLive(_4); -- _6 = no_retag copy (_1.0: &u32); -- _4 = copy (*_6); -- _0 = Mul(move _3, move _4); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb1, unwind: bb2]; ++ _11 = move _2 as std::ptr::NonNull> (Transmute); ++ _10 = std::future::ResumeTy(move _11); + _9 = copy (_1.0: &mut {async block@$DIR/async_fn.rs:61:18: 61:23}); + _8 = discriminant((*_9)); -+ switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; - } - - bb1: { -+ _0 = Poll::::Ready(move _7); -+ discriminant((*_9)) = 1; - return; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { -+ goto -> bb1; ++ switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; ++ bb1: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; + } + -+ bb4: { ++ bb2: { + unreachable; + } + -+ bb5: { -+ StorageLive(_3); ++ bb3: { + StorageLive(_3); +- _5 = no_retag copy (_1.0: &u32); + _5 = no_retag copy ((*_9).0: &u32); -+ _3 = copy (*_5); -+ StorageLive(_4); + _3 = copy (*_5); + StorageLive(_4); +- _6 = no_retag copy (_1.0: &u32); + _6 = no_retag copy ((*_9).0: &u32); -+ _4 = copy (*_6); + _4 = copy (*_6); +- _0 = Mul(move _3, move _4); + _7 = Mul(move _3, move _4); -+ StorageDead(_4); -+ StorageDead(_3); -+ goto -> bb2; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { ++ _0 = Poll::::Ready(move _7); ++ discriminant((*_9)) = 1; + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir index a17dbe3199dee..e367ee4f35112 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -4,7 +4,7 @@ fn includes_never::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn. debug _task_context => _2; debug x => (*((*_1).0: &u32)); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let mut _3: u32; let mut _4: u32; let mut _5: &u32; diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir index 11fefd8e962c4..8058024c54e96 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,8 +2,12 @@ fn includes_never::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:61:18: 61:23}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.StateTransform.diff index b51642673c26c..997b4f3b451fc 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.StateTransform.diff @@ -4,6 +4,9 @@ - fn includes_never::{closure#0}::{closure#1}(_1: {async block@$DIR/async_fn.rs:67:15: 67:20}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (*(_1.0: &u32)); +- let mut _0: u32; + fn includes_never::{closure#0}::{closure#1}(_1: Pin<&mut {async block@$DIR/async_fn.rs:67:15: 67:20}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + variant_fields = { @@ -13,9 +16,7 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- debug x => (*(_1.0: &u32)); -- let mut _0: u32; ++ debug _task_context => _10; + debug x => (*((*_9).0: &u32)); + let mut _0: std::task::Poll; let mut _3: u32; @@ -25,54 +26,49 @@ + let mut _7: u32; + let mut _8: u32; + let mut _9: &mut {async block@$DIR/async_fn.rs:67:15: 67:20}; ++ let mut _10: std::future::ResumeTy; ++ let mut _11: std::ptr::NonNull>; bb0: { -- StorageLive(_3); -- _5 = no_retag copy (_1.0: &u32); -- _3 = copy (*_5); -- StorageLive(_4); -- _6 = no_retag copy (_1.0: &u32); -- _4 = copy (*_6); -- _0 = Add(move _3, move _4); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb1, unwind: bb2]; ++ _11 = move _2 as std::ptr::NonNull> (Transmute); ++ _10 = std::future::ResumeTy(move _11); + _9 = copy (_1.0: &mut {async block@$DIR/async_fn.rs:67:15: 67:20}); + _8 = discriminant((*_9)); -+ switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; - } - - bb1: { -+ _0 = Poll::::Ready(move _7); -+ discriminant((*_9)) = 1; - return; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { -+ goto -> bb1; ++ switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; ++ bb1: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; + } + -+ bb4: { ++ bb2: { + unreachable; + } + -+ bb5: { -+ StorageLive(_3); ++ bb3: { + StorageLive(_3); +- _5 = no_retag copy (_1.0: &u32); + _5 = no_retag copy ((*_9).0: &u32); -+ _3 = copy (*_5); -+ StorageLive(_4); + _3 = copy (*_5); + StorageLive(_4); +- _6 = no_retag copy (_1.0: &u32); + _6 = no_retag copy ((*_9).0: &u32); -+ _4 = copy (*_6); + _4 = copy (*_6); +- _0 = Add(move _3, move _4); + _7 = Add(move _3, move _4); -+ StorageDead(_4); -+ StorageDead(_3); -+ goto -> bb2; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { ++ _0 = Poll::::Ready(move _7); ++ discriminant((*_9)) = 1; + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir index bf47e4c62f433..e62115da97a6b 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir @@ -4,7 +4,7 @@ fn includes_never::{closure#0}::{closure#1}(_1: &mut {async block@$DIR/async_fn. debug _task_context => _2; debug x => (*((*_1).0: &u32)); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let mut _3: u32; let mut _4: u32; let mut _5: &u32; diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop_proxy_async.0.mir index 8daa763583e8c..aa204dda81046 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop_proxy_async.0.mir @@ -2,8 +2,12 @@ fn includes_never::{closure#0}::{closure#1}(_1: {async block@$DIR/async_fn.rs:67:15: 67:20}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.StateTransform.diff index b3d14b5540c88..d96c8083b4546 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.StateTransform.diff @@ -4,6 +4,10 @@ - fn includes_never::{closure#0}(_1: {async fn body of includes_never()}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug crash => (_1.0: bool); +- debug x => (_1.1: u32); +- let mut _0: u32; + fn includes_never::{closure#0}(_1: Pin<&mut {async fn body of includes_never()}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + field _s0: bool; @@ -17,10 +21,7 @@ + } + storage_conflicts = BitMatrix(3x3) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s2, _s0), (_s2, _s1), (_s2, _s2)} + } - debug _task_context => _2; -- debug crash => (_1.0: bool); -- debug x => (_1.1: u32); -- let mut _0: u32; ++ debug _task_context => _51; + debug crash => ((*_50).0: bool); + debug x => ((*_50).1: u32); + coroutine debug crash => _s0; @@ -37,12 +38,10 @@ let mut _15: &mut {async block@$DIR/async_fn.rs:61:18: 61:23}; let mut _16: &mut std::task::Context<'_>; let mut _17: &mut std::task::Context<'_>; -- let mut _18: std::future::ResumeTy; -+ let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: isize; let mut _21: !; -- let mut _22: std::future::ResumeTy; -+ let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: (); let _24: (); let mut _25: bool; @@ -68,6 +67,8 @@ + let mut _48: u32; + let mut _49: u32; + let mut _50: &mut {async fn body of includes_never()}; ++ let mut _51: std::future::ResumeTy; ++ let mut _52: std::ptr::NonNull>; scope 1 { - debug crash => _3; + debug crash => (((*_50) as variant#3).0: bool); @@ -119,18 +120,18 @@ - _8 = &_4; - _7 = {coroutine@$DIR/async_fn.rs:61:18: 61:23 (#0)} { x: move _8 }; - StorageDead(_8); -- _6 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as IntoFuture>::into_future(move _7) -> [return: bb1, unwind: bb25]; +- _6 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as IntoFuture>::into_future(move _7) -> [return: bb1, unwind: bb23]; ++ _52 = move _2 as std::ptr::NonNull> (Transmute); ++ _51 = std::future::ResumeTy(move _52); + _50 = copy (_1.0: &mut {async fn body of includes_never()}); + _49 = discriminant((*_50)); -+ switchInt(move _49) -> [0: bb30, 1: bb29, 2: bb28, 3: bb27, otherwise: bb6]; ++ switchInt(move _49) -> [0: bb21, 1: bb20, 2: bb19, 3: bb18, otherwise: bb5]; } bb1: { StorageDead(_7); - PlaceMention(_6); - StorageLive(_9); - _9 = move _6; -+ nop; + (((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23}) = move _6; goto -> bb2; } @@ -144,8 +145,8 @@ - _15 = &mut _9; + _15 = &mut (((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23}); _14 = &mut (*_15); -- _13 = Pin::<&mut {async block@$DIR/async_fn.rs:61:18: 61:23}>::new_unchecked(move _14) -> [return: bb3, unwind: bb22]; -+ _13 = Pin::<&mut {async block@$DIR/async_fn.rs:61:18: 61:23}>::new_unchecked(move _14) -> [return: bb3, unwind: bb17]; +- _13 = Pin::<&mut {async block@$DIR/async_fn.rs:61:18: 61:23}>::new_unchecked(move _14) -> [return: bb3, unwind: bb20]; ++ _13 = Pin::<&mut {async block@$DIR/async_fn.rs:61:18: 61:23}>::new_unchecked(move _14) -> [return: bb3, unwind: bb13]; } bb3: { @@ -153,41 +154,44 @@ StorageLive(_16); StorageLive(_17); StorageLive(_18); - _18 = copy _2; -- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb4, unwind: bb20]; -+ _17 = move _18; -+ goto -> bb4; - } - - bb4: { +- _18 = copy _2; +- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb4, unwind: bb18]; +- } +- +- bb4: { ++ _18 = copy _51; ++ _17 = copy (_18.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _16 = &mut (*_17); StorageDead(_18); -- _12 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as Future>::poll(move _13, move _16) -> [return: bb5, unwind: bb21]; -+ _12 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as Future>::poll(move _13, move _16) -> [return: bb5, unwind: bb16]; +- _12 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as Future>::poll(move _13, move _16) -> [return: bb5, unwind: bb19]; ++ _12 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as Future>::poll(move _13, move _16) -> [return: bb4, unwind: bb12]; } - bb5: { +- bb5: { ++ bb4: { StorageDead(_17); StorageDead(_16); StorageDead(_15); StorageDead(_13); - PlaceMention(_12); _19 = discriminant(_12); - switchInt(move _19) -> [0: bb8, 1: bb7, otherwise: bb6]; +- switchInt(move _19) -> [0: bb8, 1: bb7, otherwise: bb6]; ++ switchInt(move _19) -> [0: bb7, 1: bb6, otherwise: bb5]; } - bb6: { +- bb6: { ++ bb5: { unreachable; } - bb7: { +- bb7: { ++ bb6: { _11 = const (); StorageDead(_12); StorageDead(_11); StorageLive(_22); StorageLive(_23); _23 = (); -- _22 = yield(move _23) -> [resume: bb9, drop: bb15]; +- _22 = yield(move _23) -> [resume: bb9, drop: bb14]; + _0 = Poll::::Pending; + StorageDead(_5); + StorageDead(_6); @@ -197,207 +201,184 @@ + return; } - bb8: { +- bb8: { ++ bb7: { StorageLive(_20); _20 = copy ((_12 as Ready).0: u32); _5 = copy _20; StorageDead(_20); StorageDead(_12); StorageDead(_11); -- drop(_9) -> [return: bb10, unwind: bb24]; -+ drop((((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb10, unwind: bb19]; - } - - bb9: { - StorageDead(_23); - _2 = move _22; - StorageDead(_22); - _10 = const (); - goto -> bb2; +- drop(_9) -> [return: bb10, unwind: bb22]; ++ drop((((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb8, unwind: bb16]; } - bb10: { +- bb9: { +- StorageDead(_23); +- _2 = move _22; +- StorageDead(_22); +- _10 = const (); +- goto -> bb2; +- } +- +- bb10: { - StorageDead(_9); -+ nop; - goto -> bb11; - } - - bb11: { ++ bb8: { StorageDead(_6); StorageLive(_24); StorageLive(_25); - _25 = copy _3; +- switchInt(move _25) -> [0: bb11, otherwise: bb12]; + _25 = copy (((*_50) as variant#3).0: bool); - switchInt(move _25) -> [0: bb12, otherwise: bb13]; ++ switchInt(move _25) -> [0: bb9, otherwise: bb10]; } - bb12: { +- bb11: { - _0 = copy _5; ++ bb9: { + _48 = copy _5; StorageDead(_25); StorageDead(_24); StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb14, unwind: bb29]; -+ nop; -+ nop; -+ goto -> bb25; +- drop(_1) -> [return: bb13, unwind: bb26]; ++ _0 = Poll::::Ready(move _48); ++ discriminant((*_50)) = 1; ++ return; } - bb13: { +- bb12: { ++ bb10: { _24 = const (); StorageDead(_25); StorageDead(_24); StorageLive(_27); -- _27 = never() -> bb19; -+ _27 = never() -> bb15; - } - - bb14: { -+ _0 = Poll::::Ready(move _48); -+ discriminant((*_50)) = 1; - return; +- _27 = never() -> bb17; ++ _27 = never() -> bb11; } -- bb15: { +- bb13: { +- return; +- } +- +- bb14: { - StorageDead(_23); - StorageDead(_22); -- drop(_9) -> [return: bb16, unwind: bb30]; -+ bb15 (cleanup): { -+ StorageDead(_27); -+ goto -> bb23; - } - -- bb16: { +- drop(_9) -> [return: bb15, unwind: bb27]; +- } +- +- bb15: { - StorageDead(_9); -- goto -> bb17; -+ bb16 (cleanup): { -+ StorageDead(_17); -+ StorageDead(_16); -+ goto -> bb18; - } - -- bb17: { - StorageDead(_6); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb18, unwind: bb29]; -+ bb17 (cleanup): { -+ StorageDead(_14); -+ goto -> bb18; - } - -- bb18: { +- drop(_1) -> [return: bb16, unwind: bb26]; +- } +- +- bb16: { - coroutine_drop; -+ bb18 (cleanup): { -+ StorageDead(_15); -+ StorageDead(_13); -+ StorageDead(_12); -+ StorageDead(_11); -+ drop((((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb19, unwind terminate(cleanup)]; - } - - bb19 (cleanup): { -- StorageDead(_27); -- goto -> bb28; -+ nop; -+ goto -> bb22; +- } +- +- bb17 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_27); +- goto -> bb25; ++ goto -> bb17; } - bb20 (cleanup): { +- bb18 (cleanup): { - StorageDead(_18); - goto -> bb21; - } - - bb21 (cleanup): { -- StorageDead(_17); -- StorageDead(_16); -- goto -> bb23; -+ StorageDead(_7); -+ goto -> bb22; +- goto -> bb19; +- } +- +- bb19 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_17); + StorageDead(_16); +- goto -> bb21; ++ goto -> bb14; } - bb22 (cleanup): { -- StorageDead(_14); -+ StorageDead(_6); - goto -> bb23; +- bb20 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_14); +- goto -> bb21; ++ goto -> bb14; } - bb23 (cleanup): { -- StorageDead(_15); -- StorageDead(_13); -- StorageDead(_12); -- StorageDead(_11); -- drop(_9) -> [return: bb24, unwind terminate(cleanup)]; -+ StorageDead(_5); -+ nop; -+ nop; -+ goto -> bb24; +- bb21 (cleanup): { ++ bb14 (cleanup): { + StorageDead(_15); + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); +- drop(_9) -> [return: bb22, unwind terminate(cleanup)]; ++ drop((((*_50) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb16, unwind terminate(cleanup)]; } - bb24 (cleanup): { +- bb22 (cleanup): { - StorageDead(_9); -- goto -> bb27; -+ goto -> bb26; +- goto -> bb24; +- } +- +- bb23 (cleanup): { ++ bb15 (cleanup): { + StorageDead(_7); +- goto -> bb24; ++ goto -> bb16; } -- bb25 (cleanup): { -- goto -> bb26; -+ bb25: { -+ goto -> bb14; +- bb24 (cleanup): { ++ bb16 (cleanup): { + StorageDead(_6); +- goto -> bb25; ++ goto -> bb17; } - bb26 (cleanup): { -- StorageDead(_7); -- goto -> bb27; +- bb25 (cleanup): { ++ bb17 (cleanup): { + StorageDead(_5); +- StorageDead(_4); +- StorageDead(_3); +- drop(_1) -> [return: bb26, unwind terminate(cleanup)]; + discriminant((*_50)) = 2; + resume; } -- bb27 (cleanup): { -- StorageDead(_6); -- goto -> bb28; -+ bb27: { +- bb26 (cleanup): { +- resume; ++ bb18: { + StorageLive(_5); + StorageLive(_6); + StorageLive(_22); + StorageLive(_23); -+ _22 = move _2; -+ goto -> bb9; - } - -- bb28 (cleanup): { -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; -+ bb28: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb28, unwind continue]; - } - -- bb29 (cleanup): { -- resume; -+ bb29: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb29, unwind continue]; ++ _22 = move _51; ++ StorageDead(_23); ++ _51 = move _22; ++ StorageDead(_22); ++ _10 = const (); ++ goto -> bb2; } -- bb30 (cleanup): { +- bb27 (cleanup): { - StorageDead(_9); -- goto -> bb31; -- } -- -- bb31 (cleanup): { - StorageDead(_6); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; -+ bb30: { -+ nop; +- drop(_1) -> [return: bb26, unwind terminate(cleanup)]; ++ bb19: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb19, unwind continue]; ++ } ++ ++ bb20: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb20, unwind continue]; ++ } ++ ++ bb21: { + (((*_50) as variant#3).0: bool) = copy ((*_50).0: bool); -+ nop; + (((*_50) as variant#3).1: u32) = copy ((*_50).1: u32); + StorageLive(_5); + StorageLive(_6); @@ -406,7 +387,7 @@ + _8 = &(((*_50) as variant#3).1: u32); + _7 = {coroutine@$DIR/async_fn.rs:61:18: 61:23 (#0)} { x: move _8 }; + StorageDead(_8); -+ _6 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as IntoFuture>::into_future(move _7) -> [return: bb1, unwind: bb20]; ++ _6 = <{async block@$DIR/async_fn.rs:61:18: 61:23} as IntoFuture>::into_future(move _7) -> [return: bb1, unwind: bb15]; } } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir index a701710ebfc58..9847ee17ed155 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir @@ -5,7 +5,7 @@ fn includes_never::{closure#0}(_1: &mut {async fn body of includes_never()}) -> debug crash => ((*_1).0: bool); debug x => ((*_1).1: u32); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: bool; let mut _6: {async block@$DIR/async_fn.rs:61:18: 61:23}; let mut _7: {async block@$DIR/async_fn.rs:61:18: 61:23}; @@ -18,10 +18,10 @@ fn includes_never::{closure#0}(_1: &mut {async fn body of includes_never()}) -> let mut _15: &mut {async block@$DIR/async_fn.rs:61:18: 61:23}; let mut _16: &mut std::task::Context<'_>; let mut _17: &mut std::task::Context<'_>; - let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: isize; let mut _21: !; - let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: (); let _24: (); let mut _25: bool; @@ -82,66 +82,58 @@ fn includes_never::{closure#0}(_1: &mut {async fn body of includes_never()}) -> bb0: { _49 = discriminant((*_1)); - switchInt(move _49) -> [0: bb9, 3: bb12, otherwise: bb13]; + switchInt(move _49) -> [0: bb7, 3: bb10, otherwise: bb11]; } bb1: { StorageDead(_23); StorageDead(_22); - drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb2, unwind: bb6]; + drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:61:18: 61:23})) -> [return: bb2, unwind: bb5]; } bb2: { nop; - goto -> bb3; - } - - bb3: { StorageDead(_6); StorageDead(_5); nop; nop; - goto -> bb10; + goto -> bb8; } - bb4: { + bb3: { return; } - bb5 (cleanup): { + bb4 (cleanup): { resume; } - bb6 (cleanup): { + bb5 (cleanup): { nop; - goto -> bb7; - } - - bb7 (cleanup): { StorageDead(_6); StorageDead(_5); nop; nop; - goto -> bb5; + goto -> bb4; } - bb8: { + bb6: { return; } - bb9: { - goto -> bb11; + bb7: { + goto -> bb9; } - bb10: { - goto -> bb4; + bb8: { + goto -> bb3; } - bb11: { - goto -> bb8; + bb9: { + goto -> bb6; } - bb12: { + bb10: { StorageLive(_5); StorageLive(_6); StorageLive(_22); @@ -149,7 +141,7 @@ fn includes_never::{closure#0}(_1: &mut {async fn body of includes_never()}) -> goto -> bb1; } - bb13: { + bb11: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop_proxy_async.0.mir index 4a6ceb7f1d4e9..0acb7d03405bb 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn includes_never::{closure#0}(_1: {async fn body of includes_never()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -22,6 +24,8 @@ fn includes_never::{closure#0}(_1: {async fn body of includes_never()}, _2: &mut } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.StateTransform.diff index 8f66ed130b333..568cd851afdd4 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.StateTransform.diff @@ -4,6 +4,9 @@ - fn partial_init::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:80:50: 80:55}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (*(_1.0: &u32)); +- let mut _0: u32; + fn partial_init::{closure#0}::{closure#0}(_1: Pin<&mut {async block@$DIR/async_fn.rs:80:50: 80:55}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + variant_fields = { @@ -13,9 +16,7 @@ + } + storage_conflicts = BitMatrix(0x0) {} + } - debug _task_context => _2; -- debug x => (*(_1.0: &u32)); -- let mut _0: u32; ++ debug _task_context => _10; + debug x => (*((*_9).0: &u32)); + let mut _0: std::task::Poll; let mut _3: u32; @@ -25,54 +26,49 @@ + let mut _7: u32; + let mut _8: u32; + let mut _9: &mut {async block@$DIR/async_fn.rs:80:50: 80:55}; ++ let mut _10: std::future::ResumeTy; ++ let mut _11: std::ptr::NonNull>; bb0: { -- StorageLive(_3); -- _5 = no_retag copy (_1.0: &u32); -- _3 = copy (*_5); -- StorageLive(_4); -- _6 = no_retag copy (_1.0: &u32); -- _4 = copy (*_6); -- _0 = Add(move _3, move _4); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb1, unwind: bb2]; ++ _11 = move _2 as std::ptr::NonNull> (Transmute); ++ _10 = std::future::ResumeTy(move _11); + _9 = copy (_1.0: &mut {async block@$DIR/async_fn.rs:80:50: 80:55}); + _8 = discriminant((*_9)); -+ switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; - } - - bb1: { -+ _0 = Poll::::Ready(move _7); -+ discriminant((*_9)) = 1; - return; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { -+ goto -> bb1; ++ switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + } + -+ bb3: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb3, unwind continue]; ++ bb1: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb1, unwind continue]; + } + -+ bb4: { ++ bb2: { + unreachable; + } + -+ bb5: { -+ StorageLive(_3); ++ bb3: { + StorageLive(_3); +- _5 = no_retag copy (_1.0: &u32); + _5 = no_retag copy ((*_9).0: &u32); -+ _3 = copy (*_5); -+ StorageLive(_4); + _3 = copy (*_5); + StorageLive(_4); +- _6 = no_retag copy (_1.0: &u32); + _6 = no_retag copy ((*_9).0: &u32); -+ _4 = copy (*_6); + _4 = copy (*_6); +- _0 = Add(move _3, move _4); + _7 = Add(move _3, move _4); -+ StorageDead(_4); -+ StorageDead(_3); -+ goto -> bb2; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { ++ _0 = Poll::::Ready(move _7); ++ discriminant((*_9)) = 1; + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir index 0261bfd7236f2..6cbf36dfed9e9 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -4,7 +4,7 @@ fn partial_init::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs debug _task_context => _2; debug x => (*((*_1).0: &u32)); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let mut _3: u32; let mut _4: u32; let mut _5: &u32; diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir index 3ddd757ef84e6..95842dccc1e19 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,8 +2,12 @@ fn partial_init::{closure#0}::{closure#0}(_1: {async block@$DIR/async_fn.rs:80:50: 80:55}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.StateTransform.diff index 7acd06e5e900c..5df2bfb719ffb 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.StateTransform.diff @@ -4,6 +4,9 @@ - fn partial_init::{closure#0}(_1: {async fn body of partial_init()}, _2: std::future::ResumeTy) -> u32 - yields () - { +- debug _task_context => _2; +- debug x => (_1.0: u32); +- let mut _0: u32; + fn partial_init::{closure#0}(_1: Pin<&mut {async fn body of partial_init()}>, _2: &mut Context<'_>) -> Poll { + coroutine layout { + field _s0: u32; @@ -17,9 +20,7 @@ + } + storage_conflicts = BitMatrix(3x3) {(_s0, _s0), (_s0, _s1), (_s0, _s2), (_s1, _s0), (_s1, _s1), (_s1, _s2), (_s2, _s0), (_s2, _s1), (_s2, _s2)} + } - debug _task_context => _2; -- debug x => (_1.0: u32); -- let mut _0: u32; ++ debug _task_context => _29; + debug x => ((*_28).0: u32); + coroutine debug x => _s0; + let mut _0: std::task::Poll; @@ -38,16 +39,16 @@ let mut _17: &mut {async block@$DIR/async_fn.rs:80:50: 80:55}; let mut _18: &mut std::task::Context<'_>; let mut _19: &mut std::task::Context<'_>; -- let mut _20: std::future::ResumeTy; -+ let mut _20: &mut std::task::Context<'_>; + let mut _20: std::future::ResumeTy; let mut _21: isize; let mut _23: !; -- let mut _24: std::future::ResumeTy; -+ let mut _24: &mut std::task::Context<'_>; + let mut _24: std::future::ResumeTy; let mut _25: (); + let mut _26: u32; + let mut _27: u32; + let mut _28: &mut {async fn body of partial_init()}; ++ let mut _29: std::future::ResumeTy; ++ let mut _30: std::ptr::NonNull>; scope 1 { - debug x => _3; + debug x => (((*_28) as variant#3).0: u32); @@ -75,10 +76,12 @@ - StorageLive(_4); - StorageLive(_5); - StorageLive(_6); -- _6 = String::new() -> [return: bb1, unwind: bb30]; +- _6 = String::new() -> [return: bb1, unwind: bb27]; ++ _30 = move _2 as std::ptr::NonNull> (Transmute); ++ _29 = std::future::ResumeTy(move _30); + _28 = copy (_1.0: &mut {async fn body of partial_init()}); + _27 = discriminant((*_28)); -+ switchInt(move _27) -> [0: bb32, 1: bb31, 2: bb30, 3: bb29, otherwise: bb7]; ++ switchInt(move _27) -> [0: bb21, 1: bb20, 2: bb19, 3: bb18, otherwise: bb6]; } bb1: { @@ -89,16 +92,14 @@ + _10 = &(((*_28) as variant#3).0: u32); _9 = {coroutine@$DIR/async_fn.rs:80:50: 80:55 (#0)} { x: move _10 }; StorageDead(_10); -- _8 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as IntoFuture>::into_future(move _9) -> [return: bb2, unwind: bb26]; -+ _8 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as IntoFuture>::into_future(move _9) -> [return: bb2, unwind: bb20]; +- _8 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as IntoFuture>::into_future(move _9) -> [return: bb2, unwind: bb24]; ++ _8 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as IntoFuture>::into_future(move _9) -> [return: bb2, unwind: bb15]; } bb2: { StorageDead(_9); - PlaceMention(_8); - StorageLive(_11); - _11 = move _8; -+ nop; + (((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55}) = move _8; goto -> bb3; } @@ -112,8 +113,8 @@ - _17 = &mut _11; + _17 = &mut (((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55}); _16 = &mut (*_17); -- _15 = Pin::<&mut {async block@$DIR/async_fn.rs:80:50: 80:55}>::new_unchecked(move _16) -> [return: bb4, unwind: bb22]; -+ _15 = Pin::<&mut {async block@$DIR/async_fn.rs:80:50: 80:55}>::new_unchecked(move _16) -> [return: bb4, unwind: bb16]; +- _15 = Pin::<&mut {async block@$DIR/async_fn.rs:80:50: 80:55}>::new_unchecked(move _16) -> [return: bb4, unwind: bb20]; ++ _15 = Pin::<&mut {async block@$DIR/async_fn.rs:80:50: 80:55}>::new_unchecked(move _16) -> [return: bb4, unwind: bb12]; } bb4: { @@ -121,41 +122,44 @@ StorageLive(_18); StorageLive(_19); StorageLive(_20); - _20 = copy _2; -- _19 = std::future::get_context::<'_, '_>(move _20) -> [return: bb5, unwind: bb20]; -+ _19 = move _20; -+ goto -> bb5; - } - - bb5: { +- _20 = copy _2; +- _19 = std::future::get_context::<'_, '_>(move _20) -> [return: bb5, unwind: bb18]; +- } +- +- bb5: { ++ _20 = copy _29; ++ _19 = copy (_20.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _18 = &mut (*_19); StorageDead(_20); -- _14 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as Future>::poll(move _15, move _18) -> [return: bb6, unwind: bb21]; -+ _14 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as Future>::poll(move _15, move _18) -> [return: bb6, unwind: bb15]; +- _14 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as Future>::poll(move _15, move _18) -> [return: bb6, unwind: bb19]; ++ _14 = <{async block@$DIR/async_fn.rs:80:50: 80:55} as Future>::poll(move _15, move _18) -> [return: bb5, unwind: bb11]; } - bb6: { +- bb6: { ++ bb5: { StorageDead(_19); StorageDead(_18); StorageDead(_17); StorageDead(_15); - PlaceMention(_14); _21 = discriminant(_14); - switchInt(move _21) -> [0: bb9, 1: bb8, otherwise: bb7]; +- switchInt(move _21) -> [0: bb9, 1: bb8, otherwise: bb7]; ++ switchInt(move _21) -> [0: bb8, 1: bb7, otherwise: bb6]; } - bb7: { +- bb7: { ++ bb6: { unreachable; } - bb8: { +- bb8: { ++ bb7: { _13 = const (); StorageDead(_14); StorageDead(_13); StorageLive(_24); StorageLive(_25); _25 = (); -- _24 = yield(move _25) -> [resume: bb10, drop: bb15]; +- _24 = yield(move _25) -> [resume: bb10, drop: bb14]; + _0 = Poll::::Pending; + StorageDead(_4); + StorageDead(_5); @@ -166,7 +170,8 @@ + return; } - bb9: { +- bb9: { ++ bb8: { StorageLive(_22); _22 = copy ((_14 as Ready).0: u32); - _0 = copy _22; @@ -174,214 +179,180 @@ StorageDead(_22); StorageDead(_14); StorageDead(_13); -- drop(_11) -> [return: bb11, unwind: bb24]; -+ drop((((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb11, unwind: bb18]; +- drop(_11) -> [return: bb11, unwind: bb22]; ++ drop((((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb9, unwind: bb14]; } - bb10: { - StorageDead(_25); - _2 = move _24; - StorageDead(_24); - _12 = const (); - goto -> bb3; +- bb10: { +- StorageDead(_25); +- _2 = move _24; +- StorageDead(_24); +- _12 = const (); +- goto -> bb3; ++ bb9: { ++ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb10, unwind: bb16]; } - bb11: { +- bb11: { - StorageDead(_11); -- drop(_6) -> [return: bb12, unwind: bb25]; -+ nop; -+ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb12, unwind: bb19]; - } - - bb12: { +- drop(_6) -> [return: bb12, unwind: bb23]; +- } +- +- bb12: { - StorageDead(_6); -+ nop; - goto -> bb13; - } - - bb13: { ++ bb10: { StorageDead(_8); StorageDead(_5); StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb14, unwind: bb32]; -+ nop; -+ goto -> bb27; - } - - bb14: { +- drop(_1) -> [return: bb13, unwind: bb29]; +- } +- +- bb13: { + _0 = Poll::::Ready(move _26); + discriminant((*_28)) = 1; return; } -- bb15: { +- bb14: { - StorageDead(_25); - StorageDead(_24); -- drop(_11) -> [return: bb16, unwind: bb33]; -+ bb15 (cleanup): { -+ StorageDead(_19); -+ StorageDead(_18); -+ goto -> bb17; - } - -- bb16: { +- drop(_11) -> [return: bb15, unwind: bb30]; +- } +- +- bb15: { - StorageDead(_11); -- drop(_6) -> [return: bb17, unwind: bb34]; -+ bb16 (cleanup): { -+ StorageDead(_16); -+ goto -> bb17; - } - -- bb17: { +- drop(_6) -> [return: bb16, unwind: bb31]; +- } +- +- bb16: { - StorageDead(_6); -- goto -> bb18; -+ bb17 (cleanup): { -+ StorageDead(_17); -+ StorageDead(_15); -+ StorageDead(_14); -+ StorageDead(_13); -+ drop((((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb18, unwind terminate(cleanup)]; - } - -- bb18: { - StorageDead(_8); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb19, unwind: bb32]; -+ bb18 (cleanup): { -+ nop; -+ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb19, unwind terminate(cleanup)]; - } - -- bb19: { +- drop(_1) -> [return: bb17, unwind: bb29]; +- } +- +- bb17: { - coroutine_drop; -+ bb19 (cleanup): { -+ nop; -+ goto -> bb23; - } - - bb20 (cleanup): { +- } +- +- bb18 (cleanup): { - StorageDead(_20); - goto -> bb21; - } - - bb21 (cleanup): { -- StorageDead(_19); -- StorageDead(_18); -- goto -> bb23; -+ StorageDead(_9); -+ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb22, unwind terminate(cleanup)]; +- goto -> bb19; +- } +- +- bb19 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_19); + StorageDead(_18); +- goto -> bb21; ++ goto -> bb13; } - bb22 (cleanup): { -- StorageDead(_16); -+ nop; - goto -> bb23; +- bb20 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_16); +- goto -> bb21; ++ goto -> bb13; } - bb23 (cleanup): { -- StorageDead(_17); -- StorageDead(_15); -- StorageDead(_14); -- StorageDead(_13); -- drop(_11) -> [return: bb24, unwind terminate(cleanup)]; -+ StorageDead(_8); -+ goto -> bb25; +- bb21 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_17); + StorageDead(_15); + StorageDead(_14); + StorageDead(_13); +- drop(_11) -> [return: bb22, unwind terminate(cleanup)]; ++ drop((((*_28) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb14, unwind terminate(cleanup)]; } - bb24 (cleanup): { +- bb22 (cleanup): { - StorageDead(_11); -- drop(_6) -> [return: bb25, unwind terminate(cleanup)]; -+ nop; -+ goto -> bb25; +- drop(_6) -> [return: bb23, unwind terminate(cleanup)]; ++ bb14 (cleanup): { ++ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb16, unwind terminate(cleanup)]; } - bb25 (cleanup): { +- bb23 (cleanup): { - StorageDead(_6); -- goto -> bb29; -+ StorageDead(_5); -+ StorageDead(_4); -+ nop; -+ goto -> bb26; +- goto -> bb26; +- } +- +- bb24 (cleanup): { ++ bb15 (cleanup): { + StorageDead(_9); +- drop(_6) -> [return: bb25, unwind terminate(cleanup)]; ++ drop((((*_28) as variant#3).1: std::string::String)) -> [return: bb16, unwind terminate(cleanup)]; } - bb26 (cleanup): { -- goto -> bb27; -+ goto -> bb28; +- bb25 (cleanup): { +- StorageDead(_6); +- goto -> bb26; +- } +- +- bb26 (cleanup): { ++ bb16 (cleanup): { + StorageDead(_8); +- goto -> bb28; ++ goto -> bb17; } - bb27 (cleanup): { -- StorageDead(_9); -- drop(_6) -> [return: bb28, unwind terminate(cleanup)]; -+ bb27: { -+ goto -> bb14; - } - - bb28 (cleanup): { - StorageDead(_6); -- goto -> bb29; +- goto -> bb28; +- } +- +- bb28 (cleanup): { ++ bb17 (cleanup): { + StorageDead(_5); + StorageDead(_4); +- StorageDead(_3); +- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; + discriminant((*_28)) = 2; + resume; } - bb29 (cleanup): { -- StorageDead(_8); -- goto -> bb31; -+ bb29: { +- resume; ++ bb18: { + StorageLive(_4); + StorageLive(_5); + StorageLive(_8); + StorageLive(_24); + StorageLive(_25); -+ _24 = move _2; -+ goto -> bb10; ++ _24 = move _29; ++ StorageDead(_25); ++ _29 = move _24; ++ StorageDead(_24); ++ _12 = const (); ++ goto -> bb3; } - bb30 (cleanup): { -- StorageDead(_6); -- goto -> bb31; -+ bb30: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb30, unwind continue]; +- StorageDead(_11); +- drop(_6) -> [return: bb31, unwind terminate(cleanup)]; ++ bb19: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb19, unwind continue]; } - bb31 (cleanup): { -- StorageDead(_5); -- StorageDead(_4); -- StorageDead(_3); -- drop(_1) -> [return: bb32, unwind terminate(cleanup)]; -+ bb31: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb31, unwind continue]; - } - -- bb32 (cleanup): { -- resume; -- } -- -- bb33 (cleanup): { -- StorageDead(_11); -- drop(_6) -> [return: bb34, unwind terminate(cleanup)]; -- } -- -- bb34 (cleanup): { - StorageDead(_6); -- goto -> bb35; -- } -- -- bb35 (cleanup): { - StorageDead(_8); - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); -- drop(_1) -> [return: bb32, unwind terminate(cleanup)]; -+ bb32: { -+ nop; +- drop(_1) -> [return: bb29, unwind terminate(cleanup)]; ++ bb20: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb20, unwind continue]; ++ } ++ ++ bb21: { + (((*_28) as variant#3).0: u32) = copy ((*_28).0: u32); + StorageLive(_4); + StorageLive(_5); -+ nop; -+ (((*_28) as variant#3).1: std::string::String) = String::new() -> [return: bb1, unwind: bb24]; ++ (((*_28) as variant#3).1: std::string::String) = String::new() -> [return: bb1, unwind: bb17]; } } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir index 20525a4cc712d..3abd7a5b5543b 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir @@ -4,7 +4,7 @@ fn partial_init::{closure#0}(_1: &mut {async fn body of partial_init()}) -> () { debug _task_context => _2; debug x => ((*_1).0: u32); let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: u32; let mut _4: !; let mut _6: std::string::String; @@ -20,10 +20,10 @@ fn partial_init::{closure#0}(_1: &mut {async fn body of partial_init()}) -> () { let mut _17: &mut {async block@$DIR/async_fn.rs:80:50: 80:55}; let mut _18: &mut std::task::Context<'_>; let mut _19: &mut std::task::Context<'_>; - let mut _20: &mut std::task::Context<'_>; + let mut _20: std::future::ResumeTy; let mut _21: isize; let mut _23: !; - let mut _24: &mut std::task::Context<'_>; + let mut _24: std::future::ResumeTy; let mut _25: (); let mut _26: u32; let mut _27: u32; @@ -47,76 +47,68 @@ fn partial_init::{closure#0}(_1: &mut {async fn body of partial_init()}) -> () { bb0: { _27 = discriminant((*_1)); - switchInt(move _27) -> [0: bb11, 3: bb14, otherwise: bb15]; + switchInt(move _27) -> [0: bb9, 3: bb12, otherwise: bb13]; } bb1: { StorageDead(_25); StorageDead(_24); - drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb2, unwind: bb7]; + drop((((*_1) as variant#3).2: {async block@$DIR/async_fn.rs:80:50: 80:55})) -> [return: bb2, unwind: bb6]; } bb2: { nop; - drop((((*_1) as variant#3).1: std::string::String)) -> [return: bb3, unwind: bb8]; + drop((((*_1) as variant#3).1: std::string::String)) -> [return: bb3, unwind: bb7]; } bb3: { nop; - goto -> bb4; - } - - bb4: { StorageDead(_8); StorageDead(_5); StorageDead(_4); nop; - goto -> bb12; + goto -> bb10; } - bb5: { + bb4: { return; } - bb6 (cleanup): { + bb5 (cleanup): { resume; } - bb7 (cleanup): { + bb6 (cleanup): { nop; - drop((((*_1) as variant#3).1: std::string::String)) -> [return: bb8, unwind terminate(cleanup)]; + drop((((*_1) as variant#3).1: std::string::String)) -> [return: bb7, unwind terminate(cleanup)]; } - bb8 (cleanup): { + bb7 (cleanup): { nop; - goto -> bb9; - } - - bb9 (cleanup): { StorageDead(_8); StorageDead(_5); StorageDead(_4); nop; - goto -> bb6; + goto -> bb5; } - bb10: { + bb8: { return; } - bb11: { - goto -> bb13; + bb9: { + goto -> bb11; } - bb12: { - goto -> bb5; + bb10: { + goto -> bb4; } - bb13: { - goto -> bb10; + bb11: { + goto -> bb8; } - bb14: { + bb12: { StorageLive(_4); StorageLive(_5); StorageLive(_8); @@ -125,7 +117,7 @@ fn partial_init::{closure#0}(_1: &mut {async fn body of partial_init()}) -> () { goto -> bb1; } - bb15: { + bb13: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop_proxy_async.0.mir index 1f67854bef25c..bbcda31ad6e55 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn partial_init::{closure#0}(_1: {async fn body of partial_init()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { } @@ -14,6 +16,8 @@ fn partial_init::{closure#0}(_1: {async fn body of partial_init()}, _2: &mut Con } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.StateTransform.diff index f29242c468c04..0f8e7f685a618 100644 --- a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.StateTransform.diff @@ -4,6 +4,8 @@ - fn uninhabited_variant::{closure#0}(_1: {async fn body of uninhabited_variant()}, _2: std::future::ResumeTy) -> () - yields () - { +- debug _task_context => _2; +- let mut _0: (); + fn uninhabited_variant::{closure#0}(_1: Pin<&mut {async fn body of uninhabited_variant()}>, _2: &mut Context<'_>) -> Poll<()> { + coroutine layout { + field _s0: {async block@$DIR/async_fn.rs:106:13: 106:18}; @@ -19,8 +21,7 @@ + } + storage_conflicts = BitMatrix(4x4) {(_s0, _s0), (_s0, _s2), (_s0, _s3), (_s1, _s1), (_s1, _s3), (_s2, _s0), (_s2, _s2), (_s2, _s3), (_s3, _s0), (_s3, _s1), (_s3, _s2), (_s3, _s3)} + } - debug _task_context => _2; -- let mut _0: (); ++ debug _task_context => _47; + coroutine debug c => _s0; + let mut _0: std::task::Poll<()>; let _3: {async block@$DIR/async_fn.rs:106:13: 106:18}; @@ -37,12 +38,10 @@ let mut _15: &mut {async block@$DIR/async_fn.rs:106:13: 106:18}; let mut _16: &mut std::task::Context<'_>; let mut _17: &mut std::task::Context<'_>; -- let mut _18: std::future::ResumeTy; -+ let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: isize; let mut _21: !; -- let mut _22: std::future::ResumeTy; -+ let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: (); let _25: (); let mut _26: {async fn body of uninhabited_variant::{closure#0}::unreachable()}; @@ -55,17 +54,17 @@ let mut _34: &mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}; let mut _35: &mut std::task::Context<'_>; let mut _36: &mut std::task::Context<'_>; -- let mut _37: std::future::ResumeTy; -+ let mut _37: &mut std::task::Context<'_>; + let mut _37: std::future::ResumeTy; let mut _38: isize; let mut _40: !; -- let mut _41: std::future::ResumeTy; -+ let mut _41: &mut std::task::Context<'_>; + let mut _41: std::future::ResumeTy; let mut _42: (); let mut _43: bool; + let mut _44: (); + let mut _45: u32; + let mut _46: &mut {async fn body of uninhabited_variant()}; ++ let mut _47: std::future::ResumeTy; ++ let mut _48: std::ptr::NonNull>; scope 1 { - debug c => _3; + debug c => (((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18}); @@ -102,12 +101,13 @@ - _3 = {coroutine@$DIR/async_fn.rs:106:13: 106:18 (#0)}; - StorageLive(_4); - _4 = Option::::None; -- PlaceMention(_4); - _5 = discriminant(_4); - switchInt(move _5) -> [0: bb3, 1: bb2, otherwise: bb1]; ++ _48 = move _2 as std::ptr::NonNull> (Transmute); ++ _47 = std::future::ResumeTy(move _48); + _46 = copy (_1.0: &mut {async fn body of uninhabited_variant()}); + _45 = discriminant((*_46)); -+ switchInt(move _45) -> [0: bb56, 1: bb55, 2: bb54, 3: bb52, 4: bb53, otherwise: bb1]; ++ switchInt(move _45) -> [0: bb40, 1: bb39, 2: bb38, 3: bb36, 4: bb37, otherwise: bb1]; } bb1: { @@ -122,8 +122,8 @@ StorageLive(_27); StorageLive(_28); _28 = move _24; -- _27 = uninhabited_variant::{closure#0}::unreachable(move _28) -> [return: bb14, unwind: bb43]; -+ _27 = uninhabited_variant::{closure#0}::unreachable(move _28) -> [return: bb14, unwind: bb33]; +- _27 = uninhabited_variant::{closure#0}::unreachable(move _28) -> [return: bb13, unwind: bb38]; ++ _27 = uninhabited_variant::{closure#0}::unreachable(move _28) -> [return: bb11, unwind: bb24]; } bb3: { @@ -132,18 +132,16 @@ StorageLive(_8); - _43 = const false; - _8 = move _3; -- _7 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as IntoFuture>::into_future(move _8) -> [return: bb4, unwind: bb51]; +- _7 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as IntoFuture>::into_future(move _8) -> [return: bb4, unwind: bb46]; + (((*_46) as variant#4).2: bool) = const false; + _8 = move (((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18}); -+ _7 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as IntoFuture>::into_future(move _8) -> [return: bb4, unwind: bb40]; ++ _7 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as IntoFuture>::into_future(move _8) -> [return: bb4, unwind: bb30]; } bb4: { StorageDead(_8); - PlaceMention(_7); - StorageLive(_9); - _9 = move _7; -+ nop; + (((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18}) = move _7; goto -> bb5; } @@ -157,8 +155,8 @@ - _15 = &mut _9; + _15 = &mut (((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18}); _14 = &mut (*_15); -- _13 = Pin::<&mut {async block@$DIR/async_fn.rs:106:13: 106:18}>::new_unchecked(move _14) -> [return: bb6, unwind: bb48]; -+ _13 = Pin::<&mut {async block@$DIR/async_fn.rs:106:13: 106:18}>::new_unchecked(move _14) -> [return: bb6, unwind: bb37]; +- _13 = Pin::<&mut {async block@$DIR/async_fn.rs:106:13: 106:18}>::new_unchecked(move _14) -> [return: bb6, unwind: bb43]; ++ _13 = Pin::<&mut {async block@$DIR/async_fn.rs:106:13: 106:18}>::new_unchecked(move _14) -> [return: bb6, unwind: bb28]; } bb6: { @@ -166,37 +164,39 @@ StorageLive(_16); StorageLive(_17); StorageLive(_18); - _18 = copy _2; -- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb7, unwind: bb46]; -+ _17 = move _18; -+ goto -> bb7; - } - - bb7: { +- _18 = copy _2; +- _17 = std::future::get_context::<'_, '_>(move _18) -> [return: bb7, unwind: bb41]; +- } +- +- bb7: { ++ _18 = copy _47; ++ _17 = copy (_18.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _16 = &mut (*_17); StorageDead(_18); -- _12 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as Future>::poll(move _13, move _16) -> [return: bb8, unwind: bb47]; -+ _12 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as Future>::poll(move _13, move _16) -> [return: bb8, unwind: bb36]; +- _12 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as Future>::poll(move _13, move _16) -> [return: bb8, unwind: bb42]; ++ _12 = <{async block@$DIR/async_fn.rs:106:13: 106:18} as Future>::poll(move _13, move _16) -> [return: bb7, unwind: bb27]; } - bb8: { +- bb8: { ++ bb7: { StorageDead(_17); StorageDead(_16); StorageDead(_15); StorageDead(_13); - PlaceMention(_12); _19 = discriminant(_12); - switchInt(move _19) -> [0: bb10, 1: bb9, otherwise: bb1]; +- switchInt(move _19) -> [0: bb10, 1: bb9, otherwise: bb1]; ++ switchInt(move _19) -> [0: bb9, 1: bb8, otherwise: bb1]; } - bb9: { +- bb9: { ++ bb8: { _11 = const (); StorageDead(_12); StorageDead(_11); StorageLive(_22); StorageLive(_23); _23 = (); -- _22 = yield(move _23) -> [resume: bb11, drop: bb31]; +- _22 = yield(move _23) -> [resume: bb11, drop: bb28]; + _0 = Poll::<()>::Pending; + StorageDead(_4); + StorageDead(_6); @@ -207,56 +207,56 @@ + return; } - bb10: { +- bb10: { ++ bb9: { StorageLive(_20); _20 = copy ((_12 as Ready).0: ()); _6 = copy _20; StorageDead(_20); StorageDead(_12); StorageDead(_11); -- drop(_9) -> [return: bb12, unwind: bb50]; -+ drop((((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb12, unwind: bb39]; +- drop(_9) -> [return: bb12, unwind: bb45]; ++ drop((((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb10, unwind: bb31]; } - bb11: { - StorageDead(_23); - _2 = move _22; - StorageDead(_22); - _10 = const (); - goto -> bb5; - } - - bb12: { +- bb11: { +- StorageDead(_23); +- _2 = move _22; +- StorageDead(_22); +- _10 = const (); +- goto -> bb5; +- } +- +- bb12: { - StorageDead(_9); -+ nop; - goto -> bb13; - } - - bb13: { ++ bb10: { StorageDead(_7); StorageDead(_6); - _0 = const (); +- goto -> bb23; + _44 = const (); - goto -> bb25; ++ goto -> bb19; } - bb14: { +- bb13: { ++ bb11: { StorageDead(_28); -- _26 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as IntoFuture>::into_future(move _27) -> [return: bb15, unwind: bb42]; -+ _26 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as IntoFuture>::into_future(move _27) -> [return: bb15, unwind: bb32]; +- _26 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as IntoFuture>::into_future(move _27) -> [return: bb14, unwind: bb39]; ++ _26 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as IntoFuture>::into_future(move _27) -> [return: bb12, unwind: bb25]; } - bb15: { +- bb14: { ++ bb12: { StorageDead(_27); - PlaceMention(_26); - StorageLive(_29); - _29 = move _26; -+ nop; +- goto -> bb15; + (((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()}) = move _26; - goto -> bb16; ++ goto -> bb13; } - bb16: { +- bb15: { ++ bb13: { StorageLive(_30); StorageLive(_31); StorageLive(_32); @@ -265,46 +265,49 @@ - _34 = &mut _29; + _34 = &mut (((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()}); _33 = &mut (*_34); -- _32 = Pin::<&mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}>::new_unchecked(move _33) -> [return: bb17, unwind: bb39]; -+ _32 = Pin::<&mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}>::new_unchecked(move _33) -> [return: bb17, unwind: bb29]; +- _32 = Pin::<&mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}>::new_unchecked(move _33) -> [return: bb16, unwind: bb35]; ++ _32 = Pin::<&mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}>::new_unchecked(move _33) -> [return: bb14, unwind: bb22]; } - bb17: { +- bb16: { ++ bb14: { StorageDead(_33); StorageLive(_35); StorageLive(_36); StorageLive(_37); - _37 = copy _2; -- _36 = std::future::get_context::<'_, '_>(move _37) -> [return: bb18, unwind: bb37]; -+ _36 = move _37; -+ goto -> bb18; - } - - bb18: { +- _37 = copy _2; +- _36 = std::future::get_context::<'_, '_>(move _37) -> [return: bb17, unwind: bb33]; +- } +- +- bb17: { ++ _37 = copy _47; ++ _36 = copy (_37.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); _35 = &mut (*_36); StorageDead(_37); -- _31 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as Future>::poll(move _32, move _35) -> [return: bb19, unwind: bb38]; -+ _31 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as Future>::poll(move _32, move _35) -> [return: bb19, unwind: bb28]; +- _31 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as Future>::poll(move _32, move _35) -> [return: bb18, unwind: bb34]; ++ _31 = <{async fn body of uninhabited_variant::{closure#0}::unreachable()} as Future>::poll(move _32, move _35) -> [return: bb15, unwind: bb21]; } - bb19: { +- bb18: { ++ bb15: { StorageDead(_36); StorageDead(_35); StorageDead(_34); StorageDead(_32); - PlaceMention(_31); _38 = discriminant(_31); - switchInt(move _38) -> [0: bb21, 1: bb20, otherwise: bb1]; +- switchInt(move _38) -> [0: bb20, 1: bb19, otherwise: bb1]; ++ switchInt(move _38) -> [0: bb17, 1: bb16, otherwise: bb1]; } - bb20: { +- bb19: { ++ bb16: { _30 = const (); StorageDead(_31); StorageDead(_30); StorageLive(_41); StorageLive(_42); _42 = (); -- _41 = yield(move _42) -> [resume: bb22, drop: bb28]; +- _41 = yield(move _42) -> [resume: bb21, drop: bb26]; + _0 = Poll::<()>::Pending; + StorageDead(_4); + StorageDead(_24); @@ -316,366 +319,308 @@ + return; } - bb21: { +- bb20: { ++ bb17: { StorageLive(_39); _39 = copy ((_31 as Ready).0: ()); _25 = copy _39; StorageDead(_39); StorageDead(_31); StorageDead(_30); -- drop(_29) -> [return: bb23, unwind: bb41]; -+ drop((((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb23, unwind: bb31]; - } - - bb22: { - StorageDead(_42); - _2 = move _41; - StorageDead(_41); - _10 = const (); - goto -> bb16; +- drop(_29) -> [return: bb22, unwind: bb37]; ++ drop((((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb18, unwind: bb26]; } - bb23: { +- bb21: { +- StorageDead(_42); +- _2 = move _41; +- StorageDead(_41); +- _10 = const (); +- goto -> bb15; +- } +- +- bb22: { - StorageDead(_29); -+ nop; - goto -> bb24; - } - - bb24: { ++ bb18: { StorageDead(_26); StorageDead(_25); - _0 = const (); + _44 = const (); StorageDead(_24); - goto -> bb25; +- goto -> bb23; ++ goto -> bb19; } - bb25: { +- bb23: { ++ bb19: { StorageDead(_4); -- goto -> bb64; -+ goto -> bb47; +- switchInt(copy _43) -> [0: bb24, otherwise: bb55]; ++ switchInt(copy (((*_46) as variant#4).2: bool)) -> [0: bb20, otherwise: bb34]; } - bb26: { +- bb24: { - _43 = const false; - StorageDead(_3); -- drop(_1) -> [return: bb27, unwind: bb56]; +- drop(_1) -> [return: bb25, unwind: bb50]; +- } +- +- bb25: { ++ bb20: { + (((*_46) as variant#4).2: bool) = const false; -+ nop; -+ goto -> bb50; - } - - bb27: { + _0 = Poll::<()>::Ready(move _44); + discriminant((*_46)) = 1; return; } -- bb28: { +- bb26: { - StorageDead(_42); - StorageDead(_41); -- drop(_29) -> [return: bb29, unwind: bb57]; +- drop(_29) -> [return: bb27, unwind: bb51]; - } - -- bb29: { +- bb27: { - StorageDead(_29); -- goto -> bb30; -- } -- -- bb30: { - StorageDead(_26); - StorageDead(_25); - StorageDead(_24); -- goto -> bb34; +- goto -> bb30; - } - -- bb31: { +- bb28: { - StorageDead(_23); - StorageDead(_22); -- drop(_9) -> [return: bb32, unwind: bb59]; +- drop(_9) -> [return: bb29, unwind: bb52]; - } - -- bb32: { +- bb29: { - StorageDead(_9); -- goto -> bb33; -- } -- -- bb33: { - StorageDead(_7); - StorageDead(_6); -- goto -> bb34; +- goto -> bb30; - } - -- bb34: { +- bb30: { - StorageDead(_4); -- goto -> bb66; +- switchInt(copy _43) -> [0: bb31, otherwise: bb56]; - } - -- bb35: { +- bb31: { - _43 = const false; - StorageDead(_3); -- drop(_1) -> [return: bb36, unwind: bb56]; +- drop(_1) -> [return: bb32, unwind: bb50]; - } - -- bb36: { +- bb32: { - coroutine_drop; - } - -- bb37 (cleanup): { +- bb33 (cleanup): { - StorageDead(_37); -- goto -> bb38; +- goto -> bb34; - } - -- bb38 (cleanup): { -+ bb28 (cleanup): { +- bb34 (cleanup): { ++ bb21 (cleanup): { StorageDead(_36); StorageDead(_35); -- goto -> bb40; -+ goto -> bb30; +- goto -> bb36; ++ goto -> bb23; } -- bb39 (cleanup): { -+ bb29 (cleanup): { +- bb35 (cleanup): { ++ bb22 (cleanup): { StorageDead(_33); -- goto -> bb40; -+ goto -> bb30; +- goto -> bb36; ++ goto -> bb23; } -- bb40 (cleanup): { -+ bb30 (cleanup): { +- bb36 (cleanup): { ++ bb23 (cleanup): { StorageDead(_34); StorageDead(_32); StorageDead(_31); StorageDead(_30); -- drop(_29) -> [return: bb41, unwind terminate(cleanup)]; -+ drop((((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb31, unwind terminate(cleanup)]; +- drop(_29) -> [return: bb37, unwind terminate(cleanup)]; ++ drop((((*_46) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb26, unwind terminate(cleanup)]; } -- bb41 (cleanup): { +- bb37 (cleanup): { - StorageDead(_29); -- goto -> bb45; -+ bb31 (cleanup): { -+ nop; -+ goto -> bb35; - } - -- bb42 (cleanup): { -- goto -> bb44; -+ bb32 (cleanup): { -+ goto -> bb34; - } - -- bb43 (cleanup): { -+ bb33 (cleanup): { +- goto -> bb40; +- } +- +- bb38 (cleanup): { ++ bb24 (cleanup): { StorageDead(_28); -- goto -> bb44; -+ goto -> bb34; +- goto -> bb39; ++ goto -> bb25; } -- bb44 (cleanup): { -+ bb34 (cleanup): { +- bb39 (cleanup): { ++ bb25 (cleanup): { StorageDead(_27); -- goto -> bb45; -+ goto -> bb35; +- goto -> bb40; ++ goto -> bb26; } -- bb45 (cleanup): { -+ bb35 (cleanup): { +- bb40 (cleanup): { ++ bb26 (cleanup): { StorageDead(_26); StorageDead(_25); StorageDead(_24); -- goto -> bb54; -+ goto -> bb43; +- goto -> bb48; ++ goto -> bb32; } -- bb46 (cleanup): { +- bb41 (cleanup): { - StorageDead(_18); -- goto -> bb47; +- goto -> bb42; - } - -- bb47 (cleanup): { -+ bb36 (cleanup): { +- bb42 (cleanup): { ++ bb27 (cleanup): { StorageDead(_17); StorageDead(_16); -- goto -> bb49; -+ goto -> bb38; +- goto -> bb44; ++ goto -> bb29; } -- bb48 (cleanup): { -+ bb37 (cleanup): { +- bb43 (cleanup): { ++ bb28 (cleanup): { StorageDead(_14); -- goto -> bb49; -+ goto -> bb38; +- goto -> bb44; ++ goto -> bb29; } -- bb49 (cleanup): { -+ bb38 (cleanup): { +- bb44 (cleanup): { ++ bb29 (cleanup): { StorageDead(_15); StorageDead(_13); StorageDead(_12); StorageDead(_11); -- drop(_9) -> [return: bb50, unwind terminate(cleanup)]; -+ drop((((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb39, unwind terminate(cleanup)]; +- drop(_9) -> [return: bb45, unwind terminate(cleanup)]; ++ drop((((*_46) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb31, unwind terminate(cleanup)]; } -- bb50 (cleanup): { +- bb45 (cleanup): { - StorageDead(_9); -- goto -> bb53; -+ bb39 (cleanup): { -+ nop; -+ goto -> bb42; - } - -- bb51 (cleanup): { -- goto -> bb52; -+ bb40 (cleanup): { -+ goto -> bb41; - } - -- bb52 (cleanup): { -+ bb41 (cleanup): { +- goto -> bb47; +- } +- +- bb46 (cleanup): { ++ bb30 (cleanup): { StorageDead(_8); -- goto -> bb53; -+ goto -> bb42; +- goto -> bb47; ++ goto -> bb31; } -- bb53 (cleanup): { -+ bb42 (cleanup): { +- bb47 (cleanup): { ++ bb31 (cleanup): { StorageDead(_7); StorageDead(_6); -- goto -> bb54; -+ goto -> bb43; +- goto -> bb48; ++ goto -> bb32; } -- bb54 (cleanup): { -+ bb43 (cleanup): { +- bb48 (cleanup): { ++ bb32 (cleanup): { StorageDead(_4); -- goto -> bb68; -+ goto -> bb49; +- switchInt(copy _43) -> [0: bb49, otherwise: bb57]; ++ switchInt(copy (((*_46) as variant#4).2: bool)) -> [0: bb33, otherwise: bb35]; } -- bb55 (cleanup): { +- bb49 (cleanup): { - _43 = const false; - StorageDead(_3); -- drop(_1) -> [return: bb56, unwind terminate(cleanup)]; -+ bb44 (cleanup): { +- drop(_1) -> [return: bb50, unwind terminate(cleanup)]; +- } +- +- bb50 (cleanup): { ++ bb33 (cleanup): { + (((*_46) as variant#4).2: bool) = const false; -+ nop; -+ goto -> bb45; - } - -- bb56 (cleanup): { -- resume; -+ bb45 (cleanup): { -+ goto -> bb51; ++ discriminant((*_46)) = 2; + resume; } -- bb57 (cleanup): { +- bb51 (cleanup): { - StorageDead(_29); -- goto -> bb58; -+ bb46: { -+ drop((((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb26, unwind: bb44]; - } - -- bb58 (cleanup): { - StorageDead(_26); - StorageDead(_25); - StorageDead(_24); -- goto -> bb61; -+ bb47: { -+ switchInt(copy (((*_46) as variant#4).2: bool)) -> [0: bb26, otherwise: bb46]; +- goto -> bb53; ++ bb34: { ++ drop((((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb20, unwind: bb33]; } -- bb59 (cleanup): { +- bb52 (cleanup): { - StorageDead(_9); -- goto -> bb60; -+ bb48 (cleanup): { -+ drop((((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb44, unwind terminate(cleanup)]; - } - -- bb60 (cleanup): { - StorageDead(_7); - StorageDead(_6); -- goto -> bb61; -+ bb49 (cleanup): { -+ switchInt(copy (((*_46) as variant#4).2: bool)) -> [0: bb44, otherwise: bb48]; +- goto -> bb53; ++ bb35 (cleanup): { ++ drop((((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb33, unwind terminate(cleanup)]; } -- bb61 (cleanup): { +- bb53 (cleanup): { - StorageDead(_4); -- goto -> bb70; -+ bb50: { -+ goto -> bb27; - } - -- bb62 (cleanup): { -- _43 = const false; -- StorageDead(_3); -- drop(_1) -> [return: bb56, unwind terminate(cleanup)]; -+ bb51 (cleanup): { -+ discriminant((*_46)) = 2; -+ resume; - } - -- bb63: { -- drop(_3) -> [return: bb26, unwind: bb55]; -+ bb52: { +- switchInt(copy _43) -> [0: bb54, otherwise: bb58]; ++ bb36: { + StorageLive(_4); + StorageLive(_6); + StorageLive(_7); + StorageLive(_22); + StorageLive(_23); -+ _22 = move _2; -+ goto -> bb11; ++ _22 = move _47; ++ StorageDead(_23); ++ _47 = move _22; ++ StorageDead(_22); ++ _10 = const (); ++ goto -> bb5; } -- bb64: { -- switchInt(copy _43) -> [0: bb26, otherwise: bb63]; -+ bb53: { +- bb54 (cleanup): { +- _43 = const false; +- StorageDead(_3); +- drop(_1) -> [return: bb50, unwind terminate(cleanup)]; ++ bb37: { + StorageLive(_4); + StorageLive(_24); + StorageLive(_25); + StorageLive(_26); + StorageLive(_41); + StorageLive(_42); -+ _41 = move _2; -+ goto -> bb22; ++ _41 = move _47; ++ StorageDead(_42); ++ _47 = move _41; ++ StorageDead(_41); ++ _10 = const (); ++ goto -> bb13; } -- bb65: { -- drop(_3) -> [return: bb35, unwind: bb62]; -+ bb54: { -+ assert(const false, "`async fn` resumed after panicking") -> [success: bb54, unwind continue]; +- bb55: { +- drop(_3) -> [return: bb24, unwind: bb49]; ++ bb38: { ++ assert(const false, "`async fn` resumed after panicking") -> [success: bb38, unwind continue]; } -- bb66: { -- switchInt(copy _43) -> [0: bb35, otherwise: bb65]; -+ bb55: { -+ assert(const false, "`async fn` resumed after completion") -> [success: bb55, unwind continue]; +- bb56: { +- drop(_3) -> [return: bb31, unwind: bb54]; ++ bb39: { ++ assert(const false, "`async fn` resumed after completion") -> [success: bb39, unwind continue]; } -- bb67 (cleanup): { -- drop(_3) -> [return: bb55, unwind terminate(cleanup)]; -- } -- -- bb68 (cleanup): { -- switchInt(copy _43) -> [0: bb55, otherwise: bb67]; -- } -- -- bb69 (cleanup): { -- drop(_3) -> [return: bb62, unwind terminate(cleanup)]; +- bb57 (cleanup): { +- drop(_3) -> [return: bb49, unwind terminate(cleanup)]; - } - -- bb70 (cleanup): { -- switchInt(copy _43) -> [0: bb62, otherwise: bb69]; -+ bb56: { +- bb58 (cleanup): { +- drop(_3) -> [return: bb54, unwind terminate(cleanup)]; ++ bb40: { + (((*_46) as variant#4).2: bool) = const false; -+ nop; + (((*_46) as variant#4).2: bool) = const true; + (((*_46) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18}) = {coroutine@$DIR/async_fn.rs:106:13: 106:18 (#0)}; + StorageLive(_4); + _4 = Option::::None; -+ PlaceMention(_4); + _5 = discriminant(_4); + switchInt(move _5) -> [0: bb3, 1: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir index 31b418c7efad9..3534b79527f25 100644 --- a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir @@ -3,7 +3,7 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_variant()}) -> () { debug _task_context => _2; let mut _0: (); - let mut _2: &mut std::task::Context<'_>; + let mut _2: std::future::ResumeTy; let _3: {async block@$DIR/async_fn.rs:106:13: 106:18}; let mut _4: std::option::Option; let mut _5: isize; @@ -18,10 +18,10 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_varia let mut _15: &mut {async block@$DIR/async_fn.rs:106:13: 106:18}; let mut _16: &mut std::task::Context<'_>; let mut _17: &mut std::task::Context<'_>; - let mut _18: &mut std::task::Context<'_>; + let mut _18: std::future::ResumeTy; let mut _19: isize; let mut _21: !; - let mut _22: &mut std::task::Context<'_>; + let mut _22: std::future::ResumeTy; let mut _23: (); let _25: (); let mut _26: {async fn body of uninhabited_variant::{closure#0}::unreachable()}; @@ -34,10 +34,10 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_varia let mut _34: &mut {async fn body of uninhabited_variant::{closure#0}::unreachable()}; let mut _35: &mut std::task::Context<'_>; let mut _36: &mut std::task::Context<'_>; - let mut _37: &mut std::task::Context<'_>; + let mut _37: std::future::ResumeTy; let mut _38: isize; let mut _40: !; - let mut _41: &mut std::task::Context<'_>; + let mut _41: std::future::ResumeTy; let mut _42: (); let mut _43: bool; let mut _44: (); @@ -68,139 +68,115 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_varia bb0: { _45 = discriminant((*_1)); - switchInt(move _45) -> [0: bb22, 3: bb25, 4: bb26, otherwise: bb27]; + switchInt(move _45) -> [0: bb16, 3: bb19, 4: bb20, otherwise: bb21]; } bb1: { StorageDead(_42); StorageDead(_41); - drop((((*_1) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb2, unwind: bb11]; + drop((((*_1) as variant#4).1: {async fn body of uninhabited_variant::{closure#0}::unreachable()})) -> [return: bb2, unwind: bb9]; } bb2: { nop; - goto -> bb3; - } - - bb3: { StorageDead(_26); StorageDead(_25); StorageDead(_24); - goto -> bb7; + goto -> bb5; } - bb4: { + bb3: { StorageDead(_23); StorageDead(_22); - drop((((*_1) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb5, unwind: bb13]; + drop((((*_1) as variant#3).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb4, unwind: bb10]; } - bb5: { + bb4: { nop; - goto -> bb6; - } - - bb6: { StorageDead(_7); StorageDead(_6); - goto -> bb7; + goto -> bb5; } - bb7: { + bb5: { StorageDead(_4); - goto -> bb18; + switchInt(copy (((*_1) as variant#4).2: bool)) -> [0: bb6, otherwise: bb13]; } - bb8: { + bb6: { (((*_1) as variant#4).2: bool) = const false; nop; - goto -> bb23; + goto -> bb17; } - bb9: { + bb7: { return; } - bb10 (cleanup): { + bb8 (cleanup): { resume; } - bb11 (cleanup): { + bb9 (cleanup): { nop; - goto -> bb12; - } - - bb12 (cleanup): { StorageDead(_26); StorageDead(_25); StorageDead(_24); - goto -> bb15; + goto -> bb11; } - bb13 (cleanup): { + bb10 (cleanup): { nop; - goto -> bb14; - } - - bb14 (cleanup): { StorageDead(_7); StorageDead(_6); - goto -> bb15; + goto -> bb11; } - bb15 (cleanup): { + bb11 (cleanup): { StorageDead(_4); - goto -> bb20; + switchInt(copy (((*_1) as variant#4).2: bool)) -> [0: bb12, otherwise: bb14]; } - bb16 (cleanup): { + bb12 (cleanup): { (((*_1) as variant#4).2: bool) = const false; nop; - goto -> bb10; - } - - bb17: { - drop((((*_1) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb8, unwind: bb16]; + goto -> bb8; } - bb18: { - switchInt(copy (((*_1) as variant#4).2: bool)) -> [0: bb8, otherwise: bb17]; + bb13: { + drop((((*_1) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb6, unwind: bb12]; } - bb19 (cleanup): { - drop((((*_1) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb16, unwind terminate(cleanup)]; - } - - bb20 (cleanup): { - switchInt(copy (((*_1) as variant#4).2: bool)) -> [0: bb16, otherwise: bb19]; + bb14 (cleanup): { + drop((((*_1) as variant#4).0: {async block@$DIR/async_fn.rs:106:13: 106:18})) -> [return: bb12, unwind terminate(cleanup)]; } - bb21: { + bb15: { return; } - bb22: { - goto -> bb24; + bb16: { + goto -> bb18; } - bb23: { - goto -> bb9; + bb17: { + goto -> bb7; } - bb24: { - goto -> bb21; + bb18: { + goto -> bb15; } - bb25: { + bb19: { StorageLive(_4); StorageLive(_6); StorageLive(_7); StorageLive(_22); StorageLive(_23); - goto -> bb4; + goto -> bb3; } - bb26: { + bb20: { StorageLive(_4); StorageLive(_24); StorageLive(_25); @@ -210,7 +186,7 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_varia goto -> bb1; } - bb27: { + bb21: { return; } } diff --git a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop_proxy_async.0.mir b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop_proxy_async.0.mir index f460d8984bacf..124debea519c1 100644 --- a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop_proxy_async.0.mir +++ b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop_proxy_async.0.mir @@ -2,6 +2,8 @@ fn uninhabited_variant::{closure#0}(_1: {async fn body of uninhabited_variant()}, _2: &mut Context<'_>) -> Poll<()> { let mut _0: std::task::Poll<()>; + let mut _3: std::future::ResumeTy; + let mut _4: std::ptr::NonNull>; scope 1 { scope 2 { scope 3 { @@ -16,6 +18,8 @@ fn uninhabited_variant::{closure#0}(_1: {async fn body of uninhabited_variant()} } bb0: { + _4 = move _2 as std::ptr::NonNull> (Transmute); + _3 = std::future::ResumeTy(move _4); drop(_1) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff index 17671228295e3..08b715091d289 100644 --- a/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff @@ -44,46 +44,37 @@ - StorageLive(_5); - StorageLive(_6); - _6 = &_2; -- _5 = ::clone(move _6) -> [return: bb1, unwind: bb31]; +- _5 = ::clone(move _6) -> [return: bb1, unwind: bb22]; + _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]; ++ switchInt(move _17) -> [0: bb24, 1: bb22, 2: bb21, 3: bb19, 4: bb20, otherwise: bb23]; } bb1: { StorageDead(_6); StorageLive(_7); -- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb30]; -+ _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; +- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; ++ _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb13]; } bb2: { _4 = (const "first", move _5, move _7); StorageDead(_7); - goto -> bb3; - } - - bb3: { StorageDead(_5); -- _3 = yield(move _4) -> [resume: bb4, drop: bb18]; +- _3 = yield(move _4) -> [resume: bb3, drop: bb12]; +- } +- +- bb3: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _4); + StorageDead(_3); -+ StorageDead(_4); + StorageDead(_4); +- drop(_3) -> [return: bb4, unwind: bb24]; + discriminant((*_18)) = 3; + return; } - bb4: { - goto -> bb5; - } - - bb5: { - StorageDead(_4); -- drop(_3) -> [return: bb6, unwind: bb34]; -+ drop(_3) -> [return: bb6, unwind: bb25]; - } - - bb6: { +- bb4: { ++ bb3: { StorageDead(_3); StorageLive(_8); StorageLive(_9); @@ -94,252 +85,213 @@ StorageLive(_12); StorageLive(_13); - _13 = &_2; -- _12 = ::clone(move _13) -> [return: bb7, unwind: bb28]; +- _12 = ::clone(move _13) -> [return: bb5, unwind: bb19]; + _13 = &(((*_18) as variant#4).0: std::string::String); -+ _12 = ::clone(move _13) -> [return: bb7, unwind: bb19]; ++ _12 = ::clone(move _13) -> [return: bb4, unwind: bb11]; } - bb7: { +- bb5: { ++ bb4: { StorageDead(_13); StorageLive(_14); StorageLive(_15); -- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb24]; -+ _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb15]; +- _15 = Location::<'_>::caller() -> [return: bb6, unwind: bb16]; ++ _15 = Location::<'_>::caller() -> [return: bb5, unwind: bb8]; } - bb8: { +- bb6: { ++ bb5: { _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]; +- _8 = yield(move _9) -> [resume: bb7, drop: bb11]; +- } +- +- bb7: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _9); + StorageDead(_8); -+ StorageDead(_9); -+ StorageDead(_11); + StorageDead(_9); +- drop(_8) -> [return: bb8, unwind: bb18]; +- } +- +- bb8: { +- StorageDead(_15); + StorageDead(_11); +- StorageDead(_8); +- _0 = const (); +- drop(_2) -> [return: bb9, unwind: bb26]; +- } +- +- bb9: { +- drop(_1) -> [return: bb10, unwind: bb27]; +- } +- +- bb10: { + StorageDead(_15); + discriminant((*_18)) = 4; -+ return; - } - - bb10: { - goto -> bb11; - } - - bb11: { - StorageDead(_9); -- drop(_8) -> [return: bb12, unwind: bb27]; -+ drop(_8) -> [return: bb12, unwind: bb18]; + return; } - bb12: { +- bb11: { +- StorageDead(_9); ++ bb6: { StorageDead(_15); StorageDead(_11); StorageDead(_8); -- _0 = const (); -- drop(_2) -> [return: bb13, unwind: bb36]; +- goto -> bb13; + _16 = const (); -+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb13, unwind: bb27]; - } - - bb13: { -- drop(_1) -> [return: bb14, unwind: bb37]; -+ goto -> bb29; ++ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb7, unwind: bb18]; } - bb14: { +- bb12: { +- StorageDead(_4); +- StorageDead(_3); +- goto -> bb13; ++ bb7: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Complete(move _16); + discriminant((*_18)) = 1; - return; ++ return; } +- bb13: { +- drop(_2) -> [return: bb14, unwind: bb28]; +- } +- +- bb14: { +- drop(_1) -> [return: bb15, unwind: bb27]; +- } +- - 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; +- coroutine_drop; +- } +- +- bb16 (cleanup): { ++ bb8 (cleanup): { + StorageDead(_14); +- drop(_12) -> [return: bb17, unwind terminate(cleanup)]; ++ drop(_12) -> [return: bb9, unwind terminate(cleanup)]; } -- bb21: { -- drop(_2) -> [return: bb22, unwind: bb38]; -+ bb21 (cleanup): { -+ StorageDead(_7); -+ drop(_5) -> [return: bb23, unwind terminate(cleanup)]; +- bb17 (cleanup): { ++ bb9 (cleanup): { + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); +- goto -> bb18; ++ goto -> bb10; } -- bb22: { -- drop(_1) -> [return: bb23, unwind: bb37]; -+ bb22 (cleanup): { -+ StorageDead(_6); -+ goto -> bb23; +- bb18 (cleanup): { ++ bb10 (cleanup): { + StorageDead(_15); +- goto -> bb20; ++ goto -> bb12; } -- bb23: { -- coroutine_drop; -+ bb23 (cleanup): { -+ StorageDead(_5); -+ goto -> bb24; +- bb19 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_13); + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); +- goto -> bb20; ++ goto -> bb12; } - bb24 (cleanup): { -- StorageDead(_14); -- drop(_12) -> [return: bb25, unwind terminate(cleanup)]; -+ StorageDead(_4); -+ goto -> bb25; +- bb20 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_11); + StorageDead(_8); +- goto -> bb25; ++ goto -> bb17; } - bb25 (cleanup): { -- StorageDead(_12); -- StorageDead(_10); -+ StorageDead(_3); - goto -> bb26; +- bb21 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_7); +- drop(_5) -> [return: bb23, unwind terminate(cleanup)]; ++ drop(_5) -> [return: bb15, unwind terminate(cleanup)]; } - bb26 (cleanup): { -- StorageDead(_9); -- goto -> bb27; -+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb27, unwind terminate(cleanup)]; +- bb22 (cleanup): { ++ bb14 (cleanup): { + StorageDead(_6); +- goto -> bb23; ++ goto -> bb15; } - bb27 (cleanup): { -- StorageDead(_15); -- goto -> bb29; -+ goto -> bb28; +- bb23 (cleanup): { ++ bb15 (cleanup): { + StorageDead(_5); + StorageDead(_4); +- goto -> bb24; ++ goto -> bb16; } - bb28 (cleanup): { -- StorageDead(_13); -- StorageDead(_12); -- StorageDead(_10); -- StorageDead(_9); -- goto -> bb29; -+ goto -> bb30; +- bb24 (cleanup): { ++ bb16 (cleanup): { + StorageDead(_3); +- goto -> bb25; ++ goto -> bb17; } -- bb29 (cleanup): { -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb35; -+ bb29: { -+ goto -> bb14; +- bb25 (cleanup): { +- drop(_2) -> [return: bb26, unwind terminate(cleanup)]; ++ bb17 (cleanup): { ++ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb18, unwind terminate(cleanup)]; } - bb30 (cleanup): { -- StorageDead(_7); -- drop(_5) -> [return: bb32, unwind terminate(cleanup)]; +- bb26 (cleanup): { +- drop(_1) -> [return: bb27, unwind terminate(cleanup)]; ++ bb18 (cleanup): { + discriminant((*_18)) = 2; + resume; } -- bb31 (cleanup): { -- StorageDead(_6); -- goto -> bb32; -+ bb31: { +- bb27 (cleanup): { +- resume; ++ bb19: { + StorageLive(_3); + StorageLive(_4); + _3 = move _2; -+ goto -> bb4; ++ StorageDead(_4); ++ drop(_3) -> [return: bb3, unwind: bb16]; } -- bb32 (cleanup): { -- StorageDead(_5); -- goto -> bb33; -+ bb32: { +- bb28 (cleanup): { +- drop(_1) -> [return: bb27, unwind terminate(cleanup)]; ++ bb20: { + 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: { ++ StorageDead(_9); ++ drop(_8) -> [return: bb6, unwind: bb10]; ++ } ++ ++ bb21: { ++ assert(const false, "coroutine resumed after panicking") -> [success: bb21, unwind continue]; ++ } ++ ++ bb22: { ++ assert(const false, "coroutine resumed after completion") -> [success: bb22, unwind continue]; ++ } ++ ++ bb23: { + unreachable; - } - -- bb36 (cleanup): { -- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; -- } -- -- bb37 (cleanup): { -- resume; -- } -- -- bb38 (cleanup): { -- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; -+ bb36: { ++ } ++ ++ bb24: { + (((*_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 = ::clone(move _6) -> [return: bb1, unwind: bb22]; ++ _5 = ::clone(move _6) -> [return: bb1, unwind: bb14]; } } diff --git a/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff index 97c45da8a18f1..bccde77074157 100644 --- a/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff @@ -44,46 +44,37 @@ - StorageLive(_5); - StorageLive(_6); - _6 = &_2; -- _5 = ::clone(move _6) -> [return: bb1, unwind: bb31]; +- _5 = ::clone(move _6) -> [return: bb1, unwind: bb22]; + _18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:26:5: 26:18}); + _17 = discriminant((*_18)); -+ switchInt(move _17) -> [0: bb36, 1: bb34, 2: bb33, 3: bb31, 4: bb32, otherwise: bb35]; ++ switchInt(move _17) -> [0: bb24, 1: bb22, 2: bb21, 3: bb19, 4: bb20, otherwise: bb23]; } bb1: { StorageDead(_6); StorageLive(_7); -- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb30]; -+ _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; +- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; ++ _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb13]; } bb2: { _4 = (const "first", move _5, move _7); StorageDead(_7); - goto -> bb3; - } - - bb3: { StorageDead(_5); -- _3 = yield(move _4) -> [resume: bb4, drop: bb18]; +- _3 = yield(move _4) -> [resume: bb3, drop: bb12]; +- } +- +- bb3: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _4); + StorageDead(_3); -+ StorageDead(_4); + StorageDead(_4); +- drop(_3) -> [return: bb4, unwind: bb24]; + discriminant((*_18)) = 3; + return; } - bb4: { - goto -> bb5; - } - - bb5: { - StorageDead(_4); -- drop(_3) -> [return: bb6, unwind: bb34]; -+ drop(_3) -> [return: bb6, unwind: bb25]; - } - - bb6: { +- bb4: { ++ bb3: { StorageDead(_3); StorageLive(_8); StorageLive(_9); @@ -94,252 +85,213 @@ StorageLive(_12); StorageLive(_13); - _13 = &_2; -- _12 = ::clone(move _13) -> [return: bb7, unwind: bb28]; +- _12 = ::clone(move _13) -> [return: bb5, unwind: bb19]; + _13 = &(((*_18) as variant#4).0: std::string::String); -+ _12 = ::clone(move _13) -> [return: bb7, unwind: bb19]; ++ _12 = ::clone(move _13) -> [return: bb4, unwind: bb11]; } - bb7: { +- bb5: { ++ bb4: { StorageDead(_13); StorageLive(_14); StorageLive(_15); -- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb24]; -+ _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb15]; +- _15 = Location::<'_>::caller() -> [return: bb6, unwind: bb16]; ++ _15 = Location::<'_>::caller() -> [return: bb5, unwind: bb8]; } - bb8: { +- bb6: { ++ bb5: { _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]; +- _8 = yield(move _9) -> [resume: bb7, drop: bb11]; +- } +- +- bb7: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _9); + StorageDead(_8); -+ StorageDead(_9); -+ StorageDead(_11); + StorageDead(_9); +- drop(_8) -> [return: bb8, unwind: bb18]; +- } +- +- bb8: { +- StorageDead(_15); + StorageDead(_11); +- StorageDead(_8); +- _0 = const (); +- drop(_2) -> [return: bb9, unwind: bb26]; +- } +- +- bb9: { +- drop(_1) -> [return: bb10, unwind: bb27]; +- } +- +- bb10: { + StorageDead(_15); + discriminant((*_18)) = 4; -+ return; - } - - bb10: { - goto -> bb11; - } - - bb11: { - StorageDead(_9); -- drop(_8) -> [return: bb12, unwind: bb27]; -+ drop(_8) -> [return: bb12, unwind: bb18]; + return; } - bb12: { +- bb11: { +- StorageDead(_9); ++ bb6: { StorageDead(_15); StorageDead(_11); StorageDead(_8); -- _0 = const (); -- drop(_2) -> [return: bb13, unwind: bb36]; +- goto -> bb13; + _16 = const (); -+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb13, unwind: bb27]; - } - - bb13: { -- drop(_1) -> [return: bb14, unwind: bb37]; -+ goto -> bb29; ++ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb7, unwind: bb18]; } - bb14: { +- bb12: { +- StorageDead(_4); +- StorageDead(_3); +- goto -> bb13; ++ bb7: { + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Complete(move _16); + discriminant((*_18)) = 1; - return; ++ return; } +- bb13: { +- drop(_2) -> [return: bb14, unwind: bb28]; +- } +- +- bb14: { +- drop(_1) -> [return: bb15, unwind: bb27]; +- } +- - 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; +- coroutine_drop; +- } +- +- bb16 (cleanup): { ++ bb8 (cleanup): { + StorageDead(_14); +- drop(_12) -> [return: bb17, unwind terminate(cleanup)]; ++ drop(_12) -> [return: bb9, unwind terminate(cleanup)]; } -- bb21: { -- drop(_2) -> [return: bb22, unwind: bb38]; -+ bb21 (cleanup): { -+ StorageDead(_7); -+ drop(_5) -> [return: bb23, unwind terminate(cleanup)]; +- bb17 (cleanup): { ++ bb9 (cleanup): { + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); +- goto -> bb18; ++ goto -> bb10; } -- bb22: { -- drop(_1) -> [return: bb23, unwind: bb37]; -+ bb22 (cleanup): { -+ StorageDead(_6); -+ goto -> bb23; +- bb18 (cleanup): { ++ bb10 (cleanup): { + StorageDead(_15); +- goto -> bb20; ++ goto -> bb12; } -- bb23: { -- coroutine_drop; -+ bb23 (cleanup): { -+ StorageDead(_5); -+ goto -> bb24; +- bb19 (cleanup): { ++ bb11 (cleanup): { + StorageDead(_13); + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); +- goto -> bb20; ++ goto -> bb12; } - bb24 (cleanup): { -- StorageDead(_14); -- drop(_12) -> [return: bb25, unwind terminate(cleanup)]; -+ StorageDead(_4); -+ goto -> bb25; +- bb20 (cleanup): { ++ bb12 (cleanup): { + StorageDead(_11); + StorageDead(_8); +- goto -> bb25; ++ goto -> bb17; } - bb25 (cleanup): { -- StorageDead(_12); -- StorageDead(_10); -+ StorageDead(_3); - goto -> bb26; +- bb21 (cleanup): { ++ bb13 (cleanup): { + StorageDead(_7); +- drop(_5) -> [return: bb23, unwind terminate(cleanup)]; ++ drop(_5) -> [return: bb15, unwind terminate(cleanup)]; } - bb26 (cleanup): { -- StorageDead(_9); -- goto -> bb27; -+ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb27, unwind terminate(cleanup)]; +- bb22 (cleanup): { ++ bb14 (cleanup): { + StorageDead(_6); +- goto -> bb23; ++ goto -> bb15; } - bb27 (cleanup): { -- StorageDead(_15); -- goto -> bb29; -+ goto -> bb28; +- bb23 (cleanup): { ++ bb15 (cleanup): { + StorageDead(_5); + StorageDead(_4); +- goto -> bb24; ++ goto -> bb16; } - bb28 (cleanup): { -- StorageDead(_13); -- StorageDead(_12); -- StorageDead(_10); -- StorageDead(_9); -- goto -> bb29; -+ goto -> bb30; +- bb24 (cleanup): { ++ bb16 (cleanup): { + StorageDead(_3); +- goto -> bb25; ++ goto -> bb17; } -- bb29 (cleanup): { -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb35; -+ bb29: { -+ goto -> bb14; +- bb25 (cleanup): { +- drop(_2) -> [return: bb26, unwind terminate(cleanup)]; ++ bb17 (cleanup): { ++ drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb18, unwind terminate(cleanup)]; } - bb30 (cleanup): { -- StorageDead(_7); -- drop(_5) -> [return: bb32, unwind terminate(cleanup)]; +- bb26 (cleanup): { +- drop(_1) -> [return: bb27, unwind terminate(cleanup)]; ++ bb18 (cleanup): { + discriminant((*_18)) = 2; + resume; } -- bb31 (cleanup): { -- StorageDead(_6); -- goto -> bb32; -+ bb31: { +- bb27 (cleanup): { +- resume; ++ bb19: { + StorageLive(_3); + StorageLive(_4); + _3 = move _2; -+ goto -> bb4; ++ StorageDead(_4); ++ drop(_3) -> [return: bb3, unwind: bb16]; } -- bb32 (cleanup): { -- StorageDead(_5); -- goto -> bb33; -+ bb32: { +- bb28 (cleanup): { +- drop(_1) -> [return: bb27, unwind terminate(cleanup)]; ++ bb20: { + 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: { ++ StorageDead(_9); ++ drop(_8) -> [return: bb6, unwind: bb10]; ++ } ++ ++ bb21: { ++ assert(const false, "coroutine resumed after panicking") -> [success: bb21, unwind continue]; ++ } ++ ++ bb22: { ++ assert(const false, "coroutine resumed after completion") -> [success: bb22, unwind continue]; ++ } ++ ++ bb23: { + unreachable; - } - -- bb36 (cleanup): { -- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; -- } -- -- bb37 (cleanup): { -- resume; -- } -- -- bb38 (cleanup): { -- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; -+ bb36: { ++ } ++ ++ bb24: { + (((*_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 = ::clone(move _6) -> [return: bb1, unwind: bb22]; ++ _5 = ::clone(move _6) -> [return: bb1, unwind: bb14]; } } diff --git a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir index f01f48598142c..d8fbedcac2984 100644 --- a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir +++ b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir @@ -6,19 +6,17 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 let _3: std::string::String; let _4: (); let mut _5: (); - let mut _6: (); - let mut _7: u32; + let mut _6: u32; scope 1 { debug _s => (((*_1) as variant#3).0: std::string::String); } bb0: { - _7 = discriminant((*_1)); - switchInt(move _7) -> [0: bb5, 3: bb8, otherwise: bb9]; + _6 = discriminant((*_1)); + switchInt(move _6) -> [0: bb5, 3: bb8, otherwise: bb9]; } bb1: { - StorageDead(_5); StorageDead(_4); drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind unreachable]; } @@ -50,7 +48,6 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 bb8: { StorageLive(_4); - StorageLive(_5); goto -> bb1; } diff --git a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir index 64d45346b93c3..ed4417daab5a3 100644 --- a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir +++ b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir @@ -6,19 +6,17 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 let _3: std::string::String; let _4: (); let mut _5: (); - let mut _6: (); - let mut _7: u32; + let mut _6: u32; scope 1 { debug _s => (((*_1) as variant#3).0: std::string::String); } bb0: { - _7 = discriminant((*_1)); - switchInt(move _7) -> [0: bb7, 3: bb10, otherwise: bb11]; + _6 = discriminant((*_1)); + switchInt(move _6) -> [0: bb7, 3: bb10, otherwise: bb11]; } bb1: { - StorageDead(_5); StorageDead(_4); drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; } @@ -59,7 +57,6 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 bb10: { StorageLive(_4); - StorageLive(_5); goto -> bb1; } diff --git a/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-abort.diff b/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-abort.diff index 9e4fb0cb64788..d2d3ceaacc182 100644 --- a/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-abort.diff +++ b/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-abort.diff @@ -5,6 +5,7 @@ - yields () - { - let mut _0: (); +- let _3: Foo; + fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}>, _2: ()) -> CoroutineState<(), ()> { + coroutine layout { + field _s0: Foo; @@ -19,24 +20,23 @@ + } + coroutine debug a => _s0; + let mut _0: std::ops::CoroutineState<(), ()>; - let _3: Foo; ++ let _3: (); ++ let mut _4: Foo; let _5: (); - let mut _6: (); - let _7: (); - let mut _8: Foo; - let _9: (); - let mut _10: Bar; -+ let mut _11: (); -+ let mut _12: u32; -+ let mut _13: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}; +- let _6: (); +- let mut _7: Foo; +- let _8: (); ++ let mut _6: (); ++ let mut _7: u32; ++ let mut _8: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}; scope 1 { - debug a => _3; -+ debug a => (((*_13) as variant#3).0: Foo); +- let _4: Bar; ++ debug a => (((*_8) as variant#3).0: Foo); + coroutine debug b => _s1; - let _4: Bar; scope 2 { - debug b => _4; -+ debug b => (((*_13) as variant#3).1: Bar); ++ debug b => (((*_8) as variant#3).1: Bar); } } @@ -46,95 +46,71 @@ - StorageLive(_4); - _4 = Bar(const 6_i32); - StorageLive(_5); -- StorageLive(_6); -- _6 = (); -- _5 = yield(move _6) -> [resume: bb1, drop: bb6]; -+ _13 = copy (_1.0: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}); -+ _12 = discriminant((*_13)); -+ switchInt(move _12) -> [0: bb10, 1: bb8, 3: bb7, otherwise: bb9]; +- _5 = yield(const ()) -> [resume: bb1, drop: bb5]; ++ _8 = copy (_1.0: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}); ++ _7 = discriminant((*_8)); ++ switchInt(move _7) -> [0: bb6, 1: bb4, 3: bb3, otherwise: bb5]; } bb1: { - StorageDead(_6); - StorageDead(_5); - StorageLive(_7); - StorageLive(_8); -- _8 = move _3; -+ _8 = move (((*_13) as variant#3).0: Foo); - _7 = take::(move _8) -> [return: bb2, unwind unreachable]; +- StorageDead(_5); +- StorageLive(_6); +- StorageLive(_7); +- _7 = move _3; +- _6 = take::(move _7) -> [return: bb2, unwind unreachable]; ++ StorageDead(_4); ++ StorageDead(_3); ++ StorageLive(_5); ++ _5 = take::(move (((*_8) as variant#3).1: Bar)) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_8); - StorageDead(_7); - StorageLive(_9); - StorageLive(_10); -- _10 = move _4; -+ _10 = move (((*_13) as variant#3).1: Bar); - _9 = take::(move _10) -> [return: bb3, unwind unreachable]; +- StorageDead(_7); +- StorageDead(_6); +- StorageLive(_8); +- _8 = take::(move _4) -> [return: bb3, unwind unreachable]; ++ StorageDead(_5); ++ _6 = const (); ++ _0 = CoroutineState::<(), ()>::Complete(move _6); ++ discriminant((*_8)) = 1; ++ return; } bb3: { - StorageDead(_10); - StorageDead(_9); +- StorageDead(_8); - _0 = const (); - StorageDead(_4); -+ _11 = const (); -+ nop; - goto -> bb4; +- StorageDead(_3); +- drop(_1) -> [return: bb4, unwind unreachable]; ++ StorageLive(_3); ++ StorageLive(_4); ++ _4 = move (((*_8) as variant#3).0: Foo); ++ _3 = take::(move _4) -> [return: bb1, unwind unreachable]; } bb4: { -- StorageDead(_3); -- drop(_1) -> [return: bb5, unwind unreachable]; -+ nop; -+ goto -> bb6; +- return; ++ assert(const false, "coroutine resumed after completion") -> [success: bb4, unwind unreachable]; } bb5: { -+ _0 = CoroutineState::<(), ()>::Complete(move _11); -+ discriminant((*_13)) = 1; - return; - } - - bb6: { -- StorageDead(_6); - StorageDead(_5); - StorageDead(_4); -- drop(_3) -> [return: bb7, unwind unreachable]; -+ goto -> bb5; +- drop(_3) -> [return: bb6, unwind unreachable]; ++ unreachable; } - bb7: { + bb6: { - StorageDead(_3); -- drop(_1) -> [return: bb8, unwind unreachable]; -+ StorageLive(_5); -+ StorageLive(_6); -+ _5 = move _2; -+ goto -> bb1; - } - - bb8: { +- drop(_1) -> [return: bb7, unwind unreachable]; +- } +- +- bb7: { - coroutine_drop; -+ assert(const false, "coroutine resumed after completion") -> [success: bb8, unwind unreachable]; -+ } -+ -+ bb9: { -+ unreachable; -+ } -+ -+ bb10: { -+ nop; -+ (((*_13) as variant#3).0: Foo) = Foo(const 5_i32); -+ nop; -+ (((*_13) as variant#3).1: Bar) = Bar(const 6_i32); -+ StorageLive(_5); -+ StorageLive(_6); -+ _6 = (); -+ _0 = CoroutineState::<(), ()>::Yielded(move _6); -+ StorageDead(_5); -+ StorageDead(_6); -+ discriminant((*_13)) = 3; ++ (((*_8) as variant#3).0: Foo) = Foo(const 5_i32); ++ (((*_8) as variant#3).1: Bar) = Bar(const 6_i32); ++ _0 = CoroutineState::<(), ()>::Yielded(const ()); ++ discriminant((*_8)) = 3; + return; } } diff --git a/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-unwind.diff b/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-unwind.diff index fa89df127094a..6f6c2f7cce84b 100644 --- a/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-unwind.diff +++ b/tests/mir-opt/coroutine/coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.panic-unwind.diff @@ -5,6 +5,7 @@ - yields () - { - let mut _0: (); +- let _3: Foo; + fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}>, _2: ()) -> CoroutineState<(), ()> { + coroutine layout { + field _s0: Foo; @@ -19,24 +20,23 @@ + } + coroutine debug a => _s0; + let mut _0: std::ops::CoroutineState<(), ()>; - let _3: Foo; ++ let _3: (); ++ let mut _4: Foo; let _5: (); - let mut _6: (); - let _7: (); - let mut _8: Foo; - let _9: (); - let mut _10: Bar; -+ let mut _11: (); -+ let mut _12: u32; -+ let mut _13: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}; +- let _6: (); +- let mut _7: Foo; +- let _8: (); ++ let mut _6: (); ++ let mut _7: u32; ++ let mut _8: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}; scope 1 { - debug a => _3; -+ debug a => (((*_13) as variant#3).0: Foo); +- let _4: Bar; ++ debug a => (((*_8) as variant#3).0: Foo); + coroutine debug b => _s1; - let _4: Bar; scope 2 { - debug b => _4; -+ debug b => (((*_13) as variant#3).1: Bar); ++ debug b => (((*_8) as variant#3).1: Bar); } } @@ -46,155 +46,109 @@ - StorageLive(_4); - _4 = Bar(const 6_i32); - StorageLive(_5); -- StorageLive(_6); -- _6 = (); -- _5 = yield(move _6) -> [resume: bb1, drop: bb6]; -+ _13 = copy (_1.0: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}); -+ _12 = discriminant((*_13)); -+ switchInt(move _12) -> [0: bb18, 1: bb16, 2: bb15, 3: bb14, otherwise: bb17]; +- _5 = yield(const ()) -> [resume: bb1, drop: bb5]; ++ _8 = copy (_1.0: &mut {coroutine@$DIR/coroutine_storage_dead_unwind.rs:24:5: 24:7}); ++ _7 = discriminant((*_8)); ++ switchInt(move _7) -> [0: bb10, 1: bb8, 2: bb7, 3: bb6, otherwise: bb9]; } bb1: { - StorageDead(_6); - StorageDead(_5); - StorageLive(_7); - StorageLive(_8); -- _8 = move _3; -- _7 = take::(move _8) -> [return: bb2, unwind: bb10]; -+ _8 = move (((*_13) as variant#3).0: Foo); -+ _7 = take::(move _8) -> [return: bb2, unwind: bb7]; - } - - bb2: { - StorageDead(_8); - StorageDead(_7); - StorageLive(_9); - StorageLive(_10); -- _10 = move _4; -- _9 = take::(move _10) -> [return: bb3, unwind: bb9]; -+ _10 = move (((*_13) as variant#3).1: Bar); -+ _9 = take::(move _10) -> [return: bb3, unwind: bb6]; - } - - bb3: { - StorageDead(_10); - StorageDead(_9); +- StorageDead(_5); +- StorageLive(_6); +- StorageLive(_7); +- _7 = move _3; +- _6 = take::(move _7) -> [return: bb2, unwind: bb9]; +- } +- +- bb2: { +- StorageDead(_7); +- StorageDead(_6); +- StorageLive(_8); +- _8 = take::(move _4) -> [return: bb3, unwind: bb8]; +- } +- +- bb3: { +- StorageDead(_8); - _0 = const (); -- StorageDead(_4); -+ _11 = const (); -+ nop; - goto -> bb4; - } - - bb4: { -- StorageDead(_3); -- drop(_1) -> [return: bb5, unwind: bb14]; -+ nop; -+ goto -> bb12; + StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb4, unwind continue]; ++ StorageLive(_5); ++ _5 = take::(move (((*_8) as variant#3).1: Bar)) -> [return: bb2, unwind: bb3]; } - bb5: { -+ _0 = CoroutineState::<(), ()>::Complete(move _11); -+ discriminant((*_13)) = 1; +- bb4: { ++ bb2: { ++ StorageDead(_5); ++ _6 = const (); ++ _0 = CoroutineState::<(), ()>::Complete(move _6); ++ discriminant((*_8)) = 1; return; } -- bb6: { -- StorageDead(_6); -- StorageDead(_5); +- bb5: { ++ bb3 (cleanup): { + StorageDead(_5); - StorageDead(_4); -- drop(_3) -> [return: bb7, unwind: bb15]; -+ bb6 (cleanup): { -+ StorageDead(_10); -+ StorageDead(_9); -+ goto -> bb9; +- drop(_3) -> [return: bb6, unwind: bb12]; ++ goto -> bb5; } -- bb7: { -- StorageDead(_3); -- drop(_1) -> [return: bb8, unwind: bb14]; -+ bb7 (cleanup): { -+ goto -> bb8; +- bb6: { ++ bb4 (cleanup): { ++ StorageDead(_4); + StorageDead(_3); +- drop(_1) -> [return: bb7, unwind continue]; ++ goto -> bb5; } -- bb8: { +- bb7: { - coroutine_drop; -+ bb8 (cleanup): { -+ StorageDead(_8); -+ StorageDead(_7); -+ goto -> bb9; - } - - bb9 (cleanup): { -- StorageDead(_10); -- StorageDead(_9); -- goto -> bb12; -+ nop; -+ goto -> bb10; ++ bb5 (cleanup): { ++ discriminant((*_8)) = 2; ++ resume; } - bb10 (cleanup): { -+ nop; - goto -> bb11; +- bb8 (cleanup): { +- StorageDead(_8); +- goto -> bb10; ++ bb6: { ++ StorageLive(_3); ++ StorageLive(_4); ++ _4 = move (((*_8) as variant#3).0: Foo); ++ _3 = take::(move _4) -> [return: bb1, unwind: bb4]; } - bb11 (cleanup): { -- StorageDead(_8); +- bb9 (cleanup): { - StorageDead(_7); -- goto -> bb12; -+ goto -> bb13; +- StorageDead(_6); +- goto -> bb10; ++ bb7: { ++ assert(const false, "coroutine resumed after panicking") -> [success: bb7, unwind continue]; } -- bb12 (cleanup): { +- bb10 (cleanup): { - StorageDead(_4); -- goto -> bb13; -+ bb12: { -+ goto -> bb5; - } - - bb13 (cleanup): { - StorageDead(_3); -- drop(_1) -> [return: bb14, unwind terminate(cleanup)]; -+ discriminant((*_13)) = 2; -+ resume; +- drop(_1) -> [return: bb11, unwind terminate(cleanup)]; ++ bb8: { ++ assert(const false, "coroutine resumed after completion") -> [success: bb8, unwind continue]; } -- bb14 (cleanup): { +- bb11 (cleanup): { - resume; -+ bb14: { -+ StorageLive(_5); -+ StorageLive(_6); -+ _5 = move _2; -+ goto -> bb1; ++ bb9: { ++ unreachable; } -- bb15 (cleanup): { +- bb12 (cleanup): { - StorageDead(_3); -- drop(_1) -> [return: bb14, unwind terminate(cleanup)]; -+ bb15: { -+ assert(const false, "coroutine resumed after panicking") -> [success: bb15, unwind continue]; -+ } -+ -+ bb16: { -+ assert(const false, "coroutine resumed after completion") -> [success: bb16, unwind continue]; -+ } -+ -+ bb17: { -+ unreachable; -+ } -+ -+ bb18: { -+ nop; -+ (((*_13) as variant#3).0: Foo) = Foo(const 5_i32); -+ nop; -+ (((*_13) as variant#3).1: Bar) = Bar(const 6_i32); -+ StorageLive(_5); -+ StorageLive(_6); -+ _6 = (); -+ _0 = CoroutineState::<(), ()>::Yielded(move _6); -+ StorageDead(_5); -+ StorageDead(_6); -+ discriminant((*_13)) = 3; +- drop(_1) -> [return: bb11, unwind terminate(cleanup)]; ++ bb10: { ++ (((*_8) as variant#3).0: Foo) = Foo(const 5_i32); ++ (((*_8) as variant#3).1: Bar) = Bar(const 6_i32); ++ _0 = CoroutineState::<(), ()>::Yielded(const ()); ++ discriminant((*_8)) = 3; + return; } } diff --git a/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff index b84e55cac4616..564634309c1e5 100644 --- a/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff @@ -17,81 +17,65 @@ + } debug _x => _2; - let mut _0: (); +- let _3: HasDrop; +- let _4: u8; +- let _5: (); + coroutine debug _d => _s0; + let mut _0: std::ops::CoroutineState<(), ()>; - let _3: HasDrop; - let mut _4: !; - let mut _5: (); - let _6: u8; - let mut _7: (); - let _8: (); -+ let mut _9: (); -+ let mut _10: u32; -+ let mut _11: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}; ++ let _3: (); ++ let mut _4: u32; ++ let mut _5: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}; scope 1 { - debug _d => _3; -+ debug _d => (((*_11) as variant#3).0: HasDrop); ++ debug _d => (((*_5) as variant#3).0: HasDrop); } bb0: { - StorageLive(_3); -- _3 = HasDrop; -- StorageLive(_4); +- _3 = const HasDrop; - goto -> bb1; -+ _11 = copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}); -+ _10 = discriminant((*_11)); -+ switchInt(move _10) -> [0: bb6, 3: bb4, otherwise: bb5]; ++ _5 = copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}); ++ _4 = discriminant((*_5)); ++ switchInt(move _4) -> [0: bb5, 3: bb3, otherwise: bb4]; } bb1: { - StorageLive(_6); - StorageLive(_7); - _7 = (); -- _6 = yield(move _7) -> [resume: bb2, drop: bb4]; -+ _0 = CoroutineState::<(), ()>::Yielded(move _7); -+ StorageDead(_4); -+ StorageDead(_6); -+ StorageDead(_7); -+ discriminant((*_11)) = 3; +- StorageLive(_4); +- _4 = yield(const ()) -> [resume: bb2, drop: bb4]; ++ _0 = CoroutineState::<(), ()>::Yielded(const ()); ++ discriminant((*_5)) = 3; + return; } bb2: { - StorageDead(_7); - StorageDead(_6); - StorageLive(_8); - _8 = callee() -> [return: bb3, unwind unreachable]; +- StorageDead(_4); +- StorageLive(_5); +- _5 = callee() -> [return: bb3, unwind unreachable]; ++ StorageDead(_3); ++ goto -> bb1; } bb3: { - StorageDead(_8); - _5 = const (); - goto -> bb1; +- StorageDead(_5); +- goto -> bb1; ++ StorageLive(_3); ++ _3 = callee() -> [return: bb2, unwind unreachable]; } bb4: { -- StorageDead(_7); -- StorageDead(_6); - StorageDead(_4); - drop(_3) -> [return: bb5, unwind unreachable]; -+ StorageLive(_4); -+ StorageLive(_6); -+ StorageLive(_7); -+ _6 = move _2; -+ goto -> bb2; ++ unreachable; } bb5: { - StorageDead(_3); - drop(_1) -> [return: bb6, unwind unreachable]; -+ unreachable; - } - - bb6: { +- } +- +- bb6: { - coroutine_drop; -+ nop; -+ (((*_11) as variant#3).0: HasDrop) = HasDrop; -+ StorageLive(_4); ++ (((*_5) as variant#3).0: HasDrop) = const HasDrop; + goto -> bb1; } } diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 151580da19e09..571bcc31e222d 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -23,6 +23,7 @@ + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; + let mut _7: u32; + let mut _8: i32; ++ let mut _9: bool; + } bb0: { @@ -39,6 +40,7 @@ + _5 = const false; + StorageLive(_6); + StorageLive(_7); ++ StorageLive(_9); + _6 = copy (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; @@ -56,6 +58,7 @@ bb2: { - StorageDead(_3); - _1 = <{coroutine@$DIR/inline_coroutine.rs:20:5: 20:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; ++ StorageDead(_9); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); @@ -97,8 +100,9 @@ + + bb8: { + StorageLive(_8); ++ _9 = move _5; + StorageDead(_8); -+ _1 = CoroutineState::::Complete(copy _5); ++ _1 = CoroutineState::::Complete(move _9); + discriminant((*_6)) = 1; + goto -> bb2; + } diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index 6196fc0d0c6bf..33751862f7c92 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -23,6 +23,7 @@ + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}; + let mut _7: u32; + let mut _8: i32; ++ let mut _9: bool; + } bb0: { @@ -39,6 +40,7 @@ + _5 = const false; + StorageLive(_6); + StorageLive(_7); ++ StorageLive(_9); + _6 = copy (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; @@ -72,6 +74,7 @@ - _0 = const (); - StorageDead(_1); - return; ++ StorageDead(_9); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); @@ -111,8 +114,9 @@ + + bb10: { + StorageLive(_8); ++ _9 = move _5; + StorageDead(_8); -+ _1 = CoroutineState::::Complete(copy _5); ++ _1 = CoroutineState::::Complete(move _9); + discriminant((*_6)) = 1; + goto -> bb4; + } diff --git a/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index 617f2ad463ed3..4b117a453c326 100644 --- a/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -33,14 +33,16 @@ + let mut _21: &mut std::future::Ready<()>; + let mut _22: &mut std::task::Context<'_>; + let mut _23: &mut std::task::Context<'_>; -+ let mut _24: &mut std::task::Context<'_>; ++ let mut _24: std::future::ResumeTy; + let mut _25: isize; + let mut _27: !; -+ let mut _28: &mut std::task::Context<'_>; ++ let mut _28: std::future::ResumeTy; + let mut _29: (); + let mut _30: (); + let mut _31: u32; + let mut _32: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _33: std::future::ResumeTy; ++ let mut _34: std::ptr::NonNull>; + scope 7 { + let mut _15: std::future::Ready<()>; + scope 8 { @@ -50,30 +52,30 @@ + scope 11 (inlined Pin::<&mut std::future::Ready<()>>::new_unchecked) { + } + scope 12 (inlined as Future>::poll) { -+ let mut _33: (); -+ let mut _34: std::option::Option<()>; -+ let mut _35: &mut std::option::Option<()>; -+ let mut _36: &mut std::future::Ready<()>; -+ let mut _37: &mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _35: (); ++ let mut _36: std::option::Option<()>; ++ let mut _37: &mut std::option::Option<()>; ++ let mut _38: &mut std::future::Ready<()>; ++ let mut _39: &mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 13 (inlined > as DerefMut>::deref_mut) { -+ let mut _38: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; -+ let mut _39: *mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _40: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; ++ let mut _41: *mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 14 (inlined > as pin::helper::PinDerefMutHelper>::deref_mut) { -+ let mut _40: &mut &mut std::future::Ready<()>; ++ let mut _42: &mut &mut std::future::Ready<()>; + scope 15 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) { + } + } + } + scope 16 (inlined Option::<()>::take) { -+ let mut _41: std::option::Option<()>; ++ let mut _43: std::option::Option<()>; + scope 17 (inlined std::mem::replace::>) { + scope 18 { + } + } + } + scope 19 (inlined #[track_caller] Option::<()>::expect) { -+ let mut _42: isize; -+ let mut _43: !; ++ let mut _44: isize; ++ let mut _45: !; + scope 20 { + } + } @@ -82,7 +84,7 @@ + scope 10 (inlined as IntoFuture>::into_future) { + } + scope 21 (inlined ready::<()>) { -+ let mut _44: std::option::Option<()>; ++ let mut _46: std::option::Option<()>; + } + } + } @@ -125,6 +127,10 @@ + StorageLive(_30); + StorageLive(_31); + StorageLive(_32); ++ StorageLive(_33); ++ StorageLive(_34); ++ _34 = move _9 as std::ptr::NonNull> (Transmute); ++ _33 = std::future::ResumeTy(move _34); + _32 = copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); + _31 = discriminant((*_32)); + switchInt(move _31) -> [0: bb10, 1: bb9, 3: bb8, otherwise: bb4]; @@ -137,6 +143,8 @@ + } + + bb2: { ++ StorageDead(_34); ++ StorageDead(_33); + StorageDead(_32); + StorageDead(_31); + StorageDead(_30); @@ -166,28 +174,28 @@ + StorageLive(_22); + StorageLive(_23); + StorageLive(_24); -+ _24 = copy _9; -+ _23 = move _24; ++ _24 = copy _33; ++ _23 = copy (_24.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _22 = &mut (*_23); + StorageDead(_24); -+ StorageLive(_36); + StorageLive(_38); -+ StorageLive(_43); -+ StorageLive(_33); -+ StorageLive(_34); -+ StorageLive(_39); -+ _39 = &raw mut _19; -+ _38 = copy _39 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ StorageDead(_39); -+ _36 = no_retag copy ((*_38).0: &mut std::future::Ready<()>); ++ StorageLive(_40); ++ StorageLive(_45); ++ StorageLive(_35); ++ StorageLive(_36); + StorageLive(_41); -+ _41 = Option::<()>::None; -+ _34 = copy ((*_36).0: std::option::Option<()>); -+ ((*_36).0: std::option::Option<()>) = move _41; ++ _41 = &raw mut _19; ++ _40 = copy _41 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); + StorageDead(_41); -+ StorageLive(_42); -+ _42 = discriminant(_34); -+ switchInt(move _42) -> [0: bb11, 1: bb12, otherwise: bb4]; ++ _38 = no_retag copy ((*_40).0: &mut std::future::Ready<()>); ++ StorageLive(_43); ++ _43 = Option::<()>::None; ++ _36 = copy ((*_38).0: std::option::Option<()>); ++ ((*_38).0: std::option::Option<()>) = move _43; ++ StorageDead(_43); ++ StorageLive(_44); ++ _44 = discriminant(_36); ++ switchInt(move _44) -> [0: bb11, 1: bb12, otherwise: bb4]; + } + bb4: { @@ -236,9 +244,9 @@ + StorageLive(_12); + StorageLive(_28); + StorageLive(_29); -+ _28 = move _9; ++ _28 = move _33; + StorageDead(_29); -+ _9 = move _28; ++ _33 = move _28; + StorageDead(_28); + _16 = const (); + goto -> bb3; @@ -254,10 +262,10 @@ + StorageLive(_13); + StorageLive(_14); + _14 = (); -+ StorageLive(_44); -+ _44 = Option::<()>::Some(copy _14); -+ _13 = std::future::Ready::<()>(move _44); -+ StorageDead(_44); ++ StorageLive(_46); ++ _46 = Option::<()>::Some(copy _14); ++ _13 = std::future::Ready::<()>(move _46); ++ StorageDead(_46); + StorageDead(_14); + _12 = move _13; + StorageDead(_13); @@ -266,18 +274,18 @@ + } + + bb11: { -+ _43 = option::expect_failed(const "`Ready` polled after completion") -> unwind unreachable; ++ _45 = option::expect_failed(const "`Ready` polled after completion") -> unwind unreachable; + } + + bb12: { -+ _33 = move ((_34 as Some).0: ()); -+ StorageDead(_42); -+ StorageDead(_34); -+ _18 = Poll::<()>::Ready(move _33); -+ StorageDead(_33); -+ StorageDead(_43); -+ StorageDead(_38); ++ _35 = move ((_36 as Some).0: ()); ++ StorageDead(_44); + StorageDead(_36); ++ _18 = Poll::<()>::Ready(move _35); ++ StorageDead(_35); ++ StorageDead(_45); ++ StorageDead(_40); ++ StorageDead(_38); + StorageDead(_22); + StorageDead(_19); + _25 = discriminant(_18); diff --git a/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index f12462a4d2b34..c365aee05f4ec 100644 --- a/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -33,14 +33,16 @@ + let mut _21: &mut std::future::Ready<()>; + let mut _22: &mut std::task::Context<'_>; + let mut _23: &mut std::task::Context<'_>; -+ let mut _24: &mut std::task::Context<'_>; ++ let mut _24: std::future::ResumeTy; + let mut _25: isize; + let mut _27: !; -+ let mut _28: &mut std::task::Context<'_>; ++ let mut _28: std::future::ResumeTy; + let mut _29: (); + let mut _30: (); + let mut _31: u32; + let mut _32: &mut {async fn body of ActionPermit<'_, T>::perform()}; ++ let mut _33: std::future::ResumeTy; ++ let mut _34: std::ptr::NonNull>; + scope 7 { + let mut _15: std::future::Ready<()>; + scope 8 { @@ -50,30 +52,30 @@ + scope 11 (inlined Pin::<&mut std::future::Ready<()>>::new_unchecked) { + } + scope 12 (inlined as Future>::poll) { -+ let mut _33: (); -+ let mut _34: std::option::Option<()>; -+ let mut _35: &mut std::option::Option<()>; -+ let mut _36: &mut std::future::Ready<()>; -+ let mut _37: &mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _35: (); ++ let mut _36: std::option::Option<()>; ++ let mut _37: &mut std::option::Option<()>; ++ let mut _38: &mut std::future::Ready<()>; ++ let mut _39: &mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 13 (inlined > as DerefMut>::deref_mut) { -+ let mut _38: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; -+ let mut _39: *mut std::pin::Pin<&mut std::future::Ready<()>>; ++ let mut _40: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>; ++ let mut _41: *mut std::pin::Pin<&mut std::future::Ready<()>>; + scope 14 (inlined > as pin::helper::PinDerefMutHelper>::deref_mut) { -+ let mut _40: &mut &mut std::future::Ready<()>; ++ let mut _42: &mut &mut std::future::Ready<()>; + scope 15 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) { + } + } + } + scope 16 (inlined Option::<()>::take) { -+ let mut _41: std::option::Option<()>; ++ let mut _43: std::option::Option<()>; + scope 17 (inlined std::mem::replace::>) { + scope 18 { + } + } + } + scope 19 (inlined #[track_caller] Option::<()>::expect) { -+ let mut _42: isize; -+ let mut _43: !; ++ let mut _44: isize; ++ let mut _45: !; + scope 20 { + } + } @@ -82,7 +84,7 @@ + scope 10 (inlined as IntoFuture>::into_future) { + } + scope 21 (inlined ready::<()>) { -+ let mut _44: std::option::Option<()>; ++ let mut _46: std::option::Option<()>; + } + } + } @@ -125,6 +127,10 @@ + StorageLive(_30); + StorageLive(_31); + StorageLive(_32); ++ StorageLive(_33); ++ StorageLive(_34); ++ _34 = move _9 as std::ptr::NonNull> (Transmute); ++ _33 = std::future::ResumeTy(move _34); + _32 = copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()}); + _31 = discriminant((*_32)); + switchInt(move _31) -> [0: bb15, 1: bb14, 2: bb13, 3: bb12, otherwise: bb6]; @@ -145,6 +151,8 @@ + } + + bb4: { ++ StorageDead(_34); ++ StorageDead(_33); + StorageDead(_32); + StorageDead(_31); + StorageDead(_30); @@ -177,28 +185,28 @@ + StorageLive(_22); + StorageLive(_23); + StorageLive(_24); -+ _24 = copy _9; -+ _23 = move _24; ++ _24 = copy _33; ++ _23 = copy (_24.0: std::ptr::NonNull>) as &mut std::task::Context<'_> (Transmute); + _22 = &mut (*_23); + StorageDead(_24); -+ StorageLive(_36); + StorageLive(_38); -+ StorageLive(_43); -+ StorageLive(_33); -+ StorageLive(_34); -+ StorageLive(_39); -+ _39 = &raw mut _19; -+ _38 = copy _39 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); -+ StorageDead(_39); -+ _36 = no_retag copy ((*_38).0: &mut std::future::Ready<()>); ++ StorageLive(_40); ++ StorageLive(_45); ++ StorageLive(_35); ++ StorageLive(_36); + StorageLive(_41); -+ _41 = Option::<()>::None; -+ _34 = copy ((*_36).0: std::option::Option<()>); -+ ((*_36).0: std::option::Option<()>) = move _41; ++ _41 = &raw mut _19; ++ _40 = copy _41 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr); + StorageDead(_41); -+ StorageLive(_42); -+ _42 = discriminant(_34); -+ switchInt(move _42) -> [0: bb16, 1: bb17, otherwise: bb6]; ++ _38 = no_retag copy ((*_40).0: &mut std::future::Ready<()>); ++ StorageLive(_43); ++ _43 = Option::<()>::None; ++ _36 = copy ((*_38).0: std::option::Option<()>); ++ ((*_38).0: std::option::Option<()>) = move _43; ++ StorageDead(_43); ++ StorageLive(_44); ++ _44 = discriminant(_36); ++ switchInt(move _44) -> [0: bb16, 1: bb17, otherwise: bb6]; } - bb5 (cleanup): { @@ -265,9 +273,9 @@ + StorageLive(_12); + StorageLive(_28); + StorageLive(_29); -+ _28 = move _9; ++ _28 = move _33; + StorageDead(_29); -+ _9 = move _28; ++ _33 = move _28; + StorageDead(_28); + _16 = const (); + goto -> bb5; @@ -287,10 +295,10 @@ + StorageLive(_13); + StorageLive(_14); + _14 = (); -+ StorageLive(_44); -+ _44 = Option::<()>::Some(copy _14); -+ _13 = std::future::Ready::<()>(move _44); -+ StorageDead(_44); ++ StorageLive(_46); ++ _46 = Option::<()>::Some(copy _14); ++ _13 = std::future::Ready::<()>(move _46); ++ StorageDead(_46); + StorageDead(_14); + _12 = move _13; + StorageDead(_13); @@ -299,18 +307,18 @@ + } + + bb16: { -+ _43 = option::expect_failed(const "`Ready` polled after completion") -> bb10; ++ _45 = option::expect_failed(const "`Ready` polled after completion") -> bb10; + } + + bb17: { -+ _33 = move ((_34 as Some).0: ()); -+ StorageDead(_42); -+ StorageDead(_34); -+ _18 = Poll::<()>::Ready(move _33); -+ StorageDead(_33); -+ StorageDead(_43); -+ StorageDead(_38); ++ _35 = move ((_36 as Some).0: ()); ++ StorageDead(_44); + StorageDead(_36); ++ _18 = Poll::<()>::Ready(move _35); ++ StorageDead(_35); ++ StorageDead(_45); ++ StorageDead(_40); ++ StorageDead(_38); + StorageDead(_22); + StorageDead(_19); + _25 = discriminant(_18); diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.rs b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs index ab2a519d98cd5..3b29356ee36e5 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.rs +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs @@ -5,7 +5,7 @@ //@ edition:2021 //@ build-pass //@ no-pass-override (codegen affects -Zprint-type-sizes) -//@ only-x86_64 +//@ only-64bit async fn wait() {} diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index 13f03ffa65b5d..51f9f34a0a813 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -1,37 +1,34 @@ -print-type-size type: `{async fn body of test()}`: 3078 bytes, alignment: 1 bytes +print-type-size type: `{async fn body of test()}`: 3079 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes -print-type-size variant `Suspend0`: 3077 bytes -print-type-size local `.__awaitee`: 3077 bytes, type: {async fn body of calls_fut<{async fn body of big_fut()}>()} +print-type-size variant `Suspend0`: 3078 bytes +print-type-size local `.__awaitee`: 3078 bytes, type: {async fn body of calls_fut<{async fn body of big_fut()}>()} print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes -print-type-size type: `std::mem::ManuallyDrop<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes -print-type-size field `.value`: 3077 bytes -print-type-size type: `std::mem::MaybeDangling<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes -print-type-size field `.0`: 3077 bytes -print-type-size type: `std::mem::MaybeUninit<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes -print-type-size variant `MaybeUninit`: 3077 bytes +print-type-size type: `std::mem::ManuallyDrop<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3078 bytes, alignment: 1 bytes +print-type-size field `.value`: 3078 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3078 bytes, alignment: 1 bytes +print-type-size field `.0`: 3078 bytes +print-type-size type: `std::mem::MaybeUninit<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3078 bytes, alignment: 1 bytes +print-type-size variant `MaybeUninit`: 3078 bytes print-type-size field `.uninit`: 0 bytes -print-type-size field `.value`: 3077 bytes -print-type-size type: `{async fn body of calls_fut<{async fn body of big_fut()}>()}`: 3077 bytes, alignment: 1 bytes +print-type-size field `.value`: 3078 bytes +print-type-size type: `{async fn body of calls_fut<{async fn body of big_fut()}>()}`: 3078 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 1025 bytes print-type-size upvar `.fut`: 1025 bytes -print-type-size variant `Suspend0`: 2052 bytes +print-type-size variant `Suspend0`: 3077 bytes print-type-size upvar `.fut`: 1025 bytes print-type-size local `.fut`: 1025 bytes -print-type-size local `..coroutine_field4`: 1 bytes, type: bool print-type-size local `.__awaitee`: 1 bytes, type: {async fn body of wait()} -print-type-size variant `Suspend1`: 3076 bytes +print-type-size padding: 1025 bytes +print-type-size local `..coroutine_field3`: 1 bytes, alignment: 1 bytes, type: bool +print-type-size variant `Suspend1`: 3077 bytes print-type-size upvar `.fut`: 1025 bytes print-type-size padding: 1025 bytes -print-type-size local `..coroutine_field4`: 1 bytes, alignment: 1 bytes, type: bool +print-type-size local `.__awaitee`: 1 bytes, alignment: 1 bytes, type: {async fn body of wait()} print-type-size local `.__awaitee`: 1025 bytes, type: {async fn body of big_fut()} -print-type-size variant `Suspend2`: 2052 bytes -print-type-size upvar `.fut`: 1025 bytes -print-type-size local `.fut`: 1025 bytes -print-type-size local `..coroutine_field4`: 1 bytes, type: bool -print-type-size local `.__awaitee`: 1 bytes, type: {async fn body of wait()} +print-type-size local `..coroutine_field3`: 1 bytes, type: bool print-type-size variant `Returned`: 1025 bytes print-type-size upvar `.fut`: 1025 bytes print-type-size variant `Panicked`: 1025 bytes @@ -72,6 +69,8 @@ print-type-size type: `std::panic::AssertUnwindSafe`: 16 bytes, alignment: 8 bytes print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::future::ResumeTy`: 8 bytes, alignment: 8 bytes +print-type-size field `.0`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of big_fut()}>`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 8 bytes, alignment: 8 bytes @@ -85,6 +84,8 @@ print-type-size field `._vtable_ptr`: 8 bytes print-type-size field `._phantom`: 0 bytes print-type-size type: `std::ptr::NonNull`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::NonNull>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes print-type-size type: `std::mem::ManuallyDrop`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/future-sizes/large-arg.rs b/tests/ui/async-await/future-sizes/large-arg.rs index 3843e36c53e83..d41bf71b2b669 100644 --- a/tests/ui/async-await/future-sizes/large-arg.rs +++ b/tests/ui/async-await/future-sizes/large-arg.rs @@ -5,7 +5,7 @@ //@ edition: 2021 //@ build-pass //@ no-pass-override (codegen affects -Zprint-type-sizes) -//@ only-x86_64 +//@ only-64bit pub async fn test() { let _ = a([0u8; 1024]).await; diff --git a/tests/ui/async-await/future-sizes/large-arg.stdout b/tests/ui/async-await/future-sizes/large-arg.stdout index d51afa33595cb..f65c5c1a7cb78 100644 --- a/tests/ui/async-await/future-sizes/large-arg.stdout +++ b/tests/ui/async-await/future-sizes/large-arg.stdout @@ -84,6 +84,8 @@ print-type-size type: `std::panic::AssertUnwindSafe`: 16 bytes, alignment: 8 bytes print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::future::ResumeTy`: 8 bytes, alignment: 8 bytes +print-type-size field `.0`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of a<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of b<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes @@ -97,6 +99,8 @@ print-type-size field `._vtable_ptr`: 8 bytes print-type-size field `._phantom`: 0 bytes print-type-size type: `std::ptr::NonNull`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::NonNull>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Ready`: 0 bytes diff --git a/tests/ui/coroutine/size-moved-locals.rs b/tests/ui/coroutine/size-moved-locals.rs index 0f800de84544d..30ff74534c3c3 100644 --- a/tests/ui/coroutine/size-moved-locals.rs +++ b/tests/ui/coroutine/size-moved-locals.rs @@ -76,5 +76,5 @@ fn main() { assert_eq!(1025, std::mem::size_of_val(&move_before_yield())); assert_eq!(1026, std::mem::size_of_val(&move_before_yield_with_noop())); assert_eq!(2051, std::mem::size_of_val(&overlap_move_points())); - assert_eq!(1026, std::mem::size_of_val(&overlap_x_and_y())); + assert_eq!(2050, std::mem::size_of_val(&overlap_x_and_y())); } diff --git a/tests/ui/force-inlining/deny-async.stderr b/tests/ui/force-inlining/deny-async.stderr index bd24bc694e8ae..d6516ed875c21 100644 --- a/tests/ui/force-inlining/deny-async.stderr +++ b/tests/ui/force-inlining/deny-async.stderr @@ -20,6 +20,14 @@ LL | pub fn callee_justified() { | = note: incompatible due to: #[rustc_no_mir_inline] +error: `callee` could not be inlined into `async_caller::{closure#0}` but is required to be inlined + --> $DIR/deny-async.rs:22:5 + | +LL | callee(); + | ^^^^^^^^ ...`callee` called here + | + = note: could not be inlined due to: #[rustc_no_mir_inline] + error: `callee_justified` could not be inlined into `async_caller::{closure#0}` but is required to be inlined --> $DIR/deny-async.rs:24:5 | @@ -29,13 +37,5 @@ LL | callee_justified(); = note: could not be inlined due to: #[rustc_no_mir_inline] = note: `callee_justified` is required to be inlined to: the test requires it -error: `callee` could not be inlined into `async_caller::{closure#0}` but is required to be inlined - --> $DIR/deny-async.rs:22:5 - | -LL | callee(); - | ^^^^^^^^ ...`callee` called here - | - = note: could not be inlined due to: #[rustc_no_mir_inline] - error: aborting due to 4 previous errors diff --git a/tests/ui/print_type_sizes/async.rs b/tests/ui/print_type_sizes/async.rs index 70da909ee6d02..36c85be2ed509 100644 --- a/tests/ui/print_type_sizes/async.rs +++ b/tests/ui/print_type_sizes/async.rs @@ -5,7 +5,7 @@ //@ edition:2021 //@ build-pass //@ no-pass-override (codegen affects -Zprint-type-sizes) -//@ only-x86_64 +//@ only-64bit #![allow(dropping_copy_types)] diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout index d2adff80e3c9c..c068818fdc9a5 100644 --- a/tests/ui/print_type_sizes/async.stdout +++ b/tests/ui/print_type_sizes/async.stdout @@ -38,6 +38,8 @@ print-type-size type: `std::panic::AssertUnwindSafe`: 16 bytes, alignment: 8 bytes print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::future::ResumeTy`: 8 bytes, alignment: 8 bytes +print-type-size field `.0`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes print-type-size type: `std::pin::Pin<&mut {async fn body of wait()}>`: 8 bytes, alignment: 8 bytes @@ -47,6 +49,8 @@ print-type-size field `._vtable_ptr`: 8 bytes print-type-size field `._phantom`: 0 bytes print-type-size type: `std::ptr::NonNull`: 8 bytes, alignment: 8 bytes print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::NonNull>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::MaybeDangling<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index b51beb514ba80..30a9df6f20948 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -1,19 +1,7 @@ -print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:13:5: 13:7}`: 8 bytes, alignment: 4 bytes +print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:13:5: 13:7}`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes -print-type-size variant `Suspend0`: 7 bytes -print-type-size padding: 3 bytes -print-type-size local `.w`: 4 bytes, alignment: 4 bytes -print-type-size variant `Suspend1`: 7 bytes -print-type-size padding: 3 bytes -print-type-size local `.z`: 4 bytes, alignment: 4 bytes +print-type-size variant `Suspend0`: 0 bytes +print-type-size variant `Suspend1`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes -print-type-size type: `std::mem::ManuallyDrop`: 4 bytes, alignment: 4 bytes -print-type-size field `.value`: 4 bytes -print-type-size type: `std::mem::MaybeDangling`: 4 bytes, alignment: 4 bytes -print-type-size field `.0`: 4 bytes -print-type-size type: `std::mem::MaybeUninit`: 4 bytes, alignment: 4 bytes -print-type-size variant `MaybeUninit`: 4 bytes -print-type-size field `.uninit`: 0 bytes -print-type-size field `.value`: 4 bytes diff --git a/tests/ui/rustc_public-ir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout index 6dbc1ddf2aad9..8a473d52fff3c 100644 --- a/tests/ui/rustc_public-ir-print/async-closure.stdout +++ b/tests/ui/rustc_public-ir-print/async-closure.stdout @@ -42,10 +42,14 @@ fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@$DIR/async-clo let mut _5: (); let mut _6: u32; let mut _7: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - debug _task_context => _2; + let mut _8: std::future::ResumeTy; + let mut _9: NonNull>; + debug _task_context => _8; debug y => (*((*_7).0: &i32)); debug y => _3; bb0: { + _9 = move _2 as NonNull>; + _8 = ResumeTy(move _9); _7 = (_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}); _6 = discriminant((*_7)); switchInt(move _6) -> [0: bb3, 1: bb1, otherwise: bb2]; @@ -74,10 +78,14 @@ fn foo::{closure#0}::{synthetic#0}(_1: Pin<&mut {async closure body@$DIR/async-c let mut _5: (); let mut _6: u32; let mut _7: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - debug _task_context => _2; + let mut _8: std::future::ResumeTy; + let mut _9: NonNull>; + debug _task_context => _8; debug y => (*((*_7).0: &i32)); debug y => _3; bb0: { + _9 = move _2 as NonNull>; + _8 = ResumeTy(move _9); _7 = (_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}); _6 = discriminant((*_7)); switchInt(move _6) -> [0: bb3, 1: bb1, otherwise: bb2];