@@ -57,6 +57,13 @@ pub struct EvalCtxt<'a, 'tcx> {
57
57
pub ( super ) search_graph : & ' a mut SearchGraph < ' tcx > ,
58
58
59
59
pub ( super ) nested_goals : NestedGoals < ' tcx > ,
60
+
61
+ // Has this `EvalCtxt` errored out with `NoSolution` in `try_evaluate_added_goals`?
62
+ //
63
+ // If so, then it can no longer be used to make a canonical query response,
64
+ // since subsequent calls to `try_evaluate_added_goals` have possibly dropped
65
+ // ambiguous goals. Instead, use a probe.
66
+ tainted : bool ,
60
67
}
61
68
62
69
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
@@ -121,6 +128,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
121
128
max_input_universe : ty:: UniverseIndex :: ROOT ,
122
129
var_values : CanonicalVarValues :: dummy ( ) ,
123
130
nested_goals : NestedGoals :: new ( ) ,
131
+ tainted : false ,
124
132
} ;
125
133
let result = ecx. evaluate_goal ( IsNormalizesToHack :: No , goal) ;
126
134
@@ -172,6 +180,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
172
180
max_input_universe : canonical_goal. max_universe ,
173
181
search_graph,
174
182
nested_goals : NestedGoals :: new ( ) ,
183
+ tainted : false ,
175
184
} ;
176
185
ecx. compute_goal ( goal)
177
186
} )
@@ -391,6 +400,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
391
400
} ,
392
401
) ;
393
402
403
+ if response. is_err ( ) {
404
+ self . tainted = true ;
405
+ }
406
+
394
407
self . nested_goals = goals;
395
408
response
396
409
}
@@ -404,6 +417,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
404
417
max_input_universe : self . max_input_universe ,
405
418
search_graph : self . search_graph ,
406
419
nested_goals : self . nested_goals . clone ( ) ,
420
+ tainted : self . tainted ,
407
421
} ;
408
422
self . infcx . probe ( |_| f ( & mut ecx) )
409
423
}
0 commit comments