@@ -73,7 +73,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
73
73
/// * R: P1, R: P2, as above
74
74
#[ instrument( level = "debug" , skip( self , tcx, only_consider_snapshot) , ret) ]
75
75
pub fn leak_check (
76
- & mut self ,
76
+ self ,
77
77
tcx : TyCtxt < ' tcx > ,
78
78
outer_universe : ty:: UniverseIndex ,
79
79
max_universe : ty:: UniverseIndex ,
@@ -83,7 +83,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
83
83
return Ok ( ( ) ) ;
84
84
}
85
85
86
- let mini_graph = & MiniGraph :: new ( tcx, self , only_consider_snapshot) ;
86
+ let mini_graph = MiniGraph :: new ( tcx, & self , only_consider_snapshot) ;
87
87
88
88
let mut leak_check = LeakCheck :: new ( tcx, outer_universe, max_universe, mini_graph, self ) ;
89
89
leak_check. assign_placeholder_values ( ) ?;
@@ -92,11 +92,11 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
92
92
}
93
93
}
94
94
95
- struct LeakCheck < ' a , ' b , ' tcx > {
95
+ struct LeakCheck < ' a , ' tcx > {
96
96
tcx : TyCtxt < ' tcx > ,
97
97
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 > ,
100
100
101
101
// Initially, for each SCC S, stores a placeholder `P` such that `S = P`
102
102
// must hold.
@@ -115,26 +115,27 @@ struct LeakCheck<'a, 'b, 'tcx> {
115
115
// either the placeholder `P1` or the empty region in that same universe.
116
116
//
117
117
// 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]`.
119
119
scc_universes : IndexVec < LeakCheckScc , SccUniverse < ' tcx > > ,
120
120
}
121
121
122
- impl < ' a , ' b , ' tcx > LeakCheck < ' a , ' b , ' tcx > {
122
+ impl < ' a , ' tcx > LeakCheck < ' a , ' tcx > {
123
123
fn new (
124
124
tcx : TyCtxt < ' tcx > ,
125
125
outer_universe : ty:: UniverseIndex ,
126
126
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 > ,
129
129
) -> Self {
130
130
let dummy_scc_universe = SccUniverse { universe : max_universe, region : None } ;
131
+ let num_sccs = mini_graph. sccs . num_sccs ( ) ;
131
132
Self {
132
133
tcx,
133
134
outer_universe,
134
135
mini_graph,
135
136
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) ,
138
139
}
139
140
}
140
141
@@ -156,34 +157,24 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
156
157
// Detect those SCCs that directly contain a placeholder
157
158
if let ty:: RePlaceholder ( placeholder) = * * region {
158
159
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
+ // This may create an error.
162
+ match self . scc_placeholders [ scc] {
163
+ Some ( p) => {
164
+ assert_ne ! ( p, placeholder) ;
165
+ return Err ( self . placeholder_error ( p, placeholder) ) ;
166
+ }
167
+ None => {
168
+ self . scc_placeholders [ scc] = Some ( placeholder) ;
169
+ }
170
+ }
160
171
}
161
172
}
162
173
}
163
174
164
175
Ok ( ( ) )
165
176
}
166
177
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
-
187
178
/// For each SCC S, iterate over each successor S1 where `S: S1`:
188
179
///
189
180
/// * Compute
0 commit comments