Skip to content

Commit 13825dc

Browse files
Take proof trees by value in inspect goal
1 parent a8a1d3a commit 13825dc

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ pub struct GoalEvaluation<'tcx> {
6060
pub evaluation: CanonicalGoalEvaluation<'tcx>,
6161
}
6262

63-
#[derive(Eq, PartialEq)]
63+
#[derive(Eq, PartialEq, Debug)]
6464
pub struct CanonicalGoalEvaluation<'tcx> {
6565
pub goal: CanonicalInput<'tcx>,
6666
pub kind: CanonicalGoalEvaluationKind<'tcx>,
6767
pub result: QueryResult<'tcx>,
6868
}
6969

70-
#[derive(Eq, PartialEq)]
70+
#[derive(Eq, PartialEq, Debug)]
7171
pub enum CanonicalGoalEvaluationKind<'tcx> {
7272
Overflow,
7373
CycleInStack,
@@ -86,7 +86,7 @@ pub struct AddedGoalsEvaluation<'tcx> {
8686
pub result: Result<Certainty, NoSolution>,
8787
}
8888

89-
#[derive(Eq, PartialEq)]
89+
#[derive(Eq, PartialEq, Debug)]
9090
pub struct GoalEvaluationStep<'tcx> {
9191
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
9292

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub struct InspectConfig {
3434
pub struct InspectGoal<'a, 'tcx> {
3535
infcx: &'a InferCtxt<'tcx>,
3636
depth: usize,
37-
orig_values: &'a [ty::GenericArg<'tcx>],
37+
orig_values: Vec<ty::GenericArg<'tcx>>,
3838
goal: Goal<'tcx, ty::Predicate<'tcx>>,
39-
evaluation: &'a inspect::GoalEvaluation<'tcx>,
39+
evaluation: inspect::CanonicalGoalEvaluation<'tcx>,
4040
}
4141

4242
pub struct InspectCandidate<'a, 'tcx> {
@@ -139,7 +139,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
139139
try_visit!(visitor.visit_goal(&InspectGoal::new(
140140
infcx,
141141
self.goal.depth + 1,
142-
&proof_tree.unwrap(),
142+
proof_tree.unwrap(),
143143
)));
144144
}
145145
}
@@ -164,7 +164,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
164164
}
165165

166166
pub fn result(&self) -> Result<Certainty, NoSolution> {
167-
self.evaluation.evaluation.result.map(|c| c.value.certainty)
167+
self.evaluation.result.map(|c| c.value.certainty)
168168
}
169169

170170
fn candidates_recur(
@@ -221,7 +221,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
221221

222222
pub fn candidates(&'a self) -> Vec<InspectCandidate<'a, 'tcx>> {
223223
let mut candidates = vec![];
224-
let last_eval_step = match self.evaluation.evaluation.kind {
224+
let last_eval_step = match self.evaluation.kind {
225225
inspect::CanonicalGoalEvaluationKind::Overflow
226226
| inspect::CanonicalGoalEvaluationKind::CycleInStack
227227
| inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit => {
@@ -254,18 +254,15 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
254254
candidates.pop().filter(|_| candidates.is_empty())
255255
}
256256

257-
fn new(
258-
infcx: &'a InferCtxt<'tcx>,
259-
depth: usize,
260-
root: &'a inspect::GoalEvaluation<'tcx>,
261-
) -> Self {
262-
match root.kind {
263-
inspect::GoalEvaluationKind::Root { ref orig_values } => InspectGoal {
257+
fn new(infcx: &'a InferCtxt<'tcx>, depth: usize, root: inspect::GoalEvaluation<'tcx>) -> Self {
258+
let inspect::GoalEvaluation { uncanonicalized_goal, kind, evaluation } = root;
259+
match kind {
260+
inspect::GoalEvaluationKind::Root { orig_values } => InspectGoal {
264261
infcx,
265262
depth,
266263
orig_values,
267-
goal: root.uncanonicalized_goal.fold_with(&mut EagerResolver::new(infcx)),
268-
evaluation: root,
264+
goal: uncanonicalized_goal.fold_with(&mut EagerResolver::new(infcx)),
265+
evaluation,
269266
},
270267
inspect::GoalEvaluationKind::Nested { .. } => unreachable!(),
271268
}
@@ -294,6 +291,6 @@ impl<'tcx> InferCtxt<'tcx> {
294291
) -> V::Result {
295292
let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes);
296293
let proof_tree = proof_tree.unwrap();
297-
visitor.visit_goal(&InspectGoal::new(self, 0, &proof_tree))
294+
visitor.visit_goal(&InspectGoal::new(self, 0, proof_tree))
298295
}
299296
}

0 commit comments

Comments
 (0)