diff options
| author | bors <bors@rust-lang.org> | 2025-06-05 00:30:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-05 00:30:08 +0000 |
| commit | 81a964c23ea4fe9ab52b4449bb166bf280035797 (patch) | |
| tree | f125374c699b8fed4c7ec8971ae9c2496b772d15 /compiler/rustc_mir_transform/src | |
| parent | ff223d35cd684f8c7c07ed4b7fd4475e482359ab (diff) | |
| parent | 4959ee314d220688de394ea7ab3f25f2788ca17b (diff) | |
| download | rust-81a964c23ea4fe9ab52b4449bb166bf280035797.tar.gz rust-81a964c23ea4fe9ab52b4449bb166bf280035797.zip | |
Auto merge of #142033 - matthiaskrgr:rollup-99lvg0j, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang/rust#141890 (Add link to correct documentation in htmldocck.py) - rust-lang/rust#141932 (Fix for async drop inside async gen fn) - rust-lang/rust#141960 (Use non-2015 edition paths in tests that do not test for their resolution) - rust-lang/rust#141968 (Run wfcheck in one big loop instead of per module) - rust-lang/rust#141969 (Triagebot: Remove `assign.users_on_vacation`) - rust-lang/rust#141985 (Ensure query keys are printed with reduced queries) - rust-lang/rust#141999 (Visit the ident in `PreciseCapturingNonLifetimeArg`.) - rust-lang/rust#142005 (Change `tag_field` to `FieldIdx` in `Variants::Multiple`) - rust-lang/rust#142017 (Fix incorrect use of "recommend" over "recommended") - rust-lang/rust#142024 (Don't refer to 'this tail expression' in expansion.) - rust-lang/rust#142025 (Don't refer to 'local binding' in extern macro.) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coroutine/drop.rs | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/compiler/rustc_mir_transform/src/coroutine/drop.rs b/compiler/rustc_mir_transform/src/coroutine/drop.rs index 6b266da5a69..625e53f9959 100644 --- a/compiler/rustc_mir_transform/src/coroutine/drop.rs +++ b/compiler/rustc_mir_transform/src/coroutine/drop.rs @@ -382,12 +382,34 @@ pub(super) fn expand_async_drops<'tcx>( dropline_call_bb = Some(drop_call_bb); } - // value needed only for return-yields or gen-coroutines, so just const here - let value = Operand::Constant(Box::new(ConstOperand { - span: body.span, - user_ty: None, - const_: Const::from_bool(tcx, false), - })); + let value = + if matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) + { + // For AsyncGen we need `yield Poll<OptRet>::Pending` + let full_yield_ty = body.yield_ty().unwrap(); + let ty::Adt(_poll_adt, args) = *full_yield_ty.kind() else { bug!() }; + let ty::Adt(_option_adt, args) = *args.type_at(0).kind() else { bug!() }; + let yield_ty = args.type_at(0); + Operand::Constant(Box::new(ConstOperand { + span: source_info.span, + const_: Const::Unevaluated( + UnevaluatedConst::new( + tcx.require_lang_item(LangItem::AsyncGenPending, None), + tcx.mk_args(&[yield_ty.into()]), + ), + full_yield_ty, + ), + user_ty: None, + })) + } else { + // value needed only for return-yields or gen-coroutines, so just const here + Operand::Constant(Box::new(ConstOperand { + span: body.span, + user_ty: None, + const_: Const::from_bool(tcx, false), + })) + }; + use rustc_middle::mir::AssertKind::ResumedAfterDrop; let panic_bb = insert_panic_block(tcx, body, ResumedAfterDrop(coroutine_kind)); |
