@@ -1565,7 +1565,9 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>(
1565
1565
let coroutine_ty = body. local_decls [ ty:: CAPTURE_STRUCT_LOCAL ] . ty ;
1566
1566
1567
1567
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
+ }
1569
1571
ty:: Error ( _) => return None ,
1570
1572
_ => span_bug ! ( body. span, "unexpected coroutine type {}" , coroutine_ty) ,
1571
1573
} ;
@@ -1597,12 +1599,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1597
1599
1598
1600
// The first argument is the coroutine type passed by value
1599
1601
let coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
1602
+ let coroutine_kind = body. coroutine_kind ( ) . unwrap ( ) ;
1600
1603
1601
1604
// Get the discriminant type and args which typeck computed
1602
1605
let ( discr_ty, movable) = match * coroutine_ty. kind ( ) {
1603
- ty:: Coroutine ( def_id , args) => {
1606
+ ty:: Coroutine ( _ , args) => {
1604
1607
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 )
1606
1609
}
1607
1610
_ => {
1608
1611
tcx. dcx ( ) . span_delayed_bug (
@@ -1613,19 +1616,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1613
1616
}
1614
1617
} ;
1615
1618
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 {
1629
1626
CoroutineKind :: Desugared ( CoroutineDesugaring :: Async , _) => {
1630
1627
// Compute Poll<return_ty>
1631
1628
let poll_did = tcx. require_lang_item ( LangItem :: Poll , None ) ;
0 commit comments