@@ -2,7 +2,7 @@ use super::{CanonicalInput, Certainty, Goal, NoSolution, QueryInput, QueryResult
22use  crate :: ty; 
33use  std:: fmt:: { Debug ,  Write } ; 
44
5- #[ derive( Eq ,  PartialEq ,  Hash ,  HashStable ) ]  
5+ #[ derive( Eq ,  PartialEq ,  Debug ,   Hash ,  HashStable ) ]  
66pub  enum  CacheHit  { 
77 Provisional , 
88 Global , 
@@ -11,16 +11,16 @@ pub enum CacheHit {
1111#[ derive( Eq ,  PartialEq ,  Hash ,  HashStable ) ]  
1212pub  struct  GoalEvaluation < ' tcx >  { 
1313 pub  uncanonicalized_goal :  Goal < ' tcx ,  ty:: Predicate < ' tcx > > , 
14-  pub  canonicalized_goal :  Option < CanonicalInput < ' tcx > > , 
15- 
16-  /// To handle coinductive cycles we can end up re-evaluating a goal 
17-   /// multiple times with different results for a nested goal. Each rerun 
18-   /// is represented as an entry in this vec. 
19-   pub  evaluation_steps :  Vec < GoalEvaluationStep < ' tcx > > , 
14+  pub  canonicalized_goal :  CanonicalInput < ' tcx > , 
2015
21-  pub  cache_hit :   Option < CacheHit > , 
16+  pub  kind :   GoalEvaluationKind < ' tcx > , 
2217
23-  pub  result :  Option < QueryResult < ' tcx > > , 
18+  pub  result :  QueryResult < ' tcx > , 
19+ } 
20+ #[ derive( Eq ,  PartialEq ,  Hash ,  HashStable ) ]  
21+ pub  enum  GoalEvaluationKind < ' tcx >  { 
22+  CacheHit ( CacheHit ) , 
23+  Uncached  {  revisions :  Vec < GoalEvaluationStep < ' tcx > >  } , 
2424} 
2525impl  Debug  for  GoalEvaluation < ' _ >  { 
2626 fn  fmt ( & self ,  f :  & mut  std:: fmt:: Formatter < ' _ > )  -> std:: fmt:: Result  { 
@@ -31,7 +31,7 @@ impl Debug for GoalEvaluation<'_> {
3131#[ derive( Eq ,  PartialEq ,  Hash ,  HashStable ) ]  
3232pub  struct  AddedGoalsEvaluation < ' tcx >  { 
3333 pub  evaluations :  Vec < Vec < GoalEvaluation < ' tcx > > > , 
34-  pub  result :  Option < Result < Certainty ,  NoSolution > > , 
34+  pub  result :  Result < Certainty ,  NoSolution > , 
3535} 
3636impl  Debug  for  AddedGoalsEvaluation < ' _ >  { 
3737 fn  fmt ( & self ,  f :  & mut  std:: fmt:: Formatter < ' _ > )  -> std:: fmt:: Result  { 
@@ -46,7 +46,7 @@ pub struct GoalEvaluationStep<'tcx> {
4646 pub  nested_goal_evaluations :  Vec < AddedGoalsEvaluation < ' tcx > > , 
4747 pub  candidates :  Vec < GoalCandidate < ' tcx > > , 
4848
49-  pub  result :  Option < QueryResult < ' tcx > > , 
49+  pub  result :  QueryResult < ' tcx > , 
5050} 
5151impl  Debug  for  GoalEvaluationStep < ' _ >  { 
5252 fn  fmt ( & self ,  f :  & mut  std:: fmt:: Formatter < ' _ > )  -> std:: fmt:: Result  { 
@@ -58,9 +58,14 @@ impl Debug for GoalEvaluationStep<'_> {
5858pub  struct  GoalCandidate < ' tcx >  { 
5959 pub  nested_goal_evaluations :  Vec < AddedGoalsEvaluation < ' tcx > > , 
6060 pub  candidates :  Vec < GoalCandidate < ' tcx > > , 
61- 
62-  pub  name :  Option < String > , 
63-  pub  result :  Option < QueryResult < ' tcx > > , 
61+  pub  kind :  CandidateKind < ' tcx > , 
62+ } 
63+ #[ derive( Eq ,  PartialEq ,  Debug ,  Hash ,  HashStable ) ]  
64+ pub  enum  CandidateKind < ' tcx >  { 
65+  /// Probe entered when normalizing the self ty during candidate assembly 
66+   NormalizedSelfTyAssembly , 
67+  /// A normal candidate for proving a goal 
68+   Candidate  {  name :  String ,  result :  QueryResult < ' tcx >  } , 
6469} 
6570impl  Debug  for  GoalCandidate < ' _ >  { 
6671 fn  fmt ( & self ,  f :  & mut  std:: fmt:: Formatter < ' _ > )  -> std:: fmt:: Result  { 
@@ -97,19 +102,23 @@ impl ProofTreeFormatter<'_, '_> {
97102 writeln ! ( f,  "GOAL: {:?}" ,  goal. uncanonicalized_goal) ?; 
98103 writeln ! ( f,  "CANONICALIZED: {:?}" ,  goal. canonicalized_goal) ?; 
99104
100-  match  goal. cache_hit  { 
101-  Some ( CacheHit :: Global )  => writeln ! ( f,  "GLOBAL CACHE HIT: {:?}" ,  goal. result) , 
102-  Some ( CacheHit :: Provisional )  => writeln ! ( f,  "PROVISIONAL CACHE HIT: {:?}" ,  goal. result) , 
103-  None  => { 
104-  for  ( n,  step)  in  goal. evaluation_steps . iter ( ) . enumerate ( )  { 
105+  match  & goal. kind  { 
106+  GoalEvaluationKind :: CacheHit ( CacheHit :: Global )  => { 
107+  writeln ! ( f,  "GLOBAL CACHE HIT: {:?}" ,  goal. result) 
108+  } 
109+  GoalEvaluationKind :: CacheHit ( CacheHit :: Provisional )  => { 
110+  writeln ! ( f,  "PROVISIONAL CACHE HIT: {:?}" ,  goal. result) 
111+  } 
112+  GoalEvaluationKind :: Uncached  {  revisions }  => { 
113+  for  ( n,  step)  in  revisions. iter ( ) . enumerate ( )  { 
105114 let  f = & mut  * self . f ; 
106-  writeln ! ( f,  "REVISION {n}: {:?}" ,  step. result. unwrap ( ) ) ?; 
115+  writeln ! ( f,  "REVISION {n}: {:?}" ,  step. result) ?; 
107116 let  mut  f = self . nested ( ) ; 
108117 f. format_evaluation_step ( step) ?; 
109118 } 
110119
111120 let  f = & mut  * self . f ; 
112-  writeln ! ( f,  "RESULT: {:?}" ,  goal. result. unwrap ( ) ) 
121+  writeln ! ( f,  "RESULT: {:?}" ,  goal. result) 
113122 } 
114123 } 
115124 } 
@@ -136,12 +145,14 @@ impl ProofTreeFormatter<'_, '_> {
136145 fn  format_candidate ( & mut  self ,  candidate :  & GoalCandidate < ' _ > )  -> std:: fmt:: Result  { 
137146 let  f = & mut  * self . f ; 
138147
139-  match  ( candidate. name . as_ref ( ) ,  candidate. result )  { 
140-  ( Some ( name) ,  Some ( result) )  => writeln ! ( f,  "CANDIDATE {}: {:?}" ,  name,  result, ) ?, 
141-  ( None ,  None )  => writeln ! ( f,  "MISC PROBE" ) ?, 
142-  ( None ,  Some ( _) )  => unreachable ! ( "unexpected probe with no name but a result" ) , 
143-  ( Some ( _) ,  None )  => unreachable ! ( "unexpected probe with a name but no candidate" ) , 
144-  } ; 
148+  match  & candidate. kind  { 
149+  CandidateKind :: NormalizedSelfTyAssembly  => { 
150+  writeln ! ( f,  "NORMALIZING SELF TY FOR ASSEMBLY:" ) 
151+  } 
152+  CandidateKind :: Candidate  {  name,  result }  => { 
153+  writeln ! ( f,  "CANDIDATE {}: {:?}" ,  name,  result) 
154+  } 
155+  } ?; 
145156
146157 let  mut  f = self . nested ( ) ; 
147158 for  candidate in  & candidate. candidates  { 
@@ -159,7 +170,7 @@ impl ProofTreeFormatter<'_, '_> {
159170 nested_goal_evaluation :  & AddedGoalsEvaluation < ' _ > , 
160171 )  -> std:: fmt:: Result  { 
161172 let  f = & mut  * self . f ; 
162-  writeln ! ( f,  "TRY_EVALUATE_ADDED_GOALS: {:?}" ,  nested_goal_evaluation. result. unwrap ( ) ) ?; 
173+  writeln ! ( f,  "TRY_EVALUATE_ADDED_GOALS: {:?}" ,  nested_goal_evaluation. result) ?; 
163174
164175 for  ( n,  revision)  in  nested_goal_evaluation. evaluations . iter ( ) . enumerate ( )  { 
165176 let  f = & mut  * self . f ; 
0 commit comments