@@ -1565,7 +1565,9 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>(
15651565    let  coroutine_ty = body. local_decls [ ty:: CAPTURE_STRUCT_LOCAL ] . ty ; 
15661566
15671567    let  movable = match  * coroutine_ty. kind ( )  { 
1568-         ty:: Coroutine ( def_id,  _)  => tcx. movability ( def_id)  == hir:: Movability :: Movable , 
1568+         ty:: Coroutine ( def_id,  _)  => { 
1569+             tcx. coroutine_kind ( def_id) . unwrap ( ) . movability ( )  == hir:: Movability :: Movable 
1570+         } 
15691571        ty:: Error ( _)  => return  None , 
15701572        _ => span_bug ! ( body. span,  "unexpected coroutine type {}" ,  coroutine_ty) , 
15711573    } ; 
@@ -1597,12 +1599,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
15971599
15981600        // The first argument is the coroutine type passed by value 
15991601        let  coroutine_ty = body. local_decls . raw [ 1 ] . ty ; 
1602+         let  coroutine_kind = body. coroutine_kind ( ) . unwrap ( ) ; 
16001603
16011604        // Get the discriminant type and args which typeck computed 
16021605        let  ( discr_ty,  movable)  = match  * coroutine_ty. kind ( )  { 
1603-             ty:: Coroutine ( def_id ,  args)  => { 
1606+             ty:: Coroutine ( _ ,  args)  => { 
16041607                let  args = args. as_coroutine ( ) ; 
1605-                 ( args. discr_ty ( tcx) ,  tcx . movability ( def_id )  == hir:: Movability :: Movable ) 
1608+                 ( args. discr_ty ( tcx) ,  coroutine_kind . movability ( )  == hir:: Movability :: Movable ) 
16061609            } 
16071610            _ => { 
16081611                tcx. dcx ( ) . span_delayed_bug ( 
@@ -1613,19 +1616,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
16131616            } 
16141617        } ; 
16151618
1616-         let  is_async_kind = matches ! ( 
1617-             body. coroutine_kind( ) , 
1618-             Some ( CoroutineKind :: Desugared ( CoroutineDesugaring :: Async ,  _) ) 
1619-         ) ; 
1620-         let  is_async_gen_kind = matches ! ( 
1621-             body. coroutine_kind( ) , 
1622-             Some ( CoroutineKind :: Desugared ( CoroutineDesugaring :: AsyncGen ,  _) ) 
1623-         ) ; 
1624-         let  is_gen_kind = matches ! ( 
1625-             body. coroutine_kind( ) , 
1626-             Some ( CoroutineKind :: Desugared ( CoroutineDesugaring :: Gen ,  _) ) 
1627-         ) ; 
1628-         let  new_ret_ty = match  body. coroutine_kind ( ) . unwrap ( )  { 
1619+         let  is_async_kind =
1620+             matches ! ( coroutine_kind,  CoroutineKind :: Desugared ( CoroutineDesugaring :: Async ,  _) ) ; 
1621+         let  is_async_gen_kind =
1622+             matches ! ( coroutine_kind,  CoroutineKind :: Desugared ( CoroutineDesugaring :: AsyncGen ,  _) ) ; 
1623+         let  is_gen_kind =
1624+             matches ! ( coroutine_kind,  CoroutineKind :: Desugared ( CoroutineDesugaring :: Gen ,  _) ) ; 
1625+         let  new_ret_ty = match  coroutine_kind { 
16291626            CoroutineKind :: Desugared ( CoroutineDesugaring :: Async ,  _)  => { 
16301627                // Compute Poll<return_ty> 
16311628                let  poll_did = tcx. require_lang_item ( LangItem :: Poll ,  None ) ; 
0 commit comments