diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 5a1e12ce9..21e233379 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs | |||
@@ -177,7 +177,7 @@ fn solve( | |||
177 | 177 | ||
178 | let fuel = std::cell::Cell::new(CHALK_SOLVER_FUEL); | 178 | let fuel = std::cell::Cell::new(CHALK_SOLVER_FUEL); |
179 | 179 | ||
180 | let solution = solver.solve_limited(&context, goal, || { | 180 | let should_continue = || { |
181 | context.db.check_canceled(); | 181 | context.db.check_canceled(); |
182 | let remaining = fuel.get(); | 182 | let remaining = fuel.get(); |
183 | fuel.set(remaining - 1); | 183 | fuel.set(remaining - 1); |
@@ -185,12 +185,21 @@ fn solve( | |||
185 | log::debug!("fuel exhausted"); | 185 | log::debug!("fuel exhausted"); |
186 | } | 186 | } |
187 | remaining > 0 | 187 | remaining > 0 |
188 | }); | 188 | }; |
189 | let mut solve = || solver.solve_limited(&context, goal, should_continue); | ||
190 | // don't set the TLS for Chalk unless Chalk debugging is active, to make | ||
191 | // extra sure we only use it for debugging | ||
192 | let solution = | ||
193 | if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; | ||
189 | 194 | ||
190 | log::debug!("solve({:?}) => {:?}", goal, solution); | 195 | log::debug!("solve({:?}) => {:?}", goal, solution); |
191 | solution | 196 | solution |
192 | } | 197 | } |
193 | 198 | ||
199 | fn is_chalk_debug() -> bool { | ||
200 | std::env::var("CHALK_DEBUG").is_ok() | ||
201 | } | ||
202 | |||
194 | fn solution_from_chalk( | 203 | fn solution_from_chalk( |
195 | db: &dyn HirDatabase, | 204 | db: &dyn HirDatabase, |
196 | solution: chalk_solve::Solution<Interner>, | 205 | solution: chalk_solve::Solution<Interner>, |