aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/traits.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 6a012cd6a..4932eac45 100644
--- a/crates/hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
@@ -152,9 +152,6 @@ fn solve(
152 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>, 152 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>,
153) -> Option<chalk_solve::Solution<Interner>> { 153) -> Option<chalk_solve::Solution<Interner>> {
154 let context = ChalkContext { db, krate }; 154 let context = ChalkContext { db, krate };
155
156 let logging_db = LoggingRustIrDatabase::new(context);
157
158 log::debug!("solve goal: {:?}", goal); 155 log::debug!("solve goal: {:?}", goal);
159 let mut solver = create_chalk_solver(); 156 let mut solver = create_chalk_solver();
160 157
@@ -169,17 +166,23 @@ fn solve(
169 } 166 }
170 remaining > 0 167 remaining > 0
171 }; 168 };
172 let mut solve = || { 169
173 let solution = solver.solve_limited(&logging_db, goal, should_continue); 170 let solution = if is_chalk_debug() {
174 log::debug!("solve({:?}) => {:?}", goal, solution); 171 let logging_db = LoggingRustIrDatabase::new(context);
175 solution 172 let solve = || {
173 let solution = solver.solve_limited(&logging_db, goal, should_continue);
174 log::debug!("chalk program:\n{}", logging_db);
175 solution
176 };
177
178 // don't set the TLS for Chalk unless Chalk debugging is active, to make
179 // extra sure we only use it for debugging
180 chalk::tls::set_current_program(db, solve)
181 } else {
182 solver.solve_limited(&context, goal, should_continue)
176 }; 183 };
177 // don't set the TLS for Chalk unless Chalk debugging is active, to make
178 // extra sure we only use it for debugging
179 let solution =
180 if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() };
181 184
182 log::debug!("chalk program:\n{}", logging_db); 185 log::debug!("solve({:?}) => {:?}", goal, solution);
183 186
184 solution 187 solution
185} 188}