@@ -135,8 +135,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
135
135
// Remove any trivial region constraints once we've resolved regions
136
136
external_constraints
137
137
. 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 ) ) ;
140
139
141
140
let canonical = Canonicalizer :: canonicalize (
142
141
self . infcx ,
@@ -179,8 +178,8 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
179
178
fn compute_external_query_constraints (
180
179
& self ,
181
180
certainty : Certainty ,
182
- normalization_nested_goals : NestedNormalizationGoals < ' tcx > ,
183
- ) -> ExternalConstraintsData < ' tcx > {
181
+ normalization_nested_goals : NestedNormalizationGoals < TyCtxt < ' tcx > > ,
182
+ ) -> ExternalConstraintsData < TyCtxt < ' tcx > > {
184
183
// We only return region constraints once the certainty is `Yes`. This
185
184
// is necessary as we may drop nested goals on ambiguity, which may result
186
185
// in unconstrained inference variables in the region constraints. It also
@@ -193,30 +192,40 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
193
192
// Cannot use `take_registered_region_obligations` as we may compute the response
194
193
// inside of a `probe` whenever we have multiple choices inside of the solver.
195
194
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![ ] ) ;
206
206
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 ( )
209
212
} else {
210
213
Default :: default ( )
211
214
} ;
212
215
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
+ }
220
229
}
221
230
222
231
/// After calling a canonical query, we apply the constraints returned
@@ -232,7 +241,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
232
241
param_env : ty:: ParamEnv < ' tcx > ,
233
242
original_values : Vec < ty:: GenericArg < ' tcx > > ,
234
243
response : CanonicalResponse < ' tcx > ,
235
- ) -> ( NestedNormalizationGoals < ' tcx > , Certainty ) {
244
+ ) -> ( NestedNormalizationGoals < TyCtxt < ' tcx > > , Certainty ) {
236
245
let instantiation = Self :: compute_query_response_instantiation_values (
237
246
self . infcx ,
238
247
& original_values,
@@ -369,16 +378,17 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
369
378
}
370
379
}
371
380
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 {
374
386
match lhs. unpack ( ) {
375
387
GenericArgKind :: Lifetime ( lhs) => self . register_region_outlives ( lhs, rhs) ,
376
388
GenericArgKind :: Type ( lhs) => self . register_ty_outlives ( lhs, rhs) ,
377
389
GenericArgKind :: Const ( _) => bug ! ( "const outlives: {lhs:?}: {rhs:?}" ) ,
378
390
}
379
391
}
380
-
381
- assert ! ( region_constraints. member_constraints. is_empty( ) ) ;
382
392
}
383
393
384
394
fn register_new_opaque_types ( & mut self , opaque_types : & [ ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) ] ) {
0 commit comments