@@ -135,8 +135,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
135135 // Remove any trivial region constraints once we've resolved regions
136136 external_constraints
137137 . region_constraints
138- . outlives
139- . retain ( |( outlives, _) | outlives. 0 . as_region ( ) . map_or ( true , |re| re != outlives. 1 ) ) ;
138+ . retain ( |outlives| outlives. 0 . as_region ( ) . map_or ( true , |re| re != outlives. 1 ) ) ;
140139
141140 let canonical = Canonicalizer :: canonicalize (
142141 self . infcx ,
@@ -179,8 +178,8 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
179178 fn compute_external_query_constraints (
180179 & self ,
181180 certainty : Certainty ,
182- normalization_nested_goals : NestedNormalizationGoals < ' tcx > ,
183- ) -> ExternalConstraintsData < ' tcx > {
181+ normalization_nested_goals : NestedNormalizationGoals < TyCtxt < ' tcx > > ,
182+ ) -> ExternalConstraintsData < TyCtxt < ' tcx > > {
184183 // We only return region constraints once the certainty is `Yes`. This
185184 // is necessary as we may drop nested goals on ambiguity, which may result
186185 // in unconstrained inference variables in the region constraints. It also
@@ -193,30 +192,40 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
193192 // Cannot use `take_registered_region_obligations` as we may compute the response
194193 // inside of a `probe` whenever we have multiple choices inside of the solver.
195194 let region_obligations = self . infcx . inner . borrow ( ) . region_obligations ( ) . to_owned ( ) ;
196- let mut region_constraints = self . infcx . with_region_constraints ( |region_constraints| {
197- make_query_region_constraints (
198- self . interner ( ) ,
199- region_obligations. iter ( ) . map ( |r_o| {
200- ( r_o. sup_type , r_o. sub_region , r_o. origin . to_constraint_category ( ) )
201- } ) ,
202- region_constraints,
203- )
204- } ) ;
205-
195+ let QueryRegionConstraints { outlives, member_constraints } =
196+ self . infcx . with_region_constraints ( |region_constraints| {
197+ make_query_region_constraints (
198+ self . interner ( ) ,
199+ region_obligations. iter ( ) . map ( |r_o| {
200+ ( r_o. sup_type , r_o. sub_region , r_o. origin . to_constraint_category ( ) )
201+ } ) ,
202+ region_constraints,
203+ )
204+ } ) ;
205+ assert_eq ! ( member_constraints, vec![ ] ) ;
206206 let mut seen = FxHashSet :: default ( ) ;
207- region_constraints. outlives . retain ( |outlives| seen. insert ( * outlives) ) ;
208- region_constraints
207+ outlives
208+ . into_iter ( )
209+ . filter ( |( outlives, _) | seen. insert ( * outlives) )
210+ . map ( |( outlives, _origin) | outlives)
211+ . collect ( )
209212 } else {
210213 Default :: default ( )
211214 } ;
212215
213- let mut opaque_types = self . infcx . clone_opaque_types_for_query_response ( ) ;
214- // Only return opaque type keys for newly-defined opaques
215- opaque_types. retain ( |( a, _) | {
216- self . predefined_opaques_in_body . opaque_types . iter ( ) . all ( |( pa, _) | pa != a)
217- } ) ;
218-
219- ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
216+ ExternalConstraintsData {
217+ region_constraints,
218+ opaque_types : self
219+ . infcx
220+ . clone_opaque_types_for_query_response ( )
221+ . into_iter ( )
222+ // Only return *newly defined* opaque types.
223+ . filter ( |( a, _) | {
224+ self . predefined_opaques_in_body . opaque_types . iter ( ) . all ( |( pa, _) | pa != a)
225+ } )
226+ . collect ( ) ,
227+ normalization_nested_goals,
228+ }
220229 }
221230
222231 /// After calling a canonical query, we apply the constraints returned
@@ -232,7 +241,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
232241 param_env : ty:: ParamEnv < ' tcx > ,
233242 original_values : Vec < ty:: GenericArg < ' tcx > > ,
234243 response : CanonicalResponse < ' tcx > ,
235- ) -> ( NestedNormalizationGoals < ' tcx > , Certainty ) {
244+ ) -> ( NestedNormalizationGoals < TyCtxt < ' tcx > > , Certainty ) {
236245 let instantiation = Self :: compute_query_response_instantiation_values (
237246 self . infcx ,
238247 & original_values,
@@ -369,16 +378,17 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
369378 }
370379 }
371380
372- fn register_region_constraints ( & mut self , region_constraints : & QueryRegionConstraints < ' tcx > ) {
373- for & ( ty:: OutlivesPredicate ( lhs, rhs) , _) in & region_constraints. outlives {
381+ fn register_region_constraints (
382+ & mut self ,
383+ outlives : & [ ty:: OutlivesPredicate < ' tcx , ty:: GenericArg < ' tcx > > ] ,
384+ ) {
385+ for & ty:: OutlivesPredicate ( lhs, rhs) in outlives {
374386 match lhs. unpack ( ) {
375387 GenericArgKind :: Lifetime ( lhs) => self . register_region_outlives ( lhs, rhs) ,
376388 GenericArgKind :: Type ( lhs) => self . register_ty_outlives ( lhs, rhs) ,
377389 GenericArgKind :: Const ( _) => bug ! ( "const outlives: {lhs:?}: {rhs:?}" ) ,
378390 }
379391 }
380-
381- assert ! ( region_constraints. member_constraints. is_empty( ) ) ;
382392 }
383393
384394 fn register_new_opaque_types ( & mut self , opaque_types : & [ ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) ] ) {
0 commit comments