@@ -1218,22 +1218,31 @@ pub fn typeid_for_instance<'tcx>(
1218
1218
let trait_id = tcx. fn_trait_kind_to_def_id ( closure_args. kind ( ) ) . unwrap ( ) ;
1219
1219
let tuple_args =
1220
1220
tcx. instantiate_bound_regions_with_erased ( closure_args. sig ( ) ) . inputs ( ) [ 0 ] ;
1221
- ( trait_id, tuple_args)
1221
+ ( trait_id, Some ( tuple_args. into ( ) ) )
1222
1222
}
1223
- ty:: Coroutine ( ..) => (
1223
+ // Implements coroutine, vtable entry could appear in `Coroutine`
1224
+ ty:: Coroutine ( ..) if tcx. is_general_coroutine ( instance. def_id ( ) ) => (
1224
1225
tcx. require_lang_item ( LangItem :: Coroutine , None ) ,
1225
- instance. args . as_coroutine ( ) . resume_ty ( ) ,
1226
+ Some ( instance. args . as_coroutine ( ) . resume_ty ( ) . into ( ) ) ,
1226
1227
) ,
1228
+ // Async coroutines implement `Future`, which have no args
1229
+ ty:: Coroutine ( ..) if tcx. coroutine_is_async ( instance. def_id ( ) ) => {
1230
+ ( tcx. require_lang_item ( LangItem :: Future , None ) , None )
1231
+ }
1227
1232
ty:: CoroutineClosure ( ..) => (
1228
1233
tcx. require_lang_item ( LangItem :: FnOnce , None ) ,
1229
- tcx. instantiate_bound_regions_with_erased (
1230
- instance. args . as_coroutine_closure ( ) . coroutine_closure_sig ( ) ,
1231
- )
1232
- . tupled_inputs_ty ,
1234
+ Some (
1235
+ tcx. instantiate_bound_regions_with_erased (
1236
+ instance. args . as_coroutine_closure ( ) . coroutine_closure_sig ( ) ,
1237
+ )
1238
+ . tupled_inputs_ty
1239
+ . into ( ) ,
1240
+ ) ,
1233
1241
) ,
1234
1242
x => bug ! ( "Unexpected type kind for closure-like: {x:?}" ) ,
1235
1243
} ;
1236
- let trait_ref = ty:: TraitRef :: new ( tcx, trait_id, [ closure_ty, inputs] ) ;
1244
+ let concrete_args = tcx. mk_args_trait ( closure_ty, inputs) ;
1245
+ let trait_ref = ty:: TraitRef :: new ( tcx, trait_id, concrete_args) ;
1237
1246
let invoke_ty = trait_object_ty ( tcx, ty:: Binder :: dummy ( trait_ref) ) ;
1238
1247
let abstract_args = tcx. mk_args_trait ( invoke_ty, trait_ref. args . into_iter ( ) . skip ( 1 ) ) ;
1239
1248
// There should be exactly one method on this trait, and it should be the one we're
0 commit comments