@@ -2,8 +2,6 @@ use rustc_data_structures::frozen::Frozen;
2
2
use rustc_data_structures:: transitive_relation:: { TransitiveRelation , TransitiveRelationBuilder } ;
3
3
use rustc_hir:: def:: DefKind ;
4
4
use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
5
- use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
6
- use rustc_infer:: infer:: region_constraints:: GenericKind ;
7
5
use rustc_infer:: infer:: { InferCtxt , outlives} ;
8
6
use rustc_infer:: traits:: ScrubbedTraitError ;
9
7
use rustc_middle:: mir:: ConstraintCategory ;
@@ -44,8 +42,7 @@ type NormalizedInputsAndOutput<'tcx> = Vec<Ty<'tcx>>;
44
42
45
43
pub ( crate ) struct CreateResult < ' tcx > {
46
44
pub ( crate ) universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
47
- pub ( crate ) region_bound_pairs : RegionBoundPairs < ' tcx > ,
48
- pub ( crate ) known_type_outlives_obligations : Vec < ty:: PolyTypeOutlivesPredicate < ' tcx > > ,
45
+ pub ( crate ) known_type_outlives : Vec < ty:: PolyTypeOutlivesPredicate < ' tcx > > ,
49
46
pub ( crate ) normalized_inputs_and_output : NormalizedInputsAndOutput < ' tcx > ,
50
47
}
51
48
@@ -62,7 +59,7 @@ pub(crate) fn create<'tcx>(
62
59
implicit_region_bound,
63
60
constraints,
64
61
universal_regions,
65
- region_bound_pairs : Default :: default ( ) ,
62
+ known_type_outlives : vec ! [ ] ,
66
63
outlives : Default :: default ( ) ,
67
64
inverse_outlives : Default :: default ( ) ,
68
65
}
@@ -189,8 +186,8 @@ struct UniversalRegionRelationsBuilder<'a, 'tcx> {
189
186
190
187
// outputs:
191
188
outlives : TransitiveRelationBuilder < RegionVid > ,
189
+ known_type_outlives : Vec < ty:: PolyTypeOutlivesPredicate < ' tcx > > ,
192
190
inverse_outlives : TransitiveRelationBuilder < RegionVid > ,
193
- region_bound_pairs : RegionBoundPairs < ' tcx > ,
194
191
}
195
192
196
193
impl < ' tcx > UniversalRegionRelationsBuilder < ' _ , ' tcx > {
@@ -228,15 +225,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
228
225
229
226
// Normalize the assumptions we use to borrowck the program.
230
227
let mut constraints = vec ! [ ] ;
231
- let mut known_type_outlives_obligations = vec ! [ ] ;
232
228
for bound in param_env. caller_bounds ( ) {
233
229
if let Some ( outlives) = bound. as_type_outlives_clause ( ) {
234
- self . normalize_and_push_type_outlives_obligation (
235
- outlives,
236
- span,
237
- & mut known_type_outlives_obligations,
238
- & mut constraints,
239
- ) ;
230
+ self . normalize_and_push_type_outlives_obligation ( outlives, span, & mut constraints) ;
240
231
} ;
241
232
}
242
233
@@ -251,8 +242,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
251
242
// - Normalize the type. This will create some region
252
243
// constraints, which we buffer up because we are
253
244
// not ready to process them yet.
254
- // - Then compute the implied bounds. This will adjust
255
- // the `region_bound_pairs` and so forth .
245
+ // - Then compute the implied bounds, updating the
246
+ // known outlives types and free region regions .
256
247
// - After this is done, we'll process the constraints, once
257
248
// the `relations` is built.
258
249
let mut normalized_inputs_and_output =
@@ -323,10 +314,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
323
314
constraint_conversion:: ConstraintConversion :: new (
324
315
self . infcx ,
325
316
& self . universal_regions ,
326
- & self . region_bound_pairs ,
327
317
self . implicit_region_bound ,
328
318
param_env,
329
- & known_type_outlives_obligations ,
319
+ & self . known_type_outlives ,
330
320
Locations :: All ( span) ,
331
321
span,
332
322
ConstraintCategory :: Internal ,
@@ -341,17 +331,15 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
341
331
outlives : self . outlives . freeze ( ) ,
342
332
inverse_outlives : self . inverse_outlives . freeze ( ) ,
343
333
} ) ,
344
- known_type_outlives_obligations,
345
- region_bound_pairs : self . region_bound_pairs ,
334
+ known_type_outlives : self . known_type_outlives ,
346
335
normalized_inputs_and_output,
347
336
}
348
337
}
349
338
350
339
fn normalize_and_push_type_outlives_obligation (
351
- & self ,
340
+ & mut self ,
352
341
mut outlives : ty:: PolyTypeOutlivesPredicate < ' tcx > ,
353
342
span : Span ,
354
- known_type_outlives_obligations : & mut Vec < ty:: PolyTypeOutlivesPredicate < ' tcx > > ,
355
343
constraints : & mut Vec < & QueryRegionConstraints < ' tcx > > ,
356
344
) {
357
345
// In the new solver, normalize the type-outlives obligation assumptions.
@@ -382,7 +370,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
382
370
}
383
371
}
384
372
385
- known_type_outlives_obligations . push ( outlives) ;
373
+ self . known_type_outlives . push ( outlives) ;
386
374
}
387
375
388
376
/// Update the type of a single local, which should represent
@@ -428,13 +416,17 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
428
416
}
429
417
430
418
OutlivesBound :: RegionSubParam ( r_a, param_b) => {
431
- self . region_bound_pairs
432
- . insert ( ty:: OutlivesPredicate ( GenericKind :: Param ( param_b) , r_a) ) ;
419
+ self . known_type_outlives . push ( ty:: Binder :: dummy ( ty:: OutlivesPredicate (
420
+ Ty :: new_param ( self . infcx . tcx , param_b. index , param_b. name ) ,
421
+ r_a,
422
+ ) ) ) ;
433
423
}
434
424
435
425
OutlivesBound :: RegionSubAlias ( r_a, alias_b) => {
436
- self . region_bound_pairs
437
- . insert ( ty:: OutlivesPredicate ( GenericKind :: Alias ( alias_b) , r_a) ) ;
426
+ self . known_type_outlives . push ( ty:: Binder :: dummy ( ty:: OutlivesPredicate (
427
+ Ty :: new_alias ( self . infcx . tcx , alias_b. kind ( self . infcx . tcx ) , alias_b) ,
428
+ r_a,
429
+ ) ) ) ;
438
430
}
439
431
}
440
432
}
0 commit comments