File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
compiler/rustc_mir_transform/src
tests/ui/async-await/async-drop Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,23 @@ impl<'tcx> TransformVisitor<'tcx> {
317317 ) ,
318318 user_ty : None ,
319319 } ) ) )
320+ } else if matches ! (
321+ val,
322+ Operand :: Constant ( box ConstOperand {
323+ const_: Const :: Val ( ConstValue :: Scalar ( _) , _) ,
324+ ..
325+ } )
326+ ) {
327+ // yield (const false) is used for async drop yields inside AsyncGen
328+ // We need to convert value to Poll<OptRet>::Pending
329+ let poll_def_id = self . tcx . require_lang_item ( LangItem :: Poll , None ) ;
330+ let ty:: Adt ( _poll_adt, args) = * self . old_yield_ty . kind ( ) else { bug ! ( ) } ;
331+ make_aggregate_adt (
332+ poll_def_id,
333+ VariantIdx :: from_usize ( 1 ) ,
334+ args,
335+ IndexVec :: new ( ) ,
336+ )
320337 } else {
321338 Rvalue :: Use ( val)
322339 }
Original file line number Diff line number Diff line change 1+ // ex-ice: #140530
2+ //@ edition: 2024
3+ //@ build-pass
4+ #![ feature( async_drop, gen_blocks) ]
5+ #![ allow( incomplete_features) ]
6+ async gen fn a ( ) {
7+ _ = async { }
8+ }
9+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments