Skip to content

Commit 1b141b6

Browse files
committed
inspect: explicitly store added goals
1 parent a3f9530 commit 1b141b6

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

compiler/rustc_middle/src/traits/solve/inspect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl Debug for Probe<'_> {
7272

7373
#[derive(Eq, PartialEq)]
7474
pub enum ProbeStep<'tcx> {
75+
AddGoal(Goal<'tcx, ty::Predicate<'tcx>>),
7576
EvaluateGoals(AddedGoalsEvaluation<'tcx>),
7677
NestedProbe(Probe<'tcx>),
7778
}

compiler/rustc_middle/src/traits/solve/inspect/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
120120
self.nested(|this| {
121121
for step in &probe.steps {
122122
match step {
123+
ProbeStep::AddGoal(goal) => writeln!(this.f, "ADDED GOAL: {goal:?}")?,
123124
ProbeStep::EvaluateGoals(eval) => this.format_added_goals_evaluation(eval)?,
124125
ProbeStep::NestedProbe(probe) => this.format_probe(probe)?,
125126
}

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub struct EvalCtxt<'a, 'tcx> {
8585
// evaluation code.
8686
tainted: Result<(), NoSolution>,
8787

88-
inspect: ProofTreeBuilder<'tcx>,
88+
pub(super) inspect: ProofTreeBuilder<'tcx>,
8989
}
9090

9191
#[derive(Debug, Clone)]

compiler/rustc_trait_selection/src/solve/inspect.rs

+17
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ impl<'tcx> WipProbe<'tcx> {
118118

119119
#[derive(Eq, PartialEq, Debug)]
120120
pub enum WipProbeStep<'tcx> {
121+
AddGoal(Goal<'tcx, ty::Predicate<'tcx>>),
121122
EvaluateGoals(WipAddedGoalsEvaluation<'tcx>),
122123
NestedProbe(WipProbe<'tcx>),
123124
}
124125

125126
impl<'tcx> WipProbeStep<'tcx> {
126127
pub fn finalize(self) -> inspect::ProbeStep<'tcx> {
127128
match self {
129+
WipProbeStep::AddGoal(goal) => inspect::ProbeStep::AddGoal(goal),
128130
WipProbeStep::EvaluateGoals(eval) => inspect::ProbeStep::EvaluateGoals(eval.finalize()),
129131
WipProbeStep::NestedProbe(probe) => inspect::ProbeStep::NestedProbe(probe.finalize()),
130132
}
@@ -370,6 +372,21 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
370372
}
371373
}
372374

375+
pub fn add_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) {
376+
if let Some(this) = self.as_mut() {
377+
match this {
378+
DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
379+
evaluation: WipProbe { steps, .. },
380+
..
381+
})
382+
| DebugSolver::Probe(WipProbe { steps, .. }) => {
383+
steps.push(WipProbeStep::AddGoal(goal))
384+
}
385+
_ => unreachable!(),
386+
}
387+
}
388+
}
389+
373390
pub fn finish_probe(&mut self, probe: ProofTreeBuilder<'tcx>) {
374391
if let Some(this) = self.as_mut() {
375392
match (this, probe.state.unwrap().tree) {

compiler/rustc_trait_selection/src/solve/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
228228

229229
#[instrument(level = "debug", skip(self))]
230230
fn add_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) {
231+
self.inspect.add_goal(goal);
231232
self.nested_goals.goals.push(goal);
232233
}
233234

0 commit comments

Comments
 (0)