add -Z flag

This commit is contained in:
Boxy 2023-06-08 19:23:24 +01:00
parent 3009b2c647
commit a2050ba12d
2 changed files with 13 additions and 3 deletions

View File

@ -1436,6 +1436,8 @@ options! {
"output statistics about monomorphization collection"), "output statistics about monomorphization collection"),
dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED], dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED],
"the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"), "the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"),
dump_solver_proof_tree: bool = (false, parse_bool, [UNTRACKED],
"dump a proof tree for every goal evaluated by the new trait solver"),
dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED], dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"), "version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
dylib_lto: bool = (false, parse_bool, [UNTRACKED], dylib_lto: bool = (false, parse_bool, [UNTRACKED],

View File

@ -147,13 +147,21 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
var_values: CanonicalVarValues::dummy(), var_values: CanonicalVarValues::dummy(),
nested_goals: NestedGoals::new(), nested_goals: NestedGoals::new(),
tainted: Ok(()), tainted: Ok(()),
inspect: Box::new(DebugSolver::new()), inspect: match self.tcx.sess.opts.unstable_opts.dump_solver_proof_tree {
true => Box::new(DebugSolver::new()),
false => Box::new(()),
},
}; };
let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal); let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal);
let tree = match ecx.inspect.into_debug_solver() { let tcx = ecx.tcx();
match ecx.inspect.into_debug_solver() {
Some(tree) => match Box::leak(tree) { Some(tree) => match Box::leak(tree) {
DebugSolver::GoalEvaluation(tree) => tree, DebugSolver::GoalEvaluation(tree) => {
if tcx.sess.opts.unstable_opts.dump_solver_proof_tree {
println!("{:?}", tree);
}
}
_ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"), _ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"),
}, },
_ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"), _ => unreachable!("unable to convert to `DebugSolver::GoalEvaluation`"),