@@ -38,12 +38,13 @@ pub struct InspectGoal<'a, 'tcx> {
38
38
orig_values : Vec < ty:: GenericArg < ' tcx > > ,
39
39
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
40
40
evaluation : inspect:: CanonicalGoalEvaluation < ' tcx > ,
41
+ source : GoalSource ,
41
42
}
42
43
43
44
pub struct InspectCandidate < ' a , ' tcx > {
44
45
goal : & ' a InspectGoal < ' a , ' tcx > ,
45
46
kind : inspect:: ProbeKind < ' tcx > ,
46
- nested_goals : Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
47
+ nested_goals : Vec < ( GoalSource , inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ) > ,
47
48
final_state : inspect:: CanonicalState < ' tcx , ( ) > ,
48
49
result : QueryResult < ' tcx > ,
49
50
shallow_certainty : Certainty ,
@@ -96,13 +97,16 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
96
97
let instantiated_goals: Vec < _ > = self
97
98
. nested_goals
98
99
. iter ( )
99
- . map ( |goal| {
100
- canonical:: instantiate_canonical_state (
101
- infcx,
102
- span,
103
- param_env,
104
- & mut orig_values,
105
- * goal,
100
+ . map ( |( source, goal) | {
101
+ (
102
+ * source,
103
+ canonical:: instantiate_canonical_state (
104
+ infcx,
105
+ span,
106
+ param_env,
107
+ & mut orig_values,
108
+ * goal,
109
+ ) ,
106
110
)
107
111
} )
108
112
. collect ( ) ;
@@ -117,7 +121,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
117
121
118
122
instantiated_goals
119
123
. into_iter ( )
120
- . map ( |goal| {
124
+ . map ( |( source , goal) | {
121
125
let proof_tree = match goal. predicate . kind ( ) . no_bound_vars ( ) {
122
126
Some ( ty:: PredicateKind :: NormalizesTo ( ty:: NormalizesTo { alias, term } ) ) => {
123
127
let unconstrained_term = match term. unpack ( ) {
@@ -150,7 +154,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
150
154
}
151
155
_ => infcx. evaluate_root_goal ( goal, GenerateProofTree :: Yes ) . 1 ,
152
156
} ;
153
- InspectGoal :: new ( infcx, self . goal . depth + 1 , proof_tree. unwrap ( ) )
157
+ InspectGoal :: new ( infcx, self . goal . depth + 1 , proof_tree. unwrap ( ) , source )
154
158
} )
155
159
. collect ( )
156
160
}
@@ -175,16 +179,23 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
175
179
self . evaluation . result . map ( |c| c. value . certainty )
176
180
}
177
181
182
+ pub fn source ( & self ) -> GoalSource {
183
+ self . source
184
+ }
185
+
178
186
fn candidates_recur (
179
187
& ' a self ,
180
188
candidates : & mut Vec < InspectCandidate < ' a , ' tcx > > ,
181
- nested_goals : & mut Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
189
+ nested_goals : & mut Vec < (
190
+ GoalSource ,
191
+ inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
192
+ ) > ,
182
193
probe : & inspect:: Probe < ' tcx > ,
183
194
) {
184
195
let mut shallow_certainty = None ;
185
196
for step in & probe. steps {
186
197
match step {
187
- & inspect:: ProbeStep :: AddGoal ( _source , goal) => nested_goals. push ( goal) ,
198
+ & inspect:: ProbeStep :: AddGoal ( source , goal) => nested_goals. push ( ( source , goal) ) ,
188
199
inspect:: ProbeStep :: NestedProbe ( ref probe) => {
189
200
// Nested probes have to prove goals added in their parent
190
201
// but do not leak them, so we truncate the added goals
@@ -262,7 +273,12 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
262
273
candidates. pop ( ) . filter ( |_| candidates. is_empty ( ) )
263
274
}
264
275
265
- fn new ( infcx : & ' a InferCtxt < ' tcx > , depth : usize , root : inspect:: GoalEvaluation < ' tcx > ) -> Self {
276
+ fn new (
277
+ infcx : & ' a InferCtxt < ' tcx > ,
278
+ depth : usize ,
279
+ root : inspect:: GoalEvaluation < ' tcx > ,
280
+ source : GoalSource ,
281
+ ) -> Self {
266
282
let inspect:: GoalEvaluation { uncanonicalized_goal, kind, evaluation } = root;
267
283
match kind {
268
284
inspect:: GoalEvaluationKind :: Root { orig_values } => InspectGoal {
@@ -271,6 +287,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
271
287
orig_values,
272
288
goal : uncanonicalized_goal. fold_with ( & mut EagerResolver :: new ( infcx) ) ,
273
289
evaluation,
290
+ source,
274
291
} ,
275
292
inspect:: GoalEvaluationKind :: Nested { .. } => unreachable ! ( ) ,
276
293
}
@@ -299,6 +316,6 @@ impl<'tcx> InferCtxt<'tcx> {
299
316
) -> V :: Result {
300
317
let ( _, proof_tree) = self . evaluate_root_goal ( goal, GenerateProofTree :: Yes ) ;
301
318
let proof_tree = proof_tree. unwrap ( ) ;
302
- visitor. visit_goal ( & InspectGoal :: new ( self , 0 , proof_tree) )
319
+ visitor. visit_goal ( & InspectGoal :: new ( self , 0 , proof_tree, GoalSource :: Misc ) )
303
320
}
304
321
}
0 commit comments