@@ -101,6 +101,9 @@ pub enum InstanceDef<'tcx> {
101
101
target_kind : ty:: ClosureKind ,
102
102
} ,
103
103
104
+ /// TODO:
105
+ CoroutineByMoveShim { coroutine_def_id : DefId } ,
106
+
104
107
/// Compiler-generated accessor for thread locals which returns a reference to the thread local
105
108
/// the `DefId` defines. This is used to export thread locals from dylibs on platforms lacking
106
109
/// native support.
@@ -186,6 +189,7 @@ impl<'tcx> InstanceDef<'tcx> {
186
189
coroutine_closure_def_id : def_id,
187
190
target_kind : _,
188
191
}
192
+ | ty:: InstanceDef :: CoroutineByMoveShim { coroutine_def_id : def_id }
189
193
| InstanceDef :: DropGlue ( def_id, _)
190
194
| InstanceDef :: CloneShim ( def_id, _)
191
195
| InstanceDef :: FnPtrAddrShim ( def_id, _) => def_id,
@@ -206,6 +210,7 @@ impl<'tcx> InstanceDef<'tcx> {
206
210
| InstanceDef :: Intrinsic ( ..)
207
211
| InstanceDef :: ClosureOnceShim { .. }
208
212
| ty:: InstanceDef :: ConstructCoroutineInClosureShim { .. }
213
+ | ty:: InstanceDef :: CoroutineByMoveShim { .. }
209
214
| InstanceDef :: DropGlue ( ..)
210
215
| InstanceDef :: CloneShim ( ..)
211
216
| InstanceDef :: FnPtrAddrShim ( ..) => None ,
@@ -302,6 +307,7 @@ impl<'tcx> InstanceDef<'tcx> {
302
307
| InstanceDef :: DropGlue ( _, Some ( _) ) => false ,
303
308
InstanceDef :: ClosureOnceShim { .. }
304
309
| InstanceDef :: ConstructCoroutineInClosureShim { .. }
310
+ | InstanceDef :: CoroutineByMoveShim { .. }
305
311
| InstanceDef :: DropGlue ( ..)
306
312
| InstanceDef :: Item ( _)
307
313
| InstanceDef :: Intrinsic ( ..)
@@ -340,6 +346,7 @@ fn fmt_instance(
340
346
InstanceDef :: FnPtrShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
341
347
InstanceDef :: ClosureOnceShim { .. } => write ! ( f, " - shim" ) ,
342
348
InstanceDef :: ConstructCoroutineInClosureShim { .. } => write ! ( f, " - shim" ) ,
349
+ InstanceDef :: CoroutineByMoveShim { .. } => write ! ( f, " - shim" ) ,
343
350
InstanceDef :: DropGlue ( _, None ) => write ! ( f, " - shim(None)" ) ,
344
351
InstanceDef :: DropGlue ( _, Some ( ty) ) => write ! ( f, " - shim(Some({ty}))" ) ,
345
352
InstanceDef :: CloneShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
@@ -631,7 +638,19 @@ impl<'tcx> Instance<'tcx> {
631
638
} ;
632
639
633
640
if tcx. lang_items ( ) . get ( coroutine_callable_item) == Some ( trait_item_id) {
634
- Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args : args } )
641
+ let ty:: Coroutine ( _, id_args) = * tcx. type_of ( coroutine_def_id) . skip_binder ( ) . kind ( )
642
+ else {
643
+ bug ! ( )
644
+ } ;
645
+
646
+ if args. as_coroutine ( ) . kind_ty ( ) == id_args. as_coroutine ( ) . kind_ty ( ) {
647
+ Some ( Instance { def : ty:: InstanceDef :: Item ( coroutine_def_id) , args } )
648
+ } else {
649
+ Some ( Instance {
650
+ def : ty:: InstanceDef :: CoroutineByMoveShim { coroutine_def_id } ,
651
+ args,
652
+ } )
653
+ }
635
654
} else {
636
655
// All other methods should be defaulted methods of the built-in trait.
637
656
// This is important for `Iterator`'s combinators, but also useful for
0 commit comments