@@ -37,12 +37,13 @@ pub struct InspectGoal<'a, 'tcx> {
37
37
orig_values : & ' a [ ty:: GenericArg < ' tcx > ] ,
38
38
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
39
39
evaluation : & ' a inspect:: GoalEvaluation < ' tcx > ,
40
+ source : GoalSource ,
40
41
}
41
42
42
43
pub struct InspectCandidate < ' a , ' tcx > {
43
44
goal : & ' a InspectGoal < ' a , ' tcx > ,
44
45
kind : inspect:: ProbeKind < ' tcx > ,
45
- nested_goals : Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
46
+ nested_goals : Vec < ( GoalSource , inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ) > ,
46
47
final_state : inspect:: CanonicalState < ' tcx , ( ) > ,
47
48
result : QueryResult < ' tcx > ,
48
49
}
@@ -65,15 +66,15 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
65
66
let param_env = self . goal . goal . param_env ;
66
67
let mut orig_values = self . goal . orig_values . to_vec ( ) ;
67
68
let mut instantiated_goals = vec ! [ ] ;
68
- for goal in & self . nested_goals {
69
+ for & ( source , goal) in & self . nested_goals {
69
70
let goal = canonical:: instantiate_canonical_state (
70
71
infcx,
71
72
visitor. span ( ) ,
72
73
param_env,
73
74
& mut orig_values,
74
- * goal,
75
+ goal,
75
76
) ;
76
- instantiated_goals. push ( goal) ;
77
+ instantiated_goals. push ( ( source , goal) ) ;
77
78
}
78
79
79
80
let ( ) = canonical:: instantiate_canonical_state (
@@ -84,7 +85,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
84
85
self . final_state ,
85
86
) ;
86
87
87
- for & goal in & instantiated_goals {
88
+ for ( source , goal) in instantiated_goals {
88
89
let proof_tree = match goal. predicate . kind ( ) . no_bound_vars ( ) {
89
90
Some ( ty:: PredicateKind :: NormalizesTo ( ty:: NormalizesTo { alias, term } ) ) => {
90
91
let unconstrained_term = match term. unpack ( ) {
@@ -127,6 +128,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
127
128
infcx,
128
129
self . goal. depth + 1 ,
129
130
& proof_tree. unwrap( ) ,
131
+ source,
130
132
) ) ) ;
131
133
}
132
134
}
@@ -150,20 +152,27 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
150
152
self . goal
151
153
}
152
154
155
+ pub fn source ( & self ) -> GoalSource {
156
+ self . source
157
+ }
158
+
153
159
pub fn result ( & self ) -> Result < Certainty , NoSolution > {
154
160
self . evaluation . evaluation . result . map ( |c| c. value . certainty )
155
161
}
156
162
157
163
fn candidates_recur (
158
164
& ' a self ,
159
165
candidates : & mut Vec < InspectCandidate < ' a , ' tcx > > ,
160
- nested_goals : & mut Vec < inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > > ,
166
+ nested_goals : & mut Vec < (
167
+ GoalSource ,
168
+ inspect:: CanonicalState < ' tcx , Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
169
+ ) > ,
161
170
probe : & inspect:: Probe < ' tcx > ,
162
171
) {
163
172
let num_candidates = candidates. len ( ) ;
164
173
for step in & probe. steps {
165
174
match step {
166
- & inspect:: ProbeStep :: AddGoal ( _source , goal) => nested_goals. push ( goal) ,
175
+ & inspect:: ProbeStep :: AddGoal ( source , goal) => nested_goals. push ( ( source , goal) ) ,
167
176
inspect:: ProbeStep :: NestedProbe ( ref probe) => {
168
177
// Nested probes have to prove goals added in their parent
169
178
// but do not leak them, so we truncate the added goals
@@ -250,6 +259,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
250
259
infcx : & ' a InferCtxt < ' tcx > ,
251
260
depth : usize ,
252
261
root : & ' a inspect:: GoalEvaluation < ' tcx > ,
262
+ source : GoalSource ,
253
263
) -> Self {
254
264
match root. kind {
255
265
inspect:: GoalEvaluationKind :: Root { ref orig_values } => InspectGoal {
@@ -258,6 +268,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
258
268
orig_values,
259
269
goal : root. uncanonicalized_goal . fold_with ( & mut EagerResolver :: new ( infcx) ) ,
260
270
evaluation : root,
271
+ source,
261
272
} ,
262
273
inspect:: GoalEvaluationKind :: Nested { .. } => unreachable ! ( ) ,
263
274
}
@@ -286,6 +297,6 @@ impl<'tcx> InferCtxt<'tcx> {
286
297
) -> V :: Result {
287
298
let ( _, proof_tree) = self . evaluate_root_goal ( goal, GenerateProofTree :: Yes ) ;
288
299
let proof_tree = proof_tree. unwrap ( ) ;
289
- visitor. visit_goal ( & InspectGoal :: new ( self , 0 , & proof_tree) )
300
+ visitor. visit_goal ( & InspectGoal :: new ( self , 0 , & proof_tree, GoalSource :: Misc ) )
290
301
}
291
302
}
0 commit comments