@@ -53,6 +53,18 @@ crate struct UniversalRegionRelations<'tcx> {
53
53
/// our special inference variable there, we would mess that up.
54
54
type RegionBoundPairs < ' tcx > = Vec < ( ty:: Region < ' tcx > , GenericKind < ' tcx > ) > ;
55
55
56
+ /// As part of computing the free region relations, we also have to
57
+ /// normalize the input-output types, which we then need later. So we
58
+ /// return those. This vector consists of first the input types and
59
+ /// then the output type as the last element.
60
+ type NormalizedInputsAndOutput < ' tcx > = Vec < Ty < ' tcx > > ;
61
+
62
+ crate struct CreateResult < ' tcx > {
63
+ crate universal_region_relations : Rc < UniversalRegionRelations < ' tcx > > ,
64
+ crate region_bound_pairs : RegionBoundPairs < ' tcx > ,
65
+ crate normalized_inputs_and_output : NormalizedInputsAndOutput < ' tcx > ,
66
+ }
67
+
56
68
crate fn create (
57
69
infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
58
70
mir_def_id : DefId ,
@@ -62,7 +74,7 @@ crate fn create(
62
74
universal_regions : & Rc < UniversalRegions < ' tcx > > ,
63
75
constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
64
76
all_facts : & mut Option < AllFacts > ,
65
- ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
77
+ ) -> CreateResult < ' tcx > {
66
78
let mir_node_id = infcx. tcx . hir . as_local_node_id ( mir_def_id) . unwrap ( ) ;
67
79
UniversalRegionRelationsBuilder {
68
80
infcx,
@@ -215,7 +227,7 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
215
227
}
216
228
217
229
impl UniversalRegionRelationsBuilder < ' cx , ' gcx , ' tcx > {
218
- crate fn create ( mut self ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
230
+ crate fn create ( mut self ) -> CreateResult < ' tcx > {
219
231
let unnormalized_input_output_tys = self
220
232
. universal_regions
221
233
. unnormalized_input_tys
@@ -231,6 +243,8 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
231
243
// the `region_bound_pairs` and so forth.
232
244
// - After this is done, we'll process the constraints, once
233
245
// the `relations` is built.
246
+ let mut normalized_inputs_and_output =
247
+ Vec :: with_capacity ( self . universal_regions . unnormalized_input_tys . len ( ) + 1 ) ;
234
248
let constraint_sets: Vec < _ > = unnormalized_input_output_tys
235
249
. flat_map ( |ty| {
236
250
debug ! ( "build: input_or_output={:?}" , ty) ;
@@ -240,6 +254,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
240
254
. fully_perform ( self . infcx )
241
255
. unwrap_or_else ( |_| bug ! ( "failed to normalize {:?}" , ty) ) ;
242
256
self . add_implied_bounds ( ty) ;
257
+ normalized_inputs_and_output. push ( ty) ;
243
258
constraints
244
259
} )
245
260
. collect ( ) ;
@@ -280,7 +295,11 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
280
295
) . convert_all ( & data) ;
281
296
}
282
297
283
- ( Rc :: new ( self . relations ) , self . region_bound_pairs )
298
+ CreateResult {
299
+ universal_region_relations : Rc :: new ( self . relations ) ,
300
+ region_bound_pairs : self . region_bound_pairs ,
301
+ normalized_inputs_and_output,
302
+ }
284
303
}
285
304
286
305
/// Update the type of a single local, which should represent
0 commit comments