From 10c33275b0c571a27e5858645984611fc5b162bf Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sun, 26 Jul 2020 12:27:25 +0200 Subject: Only use logging db if CHALK_DEBUG is active --- crates/hir_ty/src/traits.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'crates/hir_ty') 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( goal: &chalk_ir::UCanonical>>, ) -> Option> { let context = ChalkContext { db, krate }; - - let logging_db = LoggingRustIrDatabase::new(context); - log::debug!("solve goal: {:?}", goal); let mut solver = create_chalk_solver(); @@ -169,17 +166,23 @@ fn solve( } remaining > 0 }; - let mut solve = || { - let solution = solver.solve_limited(&logging_db, goal, should_continue); - log::debug!("solve({:?}) => {:?}", goal, solution); - solution + + let solution = if is_chalk_debug() { + let logging_db = LoggingRustIrDatabase::new(context); + let solve = || { + let solution = solver.solve_limited(&logging_db, goal, should_continue); + log::debug!("chalk program:\n{}", logging_db); + solution + }; + + // don't set the TLS for Chalk unless Chalk debugging is active, to make + // extra sure we only use it for debugging + chalk::tls::set_current_program(db, solve) + } else { + solver.solve_limited(&context, goal, should_continue) }; - // don't set the TLS for Chalk unless Chalk debugging is active, to make - // extra sure we only use it for debugging - let solution = - if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; - log::debug!("chalk program:\n{}", logging_db); + log::debug!("solve({:?}) => {:?}", goal, solution); solution } -- cgit v1.2.3