aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/traits.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 4932eac45..1c3abb18f 100644
--- a/crates/hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
@@ -167,21 +167,22 @@ fn solve(
167 remaining > 0 167 remaining > 0
168 }; 168 };
169 169
170 let solution = if is_chalk_debug() { 170 let mut solve = || {
171 let logging_db = LoggingRustIrDatabase::new(context); 171 if is_chalk_print() {
172 let solve = || { 172 let logging_db = LoggingRustIrDatabase::new(context);
173 let solution = solver.solve_limited(&logging_db, goal, should_continue); 173 let solution = solver.solve_limited(&logging_db, goal, should_continue);
174 log::debug!("chalk program:\n{}", logging_db); 174 log::debug!("chalk program:\n{}", logging_db);
175 solution 175 solution
176 }; 176 } else {
177 177 solver.solve_limited(&context, goal, should_continue)
178 // don't set the TLS for Chalk unless Chalk debugging is active, to make 178 }
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)
183 }; 179 };
184 180
181 // don't set the TLS for Chalk unless Chalk debugging is active, to make
182 // extra sure we only use it for debugging
183 let solution =
184 if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() };
185
185 log::debug!("solve({:?}) => {:?}", goal, solution); 186 log::debug!("solve({:?}) => {:?}", goal, solution);
186 187
187 solution 188 solution
@@ -191,6 +192,10 @@ fn is_chalk_debug() -> bool {
191 std::env::var("CHALK_DEBUG").is_ok() 192 std::env::var("CHALK_DEBUG").is_ok()
192} 193}
193 194
195fn is_chalk_print() -> bool {
196 std::env::var("CHALK_PRINT").is_ok()
197}
198
194fn solution_from_chalk( 199fn solution_from_chalk(
195 db: &dyn HirDatabase, 200 db: &dyn HirDatabase,
196 solution: chalk_solve::Solution<Interner>, 201 solution: chalk_solve::Solution<Interner>,