@@ -21,7 +21,7 @@ use rustc_data_structures::fx::FxHashSet;
21
21
use rustc_data_structures:: graph:: { self , Direction , NodeIndex , OUTGOING } ;
22
22
use std:: fmt;
23
23
use std:: u32;
24
- use ty;
24
+ use ty:: { self , TyCtxt } ;
25
25
use ty:: { Region , RegionVid } ;
26
26
use ty:: { ReEarlyBound , ReEmpty , ReErased , ReFree , ReStatic } ;
27
27
use ty:: { ReLateBound , ReScope , ReSkolemized , ReVar } ;
@@ -73,15 +73,15 @@ struct RegionAndOrigin<'tcx> {
73
73
74
74
type RegionGraph < ' tcx > = graph:: Graph < ( ) , Constraint < ' tcx > > ;
75
75
76
- impl < ' a , ' gcx , ' tcx > RegionVarBindings < ' a , ' gcx , ' tcx > {
76
+ impl < ' tcx > RegionVarBindings < ' tcx > {
77
77
/// This function performs the actual region resolution. It must be
78
78
/// called after all constraints have been added. It performs a
79
79
/// fixed-point iteration to find region values which satisfy all
80
80
/// constraints, assuming such values can be found; if they cannot,
81
81
/// errors are reported.
82
82
pub fn resolve_regions (
83
83
& self ,
84
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
84
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
85
85
) -> (
86
86
LexicalRegionResolutions < ' tcx > ,
87
87
Vec < RegionResolutionError < ' tcx > > ,
@@ -94,10 +94,11 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
94
94
95
95
fn lub_concrete_regions (
96
96
& self ,
97
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
97
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
98
98
a : Region < ' tcx > ,
99
99
b : Region < ' tcx > ,
100
100
) -> Region < ' tcx > {
101
+ let tcx = region_rels. tcx ;
101
102
match ( a, b) {
102
103
( & ReLateBound ( ..) , _) | ( _, & ReLateBound ( ..) ) | ( & ReErased , _) | ( _, & ReErased ) => {
103
104
bug ! ( "cannot relate region: LUB({:?}, {:?})" , a, b) ;
@@ -130,10 +131,10 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
130
131
// reasonably compare free regions and scopes:
131
132
let fr_scope = match ( a, b) {
132
133
( & ReEarlyBound ( ref br) , _) | ( _, & ReEarlyBound ( ref br) ) => {
133
- region_rels. region_scope_tree . early_free_scope ( self . tcx , br)
134
+ region_rels. region_scope_tree . early_free_scope ( region_rels . tcx , br)
134
135
}
135
136
( & ReFree ( ref fr) , _) | ( _, & ReFree ( ref fr) ) => {
136
- region_rels. region_scope_tree . free_scope ( self . tcx , fr)
137
+ region_rels. region_scope_tree . free_scope ( region_rels . tcx , fr)
137
138
}
138
139
_ => bug ! ( ) ,
139
140
} ;
@@ -153,7 +154,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
153
154
154
155
// otherwise, we don't know what the free region is,
155
156
// so we must conservatively say the LUB is static:
156
- self . tcx . types . re_static
157
+ tcx. types . re_static
157
158
}
158
159
159
160
( & ReScope ( a_id) , & ReScope ( b_id) ) => {
@@ -163,7 +164,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
163
164
let lub = region_rels
164
165
. region_scope_tree
165
166
. nearest_common_ancestor ( a_id, b_id) ;
166
- self . tcx . mk_region ( ReScope ( lub) )
167
+ tcx. mk_region ( ReScope ( lub) )
167
168
}
168
169
169
170
( & ReEarlyBound ( _) , & ReEarlyBound ( _) ) |
@@ -176,17 +177,17 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
176
177
( & ReSkolemized ( ..) , _) | ( _, & ReSkolemized ( ..) ) => if a == b {
177
178
a
178
179
} else {
179
- self . tcx . types . re_static
180
+ tcx. types . re_static
180
181
} ,
181
182
}
182
183
}
183
184
184
185
fn infer_variable_values (
185
186
& self ,
186
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
187
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
187
188
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
188
189
) -> LexicalRegionResolutions < ' tcx > {
189
- let mut var_data = self . construct_var_data ( ) ;
190
+ let mut var_data = self . construct_var_data ( region_rels . tcx ) ;
190
191
191
192
// Dorky hack to cause `dump_constraints` to only get called
192
193
// if debug mode is enabled:
@@ -205,16 +206,18 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
205
206
var_data
206
207
}
207
208
208
- fn construct_var_data ( & self ) -> LexicalRegionResolutions < ' tcx > {
209
+ /// Initially, the value for all variables is set to `'empty`, the
210
+ /// empty region. The `expansion` phase will grow this larger.
211
+ fn construct_var_data ( & self , tcx : TyCtxt < ' _ , ' _ , ' tcx > ) -> LexicalRegionResolutions < ' tcx > {
209
212
LexicalRegionResolutions {
210
- error_region : self . tcx . types . re_static ,
213
+ error_region : tcx. types . re_static ,
211
214
values : ( 0 ..self . num_vars ( ) as usize )
212
- . map ( |_| VarValue :: Value ( self . tcx . types . re_empty ) )
215
+ . map ( |_| VarValue :: Value ( tcx. types . re_empty ) )
213
216
. collect ( ) ,
214
217
}
215
218
}
216
219
217
- fn dump_constraints ( & self , free_regions : & RegionRelations < ' a , ' gcx , ' tcx > ) {
220
+ fn dump_constraints ( & self , free_regions : & RegionRelations < ' _ , ' _ , ' tcx > ) {
218
221
debug ! (
219
222
"----() Start constraint listing (context={:?}) ()----" ,
220
223
free_regions. context
@@ -251,7 +254,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
251
254
252
255
fn expansion (
253
256
& self ,
254
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
257
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
255
258
var_values : & mut LexicalRegionResolutions < ' tcx > ,
256
259
) {
257
260
self . iterate_until_fixed_point ( "Expansion" , |constraint, origin| {
@@ -279,7 +282,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
279
282
280
283
fn expand_node (
281
284
& self ,
282
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
285
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
283
286
a_region : Region < ' tcx > ,
284
287
b_vid : RegionVid ,
285
288
b_data : & mut VarValue < ' tcx > ,
@@ -326,7 +329,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
326
329
/// and check that they are satisfied.
327
330
fn collect_errors (
328
331
& self ,
329
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
332
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
330
333
var_data : & mut LexicalRegionResolutions < ' tcx > ,
331
334
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
332
335
) {
@@ -423,7 +426,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
423
426
/// and create a `RegionResolutionError` for each of them.
424
427
fn collect_var_errors (
425
428
& self ,
426
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
429
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
427
430
var_data : & LexicalRegionResolutions < ' tcx > ,
428
431
graph : & RegionGraph < ' tcx > ,
429
432
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
@@ -528,7 +531,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
528
531
529
532
fn collect_error_for_expanding_node (
530
533
& self ,
531
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
534
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
532
535
graph : & RegionGraph < ' tcx > ,
533
536
dup_vec : & mut [ u32 ] ,
534
537
node_idx : RegionVid ,
@@ -642,8 +645,8 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
642
645
} = state;
643
646
return ( result, dup_found) ;
644
647
645
- fn process_edges < ' a , ' gcx , ' tcx > (
646
- this : & RegionVarBindings < ' a , ' gcx , ' tcx > ,
648
+ fn process_edges < ' tcx > (
649
+ this : & RegionVarBindings < ' tcx > ,
647
650
state : & mut WalkState < ' tcx > ,
648
651
graph : & RegionGraph < ' tcx > ,
649
652
source_vid : RegionVid ,
@@ -710,10 +713,10 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
710
713
}
711
714
712
715
713
- impl < ' a , ' gcx , ' tcx > VerifyBound < ' tcx > {
716
+ impl < ' tcx > VerifyBound < ' tcx > {
714
717
fn is_met (
715
718
& self ,
716
- region_rels : & RegionRelations < ' a , ' gcx , ' tcx > ,
719
+ region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
717
720
var_values : & LexicalRegionResolutions < ' tcx > ,
718
721
min : ty:: Region < ' tcx > ,
719
722
) -> bool {
0 commit comments