diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs
index f87b1367d6a6..36f68808a2c8 100644
--- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs
@@ -132,12 +132,14 @@ pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
(Certainty::Yes, NestedNormalizationGoals(goals))
}
_ => {
- let certainty = shallow_certainty.unify_with(goals_certainty);
+ let certainty = shallow_certainty.and(goals_certainty);
(certainty, NestedNormalizationGoals::empty())
}
};
- if let Certainty::Maybe(cause @ MaybeCause::Overflow { .. }) = certainty {
+ if let Certainty::Maybe(cause @ MaybeCause::Overflow { keep_constraints: false, .. }) =
+ certainty
+ {
// If we have overflow, it's probable that we're substituting a type
// into itself infinitely and any partial substitutions in the query
// response are probably not useful anyways, so just return an empty
@@ -193,6 +195,7 @@ pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
debug!(?num_non_region_vars, "too many inference variables -> overflow");
return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow {
suggest_increasing_limit: true,
+ keep_constraints: false,
}));
}
}
diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
index c8c914be63b4..fc5dad9a3edf 100644
--- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
@@ -661,7 +661,7 @@ fn evaluate_added_goals_step(&mut self) -> Result