@@ -101,6 +101,9 @@ pub enum InstanceDef<'tcx> {
101101 target_kind : ty:: ClosureKind ,
102102 } ,
103103
104+ /// TODO:
105+ CoroutineByMoveShim { coroutine_def_id : DefId } ,
106+
104107 /// Compiler-generated accessor for thread locals which returns a reference to the thread local
105108 /// the `DefId` defines. This is used to export thread locals from dylibs on platforms lacking
106109 /// native support.
@@ -186,6 +189,7 @@ impl<'tcx> InstanceDef<'tcx> {
186189 coroutine_closure_def_id : def_id,
187190 target_kind : _,
188191 }
192+ | ty:: InstanceDef :: CoroutineByMoveShim { coroutine_def_id : def_id }
189193 | InstanceDef :: DropGlue ( def_id, _)
190194 | InstanceDef :: CloneShim ( def_id, _)
191195 | InstanceDef :: FnPtrAddrShim ( def_id, _) => def_id,
@@ -206,6 +210,7 @@ impl<'tcx> InstanceDef<'tcx> {
206210 | InstanceDef :: Intrinsic ( ..)
207211 | InstanceDef :: ClosureOnceShim { .. }
208212 | ty:: InstanceDef :: ConstructCoroutineInClosureShim { .. }
213+ | ty:: InstanceDef :: CoroutineByMoveShim { .. }
209214 | InstanceDef :: DropGlue ( ..)
210215 | InstanceDef :: CloneShim ( ..)
211216 | InstanceDef :: FnPtrAddrShim ( ..) => None ,
@@ -302,6 +307,7 @@ impl<'tcx> InstanceDef<'tcx> {
302307 | InstanceDef :: DropGlue ( _, Some ( _) ) => false ,
303308 InstanceDef :: ClosureOnceShim { .. }
304309 | InstanceDef :: ConstructCoroutineInClosureShim { .. }
310+ | InstanceDef :: CoroutineByMoveShim { .. }
305311 | InstanceDef :: DropGlue ( ..)
306312 | InstanceDef :: Item ( _)
307313 | InstanceDef :: Intrinsic ( ..)
@@ -340,6 +346,7 @@ fn fmt_instance(
340346 InstanceDef :: FnPtrShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
341347 InstanceDef :: ClosureOnceShim { .. } => write ! ( f, " - shim" ) ,
342348 InstanceDef :: ConstructCoroutineInClosureShim { .. } => write ! ( f, " - shim" ) ,
349+ InstanceDef :: CoroutineByMoveShim { .. } => write ! ( f, " - shim" ) ,
343350 InstanceDef :: DropGlue ( _, None ) => write ! ( f, " - shim(None)" ) ,
344351 InstanceDef :: DropGlue ( _, Some ( ty) ) => write ! ( f, " - shim(Some({ty}))" ) ,
345352 InstanceDef :: CloneShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
@@ -631,7 +638,19 @@ impl<'tcx> Instance<'tcx> {
631638 } ;
632639
633640 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+ }
635654 } else {
636655 // All other methods should be defaulted methods of the built-in trait.
637656 // This is important for `Iterator`'s combinators, but also useful for
0 commit comments