Skip to content

Commit 3206100

Browse files
Result is just bool but special
1 parent 4fd7739 commit 3206100

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ pub struct EvalCtxt<'a, 'tcx> {
6262
//
6363
// If so, then it can no longer be used to make a canonical query response,
6464
// since subsequent calls to `try_evaluate_added_goals` have possibly dropped
65-
// ambiguous goals. Instead, use a probe.
66-
tainted: bool,
65+
// ambiguous goals. Instead, a probe needs to be introduced somewhere in the
66+
// evaluation code.
67+
tainted: Result<(), NoSolution>,
6768
}
6869

6970
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -128,7 +129,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
128129
max_input_universe: ty::UniverseIndex::ROOT,
129130
var_values: CanonicalVarValues::dummy(),
130131
nested_goals: NestedGoals::new(),
131-
tainted: false,
132+
tainted: Ok(()),
132133
};
133134
let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal);
134135

@@ -180,7 +181,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
180181
max_input_universe: canonical_goal.max_universe,
181182
search_graph,
182183
nested_goals: NestedGoals::new(),
183-
tainted: false,
184+
tainted: Ok(()),
184185
};
185186
ecx.compute_goal(goal)
186187
})
@@ -401,7 +402,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
401402
);
402403

403404
if response.is_err() {
404-
self.tainted = true;
405+
self.tainted = Err(NoSolution);
405406
}
406407

407408
self.nested_goals = goals;

compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
5151
certainty: Certainty,
5252
) -> QueryResult<'tcx> {
5353
let goals_certainty = self.try_evaluate_added_goals()?;
54-
assert!(
55-
!self.tainted,
54+
assert_eq!(
55+
self.tainted,
56+
Ok(()),
5657
"EvalCtxt is tainted -- nested goals may have been dropped in a \
5758
previous call to `try_evaluate_added_goals!`"
5859
);

0 commit comments

Comments
 (0)