@@ -133,19 +133,15 @@ impl Region {
133
133
}
134
134
}
135
135
136
- fn from_depth ( self , depth : u32 ) -> Region {
136
+ fn shifted_out_to_binder ( self , binder : ty :: DebruijnIndex ) -> Region {
137
137
match self {
138
138
Region :: LateBound ( debruijn, id, origin) => Region :: LateBound (
139
- ty:: DebruijnIndex {
140
- depth : debruijn. depth - ( depth - 1 ) ,
141
- } ,
139
+ debruijn. shifted_out_to_binder ( binder) ,
142
140
id,
143
141
origin,
144
142
) ,
145
143
Region :: LateBoundAnon ( debruijn, index) => Region :: LateBoundAnon (
146
- ty:: DebruijnIndex {
147
- depth : debruijn. depth - ( depth - 1 ) ,
148
- } ,
144
+ debruijn. shifted_out_to_binder ( binder) ,
149
145
index,
150
146
) ,
151
147
_ => self ,
@@ -1858,7 +1854,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1858
1854
. map ( |( i, input) | {
1859
1855
let mut gather = GatherLifetimes {
1860
1856
map : self . map ,
1861
- binder_depth : 1 ,
1857
+ outer_index : ty :: DebruijnIndex :: INNERMOST ,
1862
1858
have_bound_regions : false ,
1863
1859
lifetimes : FxHashSet ( ) ,
1864
1860
} ;
@@ -1899,7 +1895,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1899
1895
1900
1896
struct GatherLifetimes < ' a > {
1901
1897
map : & ' a NamedRegionMap ,
1902
- binder_depth : u32 ,
1898
+ outer_index : ty :: DebruijnIndex ,
1903
1899
have_bound_regions : bool ,
1904
1900
lifetimes : FxHashSet < Region > ,
1905
1901
}
@@ -1911,7 +1907,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1911
1907
1912
1908
fn visit_ty ( & mut self , ty : & hir:: Ty ) {
1913
1909
if let hir:: TyBareFn ( _) = ty. node {
1914
- self . binder_depth += 1 ;
1910
+ self . outer_index . shift_in ( 1 ) ;
1915
1911
}
1916
1912
if let hir:: TyTraitObject ( ref bounds, ref lifetime) = ty. node {
1917
1913
for bound in bounds {
@@ -1927,7 +1923,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1927
1923
intravisit:: walk_ty ( self , ty) ;
1928
1924
}
1929
1925
if let hir:: TyBareFn ( _) = ty. node {
1930
- self . binder_depth -= 1 ;
1926
+ self . outer_index . shift_out ( 1 ) ;
1931
1927
}
1932
1928
}
1933
1929
@@ -1946,22 +1942,22 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1946
1942
trait_ref : & hir:: PolyTraitRef ,
1947
1943
modifier : hir:: TraitBoundModifier ,
1948
1944
) {
1949
- self . binder_depth += 1 ;
1945
+ self . outer_index . shift_in ( 1 ) ;
1950
1946
intravisit:: walk_poly_trait_ref ( self , trait_ref, modifier) ;
1951
- self . binder_depth -= 1 ;
1947
+ self . outer_index . shift_out ( 1 ) ;
1952
1948
}
1953
1949
1954
1950
fn visit_lifetime ( & mut self , lifetime_ref : & hir:: Lifetime ) {
1955
1951
if let Some ( & lifetime) = self . map . defs . get ( & lifetime_ref. id ) {
1956
1952
match lifetime {
1957
1953
Region :: LateBound ( debruijn, _, _) | Region :: LateBoundAnon ( debruijn, _)
1958
- if debruijn. depth < self . binder_depth =>
1954
+ if debruijn < self . outer_index =>
1959
1955
{
1960
1956
self . have_bound_regions = true ;
1961
1957
}
1962
1958
_ => {
1963
1959
self . lifetimes
1964
- . insert ( lifetime. from_depth ( self . binder_depth ) ) ;
1960
+ . insert ( lifetime. shifted_out_to_binder ( self . outer_index ) ) ;
1965
1961
}
1966
1962
}
1967
1963
}
0 commit comments