Skip to content

Commit 54af570

Browse files
committed
correct depth initialisation
1 parent b2d869d commit 54af570

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

src/librustc/infer/error_reporting/anon_anon_conflict.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
192192
hir_map: &self.tcx.hir,
193193
bound_region: *br,
194194
found_type: None,
195-
depth: 0,
195+
depth: 1,
196196
};
197197
nested_visitor.visit_ty(arg);
198198
nested_visitor.found_type
@@ -233,6 +233,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
233233
};
234234

235235
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+
236244
hir::TyRptr(ref lifetime, _) => {
237245
match self.infcx.tcx.named_region_map.defs.get(&lifetime.id) {
238246
// the lifetime of the TyRptr
@@ -266,38 +274,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
266274
}
267275
}
268276

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-
293277
_ => {}
294278
}
295279
// walk the embedded contents: e.g., if we are visiting `Vec<&Foo>`,
296280
// go on to visit `&Foo`
297-
self.depth += 1;
298-
debug!("depth is {:?}",self.depth);
281+
debug!("depth is {:?}", self.depth);
299282
intravisit::walk_ty(self, arg);
300-
self.depth += 1;
283+
301284
}
302285
}
303286

@@ -325,7 +308,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
325308
_ => return,
326309
};
327310

328-
329311
match self.infcx.tcx.named_region_map.defs.get(&lifetime.id) {
330312
// the lifetime of the TyPath!
331313
Some(&rl::Region::LateBoundAnon(debuijn_index, anon_index)) => {

0 commit comments

Comments
 (0)