Skip to content

Commit

Permalink
Only print chalk programs with CHALK_PRINT
Browse files Browse the repository at this point in the history
  • Loading branch information
detrumi committed Aug 14, 2020
1 parent 36052ce commit de282dd
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions crates/hir_ty/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Interner>,
Expand Down

0 comments on commit de282dd

Please sign in to comment.