@@ -42,6 +42,7 @@ pub struct InspectGoal<'a, 'tcx> {
42
42
result : Result < Certainty , NoSolution > ,
43
43
evaluation_kind : inspect:: CanonicalGoalEvaluationKind < ' tcx > ,
44
44
normalizes_to_term_hack : Option < NormalizesToTermHack < ' tcx > > ,
45
+ source : GoalSource ,
45
46
}
46
47
47
48
/// The expected term of a `NormalizesTo` goal gets replaced
@@ -92,7 +93,7 @@ impl<'tcx> NormalizesToTermHack<'tcx> {
92
93
pub struct InspectCandidate < ' a , ' tcx > {
93
94
goal : & ' a InspectGoal < ' a , ' tcx > ,
94
95
kind : inspect:: ProbeKind < ' tcx > ,
95
- nested_goals : Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
96
+ nested_goals : Vec < ( GoalSource , inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ) > ,
96
97
final_state : inspect:: CanonicalState < ' tcx , ( ) > ,
97
98
result : QueryResult < ' tcx > ,
98
99
shallow_certainty : Certainty ,
@@ -145,13 +146,16 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
145
146
let instantiated_goals: Vec < _ > = self
146
147
. nested_goals
147
148
. iter ( )
148
- . map ( |goal| {
149
- canonical:: instantiate_canonical_state (
150
- infcx,
151
- span,
152
- param_env,
153
- & mut orig_values,
154
- * goal,
149
+ . map ( |( source, goal) | {
150
+ (
151
+ * source,
152
+ canonical:: instantiate_canonical_state (
153
+ infcx,
154
+ span,
155
+ param_env,
156
+ & mut orig_values,
157
+ * goal,
158
+ ) ,
155
159
)
156
160
} )
157
161
. collect ( ) ;
@@ -173,7 +177,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
173
177
174
178
instantiated_goals
175
179
. into_iter ( )
176
- . map ( |goal| match goal. predicate . kind ( ) . no_bound_vars ( ) {
180
+ . map ( |( source , goal) | match goal. predicate . kind ( ) . no_bound_vars ( ) {
177
181
Some ( ty:: PredicateKind :: NormalizesTo ( ty:: NormalizesTo { alias, term } ) ) => {
178
182
let unconstrained_term = match term. unpack ( ) {
179
183
ty:: TermKind :: Ty ( _) => infcx
@@ -197,13 +201,15 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
197
201
self . goal . depth + 1 ,
198
202
proof_tree. unwrap ( ) ,
199
203
Some ( NormalizesToTermHack { term, unconstrained_term } ) ,
204
+ source,
200
205
)
201
206
}
202
207
_ => InspectGoal :: new (
203
208
infcx,
204
209
self . goal . depth + 1 ,
205
210
infcx. evaluate_root_goal ( goal, GenerateProofTree :: Yes ) . 1 . unwrap ( ) ,
206
211
None ,
212
+ source,
207
213
) ,
208
214
} )
209
215
. collect ( )
@@ -229,16 +235,23 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
229
235
self . result
230
236
}
231
237
238
+ pub fn source ( & self ) -> GoalSource {
239
+ self . source
240
+ }
241
+
232
242
fn candidates_recur (
233
243
& ' a self ,
234
244
candidates : & mut Vec < InspectCandidate < ' a , ' tcx > > ,
235
- nested_goals : & mut Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
245
+ nested_goals : & mut Vec < (
246
+ GoalSource ,
247
+ inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
248
+ ) > ,
236
249
probe : & inspect:: Probe < ' tcx > ,
237
250
) {
238
251
let mut shallow_certainty = None ;
239
252
for step in & probe. steps {
240
253
match step {
241
- & inspect:: ProbeStep :: AddGoal ( _source , goal) => nested_goals. push ( goal) ,
254
+ & inspect:: ProbeStep :: AddGoal ( source , goal) => nested_goals. push ( ( source , goal) ) ,
242
255
inspect:: ProbeStep :: NestedProbe ( ref probe) => {
243
256
// Nested probes have to prove goals added in their parent
244
257
// but do not leak them, so we truncate the added goals
@@ -321,6 +334,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
321
334
depth : usize ,
322
335
root : inspect:: GoalEvaluation < ' tcx > ,
323
336
normalizes_to_term_hack : Option < NormalizesToTermHack < ' tcx > > ,
337
+ source : GoalSource ,
324
338
) -> Self {
325
339
let inspect:: GoalEvaluation { uncanonicalized_goal, kind, evaluation } = root;
326
340
let inspect:: GoalEvaluationKind :: Root { orig_values } = kind else { unreachable ! ( ) } ;
@@ -343,6 +357,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
343
357
result,
344
358
evaluation_kind : evaluation. kind ,
345
359
normalizes_to_term_hack,
360
+ source,
346
361
}
347
362
}
348
363
}
@@ -369,6 +384,6 @@ impl<'tcx> InferCtxt<'tcx> {
369
384
) -> V :: Result {
370
385
let ( _, proof_tree) = self . evaluate_root_goal ( goal, GenerateProofTree :: Yes ) ;
371
386
let proof_tree = proof_tree. unwrap ( ) ;
372
- visitor. visit_goal ( & InspectGoal :: new ( self , 0 , proof_tree, None ) )
387
+ visitor. visit_goal ( & InspectGoal :: new ( self , 0 , proof_tree, None , GoalSource :: Misc ) )
373
388
}
374
389
}
0 commit comments