1
- // ignore-tidy-filelength
2
1
//! Name resolution for lifetimes.
3
2
//!
4
3
//! Name resolution for lifetimes follows *much* simpler rules than the
@@ -63,23 +62,18 @@ impl RegionExt for Region {
63
62
let i = * index;
64
63
* index += 1 ;
65
64
let def_id = hir_map. local_def_id ( param. hir_id ) ;
66
- let origin = LifetimeDefOrigin :: from_param ( param) ;
67
65
debug ! ( "Region::early: index={} def_id={:?}" , i, def_id) ;
68
- ( param. name . normalize_to_macros_2_0 ( ) , Region :: EarlyBound ( i, def_id. to_def_id ( ) , origin ) )
66
+ ( param. name . normalize_to_macros_2_0 ( ) , Region :: EarlyBound ( i, def_id. to_def_id ( ) ) )
69
67
}
70
68
71
69
fn late ( idx : u32 , hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( ParamName , Region ) {
72
70
let depth = ty:: INNERMOST ;
73
71
let def_id = hir_map. local_def_id ( param. hir_id ) ;
74
- let origin = LifetimeDefOrigin :: from_param ( param) ;
75
72
debug ! (
76
- "Region::late: idx={:?}, param={:?} depth={:?} def_id={:?} origin={:?} " ,
77
- idx, param, depth, def_id, origin ,
73
+ "Region::late: idx={:?}, param={:?} depth={:?} def_id={:?}" ,
74
+ idx, param, depth, def_id,
78
75
) ;
79
- (
80
- param. name . normalize_to_macros_2_0 ( ) ,
81
- Region :: LateBound ( depth, idx, def_id. to_def_id ( ) , origin) ,
82
- )
76
+ ( param. name . normalize_to_macros_2_0 ( ) , Region :: LateBound ( depth, idx, def_id. to_def_id ( ) ) )
83
77
}
84
78
85
79
fn late_anon ( named_late_bound_vars : u32 , index : & Cell < u32 > ) -> Region {
@@ -93,16 +87,16 @@ impl RegionExt for Region {
93
87
match * self {
94
88
Region :: Static | Region :: LateBoundAnon ( ..) => None ,
95
89
96
- Region :: EarlyBound ( _, id, _ ) | Region :: LateBound ( _, _, id, _ ) | Region :: Free ( _, id) => {
90
+ Region :: EarlyBound ( _, id) | Region :: LateBound ( _, _, id) | Region :: Free ( _, id) => {
97
91
Some ( id)
98
92
}
99
93
}
100
94
}
101
95
102
96
fn shifted ( self , amount : u32 ) -> Region {
103
97
match self {
104
- Region :: LateBound ( debruijn, idx, id, origin ) => {
105
- Region :: LateBound ( debruijn. shifted_in ( amount) , idx, id, origin )
98
+ Region :: LateBound ( debruijn, idx, id) => {
99
+ Region :: LateBound ( debruijn. shifted_in ( amount) , idx, id)
106
100
}
107
101
Region :: LateBoundAnon ( debruijn, index, anon_index) => {
108
102
Region :: LateBoundAnon ( debruijn. shifted_in ( amount) , index, anon_index)
@@ -113,8 +107,8 @@ impl RegionExt for Region {
113
107
114
108
fn shifted_out_to_binder ( self , binder : ty:: DebruijnIndex ) -> Region {
115
109
match self {
116
- Region :: LateBound ( debruijn, index, id, origin ) => {
117
- Region :: LateBound ( debruijn. shifted_out_to_binder ( binder) , index, id, origin )
110
+ Region :: LateBound ( debruijn, index, id) => {
111
+ Region :: LateBound ( debruijn. shifted_out_to_binder ( binder) , index, id)
118
112
}
119
113
Region :: LateBoundAnon ( debruijn, index, anon_index) => {
120
114
Region :: LateBoundAnon ( debruijn. shifted_out_to_binder ( binder) , index, anon_index)
@@ -127,7 +121,7 @@ impl RegionExt for Region {
127
121
where
128
122
L : Iterator < Item = & ' a hir:: Lifetime > ,
129
123
{
130
- if let Region :: EarlyBound ( index, _, _ ) = self {
124
+ if let Region :: EarlyBound ( index, _) = self {
131
125
params. nth ( index as usize ) . and_then ( |lifetime| map. defs . get ( & lifetime. hir_id ) . cloned ( ) )
132
126
} else {
133
127
Some ( self )
@@ -568,7 +562,7 @@ fn sub_items_have_self_param(node: &hir::ItemKind<'_>) -> bool {
568
562
569
563
fn late_region_as_bound_region < ' tcx > ( tcx : TyCtxt < ' tcx > , region : & Region ) -> ty:: BoundVariableKind {
570
564
match region {
571
- Region :: LateBound ( _, _, def_id, _ ) => {
565
+ Region :: LateBound ( _, _, def_id) => {
572
566
let name = tcx. hir ( ) . name ( tcx. hir ( ) . local_def_id_to_hir_id ( def_id. expect_local ( ) ) ) ;
573
567
ty:: BoundVariableKind :: Region ( ty:: BrNamed ( * def_id, name) )
574
568
}
@@ -1010,7 +1004,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
1010
1004
// well-supported at the moment, so this doesn't work.
1011
1005
// In the future, this should be fixed and this error should be removed.
1012
1006
let def = self . map . defs . get ( & lifetime. hir_id ) . cloned ( ) ;
1013
- let Some ( Region :: LateBound ( _, _, def_id, _ ) ) = def else {
1007
+ let Some ( Region :: LateBound ( _, _, def_id) ) = def else {
1014
1008
continue
1015
1009
} ;
1016
1010
let Some ( def_id) = def_id. as_local ( ) else {
@@ -1046,7 +1040,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
1046
1040
match param. kind {
1047
1041
GenericParamKind :: Lifetime { .. } => {
1048
1042
let ( name, reg) = Region :: early ( self . tcx . hir ( ) , & mut index, & param) ;
1049
- let Region :: EarlyBound ( _, def_id, _ ) = reg else {
1043
+ let Region :: EarlyBound ( _, def_id) = reg else {
1050
1044
bug ! ( ) ;
1051
1045
} ;
1052
1046
// We cannot predict what lifetimes are unused in opaque type.
@@ -1668,7 +1662,7 @@ fn compute_object_lifetime_defaults<'tcx>(
1668
1662
. map ( |set| match * set {
1669
1663
Set1 :: Empty => "BaseDefault" . into ( ) ,
1670
1664
Set1 :: One ( Region :: Static ) => "'static" . into ( ) ,
1671
- Set1 :: One ( Region :: EarlyBound ( mut i, _, _ ) ) => generics
1665
+ Set1 :: One ( Region :: EarlyBound ( mut i, _) ) => generics
1672
1666
. params
1673
1667
. iter ( )
1674
1668
. find_map ( |param| match param. kind {
@@ -1749,18 +1743,16 @@ fn object_lifetime_defaults_for_item<'tcx>(
1749
1743
. params
1750
1744
. iter ( )
1751
1745
. filter_map ( |param| match param. kind {
1752
- GenericParamKind :: Lifetime { .. } => Some ( (
1753
- param. hir_id ,
1754
- hir:: LifetimeName :: Param ( param. name ) ,
1755
- LifetimeDefOrigin :: from_param ( param) ,
1756
- ) ) ,
1746
+ GenericParamKind :: Lifetime { .. } => {
1747
+ Some ( ( param. hir_id , hir:: LifetimeName :: Param ( param. name ) ) )
1748
+ }
1757
1749
_ => None ,
1758
1750
} )
1759
1751
. enumerate ( )
1760
- . find ( |& ( _, ( _, lt_name, _ ) ) | lt_name == name)
1761
- . map_or ( Set1 :: Many , |( i, ( id, _, origin ) ) | {
1752
+ . find ( |& ( _, ( _, lt_name) ) | lt_name == name)
1753
+ . map_or ( Set1 :: Many , |( i, ( id, _) ) | {
1762
1754
let def_id = tcx. hir ( ) . local_def_id ( id) ;
1763
- Set1 :: One ( Region :: EarlyBound ( i as u32 , def_id. to_def_id ( ) , origin ) )
1755
+ Set1 :: One ( Region :: EarlyBound ( i as u32 , def_id. to_def_id ( ) ) )
1764
1756
} )
1765
1757
}
1766
1758
}
@@ -1948,8 +1940,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1948
1940
let def_ids: Vec < _ > = defined_by
1949
1941
. values ( )
1950
1942
. flat_map ( |region| match region {
1951
- Region :: EarlyBound ( _, def_id, _ )
1952
- | Region :: LateBound ( _, _, def_id, _ )
1943
+ Region :: EarlyBound ( _, def_id)
1944
+ | Region :: LateBound ( _, _, def_id)
1953
1945
| Region :: Free ( _, def_id) => Some ( * def_id) ,
1954
1946
1955
1947
Region :: LateBoundAnon ( ..) | Region :: Static => None ,
@@ -2883,7 +2875,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
2883
2875
fn visit_lifetime ( & mut self , lifetime_ref : & hir:: Lifetime ) {
2884
2876
if let Some ( & lifetime) = self . map . defs . get ( & lifetime_ref. hir_id ) {
2885
2877
match lifetime {
2886
- Region :: LateBound ( debruijn, _, _, _ )
2878
+ Region :: LateBound ( debruijn, _, _)
2887
2879
| Region :: LateBoundAnon ( debruijn, _, _)
2888
2880
if debruijn < self . outer_index =>
2889
2881
{
@@ -3289,8 +3281,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
3289
3281
}
3290
3282
3291
3283
Region :: Free ( _, def_id)
3292
- | Region :: LateBound ( _, _, def_id, _ )
3293
- | Region :: EarlyBound ( _, def_id, _ ) => {
3284
+ | Region :: LateBound ( _, _, def_id)
3285
+ | Region :: EarlyBound ( _, def_id) => {
3294
3286
// A lifetime declared by the user.
3295
3287
let track_lifetime_uses = self . track_lifetime_uses ( ) ;
3296
3288
debug ! ( ?track_lifetime_uses) ;
0 commit comments