@@ -45,6 +45,7 @@ pub struct InspectCandidate<'a, 'tcx> {
45
45
nested_goals : Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
46
46
final_state : inspect:: CanonicalState < ' tcx , ( ) > ,
47
47
result : QueryResult < ' tcx > ,
48
+ candidate_certainty : Option < Certainty > ,
48
49
}
49
50
50
51
impl < ' a , ' tcx > InspectCandidate < ' a , ' tcx > {
@@ -56,6 +57,19 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
56
57
self . result . map ( |c| c. value . certainty )
57
58
}
58
59
60
+ /// Certainty passed into `evaluate_added_goals_and_make_canonical_response`.
61
+ ///
62
+ /// If this certainty is `Some(Yes)`, then we must be confident that the candidate
63
+ /// must hold iff it's nested goals hold. This is not true if the certainty is
64
+ /// `Some(Maybe)`, which suggests we forced ambiguity instead, or if it is `None`,
65
+ /// which suggests we may have not assembled any candidates at all.
66
+ ///
67
+ /// This is *not* the certainty of the candidate's nested evaluation, which can be
68
+ /// accessed with [`Self::result`] instead.
69
+ pub fn candidate_certainty ( & self ) -> Option < Certainty > {
70
+ self . candidate_certainty
71
+ }
72
+
59
73
/// Visit all nested goals of this candidate without rolling
60
74
/// back their inference constraints. This function modifies
61
75
/// the state of the `infcx`.
@@ -160,7 +174,9 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
160
174
nested_goals : & mut Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
161
175
probe : & inspect:: Probe < ' tcx > ,
162
176
) {
177
+ let mut candidate_certainty = None ;
163
178
let num_candidates = candidates. len ( ) ;
179
+
164
180
for step in & probe. steps {
165
181
match step {
166
182
& inspect:: ProbeStep :: AddGoal ( _source, goal) => nested_goals. push ( goal) ,
@@ -172,6 +188,9 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
172
188
self . candidates_recur ( candidates, nested_goals, probe) ;
173
189
nested_goals. truncate ( num_goals) ;
174
190
}
191
+ inspect:: ProbeStep :: MakeCanonicalResponse { shallow_certainty } => {
192
+ assert_eq ! ( candidate_certainty. replace( * shallow_certainty) , None ) ;
193
+ }
175
194
inspect:: ProbeStep :: EvaluateGoals ( _) => ( ) ,
176
195
}
177
196
}
@@ -195,6 +214,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
195
214
nested_goals : nested_goals. clone ( ) ,
196
215
final_state : probe. final_state ,
197
216
result,
217
+ candidate_certainty,
198
218
} )
199
219
}
200
220
}
@@ -206,6 +226,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
206
226
nested_goals : nested_goals. clone ( ) ,
207
227
final_state : probe. final_state ,
208
228
result,
229
+ candidate_certainty,
209
230
} ) ;
210
231
}
211
232
}
0 commit comments