From a5083eb43e4916b8dcce877041fea630f4d1b2e2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 15 Mar 2022 20:14:18 -0400 Subject: [PATCH] add a fast path --- chalk-recursive/src/solve.rs | 6 ++++++ chalk-solve/src/solve.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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)