Skip to content

Commit de282dd

Browse files
committed
Only print chalk programs with CHALK_PRINT
1 parent 36052ce commit de282dd

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

crates/hir_ty/src/traits.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,22 @@ fn solve(
167167
remaining > 0
168168
};
169169

170-
let solution = if is_chalk_debug() {
171-
let logging_db = LoggingRustIrDatabase::new(context);
172-
let solve = || {
170+
let mut solve = || {
171+
if is_chalk_print() {
172+
let logging_db = LoggingRustIrDatabase::new(context);
173173
let solution = solver.solve_limited(&logging_db, goal, should_continue);
174174
log::debug!("chalk program:\n{}", logging_db);
175175
solution
176-
};
177-
178-
// don't set the TLS for Chalk unless Chalk debugging is active, to make
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)
176+
} else {
177+
solver.solve_limited(&context, goal, should_continue)
178+
}
183179
};
184180

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+
185186
log::debug!("solve({:?}) => {:?}", goal, solution);
186187

187188
solution
@@ -191,6 +192,10 @@ fn is_chalk_debug() -> bool {
191192
std::env::var("CHALK_DEBUG").is_ok()
192193
}
193194

195+
fn is_chalk_print() -> bool {
196+
std::env::var("CHALK_PRINT").is_ok()
197+
}
198+
194199
fn solution_from_chalk(
195200
db: &dyn HirDatabase,
196201
solution: chalk_solve::Solution<Interner>,

0 commit comments

Comments
 (0)