@@ -77,7 +77,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
77
77
tcx : self . tcx ,
78
78
bound_region : * br,
79
79
found_type : None ,
80
- depth : 1 ,
80
+ current_index : ty :: DebruijnIndex :: INNERMOST ,
81
81
} ;
82
82
nested_visitor. visit_ty ( arg) ;
83
83
nested_visitor. found_type
@@ -99,7 +99,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
99
99
// The type where the anonymous lifetime appears
100
100
// for e.g. Vec<`&u8`> and <`&u8`>
101
101
found_type : Option < & ' gcx hir:: Ty > ,
102
- depth : u32 ,
102
+ current_index : ty :: DebruijnIndex ,
103
103
}
104
104
105
105
impl < ' a , ' gcx , ' tcx > Visitor < ' gcx > for FindNestedTypeVisitor < ' a , ' gcx , ' tcx > {
@@ -110,16 +110,16 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
110
110
fn visit_ty ( & mut self , arg : & ' gcx hir:: Ty ) {
111
111
match arg. node {
112
112
hir:: TyBareFn ( _) => {
113
- self . depth += 1 ;
113
+ self . current_index . shift_in ( 1 ) ;
114
114
intravisit:: walk_ty ( self , arg) ;
115
- self . depth -= 1 ;
115
+ self . current_index . shift_out ( 1 ) ;
116
116
return ;
117
117
}
118
118
119
119
hir:: TyTraitObject ( ref bounds, _) => for bound in bounds {
120
- self . depth += 1 ;
120
+ self . current_index . shift_in ( 1 ) ;
121
121
self . visit_poly_trait_ref ( bound, hir:: TraitBoundModifier :: None ) ;
122
- self . depth -= 1 ;
122
+ self . current_index . shift_out ( 1 ) ;
123
123
} ,
124
124
125
125
hir:: TyRptr ( ref lifetime, _) => {
@@ -135,11 +135,11 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
135
135
) => {
136
136
debug ! (
137
137
"LateBoundAnon depth = {:?} anon_index = {:?} br_index={:?}" ,
138
- debruijn_index. depth ,
138
+ debruijn_index,
139
139
anon_index,
140
140
br_index
141
141
) ;
142
- if debruijn_index. depth == self . depth && anon_index == br_index {
142
+ if debruijn_index == self . current_index && anon_index == br_index {
143
143
self . found_type = Some ( arg) ;
144
144
return ; // we can stop visiting now
145
145
}
@@ -170,11 +170,11 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
170
170
) => {
171
171
debug ! (
172
172
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}" ,
173
- debruijn_index. depth
173
+ debruijn_index
174
174
) ;
175
175
debug ! ( "self.infcx.tcx.hir.local_def_id(id)={:?}" , id) ;
176
176
debug ! ( "def_id={:?}" , def_id) ;
177
- if debruijn_index. depth == self . depth && id == def_id {
177
+ if debruijn_index == self . current_index && id == def_id {
178
178
self . found_type = Some ( arg) ;
179
179
return ; // we can stop visiting now
180
180
}
@@ -196,7 +196,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
196
196
tcx : self . tcx ,
197
197
found_it : false ,
198
198
bound_region : self . bound_region ,
199
- depth : self . depth ,
199
+ current_index : self . current_index ,
200
200
} ;
201
201
intravisit:: walk_ty ( subvisitor, arg) ; // call walk_ty; as visit_ty is empty,
202
202
// this will visit only outermost type
@@ -222,7 +222,7 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
222
222
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
223
223
found_it : bool ,
224
224
bound_region : ty:: BoundRegion ,
225
- depth : u32 ,
225
+ current_index : ty :: DebruijnIndex ,
226
226
}
227
227
228
228
impl < ' a , ' gcx , ' tcx > Visitor < ' gcx > for TyPathVisitor < ' a , ' gcx , ' tcx > {
@@ -235,7 +235,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
235
235
match ( self . tcx . named_region ( hir_id) , self . bound_region ) {
236
236
// the lifetime of the TyPath!
237
237
( Some ( rl:: Region :: LateBoundAnon ( debruijn_index, anon_index) ) , ty:: BrAnon ( br_index) ) => {
238
- if debruijn_index. depth == self . depth && anon_index == br_index {
238
+ if debruijn_index == self . current_index && anon_index == br_index {
239
239
self . found_it = true ;
240
240
return ;
241
241
}
@@ -257,11 +257,11 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
257
257
( Some ( rl:: Region :: LateBound ( debruijn_index, id, _) ) , ty:: BrNamed ( def_id, _) ) => {
258
258
debug ! (
259
259
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}" ,
260
- debruijn_index. depth
260
+ debruijn_index,
261
261
) ;
262
262
debug ! ( "id={:?}" , id) ;
263
263
debug ! ( "def_id={:?}" , def_id) ;
264
- if debruijn_index. depth == self . depth && id == def_id {
264
+ if debruijn_index == self . current_index && id == def_id {
265
265
self . found_it = true ;
266
266
return ; // we can stop visiting now
267
267
}
0 commit comments