From de282ddd869f78fc8324f2333204b10e93939d83 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 14 Aug 2020 14:47:06 +0200 Subject: Only print chalk programs with CHALK_PRINT --- crates/hir_ty/src/traits.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'crates') 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( remaining > 0 }; - let solution = if is_chalk_debug() { - let logging_db = LoggingRustIrDatabase::new(context); - let solve = || { + let mut solve = || { + if is_chalk_print() { + let logging_db = LoggingRustIrDatabase::new(context); 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) + } 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!("solve({:?}) => {:?}", goal, solution); solution @@ -191,6 +192,10 @@ fn is_chalk_debug() -> bool { std::env::var("CHALK_DEBUG").is_ok() } +fn is_chalk_print() -> bool { + std::env::var("CHALK_PRINT").is_ok() +} + fn solution_from_chalk( db: &dyn HirDatabase, solution: chalk_solve::Solution, -- cgit v1.2.3