@@ -102,10 +102,12 @@ pub enum InstanceDef<'tcx> {
102
102
} ,
103
103
104
104
/// `<[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
107
109
/// 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 } ,
109
111
110
112
/// Compiler-generated accessor for thread locals which returns a reference to the thread local
111
113
/// the `DefId` defines. This is used to export thread locals from dylibs on platforms lacking
@@ -192,7 +194,7 @@ impl<'tcx> InstanceDef<'tcx> {
192
194
coroutine_closure_def_id : def_id,
193
195
target_kind : _,
194
196
}
195
- | ty:: InstanceDef :: CoroutineByMoveShim { coroutine_def_id : def_id }
197
+ | ty:: InstanceDef :: CoroutineKindShim { coroutine_def_id : def_id, target_kind : _ }
196
198
| InstanceDef :: DropGlue ( def_id, _)
197
199
| InstanceDef :: CloneShim ( def_id, _)
198
200
| InstanceDef :: FnPtrAddrShim ( def_id, _) => def_id,
@@ -213,7 +215,7 @@ impl<'tcx> InstanceDef<'tcx> {
213
215
| InstanceDef :: Intrinsic ( ..)
214
216
| InstanceDef :: ClosureOnceShim { .. }
215
217
| ty:: InstanceDef :: ConstructCoroutineInClosureShim { .. }
216
- | ty:: InstanceDef :: CoroutineByMoveShim { .. }
218
+ | ty:: InstanceDef :: CoroutineKindShim { .. }
217
219
| InstanceDef :: DropGlue ( ..)
218
220
| InstanceDef :: CloneShim ( ..)
219
221
| InstanceDef :: FnPtrAddrShim ( ..) => None ,
@@ -310,7 +312,7 @@ impl<'tcx> InstanceDef<'tcx> {
310
312
| InstanceDef :: DropGlue ( _, Some ( _) ) => false ,
311
313
InstanceDef :: ClosureOnceShim { .. }
312
314
| InstanceDef :: ConstructCoroutineInClosureShim { .. }
313
- | InstanceDef :: CoroutineByMoveShim { .. }
315
+ | InstanceDef :: CoroutineKindShim { .. }
314
316
| InstanceDef :: DropGlue ( ..)
315
317
| InstanceDef :: Item ( _)
316
318
| InstanceDef :: Intrinsic ( ..)
@@ -349,7 +351,7 @@ fn fmt_instance(
349
351
InstanceDef :: FnPtrShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
350
352
InstanceDef :: ClosureOnceShim { .. } => write ! ( f, " - shim" ) ,
351
353
InstanceDef :: ConstructCoroutineInClosureShim { .. } => write ! ( f, " - shim" ) ,
352
- InstanceDef :: CoroutineByMoveShim { .. } => write ! ( f, " - shim" ) ,
354
+ InstanceDef :: CoroutineKindShim { .. } => write ! ( f, " - shim" ) ,
353
355
InstanceDef :: DropGlue ( _, None ) => write ! ( f, " - shim(None)" ) ,
354
356
InstanceDef :: DropGlue ( _, Some ( ty) ) => write ! ( f, " - shim(Some({ty}))" ) ,
355
357
InstanceDef :: CloneShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
@@ -651,13 +653,11 @@ impl<'tcx> Instance<'tcx> {
651
653
if args. as_coroutine ( ) . kind_ty ( ) == id_args. as_coroutine ( ) . kind_ty ( ) {
652
654
Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args } )
653
655
} 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
- ) ;
659
656
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
+ } ,
661
661
args,
662
662
} )
663
663
}
0 commit comments