@@ -57,6 +57,13 @@ pub struct EvalCtxt<'a, 'tcx> {
5757 pub ( super ) search_graph : & ' a mut SearchGraph < ' tcx > ,
5858
5959 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 ,
6067}
6168
6269#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
@@ -121,6 +128,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
121128 max_input_universe : ty:: UniverseIndex :: ROOT ,
122129 var_values : CanonicalVarValues :: dummy ( ) ,
123130 nested_goals : NestedGoals :: new ( ) ,
131+ tainted : false ,
124132 } ;
125133 let result = ecx. evaluate_goal ( IsNormalizesToHack :: No , goal) ;
126134
@@ -172,6 +180,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
172180 max_input_universe : canonical_goal. max_universe ,
173181 search_graph,
174182 nested_goals : NestedGoals :: new ( ) ,
183+ tainted : false ,
175184 } ;
176185 ecx. compute_goal ( goal)
177186 } )
@@ -391,6 +400,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
391400 } ,
392401 ) ;
393402
403+ if response. is_err ( ) {
404+ self . tainted = true ;
405+ }
406+
394407 self . nested_goals = goals;
395408 response
396409 }
@@ -404,6 +417,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
404417 max_input_universe : self . max_input_universe ,
405418 search_graph : self . search_graph ,
406419 nested_goals : self . nested_goals . clone ( ) ,
420+ tainted : self . tainted ,
407421 } ;
408422 self . infcx . probe ( |_| f ( & mut ecx) )
409423 }
0 commit comments