@@ -145,7 +145,7 @@ pub struct RegionInferenceContext<'tcx> {
145
145
/// variables are identified by their index (`RegionVid`). The
146
146
/// definition contains information about where the region came
147
147
/// 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 > > > ,
149
149
150
150
/// The liveness constraints added to each region. For most
151
151
/// regions, these start out empty and steadily grow, though for
@@ -385,6 +385,23 @@ fn sccs_info<'tcx>(infcx: &BorrowckInferCtxt<'tcx>, sccs: &ConstraintSccs) {
385
385
debug ! ( "SCC edges {:#?}" , scc_node_to_edges) ;
386
386
}
387
387
388
+ fn create_definitions < ' tcx > (
389
+ var_infos : & VarInfos ,
390
+ universal_regions : & UniversalRegions < ' tcx > ,
391
+ ) -> Frozen < IndexVec < RegionVid , RegionDefinition < ' tcx > > > {
392
+ // Create a RegionDefinition for each inference variable.
393
+ let mut definitions: IndexVec < _ , _ > =
394
+ var_infos. iter ( ) . map ( |info| RegionDefinition :: new ( info. universe , info. origin ) ) . collect ( ) ;
395
+
396
+ // Add the external name for all universal regions.
397
+ for ( external_name, variable) in universal_regions. named_universal_regions_iter ( ) {
398
+ debug ! ( "region {variable:?} has external name {external_name:?}" ) ;
399
+ definitions[ variable] . external_name = Some ( external_name) ;
400
+ }
401
+
402
+ Frozen :: freeze ( definitions)
403
+ }
404
+
388
405
impl < ' tcx > RegionInferenceContext < ' tcx > {
389
406
/// Creates a new region inference context with a total of
390
407
/// `num_region_variables` valid inference variables; the first N
@@ -426,11 +443,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
426
443
infcx. set_tainted_by_errors ( guar) ;
427
444
}
428
445
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 ( ) ;
446
+ let definitions = create_definitions ( & var_infos, & universal_regions) ;
434
447
435
448
let constraint_sccs =
436
449
outlives_constraints. add_outlives_static ( & universal_regions, & definitions) ;
@@ -526,18 +539,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
526
539
/// means that the `R1: !1` constraint here will cause
527
540
/// `R1` to become `'static`.
528
541
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
-
541
542
for variable in self . definitions . indices ( ) {
542
543
let scc = self . constraint_sccs . scc ( variable) ;
543
544
0 commit comments