@@ -635,28 +635,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
635635
636636 let mut obligations = vec ! [ ] ;
637637
638- for & ( coroutine_def_id, interior) in coroutines. iter ( ) {
639- debug ! ( ?coroutine_def_id) ;
638+ if !self . next_trait_solver ( ) {
639+ for & ( coroutine_def_id, interior) in coroutines. iter ( ) {
640+ debug ! ( ?coroutine_def_id) ;
641+
642+ // Create the `CoroutineWitness` type that we will unify with `interior`.
643+ let args = ty:: GenericArgs :: identity_for_item (
644+ self . tcx ,
645+ self . tcx . typeck_root_def_id ( coroutine_def_id. to_def_id ( ) ) ,
646+ ) ;
647+ let witness =
648+ Ty :: new_coroutine_witness ( self . tcx , coroutine_def_id. to_def_id ( ) , args) ;
640649
641- // Create the `CoroutineWitness` type that we will unify with `interior`.
642- let args = ty:: GenericArgs :: identity_for_item (
643- self . tcx ,
644- self . tcx . typeck_root_def_id ( coroutine_def_id. to_def_id ( ) ) ,
645- ) ;
646- let witness = Ty :: new_coroutine_witness ( self . tcx , coroutine_def_id. to_def_id ( ) , args) ;
647-
648- // Unify `interior` with `witness` and collect all the resulting obligations.
649- let span = self . tcx . hir_body_owned_by ( coroutine_def_id) . value . span ;
650- let ty:: Infer ( ty:: InferTy :: TyVar ( _) ) = interior. kind ( ) else {
651- span_bug ! ( span, "coroutine interior witness not infer: {:?}" , interior. kind( ) )
652- } ;
653- let ok = self
654- . at ( & self . misc ( span) , self . param_env )
655- // Will never define opaque types, as all we do is instantiate a type variable.
656- . eq ( DefineOpaqueTypes :: Yes , interior, witness)
657- . expect ( "Failed to unify coroutine interior type" ) ;
658-
659- obligations. extend ( ok. obligations ) ;
650+ // Unify `interior` with `witness` and collect all the resulting obligations.
651+ let span = self . tcx . hir_body_owned_by ( coroutine_def_id) . value . span ;
652+ let ty:: Infer ( ty:: InferTy :: TyVar ( _) ) = interior. kind ( ) else {
653+ span_bug ! ( span, "coroutine interior witness not infer: {:?}" , interior. kind( ) )
654+ } ;
655+ let ok = self
656+ . at ( & self . misc ( span) , self . param_env )
657+ // Will never define opaque types, as all we do is instantiate a type variable.
658+ . eq ( DefineOpaqueTypes :: Yes , interior, witness)
659+ . expect ( "Failed to unify coroutine interior type" ) ;
660+
661+ obligations. extend ( ok. obligations ) ;
662+ }
660663 }
661664
662665 if !coroutines. is_empty ( ) {
0 commit comments