@@ -28,28 +28,34 @@ impl<'tcx> WipGoalEvaluation<'tcx> {
28
28
}
29
29
}
30
30
31
+ #[ derive( Eq , PartialEq , Debug ) ]
32
+ pub enum WipGoalEvaluationKind {
33
+ Overflow ,
34
+ CacheHit ( CacheHit ) ,
35
+ }
36
+
31
37
#[ derive( Eq , PartialEq , Debug ) ]
32
38
pub struct WipCanonicalGoalEvaluation < ' tcx > {
33
39
pub goal : CanonicalInput < ' tcx > ,
34
- pub cache_hit : Option < CacheHit > ,
35
- pub evaluation_steps : Vec < WipGoalEvaluationStep < ' tcx > > ,
40
+ pub kind : Option < WipGoalEvaluationKind > ,
41
+ pub revisions : Vec < WipGoalEvaluationStep < ' tcx > > ,
36
42
pub result : Option < QueryResult < ' tcx > > ,
37
43
}
38
44
39
45
impl < ' tcx > WipCanonicalGoalEvaluation < ' tcx > {
40
46
pub fn finalize ( self ) -> inspect:: CanonicalGoalEvaluation < ' tcx > {
41
- let kind = match self . cache_hit {
42
- Some ( hit) => inspect:: GoalEvaluationKind :: CacheHit ( hit) ,
43
- None => {
44
- assert ! ( !self . evaluation_steps. is_empty( ) ) ;
45
- inspect:: GoalEvaluationKind :: Uncached {
46
- revisions : self
47
- . evaluation_steps
48
- . into_iter ( )
49
- . map ( WipGoalEvaluationStep :: finalize)
50
- . collect ( ) ,
51
- }
47
+ let kind = match self . kind {
48
+ Some ( WipGoalEvaluationKind :: Overflow ) => inspect:: GoalEvaluationKind :: Overflow ,
49
+ Some ( WipGoalEvaluationKind :: CacheHit ( hit) ) => {
50
+ inspect:: GoalEvaluationKind :: CacheHit ( hit)
52
51
}
52
+ None => inspect:: GoalEvaluationKind :: Uncached {
53
+ revisions : self
54
+ . revisions
55
+ . into_iter ( )
56
+ . map ( WipGoalEvaluationStep :: finalize)
57
+ . collect ( ) ,
58
+ } ,
53
59
} ;
54
60
55
61
inspect:: CanonicalGoalEvaluation { goal : self . goal , kind, result : self . result . unwrap ( ) }
@@ -81,24 +87,17 @@ impl<'tcx> WipAddedGoalsEvaluation<'tcx> {
81
87
pub struct WipGoalEvaluationStep < ' tcx > {
82
88
pub instantiated_goal : QueryInput < ' tcx , ty:: Predicate < ' tcx > > ,
83
89
84
- pub added_goals_evaluations : Vec < WipAddedGoalsEvaluation < ' tcx > > ,
85
- pub candidates : Vec < WipGoalCandidate < ' tcx > > ,
86
-
87
- pub result : Option < QueryResult < ' tcx > > ,
90
+ pub evaluation : WipGoalCandidate < ' tcx > ,
88
91
}
89
92
90
93
impl < ' tcx > WipGoalEvaluationStep < ' tcx > {
91
94
pub fn finalize ( self ) -> inspect:: GoalEvaluationStep < ' tcx > {
92
- inspect:: GoalEvaluationStep {
93
- instantiated_goal : self . instantiated_goal ,
94
- added_goals_evaluations : self
95
- . added_goals_evaluations
96
- . into_iter ( )
97
- . map ( WipAddedGoalsEvaluation :: finalize)
98
- . collect ( ) ,
99
- candidates : self . candidates . into_iter ( ) . map ( WipGoalCandidate :: finalize) . collect ( ) ,
100
- result : self . result . unwrap ( ) ,
95
+ let evaluation = self . evaluation . finalize ( ) ;
96
+ match evaluation. kind {
97
+ ProbeKind :: Root { .. } => ( ) ,
98
+ _ => unreachable ! ( "unexpected root evaluation: {evaluation:?}" ) ,
101
99
}
100
+ inspect:: GoalEvaluationStep { instantiated_goal : self . instantiated_goal , evaluation }
102
101
}
103
102
}
104
103
@@ -269,8 +268,8 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
269
268
) -> ProofTreeBuilder < ' tcx > {
270
269
self . nested ( || WipCanonicalGoalEvaluation {
271
270
goal,
272
- cache_hit : None ,
273
- evaluation_steps : vec ! [ ] ,
271
+ kind : None ,
272
+ revisions : vec ! [ ] ,
274
273
result : None ,
275
274
} )
276
275
}
@@ -287,11 +286,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
287
286
}
288
287
}
289
288
290
- pub fn cache_hit ( & mut self , cache_hit : CacheHit ) {
289
+ pub fn goal_evaluation_kind ( & mut self , kind : WipGoalEvaluationKind ) {
291
290
if let Some ( this) = self . as_mut ( ) {
292
291
match this {
293
292
DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluation) => {
294
- assert_eq ! ( canonical_goal_evaluation. cache_hit . replace( cache_hit ) , None ) ;
293
+ assert_eq ! ( canonical_goal_evaluation. kind . replace( kind ) , None ) ;
295
294
}
296
295
_ => unreachable ! ( ) ,
297
296
} ;
@@ -330,9 +329,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
330
329
) -> ProofTreeBuilder < ' tcx > {
331
330
self . nested ( || WipGoalEvaluationStep {
332
331
instantiated_goal,
333
- added_goals_evaluations : vec ! [ ] ,
334
- candidates : vec ! [ ] ,
335
- result : None ,
332
+ evaluation : WipGoalCandidate {
333
+ added_goals_evaluations : vec ! [ ] ,
334
+ candidates : vec ! [ ] ,
335
+ kind : None ,
336
+ } ,
336
337
} )
337
338
}
338
339
pub fn goal_evaluation_step ( & mut self , goal_evaluation_step : ProofTreeBuilder < ' tcx > ) {
@@ -342,7 +343,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
342
343
DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluations) ,
343
344
DebugSolver :: GoalEvaluationStep ( goal_evaluation_step) ,
344
345
) => {
345
- canonical_goal_evaluations. evaluation_steps . push ( goal_evaluation_step) ;
346
+ canonical_goal_evaluations. revisions . push ( goal_evaluation_step) ;
346
347
}
347
348
_ => unreachable ! ( ) ,
348
349
}
@@ -373,7 +374,10 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
373
374
match ( this, candidate. state . unwrap ( ) . tree ) {
374
375
(
375
376
DebugSolver :: GoalCandidate ( WipGoalCandidate { candidates, .. } )
376
- | DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep { candidates, .. } ) ,
377
+ | DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep {
378
+ evaluation : WipGoalCandidate { candidates, .. } ,
379
+ ..
380
+ } ) ,
377
381
DebugSolver :: GoalCandidate ( candidate) ,
378
382
) => candidates. push ( candidate) ,
379
383
_ => unreachable ! ( ) ,
@@ -412,7 +416,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
412
416
match ( this, added_goals_evaluation. state . unwrap ( ) . tree ) {
413
417
(
414
418
DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep {
415
- added_goals_evaluations,
419
+ evaluation : WipGoalCandidate { added_goals_evaluations, .. } ,
416
420
..
417
421
} )
418
422
| DebugSolver :: GoalCandidate ( WipGoalCandidate {
@@ -432,7 +436,10 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
432
436
assert_eq ! ( canonical_goal_evaluation. result. replace( result) , None ) ;
433
437
}
434
438
DebugSolver :: GoalEvaluationStep ( evaluation_step) => {
435
- assert_eq ! ( evaluation_step. result. replace( result) , None ) ;
439
+ assert_eq ! (
440
+ evaluation_step. evaluation. kind. replace( ProbeKind :: Root { result } ) ,
441
+ None
442
+ ) ;
436
443
}
437
444
_ => unreachable ! ( ) ,
438
445
}
0 commit comments