10
10
11
11
//! The code to do lexical region resolution.
12
12
13
- use infer:: SubregionOrigin ;
14
- use infer:: RegionVariableOrigin ;
15
13
use infer:: region_constraints:: Constraint ;
16
14
use infer:: region_constraints:: GenericKind ;
17
15
use infer:: region_constraints:: RegionConstraintData ;
18
16
use infer:: region_constraints:: VarInfos ;
19
17
use infer:: region_constraints:: VerifyBound ;
18
+ use infer:: RegionVariableOrigin ;
19
+ use infer:: SubregionOrigin ;
20
20
use middle:: free_region:: RegionRelations ;
21
- use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
22
21
use rustc_data_structures:: fx:: FxHashSet ;
23
- use rustc_data_structures:: graph:: implementation:: { Graph , Direction , NodeIndex , INCOMING , OUTGOING } ;
22
+ use rustc_data_structures:: graph:: implementation:: {
23
+ Direction , Graph , NodeIndex , INCOMING , OUTGOING ,
24
+ } ;
25
+ use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
24
26
use std:: fmt;
25
27
use std:: u32;
26
28
use ty:: { self , TyCtxt } ;
27
- use ty:: { Region , RegionVid } ;
28
29
use ty:: { ReEarlyBound , ReEmpty , ReErased , ReFree , ReStatic } ;
29
30
use ty:: { ReLateBound , ReScope , ReSkolemized , ReVar } ;
31
+ use ty:: { Region , RegionVid } ;
30
32
31
33
mod graphviz;
32
34
@@ -239,9 +241,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
239
241
240
242
debug ! (
241
243
"Expanding value of {:?} from {:?} to {:?}" ,
242
- b_vid,
243
- cur_region,
244
- lub
244
+ b_vid, cur_region, lub
245
245
) ;
246
246
247
247
* b_data = VarValue :: Value ( lub) ;
@@ -254,18 +254,17 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
254
254
}
255
255
}
256
256
257
-
258
257
fn lub_concrete_regions ( & self , a : Region < ' tcx > , b : Region < ' tcx > ) -> Region < ' tcx > {
259
258
let tcx = self . region_rels . tcx ;
260
259
match ( a, b) {
261
- ( & ty:: ReCanonical ( ..) , _) |
262
- ( _, & ty:: ReCanonical ( ..) ) |
263
- ( & ty:: ReClosureBound ( ..) , _) |
264
- ( _, & ty:: ReClosureBound ( ..) ) |
265
- ( & ReLateBound ( ..) , _) |
266
- ( _, & ReLateBound ( ..) ) |
267
- ( & ReErased , _) |
268
- ( _, & ReErased ) => {
260
+ ( & ty:: ReCanonical ( ..) , _)
261
+ | ( _, & ty:: ReCanonical ( ..) )
262
+ | ( & ty:: ReClosureBound ( ..) , _)
263
+ | ( _, & ty:: ReClosureBound ( ..) )
264
+ | ( & ReLateBound ( ..) , _)
265
+ | ( _, & ReLateBound ( ..) )
266
+ | ( & ReErased , _)
267
+ | ( _, & ReErased ) => {
269
268
bug ! ( "cannot relate region: LUB({:?}, {:?})" , a, b) ;
270
269
}
271
270
@@ -287,10 +286,10 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
287
286
) ;
288
287
}
289
288
290
- ( & ReEarlyBound ( _) , & ReScope ( s_id) ) |
291
- ( & ReScope ( s_id) , & ReEarlyBound ( _) ) |
292
- ( & ReFree ( _) , & ReScope ( s_id) ) |
293
- ( & ReScope ( s_id) , & ReFree ( _) ) => {
289
+ ( & ReEarlyBound ( _) , & ReScope ( s_id) )
290
+ | ( & ReScope ( s_id) , & ReEarlyBound ( _) )
291
+ | ( & ReFree ( _) , & ReScope ( s_id) )
292
+ | ( & ReScope ( s_id) , & ReFree ( _) ) => {
294
293
// A "free" region can be interpreted as "some region
295
294
// at least as big as fr.scope". So, we can
296
295
// reasonably compare free regions and scopes:
@@ -332,10 +331,10 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
332
331
tcx. mk_region ( ReScope ( lub) )
333
332
}
334
333
335
- ( & ReEarlyBound ( _) , & ReEarlyBound ( _) ) |
336
- ( & ReFree ( _) , & ReEarlyBound ( _) ) |
337
- ( & ReEarlyBound ( _) , & ReFree ( _) ) |
338
- ( & ReFree ( _) , & ReFree ( _) ) => self . region_rels . lub_free_regions ( a, b) ,
334
+ ( & ReEarlyBound ( _) , & ReEarlyBound ( _) )
335
+ | ( & ReFree ( _) , & ReEarlyBound ( _) )
336
+ | ( & ReEarlyBound ( _) , & ReFree ( _) )
337
+ | ( & ReFree ( _) , & ReFree ( _) ) => self . region_rels . lub_free_regions ( a, b) ,
339
338
340
339
// For these types, we cannot define any additional
341
340
// relationship:
@@ -358,8 +357,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
358
357
for ( constraint, origin) in & self . data . constraints {
359
358
debug ! (
360
359
"collect_errors: constraint={:?} origin={:?}" ,
361
- constraint,
362
- origin
360
+ constraint, origin
363
361
) ;
364
362
match * constraint {
365
363
Constraint :: RegSubVar ( ..) | Constraint :: VarSubVar ( ..) => {
@@ -374,9 +372,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
374
372
debug ! (
375
373
"collect_errors: region error at {:?}: \
376
374
cannot verify that {:?} <= {:?}",
377
- origin,
378
- sub,
379
- sup
375
+ origin, sub, sup
380
376
) ;
381
377
382
378
errors. push ( RegionResolutionError :: ConcreteFailure (
@@ -402,10 +398,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
402
398
debug ! (
403
399
"collect_errors: region error at {:?}: \
404
400
cannot verify that {:?}={:?} <= {:?}",
405
- origin,
406
- a_vid,
407
- a_region,
408
- b_region
401
+ origin, a_vid, a_region, b_region
409
402
) ;
410
403
* a_data = VarValue :: ErrorValue ;
411
404
}
@@ -430,9 +423,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
430
423
debug ! (
431
424
"collect_errors: region error at {:?}: \
432
425
cannot verify that {:?} <= {:?}",
433
- verify. origin,
434
- verify. region,
435
- verify. bound
426
+ verify. origin, verify. region, verify. bound
436
427
) ;
437
428
438
429
errors. push ( RegionResolutionError :: GenericBoundFailure (
@@ -580,10 +571,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
580
571
debug ! (
581
572
"region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \
582
573
sup: {:?}",
583
- origin,
584
- node_idx,
585
- lower_bound. region,
586
- upper_bound. region
574
+ origin, node_idx, lower_bound. region, upper_bound. region
587
575
) ;
588
576
errors. push ( RegionResolutionError :: SubSupConflict (
589
577
origin,
@@ -645,8 +633,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
645
633
646
634
debug ! (
647
635
"collect_concrete_regions(orig_node_idx={:?}, node_idx={:?})" ,
648
- orig_node_idx,
649
- node_idx
636
+ orig_node_idx, node_idx
650
637
) ;
651
638
652
639
process_edges ( & self . data , & mut state, graph, node_idx, dir) ;
@@ -745,7 +732,6 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
745
732
}
746
733
}
747
734
748
-
749
735
impl < ' tcx > LexicalRegionResolutions < ' tcx > {
750
736
fn normalize ( & self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
751
737
match * r {
0 commit comments