@@ -13,8 +13,7 @@ use rustc_type_ir::{self as ty, Interner};
1313use crate :: delegate:: SolverDelegate ;
1414use crate :: solve:: eval_ctxt:: canonical;
1515use crate :: solve:: {
16- CanonicalInput , Certainty , GenerateProofTree , Goal , GoalEvaluationKind , GoalSource ,
17- QueryResult , inspect,
16+ Certainty , GenerateProofTree , Goal , GoalEvaluationKind , GoalSource , QueryResult , inspect,
1817} ;
1918
2019/// The core data structure when building proof trees.
5453enum DebugSolver < I : Interner > {
5554 Root ,
5655 GoalEvaluation ( WipGoalEvaluation < I > ) ,
57- CanonicalGoalEvaluation ( WipCanonicalGoalEvaluation < I > ) ,
5856 CanonicalGoalEvaluationStep ( WipCanonicalGoalEvaluationStep < I > ) ,
5957}
6058
@@ -64,12 +62,6 @@ impl<I: Interner> From<WipGoalEvaluation<I>> for DebugSolver<I> {
6462 }
6563}
6664
67- impl < I : Interner > From < WipCanonicalGoalEvaluation < I > > for DebugSolver < I > {
68- fn from ( g : WipCanonicalGoalEvaluation < I > ) -> DebugSolver < I > {
69- DebugSolver :: CanonicalGoalEvaluation ( g)
70- }
71- }
72-
7365impl < I : Interner > From < WipCanonicalGoalEvaluationStep < I > > for DebugSolver < I > {
7466 fn from ( g : WipCanonicalGoalEvaluationStep < I > ) -> DebugSolver < I > {
7567 DebugSolver :: CanonicalGoalEvaluationStep ( g)
@@ -80,39 +72,24 @@ impl<I: Interner> From<WipCanonicalGoalEvaluationStep<I>> for DebugSolver<I> {
8072struct WipGoalEvaluation < I : Interner > {
8173 pub uncanonicalized_goal : Goal < I , I :: Predicate > ,
8274 pub orig_values : Vec < I :: GenericArg > ,
83- pub evaluation : Option < WipCanonicalGoalEvaluation < I > > ,
75+ pub encountered_overflow : bool ,
76+ /// Only used for uncached goals. After we finished evaluating
77+ /// the goal, this is interned and moved into `kind`.
78+ pub final_revision : Option < WipCanonicalGoalEvaluationStep < I > > ,
79+ pub result : Option < QueryResult < I > > ,
8480}
8581
8682impl < I : Interner > WipGoalEvaluation < I > {
8783 fn finalize ( self ) -> inspect:: GoalEvaluation < I > {
8884 inspect:: GoalEvaluation {
8985 uncanonicalized_goal : self . uncanonicalized_goal ,
9086 orig_values : self . orig_values ,
91- evaluation : self . evaluation . unwrap ( ) . finalize ( ) ,
92- }
93- }
94- }
95-
96- #[ derive_where( PartialEq , Eq , Debug ; I : Interner ) ]
97- struct WipCanonicalGoalEvaluation < I : Interner > {
98- goal : CanonicalInput < I > ,
99- encountered_overflow : bool ,
100- /// Only used for uncached goals. After we finished evaluating
101- /// the goal, this is interned and moved into `kind`.
102- final_revision : Option < WipCanonicalGoalEvaluationStep < I > > ,
103- result : Option < QueryResult < I > > ,
104- }
105-
106- impl < I : Interner > WipCanonicalGoalEvaluation < I > {
107- fn finalize ( self ) -> inspect:: CanonicalGoalEvaluation < I > {
108- inspect:: CanonicalGoalEvaluation {
109- goal : self . goal ,
11087 kind : if self . encountered_overflow {
11188 assert ! ( self . final_revision. is_none( ) ) ;
112- inspect:: CanonicalGoalEvaluationKind :: Overflow
89+ inspect:: GoalEvaluationKind :: Overflow
11390 } else {
11491 let final_revision = self . final_revision . unwrap ( ) . finalize ( ) ;
115- inspect:: CanonicalGoalEvaluationKind :: Evaluation { final_revision }
92+ inspect:: GoalEvaluationKind :: Evaluation { final_revision }
11693 } ,
11794 result : self . result . unwrap ( ) ,
11895 }
@@ -256,55 +233,27 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
256233
257234 pub ( in crate :: solve) fn new_goal_evaluation (
258235 & mut self ,
259- goal : Goal < I , I :: Predicate > ,
236+ uncanonicalized_goal : Goal < I , I :: Predicate > ,
260237 orig_values : & [ I :: GenericArg ] ,
261238 kind : GoalEvaluationKind ,
262239 ) -> ProofTreeBuilder < D > {
263240 self . opt_nested ( || match kind {
264241 GoalEvaluationKind :: Root => Some ( WipGoalEvaluation {
265- uncanonicalized_goal : goal ,
242+ uncanonicalized_goal,
266243 orig_values : orig_values. to_vec ( ) ,
267- evaluation : None ,
244+ encountered_overflow : false ,
245+ final_revision : None ,
246+ result : None ,
268247 } ) ,
269248 GoalEvaluationKind :: Nested => None ,
270249 } )
271250 }
272251
273- pub ( crate ) fn new_canonical_goal_evaluation (
274- & mut self ,
275- goal : CanonicalInput < I > ,
276- ) -> ProofTreeBuilder < D > {
277- self . nested ( || WipCanonicalGoalEvaluation {
278- goal,
279- encountered_overflow : false ,
280- final_revision : None ,
281- result : None ,
282- } )
283- }
284-
285- pub ( crate ) fn canonical_goal_evaluation (
286- & mut self ,
287- canonical_goal_evaluation : ProofTreeBuilder < D > ,
288- ) {
289- if let Some ( this) = self . as_mut ( ) {
290- match ( this, * canonical_goal_evaluation. state . unwrap ( ) ) {
291- (
292- DebugSolver :: GoalEvaluation ( goal_evaluation) ,
293- DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluation) ,
294- ) => {
295- let prev = goal_evaluation. evaluation . replace ( canonical_goal_evaluation) ;
296- assert_eq ! ( prev, None ) ;
297- }
298- _ => unreachable ! ( ) ,
299- }
300- }
301- }
302-
303252 pub ( crate ) fn canonical_goal_evaluation_overflow ( & mut self ) {
304253 if let Some ( this) = self . as_mut ( ) {
305254 match this {
306- DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluation ) => {
307- canonical_goal_evaluation . encountered_overflow = true ;
255+ DebugSolver :: GoalEvaluation ( goal_evaluation ) => {
256+ goal_evaluation . encountered_overflow = true ;
308257 }
309258 _ => unreachable ! ( ) ,
310259 } ;
@@ -343,10 +292,10 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
343292 if let Some ( this) = self . as_mut ( ) {
344293 match ( this, * goal_evaluation_step. state . unwrap ( ) ) {
345294 (
346- DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluations ) ,
295+ DebugSolver :: GoalEvaluation ( goal_evaluation ) ,
347296 DebugSolver :: CanonicalGoalEvaluationStep ( goal_evaluation_step) ,
348297 ) => {
349- canonical_goal_evaluations . final_revision = Some ( goal_evaluation_step) ;
298+ goal_evaluation . final_revision = Some ( goal_evaluation_step) ;
350299 }
351300 _ => unreachable ! ( ) ,
352301 }
@@ -489,8 +438,8 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
489438 pub ( crate ) fn query_result ( & mut self , result : QueryResult < I > ) {
490439 if let Some ( this) = self . as_mut ( ) {
491440 match this {
492- DebugSolver :: CanonicalGoalEvaluation ( canonical_goal_evaluation ) => {
493- assert_eq ! ( canonical_goal_evaluation . result. replace( result) , None ) ;
441+ DebugSolver :: GoalEvaluation ( goal_evaluation ) => {
442+ assert_eq ! ( goal_evaluation . result. replace( result) , None ) ;
494443 }
495444 DebugSolver :: CanonicalGoalEvaluationStep ( evaluation_step) => {
496445 assert_eq ! (
0 commit comments