diff --git a/chalk-recursive/src/solve.rs b/chalk-recursive/src/solve.rs index a3212bafb09..47db7080ab3 100644 --- a/chalk-recursive/src/solve.rs +++ b/chalk-recursive/src/solve.rs @@ -179,6 +179,12 @@ trait SolveIterationHelpers: SolveDatabase { } else { debug!("Error"); } + + if let Some((cur_solution, _)) = &cur_solution { + if cur_solution.is_trivial_and_always_true(self.interner()) { + break; + } + } } if let Some((s, _)) = cur_solution { diff --git a/chalk-solve/src/solve.rs b/chalk-solve/src/solve.rs index 19389188650..0734fc53ea3 100644 --- a/chalk-solve/src/solve.rs +++ b/chalk-solve/src/solve.rs @@ -101,7 +101,7 @@ impl Solution { Solution::Ambig(guidance) } - fn is_trivial_and_always_true(&self, interner: I) -> bool { + pub fn is_trivial_and_always_true(&self, interner: I) -> bool { match self { Solution::Unique(constrained_subst) => { constrained_subst.value.subst.is_identity_subst(interner)