diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs index 4c79445d345..bd52957d162 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs @@ -62,8 +62,9 @@ pub struct EvalCtxt<'a, 'tcx> { // // If so, then it can no longer be used to make a canonical query response, // since subsequent calls to `try_evaluate_added_goals` have possibly dropped - // ambiguous goals. Instead, use a probe. - tainted: bool, + // ambiguous goals. Instead, a probe needs to be introduced somewhere in the + // evaluation code. + tainted: Result<(), NoSolution>, } #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -128,7 +129,7 @@ fn evaluate_root_goal( max_input_universe: ty::UniverseIndex::ROOT, var_values: CanonicalVarValues::dummy(), nested_goals: NestedGoals::new(), - tainted: false, + tainted: Ok(()), }; let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal); @@ -180,7 +181,7 @@ fn evaluate_canonical_goal( max_input_universe: canonical_goal.max_universe, search_graph, nested_goals: NestedGoals::new(), - tainted: false, + tainted: Ok(()), }; ecx.compute_goal(goal) }) @@ -401,7 +402,7 @@ pub(super) fn try_evaluate_added_goals(&mut self) -> Result QueryResult<'tcx> { let goals_certainty = self.try_evaluate_added_goals()?; - assert!( - !self.tainted, + assert_eq!( + self.tainted, + Ok(()), "EvalCtxt is tainted -- nested goals may have been dropped in a \ previous call to `try_evaluate_added_goals!`" );