@@ -15,7 +15,6 @@ use rustc_hir::def_id::LocalDefId;
15
15
use rustc_hir:: intravisit:: { self , Visitor } ;
16
16
use rustc_hir:: { GenericArg , GenericParam , GenericParamKind , HirIdMap , LifetimeName , Node } ;
17
17
use rustc_middle:: bug;
18
- use rustc_middle:: hir:: map:: Map ;
19
18
use rustc_middle:: hir:: nested_filter;
20
19
use rustc_middle:: middle:: resolve_lifetime:: * ;
21
20
use rustc_middle:: ty:: { self , DefIdTree , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
@@ -25,30 +24,28 @@ use rustc_span::Span;
25
24
use std:: fmt;
26
25
27
26
trait RegionExt {
28
- fn early ( hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) ;
27
+ fn early ( param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) ;
29
28
30
- fn late ( index : u32 , hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) ;
29
+ fn late ( index : u32 , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) ;
31
30
32
31
fn id ( & self ) -> Option < DefId > ;
33
32
34
33
fn shifted ( self , amount : u32 ) -> Region ;
35
34
}
36
35
37
36
impl RegionExt for Region {
38
- fn early ( hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) {
39
- let def_id = hir_map. local_def_id ( param. hir_id ) ;
40
- debug ! ( "Region::early: def_id={:?}" , def_id) ;
41
- ( def_id, Region :: EarlyBound ( def_id. to_def_id ( ) ) )
37
+ fn early ( param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) {
38
+ debug ! ( "Region::early: def_id={:?}" , param. def_id) ;
39
+ ( param. def_id , Region :: EarlyBound ( param. def_id . to_def_id ( ) ) )
42
40
}
43
41
44
- fn late ( idx : u32 , hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) {
42
+ fn late ( idx : u32 , param : & GenericParam < ' _ > ) -> ( LocalDefId , Region ) {
45
43
let depth = ty:: INNERMOST ;
46
- let def_id = hir_map. local_def_id ( param. hir_id ) ;
47
44
debug ! (
48
45
"Region::late: idx={:?}, param={:?} depth={:?} def_id={:?}" ,
49
- idx, param, depth, def_id,
46
+ idx, param, depth, param . def_id,
50
47
) ;
51
- ( def_id, Region :: LateBound ( depth, idx, def_id. to_def_id ( ) ) )
48
+ ( param . def_id , Region :: LateBound ( depth, idx, param . def_id . to_def_id ( ) ) )
52
49
}
53
50
54
51
fn id ( & self ) -> Option < DefId > {
@@ -395,7 +392,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
395
392
. filter ( |param| matches ! ( param. kind, GenericParamKind :: Lifetime { .. } ) )
396
393
. enumerate ( )
397
394
. map ( |( late_bound_idx, param) | {
398
- let pair = Region :: late ( late_bound_idx as u32 , self . tcx . hir ( ) , param) ;
395
+ let pair = Region :: late ( late_bound_idx as u32 , param) ;
399
396
let r = late_region_as_bound_region ( self . tcx , & pair. 1 ) ;
400
397
( pair, r)
401
398
} )
@@ -492,7 +489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
492
489
for param in generics. params {
493
490
match param. kind {
494
491
GenericParamKind :: Lifetime { .. } => {
495
- let ( def_id, reg) = Region :: early ( self . tcx . hir ( ) , & param) ;
492
+ let ( def_id, reg) = Region :: early ( & param) ;
496
493
lifetimes. insert ( def_id, reg) ;
497
494
}
498
495
GenericParamKind :: Type { .. } | GenericParamKind :: Const { .. } => { }
@@ -523,9 +520,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
523
520
. params
524
521
. iter ( )
525
522
. filter_map ( |param| match param. kind {
526
- GenericParamKind :: Lifetime { .. } => {
527
- Some ( Region :: early ( self . tcx . hir ( ) , param) )
528
- }
523
+ GenericParamKind :: Lifetime { .. } => Some ( Region :: early ( param) ) ,
529
524
GenericParamKind :: Type { .. } | GenericParamKind :: Const { .. } => None ,
530
525
} )
531
526
. collect ( ) ;
@@ -573,7 +568,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
573
568
. filter ( |param| matches ! ( param. kind, GenericParamKind :: Lifetime { .. } ) )
574
569
. enumerate ( )
575
570
. map ( |( late_bound_idx, param) | {
576
- let pair = Region :: late ( late_bound_idx as u32 , self . tcx . hir ( ) , param) ;
571
+ let pair = Region :: late ( late_bound_idx as u32 , param) ;
577
572
let r = late_region_as_bound_region ( self . tcx , & pair. 1 ) ;
578
573
( pair, r)
579
574
} )
@@ -731,9 +726,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
731
726
. params
732
727
. iter ( )
733
728
. filter_map ( |param| match param. kind {
734
- GenericParamKind :: Lifetime { .. } => {
735
- Some ( Region :: early ( self . tcx . hir ( ) , param) )
736
- }
729
+ GenericParamKind :: Lifetime { .. } => Some ( Region :: early ( param) ) ,
737
730
GenericParamKind :: Type { .. } | GenericParamKind :: Const { .. } => None ,
738
731
} )
739
732
. collect ( ) ;
@@ -779,9 +772,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
779
772
. params
780
773
. iter ( )
781
774
. filter_map ( |param| match param. kind {
782
- GenericParamKind :: Lifetime { .. } => {
783
- Some ( Region :: early ( self . tcx . hir ( ) , param) )
784
- }
775
+ GenericParamKind :: Lifetime { .. } => Some ( Region :: early ( param) ) ,
785
776
GenericParamKind :: Const { .. } | GenericParamKind :: Type { .. } => None ,
786
777
} )
787
778
. collect ( ) ;
@@ -886,7 +877,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
886
877
} )
887
878
. enumerate ( )
888
879
. map ( |( late_bound_idx, param) | {
889
- Region :: late ( late_bound_idx as u32 , this . tcx . hir ( ) , param)
880
+ Region :: late ( late_bound_idx as u32 , param)
890
881
} )
891
882
. collect ( ) ;
892
883
let binders: Vec < _ > =
@@ -999,8 +990,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
999
990
. filter ( |param| matches ! ( param. kind, GenericParamKind :: Lifetime { .. } ) )
1000
991
. enumerate ( )
1001
992
. map ( |( late_bound_idx, param) | {
1002
- let pair =
1003
- Region :: late ( initial_bound_vars + late_bound_idx as u32 , self . tcx . hir ( ) , param) ;
993
+ let pair = Region :: late ( initial_bound_vars + late_bound_idx as u32 , param) ;
1004
994
let r = late_region_as_bound_region ( self . tcx , & pair. 1 ) ;
1005
995
lifetimes. insert ( pair. 0 , pair. 1 ) ;
1006
996
r
@@ -1131,9 +1121,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1131
1121
if self . tcx . is_late_bound ( param. hir_id ) {
1132
1122
let late_bound_idx = named_late_bound_vars;
1133
1123
named_late_bound_vars += 1 ;
1134
- Some ( Region :: late ( late_bound_idx, self . tcx . hir ( ) , param) )
1124
+ Some ( Region :: late ( late_bound_idx, param) )
1135
1125
} else {
1136
- Some ( Region :: early ( self . tcx . hir ( ) , param) )
1126
+ Some ( Region :: early ( param) )
1137
1127
}
1138
1128
}
1139
1129
GenericParamKind :: Type { .. } | GenericParamKind :: Const { .. } => None ,
@@ -1149,7 +1139,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1149
1139
} )
1150
1140
. enumerate ( )
1151
1141
. map ( |( late_bound_idx, param) | {
1152
- let pair = Region :: late ( late_bound_idx as u32 , self . tcx . hir ( ) , param) ;
1142
+ let pair = Region :: late ( late_bound_idx as u32 , param) ;
1153
1143
late_region_as_bound_region ( self . tcx , & pair. 1 )
1154
1144
} )
1155
1145
. collect ( ) ;
0 commit comments