Skip to content

Commit 27e4877

Browse files
committed
inspect: handle None in nested
1 parent 2900c6d commit 27e4877

File tree

1 file changed

+7
-27
lines changed
  • compiler/rustc_trait_selection/src/solve

1 file changed

+7
-27
lines changed

compiler/rustc_trait_selection/src/solve/inspect.rs

+7-27
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
182182
}
183183
}
184184

185-
fn nested(&self, state: impl Into<DebugSolver<'tcx>>) -> Self {
185+
fn nested<T: Into<DebugSolver<'tcx>>>(&self, state: impl FnOnce() -> T) -> Self {
186186
match &self.state {
187187
Some(prev_state) => Self {
188188
state: Some(Box::new(BuilderData {
189-
tree: state.into(),
189+
tree: state().into(),
190190
use_global_cache: prev_state.use_global_cache,
191191
})),
192192
},
@@ -255,11 +255,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
255255
goal: Goal<'tcx, ty::Predicate<'tcx>>,
256256
is_normalizes_to_hack: IsNormalizesToHack,
257257
) -> ProofTreeBuilder<'tcx> {
258-
if self.state.is_none() {
259-
return ProofTreeBuilder { state: None };
260-
}
261-
262-
self.nested(WipGoalEvaluation {
258+
self.nested(|| WipGoalEvaluation {
263259
uncanonicalized_goal: goal,
264260
evaluation: None,
265261
is_normalizes_to_hack,
@@ -271,11 +267,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
271267
&mut self,
272268
goal: CanonicalInput<'tcx>,
273269
) -> ProofTreeBuilder<'tcx> {
274-
if self.state.is_none() {
275-
return ProofTreeBuilder { state: None };
276-
}
277-
278-
self.nested(WipCanonicalGoalEvaluation {
270+
self.nested(|| WipCanonicalGoalEvaluation {
279271
goal,
280272
cache_hit: None,
281273
evaluation_steps: vec![],
@@ -336,11 +328,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
336328
&mut self,
337329
instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
338330
) -> ProofTreeBuilder<'tcx> {
339-
if self.state.is_none() {
340-
return ProofTreeBuilder { state: None };
341-
}
342-
343-
self.nested(WipGoalEvaluationStep {
331+
self.nested(|| WipGoalEvaluationStep {
344332
instantiated_goal,
345333
added_goals_evaluations: vec![],
346334
candidates: vec![],
@@ -362,11 +350,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
362350
}
363351

364352
pub fn new_goal_candidate(&mut self) -> ProofTreeBuilder<'tcx> {
365-
if self.state.is_none() {
366-
return ProofTreeBuilder { state: None };
367-
}
368-
369-
self.nested(WipGoalCandidate {
353+
self.nested(|| WipGoalCandidate {
370354
added_goals_evaluations: vec![],
371355
candidates: vec![],
372356
kind: None,
@@ -398,11 +382,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
398382
}
399383

400384
pub fn new_evaluate_added_goals(&mut self) -> ProofTreeBuilder<'tcx> {
401-
if self.state.is_none() {
402-
return ProofTreeBuilder { state: None };
403-
}
404-
405-
self.nested(WipAddedGoalsEvaluation { evaluations: vec![], result: None })
385+
self.nested(|| WipAddedGoalsEvaluation { evaluations: vec![], result: None })
406386
}
407387

408388
pub fn evaluate_added_goals_loop_start(&mut self) {

0 commit comments

Comments
 (0)