Skip to content

Commit a2050ba

Browse files
committed
add -Z flag
1 parent 3009b2c commit a2050ba

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,8 @@ options! {
14361436
"output statistics about monomorphization collection"),
14371437
dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED],
14381438
"the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"),
1439+
dump_solver_proof_tree: bool = (false, parse_bool, [UNTRACKED],
1440+
"dump a proof tree for every goal evaluated by the new trait solver"),
14391441
dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
14401442
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
14411443
dylib_lto: bool = (false, parse_bool, [UNTRACKED],

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,21 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
147147
var_values: CanonicalVarValues::dummy(),
148148
nested_goals: NestedGoals::new(),
149149
tainted: Ok(()),
150-
inspect: Box::new(DebugSolver::new()),
150+
inspect: match self.tcx.sess.opts.unstable_opts.dump_solver_proof_tree {
151+
true => Box::new(DebugSolver::new()),
152+
false => Box::new(()),
153+
},
151154
};
152155
let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal);
153156

154-
let tree = match ecx.inspect.into_debug_solver() {
157+
let tcx = ecx.tcx();
158+
match ecx.inspect.into_debug_solver() {
155159
Some(tree) => match Box::leak(tree) {
156-
DebugSolver::GoalEvaluation(tree) => tree,
160+
DebugSolver::GoalEvaluation(tree) => {
161+
if tcx.sess.opts.unstable_opts.dump_solver_proof_tree {
162+
println!("{:?}", tree);
163+
}
164+
}
157165
_ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"),
158166
},
159167
_ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"),

0 commit comments

Comments
 (0)