@@ -102,10 +102,12 @@ pub enum InstanceDef<'tcx> {
102102    } , 
103103
104104    /// `<[coroutine] as Future>::poll`, but for coroutines produced when `AsyncFnOnce` 
105-      /// is called on a coroutine-closure whose closure kind is not `FnOnce`. This 
106-      /// will select the body that is produced by the `ByMoveBody` transform, and thus 
105+      /// is called on a coroutine-closure whose closure kind greater than `FnOnce`, or 
106+      /// similarly for `AsyncFnMut`. 
107+      /// 
108+      /// This will select the body that is produced by the `ByMoveBody` transform, and thus 
107109     /// take and use all of its upvars by-move rather than by-ref. 
108-      CoroutineByMoveShim  {  coroutine_def_id :  DefId  } , 
110+      CoroutineKindShim  {  coroutine_def_id :  DefId ,   target_kind :  ty :: ClosureKind  } , 
109111
110112    /// Compiler-generated accessor for thread locals which returns a reference to the thread local 
111113     /// the `DefId` defines. This is used to export thread locals from dylibs on platforms lacking 
@@ -192,7 +194,7 @@ impl<'tcx> InstanceDef<'tcx> {
192194                coroutine_closure_def_id :  def_id, 
193195                target_kind :  _, 
194196            } 
195-             | ty:: InstanceDef :: CoroutineByMoveShim  {  coroutine_def_id :  def_id } 
197+             | ty:: InstanceDef :: CoroutineKindShim  {  coroutine_def_id :  def_id,   target_kind :  _  } 
196198            | InstanceDef :: DropGlue ( def_id,  _) 
197199            | InstanceDef :: CloneShim ( def_id,  _) 
198200            | InstanceDef :: FnPtrAddrShim ( def_id,  _)  => def_id, 
@@ -213,7 +215,7 @@ impl<'tcx> InstanceDef<'tcx> {
213215            | InstanceDef :: Intrinsic ( ..) 
214216            | InstanceDef :: ClosureOnceShim  {  .. } 
215217            | ty:: InstanceDef :: ConstructCoroutineInClosureShim  {  .. } 
216-             | ty:: InstanceDef :: CoroutineByMoveShim  {  .. } 
218+             | ty:: InstanceDef :: CoroutineKindShim  {  .. } 
217219            | InstanceDef :: DropGlue ( ..) 
218220            | InstanceDef :: CloneShim ( ..) 
219221            | InstanceDef :: FnPtrAddrShim ( ..)  => None , 
@@ -310,7 +312,7 @@ impl<'tcx> InstanceDef<'tcx> {
310312            | InstanceDef :: DropGlue ( _,  Some ( _) )  => false , 
311313            InstanceDef :: ClosureOnceShim  {  .. } 
312314            | InstanceDef :: ConstructCoroutineInClosureShim  {  .. } 
313-             | InstanceDef :: CoroutineByMoveShim  {  .. } 
315+             | InstanceDef :: CoroutineKindShim  {  .. } 
314316            | InstanceDef :: DropGlue ( ..) 
315317            | InstanceDef :: Item ( _) 
316318            | InstanceDef :: Intrinsic ( ..) 
@@ -349,7 +351,7 @@ fn fmt_instance(
349351        InstanceDef :: FnPtrShim ( _,  ty)  => write ! ( f,  " - shim({ty})" ) , 
350352        InstanceDef :: ClosureOnceShim  {  .. }  => write ! ( f,  " - shim" ) , 
351353        InstanceDef :: ConstructCoroutineInClosureShim  {  .. }  => write ! ( f,  " - shim" ) , 
352-         InstanceDef :: CoroutineByMoveShim  {  .. }  => write ! ( f,  " - shim" ) , 
354+         InstanceDef :: CoroutineKindShim  {  .. }  => write ! ( f,  " - shim" ) , 
353355        InstanceDef :: DropGlue ( _,  None )  => write ! ( f,  " - shim(None)" ) , 
354356        InstanceDef :: DropGlue ( _,  Some ( ty) )  => write ! ( f,  " - shim(Some({ty}))" ) , 
355357        InstanceDef :: CloneShim ( _,  ty)  => write ! ( f,  " - shim({ty})" ) , 
@@ -651,13 +653,11 @@ impl<'tcx> Instance<'tcx> {
651653            if  args. as_coroutine ( ) . kind_ty ( )  == id_args. as_coroutine ( ) . kind_ty ( )  { 
652654                Some ( Instance  {  def :  ty:: InstanceDef :: Item ( coroutine_def_id) ,  args } ) 
653655            }  else  { 
654-                 assert_eq ! ( 
655-                     args. as_coroutine( ) . kind_ty( ) . to_opt_closure_kind( ) . unwrap( ) , 
656-                     ty:: ClosureKind :: FnOnce , 
657-                     "FIXME(async_closures): Generate a by-mut body here." 
658-                 ) ; 
659656                Some ( Instance  { 
660-                     def :  ty:: InstanceDef :: CoroutineByMoveShim  {  coroutine_def_id } , 
657+                     def :  ty:: InstanceDef :: CoroutineKindShim  { 
658+                         coroutine_def_id, 
659+                         target_kind :  args. as_coroutine ( ) . kind_ty ( ) . to_opt_closure_kind ( ) . unwrap ( ) , 
660+                     } , 
661661                    args, 
662662                } ) 
663663            } 
0 commit comments