@@ -2,7 +2,7 @@ use super::{CanonicalInput, Certainty, Goal, NoSolution, QueryInput, QueryResult
2
2
use crate :: ty;
3
3
use std:: fmt:: { Debug , Write } ;
4
4
5
- #[ derive( Eq , PartialEq , Hash , HashStable ) ]
5
+ #[ derive( Eq , PartialEq , Debug , Hash , HashStable ) ]
6
6
pub enum CacheHit {
7
7
Provisional ,
8
8
Global ,
@@ -11,16 +11,16 @@ pub enum CacheHit {
11
11
#[ derive( Eq , PartialEq , Hash , HashStable ) ]
12
12
pub struct GoalEvaluation < ' tcx > {
13
13
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 > ,
20
15
21
- pub cache_hit : Option < CacheHit > ,
16
+ pub kind : GoalEvaluationKind < ' tcx > ,
22
17
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 > > } ,
24
24
}
25
25
impl Debug for GoalEvaluation < ' _ > {
26
26
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
@@ -31,7 +31,7 @@ impl Debug for GoalEvaluation<'_> {
31
31
#[ derive( Eq , PartialEq , Hash , HashStable ) ]
32
32
pub struct AddedGoalsEvaluation < ' tcx > {
33
33
pub evaluations : Vec < Vec < GoalEvaluation < ' tcx > > > ,
34
- pub result : Option < Result < Certainty , NoSolution > > ,
34
+ pub result : Result < Certainty , NoSolution > ,
35
35
}
36
36
impl Debug for AddedGoalsEvaluation < ' _ > {
37
37
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
@@ -46,7 +46,7 @@ pub struct GoalEvaluationStep<'tcx> {
46
46
pub nested_goal_evaluations : Vec < AddedGoalsEvaluation < ' tcx > > ,
47
47
pub candidates : Vec < GoalCandidate < ' tcx > > ,
48
48
49
- pub result : Option < QueryResult < ' tcx > > ,
49
+ pub result : QueryResult < ' tcx > ,
50
50
}
51
51
impl Debug for GoalEvaluationStep < ' _ > {
52
52
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
@@ -58,9 +58,14 @@ impl Debug for GoalEvaluationStep<'_> {
58
58
pub struct GoalCandidate < ' tcx > {
59
59
pub nested_goal_evaluations : Vec < AddedGoalsEvaluation < ' tcx > > ,
60
60
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 > } ,
64
69
}
65
70
impl Debug for GoalCandidate < ' _ > {
66
71
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
@@ -97,19 +102,23 @@ impl ProofTreeFormatter<'_, '_> {
97
102
writeln ! ( f, "GOAL: {:?}" , goal. uncanonicalized_goal) ?;
98
103
writeln ! ( f, "CANONICALIZED: {:?}" , goal. canonicalized_goal) ?;
99
104
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 ( ) {
105
114
let f = & mut * self . f ;
106
- writeln ! ( f, "REVISION {n}: {:?}" , step. result. unwrap ( ) ) ?;
115
+ writeln ! ( f, "REVISION {n}: {:?}" , step. result) ?;
107
116
let mut f = self . nested ( ) ;
108
117
f. format_evaluation_step ( step) ?;
109
118
}
110
119
111
120
let f = & mut * self . f ;
112
- writeln ! ( f, "RESULT: {:?}" , goal. result. unwrap ( ) )
121
+ writeln ! ( f, "RESULT: {:?}" , goal. result)
113
122
}
114
123
}
115
124
}
@@ -136,12 +145,14 @@ impl ProofTreeFormatter<'_, '_> {
136
145
fn format_candidate ( & mut self , candidate : & GoalCandidate < ' _ > ) -> std:: fmt:: Result {
137
146
let f = & mut * self . f ;
138
147
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
+ } ?;
145
156
146
157
let mut f = self . nested ( ) ;
147
158
for candidate in & candidate. candidates {
@@ -159,7 +170,7 @@ impl ProofTreeFormatter<'_, '_> {
159
170
nested_goal_evaluation : & AddedGoalsEvaluation < ' _ > ,
160
171
) -> std:: fmt:: Result {
161
172
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) ?;
163
174
164
175
for ( n, revision) in nested_goal_evaluation. evaluations . iter ( ) . enumerate ( ) {
165
176
let f = & mut * self . f ;
0 commit comments