Skip to content

Commit a3f9530

Browse files
committed
order added_goals_evaluation and nested_probes
1 parent be9d7e0 commit a3f9530

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ pub struct GoalEvaluationStep<'tcx> {
6060
/// of a goal.
6161
#[derive(Eq, PartialEq)]
6262
pub struct Probe<'tcx> {
63-
pub added_goals_evaluations: Vec<AddedGoalsEvaluation<'tcx>>,
64-
pub nested_probes: Vec<Probe<'tcx>>,
63+
pub steps: Vec<ProbeStep<'tcx>>,
6564
pub kind: ProbeKind<'tcx>,
6665
}
6766

@@ -71,6 +70,12 @@ impl Debug for Probe<'_> {
7170
}
7271
}
7372

73+
#[derive(Eq, PartialEq)]
74+
pub enum ProbeStep<'tcx> {
75+
EvaluateGoals(AddedGoalsEvaluation<'tcx>),
76+
NestedProbe(Probe<'tcx>),
77+
}
78+
7479
#[derive(Debug, PartialEq, Eq)]
7580
pub enum ProbeKind<'tcx> {
7681
/// The root inference context while proving a goal.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
118118
}?;
119119

120120
self.nested(|this| {
121-
for probe in &probe.nested_probes {
122-
this.format_probe(probe)?;
123-
}
124-
for nested in &probe.added_goals_evaluations {
125-
this.format_added_goals_evaluation(nested)?;
121+
for step in &probe.steps {
122+
match step {
123+
ProbeStep::EvaluateGoals(eval) => this.format_added_goals_evaluation(eval)?,
124+
ProbeStep::NestedProbe(probe) => this.format_probe(probe)?,
125+
}
126126
}
127127
Ok(())
128128
})

compiler/rustc_trait_selection/src/solve/inspect.rs

+25-24
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,34 @@ impl<'tcx> WipGoalEvaluationStep<'tcx> {
103103

104104
#[derive(Eq, PartialEq, Debug)]
105105
pub struct WipProbe<'tcx> {
106-
pub added_goals_evaluations: Vec<WipAddedGoalsEvaluation<'tcx>>,
107-
pub nested_probes: Vec<WipProbe<'tcx>>,
106+
pub steps: Vec<WipProbeStep<'tcx>>,
108107
pub kind: Option<ProbeKind<'tcx>>,
109108
}
110109

111110
impl<'tcx> WipProbe<'tcx> {
112111
pub fn finalize(self) -> inspect::Probe<'tcx> {
113112
inspect::Probe {
114-
added_goals_evaluations: self
115-
.added_goals_evaluations
116-
.into_iter()
117-
.map(WipAddedGoalsEvaluation::finalize)
118-
.collect(),
119-
nested_probes: self.nested_probes.into_iter().map(WipProbe::finalize).collect(),
113+
steps: self.steps.into_iter().map(WipProbeStep::finalize).collect(),
120114
kind: self.kind.unwrap(),
121115
}
122116
}
123117
}
124118

119+
#[derive(Eq, PartialEq, Debug)]
120+
pub enum WipProbeStep<'tcx> {
121+
EvaluateGoals(WipAddedGoalsEvaluation<'tcx>),
122+
NestedProbe(WipProbe<'tcx>),
123+
}
124+
125+
impl<'tcx> WipProbeStep<'tcx> {
126+
pub fn finalize(self) -> inspect::ProbeStep<'tcx> {
127+
match self {
128+
WipProbeStep::EvaluateGoals(eval) => inspect::ProbeStep::EvaluateGoals(eval.finalize()),
129+
WipProbeStep::NestedProbe(probe) => inspect::ProbeStep::NestedProbe(probe.finalize()),
130+
}
131+
}
132+
}
133+
125134
#[derive(Debug)]
126135
pub enum DebugSolver<'tcx> {
127136
Root,
@@ -329,11 +338,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
329338
) -> ProofTreeBuilder<'tcx> {
330339
self.nested(|| WipGoalEvaluationStep {
331340
instantiated_goal,
332-
evaluation: WipProbe {
333-
added_goals_evaluations: vec![],
334-
nested_probes: vec![],
335-
kind: None,
336-
},
341+
evaluation: WipProbe { steps: vec![], kind: None },
337342
})
338343
}
339344
pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<'tcx>) {
@@ -351,11 +356,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
351356
}
352357

353358
pub fn new_probe(&mut self) -> ProofTreeBuilder<'tcx> {
354-
self.nested(|| WipProbe {
355-
added_goals_evaluations: vec![],
356-
nested_probes: vec![],
357-
kind: None,
358-
})
359+
self.nested(|| WipProbe { steps: vec![], kind: None })
359360
}
360361

361362
pub fn probe_kind(&mut self, probe_kind: ProbeKind<'tcx>) {
@@ -373,13 +374,13 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
373374
if let Some(this) = self.as_mut() {
374375
match (this, probe.state.unwrap().tree) {
375376
(
376-
DebugSolver::Probe(WipProbe { nested_probes, .. })
377+
DebugSolver::Probe(WipProbe { steps, .. })
377378
| DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
378-
evaluation: WipProbe { nested_probes, .. },
379+
evaluation: WipProbe { steps, .. },
379380
..
380381
}),
381382
DebugSolver::Probe(probe),
382-
) => nested_probes.push(probe),
383+
) => steps.push(WipProbeStep::NestedProbe(probe)),
383384
_ => unreachable!(),
384385
}
385386
}
@@ -416,12 +417,12 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
416417
match (this, added_goals_evaluation.state.unwrap().tree) {
417418
(
418419
DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
419-
evaluation: WipProbe { added_goals_evaluations, .. },
420+
evaluation: WipProbe { steps, .. },
420421
..
421422
})
422-
| DebugSolver::Probe(WipProbe { added_goals_evaluations, .. }),
423+
| DebugSolver::Probe(WipProbe { steps, .. }),
423424
DebugSolver::AddedGoalsEvaluation(added_goals_evaluation),
424-
) => added_goals_evaluations.push(added_goals_evaluation),
425+
) => steps.push(WipProbeStep::EvaluateGoals(added_goals_evaluation)),
425426
_ => unreachable!(),
426427
}
427428
}

0 commit comments

Comments
 (0)