@@ -182,11 +182,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
182
182
}
183
183
}
184
184
185
- fn nested ( & self , state : impl Into < DebugSolver < ' tcx > > ) -> Self {
185
+ fn nested < T : Into < DebugSolver < ' tcx > > > ( & self , state : impl FnOnce ( ) -> T ) -> Self {
186
186
match & self . state {
187
187
Some ( prev_state) => Self {
188
188
state : Some ( Box :: new ( BuilderData {
189
- tree : state. into ( ) ,
189
+ tree : state ( ) . into ( ) ,
190
190
use_global_cache : prev_state. use_global_cache ,
191
191
} ) ) ,
192
192
} ,
@@ -255,11 +255,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
255
255
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
256
256
is_normalizes_to_hack : IsNormalizesToHack ,
257
257
) -> ProofTreeBuilder < ' tcx > {
258
- if self . state . is_none ( ) {
259
- return ProofTreeBuilder { state : None } ;
260
- }
261
-
262
- self . nested ( WipGoalEvaluation {
258
+ self . nested ( || WipGoalEvaluation {
263
259
uncanonicalized_goal : goal,
264
260
evaluation : None ,
265
261
is_normalizes_to_hack,
@@ -271,11 +267,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
271
267
& mut self ,
272
268
goal : CanonicalInput < ' tcx > ,
273
269
) -> ProofTreeBuilder < ' tcx > {
274
- if self . state . is_none ( ) {
275
- return ProofTreeBuilder { state : None } ;
276
- }
277
-
278
- self . nested ( WipCanonicalGoalEvaluation {
270
+ self . nested ( || WipCanonicalGoalEvaluation {
279
271
goal,
280
272
cache_hit : None ,
281
273
evaluation_steps : vec ! [ ] ,
@@ -336,11 +328,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
336
328
& mut self ,
337
329
instantiated_goal : QueryInput < ' tcx , ty:: Predicate < ' tcx > > ,
338
330
) -> ProofTreeBuilder < ' tcx > {
339
- if self . state . is_none ( ) {
340
- return ProofTreeBuilder { state : None } ;
341
- }
342
-
343
- self . nested ( WipGoalEvaluationStep {
331
+ self . nested ( || WipGoalEvaluationStep {
344
332
instantiated_goal,
345
333
added_goals_evaluations : vec ! [ ] ,
346
334
candidates : vec ! [ ] ,
@@ -362,11 +350,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
362
350
}
363
351
364
352
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 {
370
354
added_goals_evaluations : vec ! [ ] ,
371
355
candidates : vec ! [ ] ,
372
356
kind : None ,
@@ -398,11 +382,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
398
382
}
399
383
400
384
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 } )
406
386
}
407
387
408
388
pub fn evaluate_added_goals_loop_start ( & mut self ) {
0 commit comments