Skip to content

Commit be9d7e0

Browse files
committed
GoalCandidate to Probe
1 parent 2394959 commit be9d7e0

File tree

4 files changed

+41
-40
lines changed

4 files changed

+41
-40
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,22 @@ pub struct GoalEvaluationStep<'tcx> {
5252
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
5353

5454
/// The actual evaluation of the goal, always `ProbeKind::Root`.
55-
pub evaluation: GoalCandidate<'tcx>,
55+
pub evaluation: Probe<'tcx>,
5656
}
5757

58+
/// A self-contained computation during trait solving. This either
59+
/// corresponds to a `EvalCtxt::probe(_X)` call or the root evaluation
60+
/// of a goal.
5861
#[derive(Eq, PartialEq)]
59-
pub struct GoalCandidate<'tcx> {
62+
pub struct Probe<'tcx> {
6063
pub added_goals_evaluations: Vec<AddedGoalsEvaluation<'tcx>>,
61-
pub candidates: Vec<GoalCandidate<'tcx>>,
64+
pub nested_probes: Vec<Probe<'tcx>>,
6265
pub kind: ProbeKind<'tcx>,
6366
}
6467

65-
impl Debug for GoalCandidate<'_> {
68+
impl Debug for Probe<'_> {
6669
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67-
ProofTreeFormatter::new(f).format_candidate(self)
70+
ProofTreeFormatter::new(f).format_probe(self)
6871
}
6972
}
7073

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
9292
evaluation_step: &GoalEvaluationStep<'_>,
9393
) -> std::fmt::Result {
9494
writeln!(self.f, "INSTANTIATED: {:?}", evaluation_step.instantiated_goal)?;
95-
self.format_candidate(&evaluation_step.evaluation)
95+
self.format_probe(&evaluation_step.evaluation)
9696
}
9797

98-
pub(super) fn format_candidate(&mut self, candidate: &GoalCandidate<'_>) -> std::fmt::Result {
99-
match &candidate.kind {
98+
pub(super) fn format_probe(&mut self, probe: &Probe<'_>) -> std::fmt::Result {
99+
match &probe.kind {
100100
ProbeKind::Root { result } => {
101101
writeln!(self.f, "ROOT RESULT: {result:?}")
102102
}
@@ -118,10 +118,10 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
118118
}?;
119119

120120
self.nested(|this| {
121-
for candidate in &candidate.candidates {
122-
this.format_candidate(candidate)?;
121+
for probe in &probe.nested_probes {
122+
this.format_probe(probe)?;
123123
}
124-
for nested in &candidate.added_goals_evaluations {
124+
for nested in &probe.added_goals_evaluations {
125125
this.format_added_goals_evaluation(nested)?;
126126
}
127127
Ok(())

compiler/rustc_trait_selection/src/solve/eval_ctxt/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ where
2424
search_graph: outer_ecx.search_graph,
2525
nested_goals: outer_ecx.nested_goals.clone(),
2626
tainted: outer_ecx.tainted,
27-
inspect: outer_ecx.inspect.new_goal_candidate(),
27+
inspect: outer_ecx.inspect.new_probe(),
2828
};
2929
let r = nested_ecx.infcx.probe(|_| f(&mut nested_ecx));
3030
if !outer_ecx.inspect.is_noop() {
3131
let probe_kind = probe_kind(&r);
3232
nested_ecx.inspect.probe_kind(probe_kind);
33-
outer_ecx.inspect.goal_candidate(nested_ecx.inspect);
33+
outer_ecx.inspect.finish_probe(nested_ecx.inspect);
3434
}
3535
r
3636
}

compiler/rustc_trait_selection/src/solve/inspect.rs

+25-27
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> WipAddedGoalsEvaluation<'tcx> {
8787
pub struct WipGoalEvaluationStep<'tcx> {
8888
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
8989

90-
pub evaluation: WipGoalCandidate<'tcx>,
90+
pub evaluation: WipProbe<'tcx>,
9191
}
9292

9393
impl<'tcx> WipGoalEvaluationStep<'tcx> {
@@ -102,21 +102,21 @@ impl<'tcx> WipGoalEvaluationStep<'tcx> {
102102
}
103103

104104
#[derive(Eq, PartialEq, Debug)]
105-
pub struct WipGoalCandidate<'tcx> {
105+
pub struct WipProbe<'tcx> {
106106
pub added_goals_evaluations: Vec<WipAddedGoalsEvaluation<'tcx>>,
107-
pub candidates: Vec<WipGoalCandidate<'tcx>>,
107+
pub nested_probes: Vec<WipProbe<'tcx>>,
108108
pub kind: Option<ProbeKind<'tcx>>,
109109
}
110110

111-
impl<'tcx> WipGoalCandidate<'tcx> {
112-
pub fn finalize(self) -> inspect::GoalCandidate<'tcx> {
113-
inspect::GoalCandidate {
111+
impl<'tcx> WipProbe<'tcx> {
112+
pub fn finalize(self) -> inspect::Probe<'tcx> {
113+
inspect::Probe {
114114
added_goals_evaluations: self
115115
.added_goals_evaluations
116116
.into_iter()
117117
.map(WipAddedGoalsEvaluation::finalize)
118118
.collect(),
119-
candidates: self.candidates.into_iter().map(WipGoalCandidate::finalize).collect(),
119+
nested_probes: self.nested_probes.into_iter().map(WipProbe::finalize).collect(),
120120
kind: self.kind.unwrap(),
121121
}
122122
}
@@ -129,7 +129,7 @@ pub enum DebugSolver<'tcx> {
129129
CanonicalGoalEvaluation(WipCanonicalGoalEvaluation<'tcx>),
130130
AddedGoalsEvaluation(WipAddedGoalsEvaluation<'tcx>),
131131
GoalEvaluationStep(WipGoalEvaluationStep<'tcx>),
132-
GoalCandidate(WipGoalCandidate<'tcx>),
132+
Probe(WipProbe<'tcx>),
133133
}
134134

135135
impl<'tcx> From<WipGoalEvaluation<'tcx>> for DebugSolver<'tcx> {
@@ -156,9 +156,9 @@ impl<'tcx> From<WipGoalEvaluationStep<'tcx>> for DebugSolver<'tcx> {
156156
}
157157
}
158158

159-
impl<'tcx> From<WipGoalCandidate<'tcx>> for DebugSolver<'tcx> {
160-
fn from(g: WipGoalCandidate<'tcx>) -> DebugSolver<'tcx> {
161-
DebugSolver::GoalCandidate(g)
159+
impl<'tcx> From<WipProbe<'tcx>> for DebugSolver<'tcx> {
160+
fn from(p: WipProbe<'tcx>) -> DebugSolver<'tcx> {
161+
DebugSolver::Probe(p)
162162
}
163163
}
164164

@@ -329,9 +329,9 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
329329
) -> ProofTreeBuilder<'tcx> {
330330
self.nested(|| WipGoalEvaluationStep {
331331
instantiated_goal,
332-
evaluation: WipGoalCandidate {
332+
evaluation: WipProbe {
333333
added_goals_evaluations: vec![],
334-
candidates: vec![],
334+
nested_probes: vec![],
335335
kind: None,
336336
},
337337
})
@@ -350,36 +350,36 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
350350
}
351351
}
352352

353-
pub fn new_goal_candidate(&mut self) -> ProofTreeBuilder<'tcx> {
354-
self.nested(|| WipGoalCandidate {
353+
pub fn new_probe(&mut self) -> ProofTreeBuilder<'tcx> {
354+
self.nested(|| WipProbe {
355355
added_goals_evaluations: vec![],
356-
candidates: vec![],
356+
nested_probes: vec![],
357357
kind: None,
358358
})
359359
}
360360

361361
pub fn probe_kind(&mut self, probe_kind: ProbeKind<'tcx>) {
362362
if let Some(this) = self.as_mut() {
363363
match this {
364-
DebugSolver::GoalCandidate(this) => {
364+
DebugSolver::Probe(this) => {
365365
assert_eq!(this.kind.replace(probe_kind), None)
366366
}
367367
_ => unreachable!(),
368368
}
369369
}
370370
}
371371

372-
pub fn goal_candidate(&mut self, candidate: ProofTreeBuilder<'tcx>) {
372+
pub fn finish_probe(&mut self, probe: ProofTreeBuilder<'tcx>) {
373373
if let Some(this) = self.as_mut() {
374-
match (this, candidate.state.unwrap().tree) {
374+
match (this, probe.state.unwrap().tree) {
375375
(
376-
DebugSolver::GoalCandidate(WipGoalCandidate { candidates, .. })
376+
DebugSolver::Probe(WipProbe { nested_probes, .. })
377377
| DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
378-
evaluation: WipGoalCandidate { candidates, .. },
378+
evaluation: WipProbe { nested_probes, .. },
379379
..
380380
}),
381-
DebugSolver::GoalCandidate(candidate),
382-
) => candidates.push(candidate),
381+
DebugSolver::Probe(probe),
382+
) => nested_probes.push(probe),
383383
_ => unreachable!(),
384384
}
385385
}
@@ -416,12 +416,10 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
416416
match (this, added_goals_evaluation.state.unwrap().tree) {
417417
(
418418
DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
419-
evaluation: WipGoalCandidate { added_goals_evaluations, .. },
419+
evaluation: WipProbe { added_goals_evaluations, .. },
420420
..
421421
})
422-
| DebugSolver::GoalCandidate(WipGoalCandidate {
423-
added_goals_evaluations, ..
424-
}),
422+
| DebugSolver::Probe(WipProbe { added_goals_evaluations, .. }),
425423
DebugSolver::AddedGoalsEvaluation(added_goals_evaluation),
426424
) => added_goals_evaluations.push(added_goals_evaluation),
427425
_ => unreachable!(),

0 commit comments

Comments
 (0)