@@ -9,7 +9,7 @@ use rustc_errors::Diag;
99use rustc_hir:: def_id:: CRATE_DEF_ID ;
1010use rustc_index:: IndexVec ;
1111use rustc_infer:: infer:: outlives:: test_type_match;
12- use rustc_infer:: infer:: region_constraints:: { GenericKind , VarInfos , VerifyBound , VerifyIfEq } ;
12+ use rustc_infer:: infer:: region_constraints:: { GenericKind , VerifyBound , VerifyIfEq } ;
1313use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin } ;
1414use rustc_middle:: bug;
1515use rustc_middle:: mir:: {
@@ -145,7 +145,7 @@ pub struct RegionInferenceContext<'tcx> {
145145 /// variables are identified by their index (`RegionVid`). The
146146 /// definition contains information about where the region came
147147 /// from as well as its final inferred value.
148- pub ( crate ) definitions : IndexVec < RegionVid , RegionDefinition < ' tcx > > ,
148+ pub ( crate ) definitions : Frozen < IndexVec < RegionVid , RegionDefinition < ' tcx > > > ,
149149
150150 /// The liveness constraints added to each region. For most
151151 /// regions, these start out empty and steadily grow, though for
@@ -385,6 +385,26 @@ fn sccs_info<'tcx>(infcx: &BorrowckInferCtxt<'tcx>, sccs: &ConstraintSccs) {
385385 debug ! ( "SCC edges {:#?}" , scc_node_to_edges) ;
386386}
387387
388+ fn create_definitions < ' tcx > (
389+ infcx : & BorrowckInferCtxt < ' tcx > ,
390+ universal_regions : & UniversalRegions < ' tcx > ,
391+ ) -> Frozen < IndexVec < RegionVid , RegionDefinition < ' tcx > > > {
392+ // Create a RegionDefinition for each inference variable.
393+ let mut definitions: IndexVec < _ , _ > = infcx
394+ . get_region_var_infos ( )
395+ . iter ( )
396+ . map ( |info| RegionDefinition :: new ( info. universe , info. origin ) )
397+ . collect ( ) ;
398+
399+ // Add the external name for all universal regions.
400+ for ( external_name, variable) in universal_regions. named_universal_regions_iter ( ) {
401+ debug ! ( "region {variable:?} has external name {external_name:?}" ) ;
402+ definitions[ variable] . external_name = Some ( external_name) ;
403+ }
404+
405+ Frozen :: freeze ( definitions)
406+ }
407+
388408impl < ' tcx > RegionInferenceContext < ' tcx > {
389409 /// Creates a new region inference context with a total of
390410 /// `num_region_variables` valid inference variables; the first N
@@ -395,7 +415,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
395415 /// of constraints produced by the MIR type check.
396416 pub ( crate ) fn new (
397417 infcx : & BorrowckInferCtxt < ' tcx > ,
398- var_infos : VarInfos ,
399418 constraints : MirTypeckRegionConstraints < ' tcx > ,
400419 universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
401420 location_map : Rc < DenseLocationMap > ,
@@ -426,11 +445,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
426445 infcx. set_tainted_by_errors ( guar) ;
427446 }
428447
429- // Create a RegionDefinition for each inference variable.
430- let definitions: IndexVec < _ , _ > = var_infos
431- . iter ( )
432- . map ( |info| RegionDefinition :: new ( info. universe , info. origin ) )
433- . collect ( ) ;
448+ let definitions = create_definitions ( infcx, & universal_regions) ;
434449
435450 let constraint_sccs =
436451 outlives_constraints. add_outlives_static ( & universal_regions, & definitions) ;
@@ -526,18 +541,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
526541 /// means that the `R1: !1` constraint here will cause
527542 /// `R1` to become `'static`.
528543 fn init_free_and_bound_regions ( & mut self ) {
529- // Update the names (if any)
530- // This iterator has unstable order but we collect it all into an IndexVec
531- for ( external_name, variable) in
532- self . universal_region_relations . universal_regions . named_universal_regions_iter ( )
533- {
534- debug ! (
535- "init_free_and_bound_regions: region {:?} has external name {:?}" ,
536- variable, external_name
537- ) ;
538- self . definitions [ variable] . external_name = Some ( external_name) ;
539- }
540-
541544 for variable in self . definitions . indices ( ) {
542545 let scc = self . constraint_sccs . scc ( variable) ;
543546
0 commit comments