Result is just bool but special

This commit is contained in:
Michael Goulet 2023-04-20 18:40:34 +00:00
parent 4fd7739aac
commit 3206100ed9
2 changed files with 9 additions and 7 deletions

View File

@ -62,8 +62,9 @@ pub struct EvalCtxt<'a, 'tcx> {
// //
// If so, then it can no longer be used to make a canonical query response, // 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 // since subsequent calls to `try_evaluate_added_goals` have possibly dropped
// ambiguous goals. Instead, use a probe. // ambiguous goals. Instead, a probe needs to be introduced somewhere in the
tainted: bool, // evaluation code.
tainted: Result<(), NoSolution>,
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
@ -128,7 +129,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
max_input_universe: ty::UniverseIndex::ROOT, max_input_universe: ty::UniverseIndex::ROOT,
var_values: CanonicalVarValues::dummy(), var_values: CanonicalVarValues::dummy(),
nested_goals: NestedGoals::new(), nested_goals: NestedGoals::new(),
tainted: false, tainted: Ok(()),
}; };
let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal); let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal);
@ -180,7 +181,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
max_input_universe: canonical_goal.max_universe, max_input_universe: canonical_goal.max_universe,
search_graph, search_graph,
nested_goals: NestedGoals::new(), nested_goals: NestedGoals::new(),
tainted: false, tainted: Ok(()),
}; };
ecx.compute_goal(goal) ecx.compute_goal(goal)
}) })
@ -401,7 +402,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
); );
if response.is_err() { if response.is_err() {
self.tainted = true; self.tainted = Err(NoSolution);
} }
self.nested_goals = goals; self.nested_goals = goals;

View File

@ -51,8 +51,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
certainty: Certainty, certainty: Certainty,
) -> QueryResult<'tcx> { ) -> QueryResult<'tcx> {
let goals_certainty = self.try_evaluate_added_goals()?; let goals_certainty = self.try_evaluate_added_goals()?;
assert!( assert_eq!(
!self.tainted, self.tainted,
Ok(()),
"EvalCtxt is tainted -- nested goals may have been dropped in a \ "EvalCtxt is tainted -- nested goals may have been dropped in a \
previous call to `try_evaluate_added_goals!`" previous call to `try_evaluate_added_goals!`"
); );