@@ -436,7 +436,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
436
436
) -> Option < ClosureRegionRequirements < ' gcx > > {
437
437
assert ! ( self . inferred_values. is_none( ) , "values already inferred" ) ;
438
438
439
- self . propagate_constraints ( mir) ;
439
+ let dfs_storage = & mut self . new_dfs_storage ( ) ;
440
+
441
+ self . propagate_constraints ( mir, dfs_storage) ;
440
442
441
443
// If this is a closure, we can propagate unsatisfied
442
444
// `outlives_requirements` to our creator, so create a vector
@@ -449,7 +451,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
449
451
None
450
452
} ;
451
453
452
- self . check_type_tests ( infcx, mir, mir_def_id, outlives_requirements. as_mut ( ) ) ;
454
+ self . check_type_tests ( infcx, mir, dfs_storage , mir_def_id, outlives_requirements. as_mut ( ) ) ;
453
455
454
456
self . check_universal_regions ( infcx, mir_def_id, outlives_requirements. as_mut ( ) ) ;
455
457
@@ -469,22 +471,28 @@ impl<'tcx> RegionInferenceContext<'tcx> {
469
471
/// Re-execute the region inference, this time tracking causal information.
470
472
/// This is significantly slower, so it is done only when an error is being reported.
471
473
pub ( super ) fn compute_causal_info ( & self , mir : & Mir < ' tcx > ) -> RegionCausalInfo {
472
- let inferred_values = self . compute_region_values ( mir, TrackCauses ( true ) ) ;
474
+ let dfs_storage = & mut self . new_dfs_storage ( ) ;
475
+ let inferred_values = self . compute_region_values ( mir, dfs_storage, TrackCauses ( true ) ) ;
473
476
RegionCausalInfo { inferred_values }
474
477
}
475
478
476
479
/// Propagate the region constraints: this will grow the values
477
480
/// for each region variable until all the constraints are
478
481
/// satisfied. Note that some values may grow **too** large to be
479
482
/// feasible, but we check this later.
480
- fn propagate_constraints ( & mut self , mir : & Mir < ' tcx > ) {
483
+ fn propagate_constraints ( & mut self , mir : & Mir < ' tcx > , dfs_storage : & mut dfs :: DfsStorage ) {
481
484
self . dependency_map = Some ( self . build_dependency_map ( ) ) ;
482
- let inferred_values = self . compute_region_values ( mir, TrackCauses ( false ) ) ;
485
+ let inferred_values = self . compute_region_values ( mir, dfs_storage , TrackCauses ( false ) ) ;
483
486
self . inferred_values = Some ( inferred_values) ;
484
487
}
485
488
486
489
#[ inline( never) ] // ensure dfs is identifiable in profiles
487
- fn compute_region_values ( & self , mir : & Mir < ' tcx > , track_causes : TrackCauses ) -> RegionValues {
490
+ fn compute_region_values (
491
+ & self ,
492
+ mir : & Mir < ' tcx > ,
493
+ dfs_storage : & mut dfs:: DfsStorage ,
494
+ track_causes : TrackCauses ,
495
+ ) -> RegionValues {
488
496
debug ! ( "compute_region_values()" ) ;
489
497
debug ! ( "compute_region_values: constraints={:#?}" , {
490
498
let mut constraints: Vec <_> = self . constraints. iter( ) . collect( ) ;
@@ -515,6 +523,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
515
523
// outlives constraint.
516
524
let Ok ( made_changes) = self . dfs (
517
525
mir,
526
+ dfs_storage,
518
527
CopyFromSourceToTarget {
519
528
source_region : constraint. sub ,
520
529
target_region : constraint. sup ,
@@ -569,6 +578,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
569
578
& self ,
570
579
infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
571
580
mir : & Mir < ' tcx > ,
581
+ dfs_storage : & mut dfs:: DfsStorage ,
572
582
mir_def_id : DefId ,
573
583
mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' gcx > > > ,
574
584
) {
@@ -577,7 +587,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
577
587
for type_test in & self . type_tests {
578
588
debug ! ( "check_type_test: {:?}" , type_test) ;
579
589
580
- if self . eval_region_test ( mir, type_test. point , type_test. lower_bound , & type_test. test ) {
590
+ if self . eval_region_test ( mir, dfs_storage , type_test. point , type_test. lower_bound , & type_test. test ) {
581
591
continue ;
582
592
}
583
593
@@ -834,6 +844,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
834
844
fn eval_region_test (
835
845
& self ,
836
846
mir : & Mir < ' tcx > ,
847
+ dfs_storage : & mut dfs:: DfsStorage ,
837
848
point : Location ,
838
849
lower_bound : RegionVid ,
839
850
test : & RegionTest ,
@@ -846,26 +857,27 @@ impl<'tcx> RegionInferenceContext<'tcx> {
846
857
match test {
847
858
RegionTest :: IsOutlivedByAllRegionsIn ( regions) => regions
848
859
. iter ( )
849
- . all ( |& r| self . eval_outlives ( mir, r, lower_bound, point) ) ,
860
+ . all ( |& r| self . eval_outlives ( mir, dfs_storage , r, lower_bound, point) ) ,
850
861
851
862
RegionTest :: IsOutlivedByAnyRegionIn ( regions) => regions
852
863
. iter ( )
853
- . any ( |& r| self . eval_outlives ( mir, r, lower_bound, point) ) ,
864
+ . any ( |& r| self . eval_outlives ( mir, dfs_storage , r, lower_bound, point) ) ,
854
865
855
866
RegionTest :: Any ( tests) => tests
856
867
. iter ( )
857
- . any ( |test| self . eval_region_test ( mir, point, lower_bound, test) ) ,
868
+ . any ( |test| self . eval_region_test ( mir, dfs_storage , point, lower_bound, test) ) ,
858
869
859
870
RegionTest :: All ( tests) => tests
860
871
. iter ( )
861
- . all ( |test| self . eval_region_test ( mir, point, lower_bound, test) ) ,
872
+ . all ( |test| self . eval_region_test ( mir, dfs_storage , point, lower_bound, test) ) ,
862
873
}
863
874
}
864
875
865
876
// Evaluate whether `sup_region: sub_region @ point`.
866
877
fn eval_outlives (
867
878
& self ,
868
879
mir : & Mir < ' tcx > ,
880
+ dfs_storage : & mut dfs:: DfsStorage ,
869
881
sup_region : RegionVid ,
870
882
sub_region : RegionVid ,
871
883
point : Location ,
@@ -881,6 +893,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
881
893
// yield an `Err` result.
882
894
match self . dfs (
883
895
mir,
896
+ dfs_storage,
884
897
TestTargetOutlivesSource {
885
898
source_region : sub_region,
886
899
target_region : sup_region,
0 commit comments