1- // ignore-tidy-filelength
21//! Name resolution for lifetimes.
32//!
43//! Name resolution for lifetimes follows *much* simpler rules than the
@@ -63,23 +62,18 @@ impl RegionExt for Region {
6362 let i = * index;
6463 * index += 1 ;
6564 let def_id = hir_map. local_def_id ( param. hir_id ) ;
66- let origin = LifetimeDefOrigin :: from_param ( param) ;
6765 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 ( ) ) )
6967 }
7068
7169 fn late ( idx : u32 , hir_map : Map < ' _ > , param : & GenericParam < ' _ > ) -> ( ParamName , Region ) {
7270 let depth = ty:: INNERMOST ;
7371 let def_id = hir_map. local_def_id ( param. hir_id ) ;
74- let origin = LifetimeDefOrigin :: from_param ( param) ;
7572 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,
7875 ) ;
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 ( ) ) )
8377 }
8478
8579 fn late_anon ( named_late_bound_vars : u32 , index : & Cell < u32 > ) -> Region {
@@ -93,16 +87,16 @@ impl RegionExt for Region {
9387 match * self {
9488 Region :: Static | Region :: LateBoundAnon ( ..) => None ,
9589
96- Region :: EarlyBound ( _, id, _ ) | Region :: LateBound ( _, _, id, _ ) | Region :: Free ( _, id) => {
90+ Region :: EarlyBound ( _, id) | Region :: LateBound ( _, _, id) | Region :: Free ( _, id) => {
9791 Some ( id)
9892 }
9993 }
10094 }
10195
10296 fn shifted ( self , amount : u32 ) -> Region {
10397 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)
106100 }
107101 Region :: LateBoundAnon ( debruijn, index, anon_index) => {
108102 Region :: LateBoundAnon ( debruijn. shifted_in ( amount) , index, anon_index)
@@ -113,8 +107,8 @@ impl RegionExt for Region {
113107
114108 fn shifted_out_to_binder ( self , binder : ty:: DebruijnIndex ) -> Region {
115109 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)
118112 }
119113 Region :: LateBoundAnon ( debruijn, index, anon_index) => {
120114 Region :: LateBoundAnon ( debruijn. shifted_out_to_binder ( binder) , index, anon_index)
@@ -127,7 +121,7 @@ impl RegionExt for Region {
127121 where
128122 L : Iterator < Item = & ' a hir:: Lifetime > ,
129123 {
130- if let Region :: EarlyBound ( index, _, _ ) = self {
124+ if let Region :: EarlyBound ( index, _) = self {
131125 params. nth ( index as usize ) . and_then ( |lifetime| map. defs . get ( & lifetime. hir_id ) . cloned ( ) )
132126 } else {
133127 Some ( self )
@@ -568,7 +562,7 @@ fn sub_items_have_self_param(node: &hir::ItemKind<'_>) -> bool {
568562
569563fn late_region_as_bound_region < ' tcx > ( tcx : TyCtxt < ' tcx > , region : & Region ) -> ty:: BoundVariableKind {
570564 match region {
571- Region :: LateBound ( _, _, def_id, _ ) => {
565+ Region :: LateBound ( _, _, def_id) => {
572566 let name = tcx. hir ( ) . name ( tcx. hir ( ) . local_def_id_to_hir_id ( def_id. expect_local ( ) ) ) ;
573567 ty:: BoundVariableKind :: Region ( ty:: BrNamed ( * def_id, name) )
574568 }
@@ -1010,7 +1004,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
10101004 // well-supported at the moment, so this doesn't work.
10111005 // In the future, this should be fixed and this error should be removed.
10121006 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 {
10141008 continue
10151009 } ;
10161010 let Some ( def_id) = def_id. as_local ( ) else {
@@ -1046,7 +1040,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
10461040 match param. kind {
10471041 GenericParamKind :: Lifetime { .. } => {
10481042 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 {
10501044 bug ! ( ) ;
10511045 } ;
10521046 // We cannot predict what lifetimes are unused in opaque type.
@@ -1668,7 +1662,7 @@ fn compute_object_lifetime_defaults<'tcx>(
16681662 . map ( |set| match * set {
16691663 Set1 :: Empty => "BaseDefault" . into ( ) ,
16701664 Set1 :: One ( Region :: Static ) => "'static" . into ( ) ,
1671- Set1 :: One ( Region :: EarlyBound ( mut i, _, _ ) ) => generics
1665+ Set1 :: One ( Region :: EarlyBound ( mut i, _) ) => generics
16721666 . params
16731667 . iter ( )
16741668 . find_map ( |param| match param. kind {
@@ -1749,18 +1743,16 @@ fn object_lifetime_defaults_for_item<'tcx>(
17491743 . params
17501744 . iter ( )
17511745 . 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+ }
17571749 _ => None ,
17581750 } )
17591751 . 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, _) ) | {
17621754 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 ( ) ) )
17641756 } )
17651757 }
17661758 }
@@ -1948,8 +1940,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
19481940 let def_ids: Vec < _ > = defined_by
19491941 . values ( )
19501942 . 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)
19531945 | Region :: Free ( _, def_id) => Some ( * def_id) ,
19541946
19551947 Region :: LateBoundAnon ( ..) | Region :: Static => None ,
@@ -2883,7 +2875,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
28832875 fn visit_lifetime ( & mut self , lifetime_ref : & hir:: Lifetime ) {
28842876 if let Some ( & lifetime) = self . map . defs . get ( & lifetime_ref. hir_id ) {
28852877 match lifetime {
2886- Region :: LateBound ( debruijn, _, _, _ )
2878+ Region :: LateBound ( debruijn, _, _)
28872879 | Region :: LateBoundAnon ( debruijn, _, _)
28882880 if debruijn < self . outer_index =>
28892881 {
@@ -3289,8 +3281,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
32893281 }
32903282
32913283 Region :: Free ( _, def_id)
3292- | Region :: LateBound ( _, _, def_id, _ )
3293- | Region :: EarlyBound ( _, def_id, _ ) => {
3284+ | Region :: LateBound ( _, _, def_id)
3285+ | Region :: EarlyBound ( _, def_id) => {
32943286 // A lifetime declared by the user.
32953287 let track_lifetime_uses = self . track_lifetime_uses ( ) ;
32963288 debug ! ( ?track_lifetime_uses) ;
0 commit comments