@@ -20,7 +20,7 @@ use std::mem;
20
20
use rustc_hir:: def_id:: DefId ;
21
21
use rustc_infer:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
22
22
use rustc_infer:: infer:: canonical:: { OriginalQueryValues , QueryRegionConstraints , QueryResponse } ;
23
- use rustc_infer:: infer:: { InferCtxt , InferOk , TyCtxtInferExt } ;
23
+ use rustc_infer:: infer:: { DefiningAnchor , InferCtxt , InferOk , TyCtxtInferExt } ;
24
24
use rustc_infer:: traits:: query:: NoSolution ;
25
25
use rustc_infer:: traits:: Obligation ;
26
26
use rustc_middle:: infer:: canonical:: Certainty as OldCertainty ;
@@ -156,13 +156,15 @@ pub trait InferCtxtEvalExt<'tcx> {
156
156
fn evaluate_root_goal (
157
157
& self ,
158
158
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
159
+ defining_use_anchor : DefiningAnchor ,
159
160
) -> Result < ( bool , Certainty ) , NoSolution > ;
160
161
}
161
162
162
163
impl < ' tcx > InferCtxtEvalExt < ' tcx > for InferCtxt < ' tcx > {
163
164
fn evaluate_root_goal (
164
165
& self ,
165
166
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
167
+ defining_use_anchor : DefiningAnchor ,
166
168
) -> Result < ( bool , Certainty ) , NoSolution > {
167
169
let mut search_graph = search_graph:: SearchGraph :: new ( self . tcx ) ;
168
170
@@ -171,6 +173,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
171
173
infcx : self ,
172
174
var_values : CanonicalVarValues :: dummy ( ) ,
173
175
in_projection_eq_hack : false ,
176
+ defining_use_anchor,
174
177
}
175
178
. evaluate_goal ( goal) ;
176
179
@@ -194,15 +197,21 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
194
197
tcx : TyCtxt < ' tcx > ,
195
198
search_graph : & ' a mut search_graph:: SearchGraph < ' tcx > ,
196
199
canonical_goal : CanonicalGoal < ' tcx > ,
200
+ defining_use_anchor : DefiningAnchor ,
197
201
) -> QueryResult < ' tcx > {
198
202
// Deal with overflow, caching, and coinduction.
199
203
//
200
204
// The actual solver logic happens in `ecx.compute_goal`.
201
205
search_graph. with_new_goal ( tcx, canonical_goal, |search_graph| {
202
206
let ( ref infcx, goal, var_values) =
203
207
tcx. infer_ctxt ( ) . build_with_canonical ( DUMMY_SP , & canonical_goal) ;
204
- let mut ecx =
205
- EvalCtxt { infcx, var_values, search_graph, in_projection_eq_hack : false } ;
208
+ let mut ecx = EvalCtxt {
209
+ infcx,
210
+ var_values,
211
+ search_graph,
212
+ in_projection_eq_hack : false ,
213
+ defining_use_anchor,
214
+ } ;
206
215
ecx. compute_goal ( goal)
207
216
} )
208
217
}
@@ -225,12 +234,20 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
225
234
) -> Result < ( bool , Certainty ) , NoSolution > {
226
235
let mut orig_values = OriginalQueryValues :: default ( ) ;
227
236
let canonical_goal = self . infcx . canonicalize_query ( goal, & mut orig_values) ;
228
- let canonical_response =
229
- EvalCtxt :: evaluate_canonical_goal ( self . tcx ( ) , self . search_graph , canonical_goal) ?;
237
+ let canonical_response = EvalCtxt :: evaluate_canonical_goal (
238
+ self . tcx ( ) ,
239
+ self . search_graph ,
240
+ canonical_goal,
241
+ self . defining_use_anchor ,
242
+ ) ?;
230
243
231
244
let has_changed = !canonical_response. value . var_values . is_identity ( ) ;
232
- let certainty =
233
- instantiate_canonical_query_response ( self . infcx , & orig_values, canonical_response) ;
245
+ let certainty = instantiate_canonical_query_response (
246
+ self . infcx ,
247
+ & orig_values,
248
+ canonical_response,
249
+ self . defining_use_anchor ,
250
+ ) ;
234
251
235
252
// Check that rerunning this query with its inference constraints applied
236
253
// doesn't result in new inference constraints and has the same result.
@@ -246,8 +263,12 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
246
263
{
247
264
let mut orig_values = OriginalQueryValues :: default ( ) ;
248
265
let canonical_goal = self . infcx . canonicalize_query ( goal, & mut orig_values) ;
249
- let canonical_response =
250
- EvalCtxt :: evaluate_canonical_goal ( self . tcx ( ) , self . search_graph , canonical_goal) ?;
266
+ let canonical_response = EvalCtxt :: evaluate_canonical_goal (
267
+ self . tcx ( ) ,
268
+ self . search_graph ,
269
+ canonical_goal,
270
+ self . defining_use_anchor ,
271
+ ) ?;
251
272
if !canonical_response. value . var_values . is_identity ( ) {
252
273
bug ! ( "unstable result: {goal:?} {canonical_goal:?} {canonical_response:?}" ) ;
253
274
}
@@ -580,6 +601,7 @@ fn instantiate_canonical_query_response<'tcx>(
580
601
infcx : & InferCtxt < ' tcx > ,
581
602
original_values : & OriginalQueryValues < ' tcx > ,
582
603
response : CanonicalResponse < ' tcx > ,
604
+ defining_use_anchor : DefiningAnchor ,
583
605
) -> Certainty {
584
606
let Ok ( InferOk { value, obligations } ) = infcx
585
607
. instantiate_query_response_and_region_obligations (
@@ -599,6 +621,7 @@ fn instantiate_canonical_query_response<'tcx>(
599
621
opaque_types : resp. external_constraints . opaque_types . to_owned ( ) ,
600
622
value : resp. certainty ,
601
623
} ) ,
624
+ defining_use_anchor,
602
625
) else { bug ! ( ) ; } ;
603
626
assert ! ( obligations. is_empty( ) ) ;
604
627
value
0 commit comments