@@ -1218,22 +1218,31 @@ pub fn typeid_for_instance<'tcx>(
12181218 let trait_id = tcx. fn_trait_kind_to_def_id ( closure_args. kind ( ) ) . unwrap ( ) ;
12191219 let tuple_args =
12201220 tcx. instantiate_bound_regions_with_erased ( closure_args. sig ( ) ) . inputs ( ) [ 0 ] ;
1221- ( trait_id, tuple_args)
1221+ ( trait_id, Some ( tuple_args. into ( ) ) )
12221222 }
1223- ty:: Coroutine ( ..) => (
1223+ // Implements coroutine, vtable entry could appear in `Coroutine`
1224+ ty:: Coroutine ( ..) if tcx. is_general_coroutine ( instance. def_id ( ) ) => (
12241225 tcx. require_lang_item ( LangItem :: Coroutine , None ) ,
1225- instance. args . as_coroutine ( ) . resume_ty ( ) ,
1226+ Some ( instance. args . as_coroutine ( ) . resume_ty ( ) . into ( ) ) ,
12261227 ) ,
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+ }
12271232 ty:: CoroutineClosure ( ..) => (
12281233 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+ ) ,
12331241 ) ,
12341242 x => bug ! ( "Unexpected type kind for closure-like: {x:?}" ) ,
12351243 } ;
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) ;
12371246 let invoke_ty = trait_object_ty ( tcx, ty:: Binder :: dummy ( trait_ref) ) ;
12381247 let abstract_args = tcx. mk_args_trait ( invoke_ty, trait_ref. args . into_iter ( ) . skip ( 1 ) ) ;
12391248 // There should be exactly one method on this trait, and it should be the one we're
0 commit comments