@@ -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,26 @@ 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
+ 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
+
388
408
impl < ' tcx > RegionInferenceContext < ' tcx > {
389
409
/// Creates a new region inference context with a total of
390
410
/// `num_region_variables` valid inference variables; the first N
@@ -395,7 +415,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
395
415
/// of constraints produced by the MIR type check.
396
416
pub ( crate ) fn new (
397
417
infcx : & BorrowckInferCtxt < ' tcx > ,
398
- var_infos : VarInfos ,
399
418
constraints : MirTypeckRegionConstraints < ' tcx > ,
400
419
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
401
420
location_map : Rc < DenseLocationMap > ,
@@ -426,11 +445,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
426
445
infcx. set_tainted_by_errors ( guar) ;
427
446
}
428
447
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) ;
434
449
435
450
let constraint_sccs =
436
451
outlives_constraints. add_outlives_static ( & universal_regions, & definitions) ;
@@ -526,18 +541,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
526
541
/// means that the `R1: !1` constraint here will cause
527
542
/// `R1` to become `'static`.
528
543
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
544
for variable in self . definitions . indices ( ) {
542
545
let scc = self . constraint_sccs . scc ( variable) ;
543
546
0 commit comments