@@ -426,7 +426,10 @@ impl<'tcx> Instance<'tcx> {
426426 ) -> Option < Instance < ' tcx > > {
427427 debug ! ( "resolve(def_id={:?}, args={:?})" , def_id, args) ;
428428 // Use either `resolve_closure` or `resolve_for_vtable`
429- assert ! ( !tcx. is_closure( def_id) , "Called `resolve_for_fn_ptr` on closure: {def_id:?}" ) ;
429+ assert ! (
430+ !tcx. is_closure_or_coroutine( def_id) ,
431+ "Called `resolve_for_fn_ptr` on closure: {def_id:?}"
432+ ) ;
430433 Instance :: resolve ( tcx, param_env, def_id, args) . ok ( ) . flatten ( ) . map ( |mut resolved| {
431434 match resolved. def {
432435 InstanceDef :: Item ( def) if resolved. def . requires_caller_location ( tcx) => {
@@ -488,7 +491,7 @@ impl<'tcx> Instance<'tcx> {
488491 } )
489492 )
490493 {
491- if tcx. is_closure ( def) {
494+ if tcx. is_closure_or_coroutine ( def) {
492495 debug ! ( " => vtable fn pointer created for closure with #[track_caller]: {:?} for method {:?} {:?}" ,
493496 def, def_id, args) ;
494497
@@ -658,12 +661,10 @@ fn polymorphize<'tcx>(
658661 // the unpolymorphized upvar closure would result in a polymorphized closure producing
659662 // multiple mono items (and eventually symbol clashes).
660663 let def_id = instance. def_id ( ) ;
661- let upvars_ty = if tcx. is_closure ( def_id) {
662- Some ( args. as_closure ( ) . tupled_upvars_ty ( ) )
663- } else if tcx. type_of ( def_id) . skip_binder ( ) . is_coroutine ( ) {
664- Some ( args. as_coroutine ( ) . tupled_upvars_ty ( ) )
665- } else {
666- None
664+ let upvars_ty = match tcx. type_of ( def_id) . skip_binder ( ) . kind ( ) {
665+ ty:: Closure ( ..) => Some ( args. as_closure ( ) . tupled_upvars_ty ( ) ) ,
666+ ty:: Coroutine ( ..) => Some ( args. as_coroutine ( ) . tupled_upvars_ty ( ) ) ,
667+ _ => None ,
667668 } ;
668669 let has_upvars = upvars_ty. is_some_and ( |ty| !ty. tuple_fields ( ) . is_empty ( ) ) ;
669670 debug ! ( "polymorphize: upvars_ty={:?} has_upvars={:?}" , upvars_ty, has_upvars) ;
0 commit comments