@@ -38,14 +38,18 @@ mod graphviz;
38
38
pub fn resolve < ' tcx > (
39
39
region_rels : & RegionRelations < ' _ , ' _ , ' tcx > ,
40
40
var_origins : VarOrigins ,
41
- data : RegionConstraintData < ' tcx >
41
+ data : RegionConstraintData < ' tcx > ,
42
42
) -> (
43
43
LexicalRegionResolutions < ' tcx > ,
44
44
Vec < RegionResolutionError < ' tcx > > ,
45
45
) {
46
46
debug ! ( "RegionConstraintData: resolve_regions()" ) ;
47
47
let mut errors = vec ! [ ] ;
48
- let mut resolver = LexicalResolver { region_rels, var_origins, data } ;
48
+ let mut resolver = LexicalResolver {
49
+ region_rels,
50
+ var_origins,
51
+ data,
52
+ } ;
49
53
let values = resolver. infer_variable_values ( & mut errors) ;
50
54
( values, errors)
51
55
}
@@ -100,7 +104,7 @@ type RegionGraph<'tcx> = graph::Graph<(), Constraint<'tcx>>;
100
104
struct LexicalResolver < ' cx , ' gcx : ' tcx , ' tcx : ' cx > {
101
105
region_rels : & ' cx RegionRelations < ' cx , ' gcx , ' tcx > ,
102
106
var_origins : VarOrigins ,
103
- data : RegionConstraintData < ' tcx >
107
+ data : RegionConstraintData < ' tcx > ,
104
108
}
105
109
106
110
impl < ' cx , ' gcx , ' tcx > LexicalResolver < ' cx , ' gcx , ' tcx > {
@@ -165,7 +169,6 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
165
169
166
170
let seeds: Vec < _ > = self . data . givens . iter ( ) . cloned ( ) . collect ( ) ;
167
171
for ( r, vid) in seeds {
168
-
169
172
// While all things transitively reachable in the graph
170
173
// from the variable (`'0` in the example above).
171
174
let seed_index = NodeIndex ( vid. index as usize ) ;
@@ -185,10 +188,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
185
188
}
186
189
}
187
190
188
- fn expansion (
189
- & self ,
190
- var_values : & mut LexicalRegionResolutions < ' tcx > ,
191
- ) {
191
+ fn expansion ( & self , var_values : & mut LexicalRegionResolutions < ' tcx > ) {
192
192
self . iterate_until_fixed_point ( "Expansion" , |constraint, origin| {
193
193
debug ! ( "expansion: constraint={:?} origin={:?}" , constraint, origin) ;
194
194
match * constraint {
@@ -222,12 +222,11 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
222
222
223
223
// Check if this relationship is implied by a given.
224
224
match * a_region {
225
- ty:: ReEarlyBound ( _) | ty:: ReFree ( _) => {
226
- if self . data . givens . contains ( & ( a_region, b_vid) ) {
227
- debug ! ( "given" ) ;
228
- return false ;
229
- }
230
- }
225
+ ty:: ReEarlyBound ( _) | ty:: ReFree ( _) => if self . data . givens . contains ( & ( a_region, b_vid) )
226
+ {
227
+ debug ! ( "given" ) ;
228
+ return false ;
229
+ } ,
231
230
_ => { }
232
231
}
233
232
@@ -256,11 +255,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
256
255
}
257
256
258
257
259
- fn lub_concrete_regions (
260
- & self ,
261
- a : Region < ' tcx > ,
262
- b : Region < ' tcx > ,
263
- ) -> Region < ' tcx > {
258
+ fn lub_concrete_regions ( & self , a : Region < ' tcx > , b : Region < ' tcx > ) -> Region < ' tcx > {
264
259
let tcx = self . region_rels . tcx ;
265
260
match ( a, b) {
266
261
( & ReLateBound ( ..) , _) | ( _, & ReLateBound ( ..) ) | ( & ReErased , _) | ( _, & ReErased ) => {
@@ -293,12 +288,12 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
293
288
// at least as big as fr.scope". So, we can
294
289
// reasonably compare free regions and scopes:
295
290
let fr_scope = match ( a, b) {
296
- ( & ReEarlyBound ( ref br) , _) | ( _, & ReEarlyBound ( ref br) ) => {
297
- self . region_rels . region_scope_tree . early_free_scope ( self . region_rels . tcx , br )
298
- }
299
- ( & ReFree ( ref fr) , _) | ( _, & ReFree ( ref fr) ) => {
300
- self . region_rels . region_scope_tree . free_scope ( self . region_rels . tcx , fr )
301
- }
291
+ ( & ReEarlyBound ( ref br) , _) | ( _, & ReEarlyBound ( ref br) ) => self . region_rels
292
+ . region_scope_tree
293
+ . early_free_scope ( self . region_rels . tcx , br ) ,
294
+ ( & ReFree ( ref fr) , _) | ( _, & ReFree ( ref fr) ) => self . region_rels
295
+ . region_scope_tree
296
+ . free_scope ( self . region_rels . tcx , fr ) ,
302
297
_ => bug ! ( ) ,
303
298
} ;
304
299
let r_id = self . region_rels
@@ -490,12 +485,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
490
485
that is not used is not a problem, so if this rule
491
486
starts to create problems we'll have to revisit
492
487
this portion of the code and think hard about it. =) */
493
- self . collect_error_for_expanding_node (
494
- graph,
495
- & mut dup_vec,
496
- node_vid,
497
- errors,
498
- ) ;
488
+ self . collect_error_for_expanding_node ( graph, & mut dup_vec, node_vid, errors) ;
499
489
}
500
490
}
501
491
}
@@ -576,7 +566,9 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
576
566
577
567
for lower_bound in & lower_bounds {
578
568
for upper_bound in & upper_bounds {
579
- if !self . region_rels . is_subregion_of ( lower_bound. region , upper_bound. region ) {
569
+ if !self . region_rels
570
+ . is_subregion_of ( lower_bound. region , upper_bound. region )
571
+ {
580
572
let origin = self . var_origins [ node_idx] . clone ( ) ;
581
573
debug ! (
582
574
"region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \
0 commit comments