@@ -208,20 +208,9 @@ where
208208 }
209209 }
210210
211- // TODO:
212- if let ty:: CoroutineWitness ( def_id, _) = goal. predicate . self_ty ( ) . kind ( ) {
213- match ecx. typing_mode ( ) {
214- TypingMode :: Analysis { stalled_generators, defining_opaque_types : _ } => {
215- if def_id. as_local ( ) . is_some_and ( |def_id| stalled_generators. contains ( & def_id) )
216- {
217- return ecx. forced_ambiguity ( MaybeCause :: Ambiguity ) ;
218- }
219- }
220- TypingMode :: Coherence
221- | TypingMode :: PostAnalysis
222- | TypingMode :: Borrowck { defining_opaque_types : _ }
223- | TypingMode :: PostBorrowckAnalysis { defined_opaque_types : _ } => { }
224- }
211+ // We need to make sure to stall any coroutines we are inferring to avoid query cycles.
212+ if let Some ( cand) = ecx. try_stall_coroutine_witness ( goal. predicate . self_ty ( ) ) {
213+ return cand;
225214 }
226215
227216 ecx. probe_and_evaluate_goal_for_constituent_tys (
@@ -275,20 +264,9 @@ where
275264 return Err ( NoSolution ) ;
276265 }
277266
278- // TODO:
279- if let ty:: CoroutineWitness ( def_id, _) = goal. predicate . self_ty ( ) . kind ( ) {
280- match ecx. typing_mode ( ) {
281- TypingMode :: Analysis { stalled_generators, defining_opaque_types : _ } => {
282- if def_id. as_local ( ) . is_some_and ( |def_id| stalled_generators. contains ( & def_id) )
283- {
284- return ecx. forced_ambiguity ( MaybeCause :: Ambiguity ) ;
285- }
286- }
287- TypingMode :: Coherence
288- | TypingMode :: PostAnalysis
289- | TypingMode :: Borrowck { defining_opaque_types : _ }
290- | TypingMode :: PostBorrowckAnalysis { defined_opaque_types : _ } => { }
291- }
267+ // We need to make sure to stall any coroutines we are inferring to avoid query cycles.
268+ if let Some ( cand) = ecx. try_stall_coroutine_witness ( goal. predicate . self_ty ( ) ) {
269+ return cand;
292270 }
293271
294272 ecx. probe_and_evaluate_goal_for_constituent_tys (
@@ -1400,4 +1378,28 @@ where
14001378 let candidates = self . assemble_and_evaluate_candidates ( goal, AssembleCandidatesFrom :: All ) ;
14011379 self . merge_trait_candidates ( goal, candidates)
14021380 }
1381+
1382+ fn try_stall_coroutine_witness (
1383+ & mut self ,
1384+ self_ty : I :: Ty ,
1385+ ) -> Option < Result < Candidate < I > , NoSolution > > {
1386+ if let ty:: CoroutineWitness ( def_id, _) = self_ty. kind ( ) {
1387+ match self . typing_mode ( ) {
1388+ TypingMode :: Analysis {
1389+ defining_opaque_types_and_generators : stalled_generators,
1390+ } => {
1391+ if def_id. as_local ( ) . is_some_and ( |def_id| stalled_generators. contains ( & def_id) )
1392+ {
1393+ return Some ( self . forced_ambiguity ( MaybeCause :: Ambiguity ) ) ;
1394+ }
1395+ }
1396+ TypingMode :: Coherence
1397+ | TypingMode :: PostAnalysis
1398+ | TypingMode :: Borrowck { defining_opaque_types : _ }
1399+ | TypingMode :: PostBorrowckAnalysis { defined_opaque_types : _ } => { }
1400+ }
1401+ }
1402+
1403+ None
1404+ }
14031405}
0 commit comments