@@ -28,28 +28,34 @@ impl<'tcx> WipGoalEvaluation<'tcx> {
2828 }
2929}
3030
31+ #[ derive( Eq , PartialEq , Debug ) ]
32+ pub enum WipGoalEvaluationKind {
33+ Overflow ,
34+ CacheHit ( CacheHit ) ,
35+ }
36+
3137#[ derive( Eq , PartialEq , Debug ) ]
3238pub struct WipCanonicalGoalEvaluation < ' tcx > {
3339 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 > > ,
3642 pub result : Option < QueryResult < ' tcx > > ,
3743}
3844
3945impl < ' tcx > WipCanonicalGoalEvaluation < ' tcx > {
4046 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)
5251 }
52+ None => inspect:: GoalEvaluationKind :: Uncached {
53+ revisions : self
54+ . revisions
55+ . into_iter ( )
56+ . map ( WipGoalEvaluationStep :: finalize)
57+ . collect ( ) ,
58+ } ,
5359 } ;
5460
5561 inspect:: CanonicalGoalEvaluation { goal : self . goal , kind, result : self . result . unwrap ( ) }
@@ -81,24 +87,17 @@ impl<'tcx> WipAddedGoalsEvaluation<'tcx> {
8187pub struct WipGoalEvaluationStep < ' tcx > {
8288 pub instantiated_goal : QueryInput < ' tcx , ty:: Predicate < ' tcx > > ,
8389
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 > ,
8891}
8992
9093impl < ' tcx > WipGoalEvaluationStep < ' tcx > {
9194 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:?}" ) ,
10199 }
100+ inspect:: GoalEvaluationStep { instantiated_goal : self . instantiated_goal , evaluation }
102101 }
103102}
104103
@@ -269,8 +268,8 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
269268 ) -> ProofTreeBuilder < ' tcx > {
270269 self . nested ( || WipCanonicalGoalEvaluation {
271270 goal,
272- cache_hit : None ,
273- evaluation_steps : vec ! [ ] ,
271+ kind : None ,
272+ revisions : vec ! [ ] ,
274273 result : None ,
275274 } )
276275 }
@@ -287,11 +286,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
287286 }
288287 }
289288
290- pub fn cache_hit ( & mut self , cache_hit : CacheHit ) {
289+ pub fn goal_evaluation_kind ( & mut self , kind : WipGoalEvaluationKind ) {
291290 if let Some ( this) = self . as_mut ( ) {
292291 match this {
293292 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 ) ;
295294 }
296295 _ => unreachable ! ( ) ,
297296 } ;
@@ -330,9 +329,11 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
330329 ) -> ProofTreeBuilder < ' tcx > {
331330 self . nested ( || WipGoalEvaluationStep {
332331 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+ } ,
336337 } )
337338 }
338339 pub fn goal_evaluation_step ( & mut self , goal_evaluation_step : ProofTreeBuilder < ' tcx > ) {
@@ -342,7 +343,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
342343 DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluations) ,
343344 DebugSolver :: GoalEvaluationStep ( goal_evaluation_step) ,
344345 ) => {
345- canonical_goal_evaluations. evaluation_steps . push ( goal_evaluation_step) ;
346+ canonical_goal_evaluations. revisions . push ( goal_evaluation_step) ;
346347 }
347348 _ => unreachable ! ( ) ,
348349 }
@@ -373,7 +374,10 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
373374 match ( this, candidate. state . unwrap ( ) . tree ) {
374375 (
375376 DebugSolver :: GoalCandidate ( WipGoalCandidate { candidates, .. } )
376- | DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep { candidates, .. } ) ,
377+ | DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep {
378+ evaluation : WipGoalCandidate { candidates, .. } ,
379+ ..
380+ } ) ,
377381 DebugSolver :: GoalCandidate ( candidate) ,
378382 ) => candidates. push ( candidate) ,
379383 _ => unreachable ! ( ) ,
@@ -412,7 +416,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
412416 match ( this, added_goals_evaluation. state . unwrap ( ) . tree ) {
413417 (
414418 DebugSolver :: GoalEvaluationStep ( WipGoalEvaluationStep {
415- added_goals_evaluations,
419+ evaluation : WipGoalCandidate { added_goals_evaluations, .. } ,
416420 ..
417421 } )
418422 | DebugSolver :: GoalCandidate ( WipGoalCandidate {
@@ -432,7 +436,10 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
432436 assert_eq ! ( canonical_goal_evaluation. result. replace( result) , None ) ;
433437 }
434438 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+ ) ;
436443 }
437444 _ => unreachable ! ( ) ,
438445 }
0 commit comments