@@ -208,20 +208,9 @@ where
208
208
}
209
209
}
210
210
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;
225
214
}
226
215
227
216
ecx. probe_and_evaluate_goal_for_constituent_tys (
@@ -275,20 +264,9 @@ where
275
264
return Err ( NoSolution ) ;
276
265
}
277
266
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;
292
270
}
293
271
294
272
ecx. probe_and_evaluate_goal_for_constituent_tys (
@@ -1400,4 +1378,26 @@ where
1400
1378
let candidates = self . assemble_and_evaluate_candidates ( goal, AssembleCandidatesFrom :: All ) ;
1401
1379
self . merge_trait_candidates ( goal, candidates)
1402
1380
}
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 { stalled_generators, defining_opaque_types : _ } => {
1389
+ if def_id. as_local ( ) . is_some_and ( |def_id| stalled_generators. contains ( & def_id) )
1390
+ {
1391
+ return Some ( self . forced_ambiguity ( MaybeCause :: Ambiguity ) ) ;
1392
+ }
1393
+ }
1394
+ TypingMode :: Coherence
1395
+ | TypingMode :: PostAnalysis
1396
+ | TypingMode :: Borrowck { defining_opaque_types : _ }
1397
+ | TypingMode :: PostBorrowckAnalysis { defined_opaque_types : _ } => { }
1398
+ }
1399
+ }
1400
+
1401
+ None
1402
+ }
1403
1403
}
0 commit comments