diff options
Diffstat (limited to 'crates/hir_ty/src/traits.rs')
-rw-r--r-- | crates/hir_ty/src/traits.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 255323717..1c3abb18f 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs | |||
@@ -3,7 +3,7 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use base_db::CrateId; | 4 | use base_db::CrateId; |
5 | use chalk_ir::cast::Cast; | 5 | use chalk_ir::cast::Cast; |
6 | use chalk_solve::Solver; | 6 | use chalk_solve::{logging_db::LoggingRustIrDatabase, Solver}; |
7 | use hir_def::{lang_item::LangItemTarget, TraitId}; | 7 | use hir_def::{lang_item::LangItemTarget, TraitId}; |
8 | 8 | ||
9 | use crate::{db::HirDatabase, DebruijnIndex, Substs}; | 9 | use crate::{db::HirDatabase, DebruijnIndex, Substs}; |
@@ -166,16 +166,25 @@ fn solve( | |||
166 | } | 166 | } |
167 | remaining > 0 | 167 | remaining > 0 |
168 | }; | 168 | }; |
169 | |||
169 | let mut solve = || { | 170 | let mut solve = || { |
170 | let solution = solver.solve_limited(&context, goal, should_continue); | 171 | if is_chalk_print() { |
171 | log::debug!("solve({:?}) => {:?}", goal, solution); | 172 | let logging_db = LoggingRustIrDatabase::new(context); |
172 | solution | 173 | let solution = solver.solve_limited(&logging_db, goal, should_continue); |
174 | log::debug!("chalk program:\n{}", logging_db); | ||
175 | solution | ||
176 | } else { | ||
177 | solver.solve_limited(&context, goal, should_continue) | ||
178 | } | ||
173 | }; | 179 | }; |
180 | |||
174 | // don't set the TLS for Chalk unless Chalk debugging is active, to make | 181 | // don't set the TLS for Chalk unless Chalk debugging is active, to make |
175 | // extra sure we only use it for debugging | 182 | // extra sure we only use it for debugging |
176 | let solution = | 183 | let solution = |
177 | if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; | 184 | if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; |
178 | 185 | ||
186 | log::debug!("solve({:?}) => {:?}", goal, solution); | ||
187 | |||
179 | solution | 188 | solution |
180 | } | 189 | } |
181 | 190 | ||
@@ -183,6 +192,10 @@ fn is_chalk_debug() -> bool { | |||
183 | std::env::var("CHALK_DEBUG").is_ok() | 192 | std::env::var("CHALK_DEBUG").is_ok() |
184 | } | 193 | } |
185 | 194 | ||
195 | fn is_chalk_print() -> bool { | ||
196 | std::env::var("CHALK_PRINT").is_ok() | ||
197 | } | ||
198 | |||
186 | fn solution_from_chalk( | 199 | fn solution_from_chalk( |
187 | db: &dyn HirDatabase, | 200 | db: &dyn HirDatabase, |
188 | solution: chalk_solve::Solution<Interner>, | 201 | solution: chalk_solve::Solution<Interner>, |