22
22
//! The code in this file doesn't *do anything* with those results; it
23
23
//! just returns them for other code to use.
24
24
25
- use rustc:: hir:: { self , BodyOwnerKind , HirId } ;
26
25
use rustc:: hir:: def_id:: DefId ;
27
- use rustc:: infer:: { InferCtxt , NLLRegionVariableOrigin } ;
28
- use rustc:: infer:: region_constraints:: GenericKind ;
26
+ use rustc:: hir:: { self , BodyOwnerKind , HirId } ;
29
27
use rustc:: infer:: outlives:: bounds:: { self , OutlivesBound } ;
30
28
use rustc:: infer:: outlives:: free_region_map:: FreeRegionRelations ;
31
- use rustc:: ty:: { self , RegionVid , Ty , TyCtxt , ClosureSubsts , GeneratorSubsts } ;
29
+ use rustc:: infer:: region_constraints:: GenericKind ;
30
+ use rustc:: infer:: { InferCtxt , NLLRegionVariableOrigin } ;
32
31
use rustc:: ty:: fold:: TypeFoldable ;
33
32
use rustc:: ty:: subst:: Substs ;
33
+ use rustc:: ty:: { self , ClosureSubsts , GeneratorSubsts , RegionVid , Ty , TyCtxt } ;
34
34
use rustc:: util:: nodemap:: FxHashMap ;
35
35
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
36
36
use rustc_data_structures:: transitive_relation:: TransitiveRelation ;
@@ -493,18 +493,15 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
493
493
494
494
debug ! (
495
495
"build: global regions = {}..{}" ,
496
- FIRST_GLOBAL_INDEX ,
497
- first_extern_index
496
+ FIRST_GLOBAL_INDEX , first_extern_index
498
497
) ;
499
498
debug ! (
500
499
"build: extern regions = {}..{}" ,
501
- first_extern_index,
502
- first_local_index
500
+ first_extern_index, first_local_index
503
501
) ;
504
502
debug ! (
505
503
"build: local regions = {}..{}" ,
506
- first_local_index,
507
- num_universals
504
+ first_local_index, num_universals
508
505
) ;
509
506
510
507
let yield_ty = match defining_ty {
@@ -548,7 +545,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
548
545
let defining_ty = self . infcx
549
546
. replace_free_regions_with_nll_infer_vars ( FR , & defining_ty) ;
550
547
551
- match defining_ty. sty {
548
+ match defining_ty. sty {
552
549
ty:: TyClosure ( def_id, substs) => DefiningTy :: Closure ( def_id, substs) ,
553
550
ty:: TyGenerator ( def_id, substs, movability) => {
554
551
DefiningTy :: Generator ( def_id, substs, movability)
@@ -587,8 +584,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
587
584
let closure_base_def_id = tcx. closure_base_def_id ( self . mir_def_id ) ;
588
585
let identity_substs = Substs :: identity_for_item ( gcx, closure_base_def_id) ;
589
586
let fr_substs = match defining_ty {
590
- DefiningTy :: Closure ( _, ClosureSubsts { ref substs } ) |
591
- DefiningTy :: Generator ( _, GeneratorSubsts { ref substs } , _) => {
587
+ DefiningTy :: Closure ( _, ClosureSubsts { ref substs } )
588
+ | DefiningTy :: Generator ( _, GeneratorSubsts { ref substs } , _) => {
592
589
// In the case of closures, we rely on the fact that
593
590
// the first N elements in the ClosureSubsts are
594
591
// inherited from the `closure_base_def_id`.
@@ -726,8 +723,7 @@ impl UniversalRegionRelations {
726
723
fn relate_universal_regions ( & mut self , fr_a : RegionVid , fr_b : RegionVid ) {
727
724
debug ! (
728
725
"relate_universal_regions: fr_a={:?} outlives fr_b={:?}" ,
729
- fr_a,
730
- fr_b
726
+ fr_a, fr_b
731
727
) ;
732
728
self . outlives . add ( fr_a, fr_b) ;
733
729
self . inverse_outlives . add ( fr_b, fr_a) ;
@@ -780,8 +776,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
780
776
{
781
777
debug ! (
782
778
"replace_bound_regions_with_nll_infer_vars(value={:?}, all_outlive_scope={:?})" ,
783
- value,
784
- all_outlive_scope,
779
+ value, all_outlive_scope,
785
780
) ;
786
781
let ( value, _map) = self . tcx . replace_late_bound_regions ( value, |br| {
787
782
let liberated_region = self . tcx . mk_region ( ty:: ReFree ( ty:: FreeRegion {
@@ -790,7 +785,10 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
790
785
} ) ) ;
791
786
let region_vid = self . next_nll_region_var ( origin) ;
792
787
indices. insert_late_bound_region ( liberated_region, region_vid. to_region_vid ( ) ) ;
793
- debug ! ( "liberated_region={:?} => {:?}" , liberated_region, region_vid) ;
788
+ debug ! (
789
+ "liberated_region={:?} => {:?}" ,
790
+ liberated_region, region_vid
791
+ ) ;
794
792
region_vid
795
793
} ) ;
796
794
value
@@ -803,9 +801,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
803
801
/// in later and instantiate the late-bound regions, and then we
804
802
/// insert the `ReFree` version of those into the map as
805
803
/// well. These are used for error reporting.
806
- fn insert_late_bound_region ( & mut self , r : ty:: Region < ' tcx > ,
807
- vid : ty:: RegionVid )
808
- {
804
+ fn insert_late_bound_region ( & mut self , r : ty:: Region < ' tcx > , vid : ty:: RegionVid ) {
809
805
self . indices . insert ( r, vid) ;
810
806
}
811
807
@@ -821,9 +817,9 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
821
817
if let ty:: ReVar ( ..) = r {
822
818
r. to_region_vid ( )
823
819
} else {
824
- * self . indices . get ( & r ) . unwrap_or_else ( || {
825
- bug ! ( "cannot convert `{:?}` to a region vid" , r)
826
- } )
820
+ * self . indices
821
+ . get ( & r)
822
+ . unwrap_or_else ( || bug ! ( "cannot convert `{:?}` to a region vid" , r ) )
827
823
}
828
824
}
829
825
0 commit comments