@@ -53,6 +53,18 @@ crate struct UniversalRegionRelations<'tcx> {
5353/// our special inference variable there, we would mess that up.
5454type RegionBoundPairs < ' tcx > = Vec < ( ty:: Region < ' tcx > , GenericKind < ' tcx > ) > ;
5555
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+
5668crate fn create (
5769 infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
5870 mir_def_id : DefId ,
@@ -62,7 +74,7 @@ crate fn create(
6274 universal_regions : & Rc < UniversalRegions < ' tcx > > ,
6375 constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
6476 all_facts : & mut Option < AllFacts > ,
65- ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
77+ ) -> CreateResult < ' tcx > {
6678 let mir_node_id = infcx. tcx . hir . as_local_node_id ( mir_def_id) . unwrap ( ) ;
6779 UniversalRegionRelationsBuilder {
6880 infcx,
@@ -215,7 +227,7 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
215227}
216228
217229impl UniversalRegionRelationsBuilder < ' cx , ' gcx , ' tcx > {
218- crate fn create ( mut self ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
230+ crate fn create ( mut self ) -> CreateResult < ' tcx > {
219231 let unnormalized_input_output_tys = self
220232 . universal_regions
221233 . unnormalized_input_tys
@@ -231,6 +243,8 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
231243 // the `region_bound_pairs` and so forth.
232244 // - After this is done, we'll process the constraints, once
233245 // the `relations` is built.
246+ let mut normalized_inputs_and_output =
247+ Vec :: with_capacity ( self . universal_regions . unnormalized_input_tys . len ( ) + 1 ) ;
234248 let constraint_sets: Vec < _ > = unnormalized_input_output_tys
235249 . flat_map ( |ty| {
236250 debug ! ( "build: input_or_output={:?}" , ty) ;
@@ -240,6 +254,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
240254 . fully_perform ( self . infcx )
241255 . unwrap_or_else ( |_| bug ! ( "failed to normalize {:?}" , ty) ) ;
242256 self . add_implied_bounds ( ty) ;
257+ normalized_inputs_and_output. push ( ty) ;
243258 constraints
244259 } )
245260 . collect ( ) ;
@@ -280,7 +295,11 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
280295 ) . convert_all ( & data) ;
281296 }
282297
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+ }
284303 }
285304
286305 /// Update the type of a single local, which should represent
0 commit comments