@@ -73,7 +73,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
7373 /// * R: P1, R: P2, as above
7474 #[ instrument( level = "debug" , skip( self , tcx, only_consider_snapshot) , ret) ]
7575 pub fn leak_check (
76- & mut self ,
76+ self ,
7777 tcx : TyCtxt < ' tcx > ,
7878 outer_universe : ty:: UniverseIndex ,
7979 max_universe : ty:: UniverseIndex ,
@@ -83,7 +83,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
8383 return Ok ( ( ) ) ;
8484 }
8585
86- let mini_graph = & MiniGraph :: new ( tcx, self , only_consider_snapshot) ;
86+ let mini_graph = MiniGraph :: new ( tcx, & self , only_consider_snapshot) ;
8787
8888 let mut leak_check = LeakCheck :: new ( tcx, outer_universe, max_universe, mini_graph, self ) ;
8989 leak_check. assign_placeholder_values ( ) ?;
@@ -92,11 +92,11 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
9292 }
9393}
9494
95- struct LeakCheck < ' a , ' b , ' tcx > {
95+ struct LeakCheck < ' a , ' tcx > {
9696 tcx : TyCtxt < ' tcx > ,
9797 outer_universe : ty:: UniverseIndex ,
98- mini_graph : & ' a MiniGraph < ' tcx > ,
99- rcc : & ' a mut RegionConstraintCollector < ' b , ' tcx > ,
98+ mini_graph : MiniGraph < ' tcx > ,
99+ rcc : RegionConstraintCollector < ' a , ' tcx > ,
100100
101101 // Initially, for each SCC S, stores a placeholder `P` such that `S = P`
102102 // must hold.
@@ -115,26 +115,27 @@ struct LeakCheck<'a, 'b, 'tcx> {
115115 // either the placeholder `P1` or the empty region in that same universe.
116116 //
117117 // To detect errors, we look for an SCC S where the values in
118- // `scc_values [S]` (if any) cannot be stored into `scc_universes[S]`.
118+ // `scc_placeholders [S]` (if any) cannot be stored into `scc_universes[S]`.
119119 scc_universes : IndexVec < LeakCheckScc , SccUniverse < ' tcx > > ,
120120}
121121
122- impl < ' a , ' b , ' tcx > LeakCheck < ' a , ' b , ' tcx > {
122+ impl < ' a , ' tcx > LeakCheck < ' a , ' tcx > {
123123 fn new (
124124 tcx : TyCtxt < ' tcx > ,
125125 outer_universe : ty:: UniverseIndex ,
126126 max_universe : ty:: UniverseIndex ,
127- mini_graph : & ' a MiniGraph < ' tcx > ,
128- rcc : & ' a mut RegionConstraintCollector < ' b , ' tcx > ,
127+ mini_graph : MiniGraph < ' tcx > ,
128+ rcc : RegionConstraintCollector < ' a , ' tcx > ,
129129 ) -> Self {
130130 let dummy_scc_universe = SccUniverse { universe : max_universe, region : None } ;
131+ let num_sccs = mini_graph. sccs . num_sccs ( ) ;
131132 Self {
132133 tcx,
133134 outer_universe,
134135 mini_graph,
135136 rcc,
136- scc_placeholders : IndexVec :: from_elem_n ( None , mini_graph . sccs . num_sccs ( ) ) ,
137- scc_universes : IndexVec :: from_elem_n ( dummy_scc_universe, mini_graph . sccs . num_sccs ( ) ) ,
137+ scc_placeholders : IndexVec :: from_elem_n ( None , num_sccs) ,
138+ scc_universes : IndexVec :: from_elem_n ( dummy_scc_universe, num_sccs) ,
138139 }
139140 }
140141
@@ -156,34 +157,23 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
156157 // Detect those SCCs that directly contain a placeholder
157158 if let ty:: RePlaceholder ( placeholder) = * * region {
158159 if self . outer_universe . cannot_name ( placeholder. universe ) {
159- self . assign_scc_value ( scc, placeholder) ?;
160+ // Update `scc_placeholders` to account for the fact that `P: S` must hold.
161+ match self . scc_placeholders [ scc] {
162+ Some ( p) => {
163+ assert_ne ! ( p, placeholder) ;
164+ return Err ( self . placeholder_error ( p, placeholder) ) ;
165+ }
166+ None => {
167+ self . scc_placeholders [ scc] = Some ( placeholder) ;
168+ }
169+ }
160170 }
161171 }
162172 }
163173
164174 Ok ( ( ) )
165175 }
166176
167- // assign_scc_value(S, P): Update `scc_values` to account for the fact that `P: S` must hold.
168- // This may create an error.
169- fn assign_scc_value (
170- & mut self ,
171- scc : LeakCheckScc ,
172- placeholder : ty:: PlaceholderRegion ,
173- ) -> RelateResult < ' tcx , ( ) > {
174- match self . scc_placeholders [ scc] {
175- Some ( p) => {
176- assert_ne ! ( p, placeholder) ;
177- return Err ( self . placeholder_error ( p, placeholder) ) ;
178- }
179- None => {
180- self . scc_placeholders [ scc] = Some ( placeholder) ;
181- }
182- } ;
183-
184- Ok ( ( ) )
185- }
186-
187177 /// For each SCC S, iterate over each successor S1 where `S: S1`:
188178 ///
189179 /// * Compute
0 commit comments