@@ -20,7 +20,7 @@ use std::mem;
2020use rustc_hir:: def_id:: DefId ;
2121use rustc_infer:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
2222use rustc_infer:: infer:: canonical:: { OriginalQueryValues , QueryRegionConstraints , QueryResponse } ;
23- use rustc_infer:: infer:: { InferCtxt , InferOk , TyCtxtInferExt } ;
23+ use rustc_infer:: infer:: { DefiningAnchor , InferCtxt , InferOk , TyCtxtInferExt } ;
2424use rustc_infer:: traits:: query:: NoSolution ;
2525use rustc_infer:: traits:: Obligation ;
2626use rustc_middle:: infer:: canonical:: Certainty as OldCertainty ;
@@ -156,13 +156,15 @@ pub trait InferCtxtEvalExt<'tcx> {
156156 fn evaluate_root_goal (
157157 & self ,
158158 goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
159+ defining_use_anchor : DefiningAnchor ,
159160 ) -> Result < ( bool , Certainty ) , NoSolution > ;
160161}
161162
162163impl < ' tcx > InferCtxtEvalExt < ' tcx > for InferCtxt < ' tcx > {
163164 fn evaluate_root_goal (
164165 & self ,
165166 goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
167+ defining_use_anchor : DefiningAnchor ,
166168 ) -> Result < ( bool , Certainty ) , NoSolution > {
167169 let mut search_graph = search_graph:: SearchGraph :: new ( self . tcx ) ;
168170
@@ -171,6 +173,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
171173 infcx : self ,
172174 var_values : CanonicalVarValues :: dummy ( ) ,
173175 in_projection_eq_hack : false ,
176+ defining_use_anchor,
174177 }
175178 . evaluate_goal ( goal) ;
176179
@@ -194,15 +197,21 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
194197 tcx : TyCtxt < ' tcx > ,
195198 search_graph : & ' a mut search_graph:: SearchGraph < ' tcx > ,
196199 canonical_goal : CanonicalGoal < ' tcx > ,
200+ defining_use_anchor : DefiningAnchor ,
197201 ) -> QueryResult < ' tcx > {
198202 // Deal with overflow, caching, and coinduction.
199203 //
200204 // The actual solver logic happens in `ecx.compute_goal`.
201205 search_graph. with_new_goal ( tcx, canonical_goal, |search_graph| {
202206 let ( ref infcx, goal, var_values) =
203207 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+ } ;
206215 ecx. compute_goal ( goal)
207216 } )
208217 }
@@ -225,12 +234,20 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
225234 ) -> Result < ( bool , Certainty ) , NoSolution > {
226235 let mut orig_values = OriginalQueryValues :: default ( ) ;
227236 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+ ) ?;
230243
231244 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+ ) ;
234251
235252 // Check that rerunning this query with its inference constraints applied
236253 // doesn't result in new inference constraints and has the same result.
@@ -246,8 +263,12 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
246263 {
247264 let mut orig_values = OriginalQueryValues :: default ( ) ;
248265 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+ ) ?;
251272 if !canonical_response. value . var_values . is_identity ( ) {
252273 bug ! ( "unstable result: {goal:?} {canonical_goal:?} {canonical_response:?}" ) ;
253274 }
@@ -580,6 +601,7 @@ fn instantiate_canonical_query_response<'tcx>(
580601 infcx : & InferCtxt < ' tcx > ,
581602 original_values : & OriginalQueryValues < ' tcx > ,
582603 response : CanonicalResponse < ' tcx > ,
604+ defining_use_anchor : DefiningAnchor ,
583605) -> Certainty {
584606 let Ok ( InferOk { value, obligations } ) = infcx
585607 . instantiate_query_response_and_region_obligations (
@@ -599,6 +621,7 @@ fn instantiate_canonical_query_response<'tcx>(
599621 opaque_types : resp. external_constraints . opaque_types . to_owned ( ) ,
600622 value : resp. certainty ,
601623 } ) ,
624+ defining_use_anchor,
602625 ) else { bug ! ( ) ; } ;
603626 assert ! ( obligations. is_empty( ) ) ;
604627 value
0 commit comments