@@ -192,7 +192,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
192
192
hir_map : & self . tcx . hir ,
193
193
bound_region : * br,
194
194
found_type : None ,
195
- depth : 0 ,
195
+ depth : 1 ,
196
196
} ;
197
197
nested_visitor. visit_ty ( arg) ;
198
198
nested_visitor. found_type
@@ -233,6 +233,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
233
233
} ;
234
234
235
235
match arg. node {
236
+
237
+ hir:: TyBareFn ( ref fndecl) => {
238
+ self . depth += 1 ;
239
+ intravisit:: walk_ty ( self , arg) ;
240
+ self . depth -= 1 ;
241
+ return ;
242
+ }
243
+
236
244
hir:: TyRptr ( ref lifetime, _) => {
237
245
match self . infcx . tcx . named_region_map . defs . get ( & lifetime. id ) {
238
246
// the lifetime of the TyRptr
@@ -266,38 +274,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
266
274
}
267
275
}
268
276
269
- hir:: TyBareFn ( ref fndecl) => {
270
- fndecl. lifetimes . iter ( ) . map ( |lf| {
271
- debug ! ( "arg we are handling is...{:?}" , arg) ;
272
- match self . infcx . tcx . named_region_map . defs . get ( & lf. lifetime . id ) {
273
- Some ( & rl:: Region :: LateBoundAnon ( debuijn_index, anon_index) ) => {
274
- debug ! ( "debuijn_index.depth ={:?} self.depth = {:?} anon_index ={:?} br_index={:?}" ,
275
- debuijn_index. depth, self . depth, anon_index, br_index) ;
276
- if debuijn_index. depth == self . depth && anon_index == br_index {
277
- debug ! ( "arg is {:?}" , Some ( arg) ) ;
278
- self . found_type = Some ( arg) ;
279
- return ; // we can stop visiting now
280
- }
281
- }
282
- Some ( & rl:: Region :: Static ) |
283
- Some ( & rl:: Region :: EarlyBound ( _, _) ) |
284
- Some ( & rl:: Region :: LateBound ( _, _) ) |
285
- Some ( & rl:: Region :: Free ( _, _) ) |
286
- None => {
287
- debug ! ( "no arg found" ) ;
288
- }
289
- }
290
-
291
- } ) . next ( ) ; }
292
-
293
277
_ => { }
294
278
}
295
279
// walk the embedded contents: e.g., if we are visiting `Vec<&Foo>`,
296
280
// go on to visit `&Foo`
297
- self . depth += 1 ;
298
- debug ! ( "depth is {:?}" , self . depth) ;
281
+ debug ! ( "depth is {:?}" , self . depth) ;
299
282
intravisit:: walk_ty ( self , arg) ;
300
- self . depth += 1 ;
283
+
301
284
}
302
285
}
303
286
@@ -325,7 +308,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
325
308
_ => return ,
326
309
} ;
327
310
328
-
329
311
match self . infcx . tcx . named_region_map . defs . get ( & lifetime. id ) {
330
312
// the lifetime of the TyPath!
331
313
Some ( & rl:: Region :: LateBoundAnon ( debuijn_index, anon_index) ) => {
0 commit comments