Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend E0623 for fn items #44516

Merged
merged 8 commits into from
Sep 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
correct depth initialisation
  • Loading branch information
gaurikholkar committed Sep 12, 2017
commit 54af57018b57810c4467b6ed092a0294c3467ef5
40 changes: 11 additions & 29 deletions src/librustc/infer/error_reporting/anon_anon_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
hir_map: &self.tcx.hir,
bound_region: *br,
found_type: None,
depth: 0,
depth: 1,
};
nested_visitor.visit_ty(arg);
nested_visitor.found_type
Expand Down Expand Up @@ -233,6 +233,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
};

match arg.node {

hir::TyBareFn(ref fndecl) => {
self.depth += 1;
intravisit::walk_ty(self, arg);
self.depth -= 1;
return;
}

hir::TyRptr(ref lifetime, _) => {
match self.infcx.tcx.named_region_map.defs.get(&lifetime.id) {
// the lifetime of the TyRptr
Expand Down Expand Up @@ -266,38 +274,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
}
}

hir::TyBareFn(ref fndecl) => {
fndecl.lifetimes.iter().map(|lf| {
debug!("arg we are handling is...{:?}",arg);
match self.infcx.tcx.named_region_map.defs.get(&lf.lifetime.id) {
Some(&rl::Region::LateBoundAnon(debuijn_index, anon_index)) => {
debug!("debuijn_index.depth ={:?} self.depth = {:?} anon_index ={:?} br_index={:?}",
debuijn_index.depth, self.depth, anon_index, br_index);
if debuijn_index.depth == self.depth && anon_index == br_index {
debug!("arg is {:?}",Some(arg));
self.found_type = Some(arg);
return; // we can stop visiting now
}
}
Some(&rl::Region::Static) |
Some(&rl::Region::EarlyBound(_, _)) |
Some(&rl::Region::LateBound(_, _)) |
Some(&rl::Region::Free(_, _)) |
None => {
debug!("no arg found");
}
}

}).next();}

_ => {}
}
// walk the embedded contents: e.g., if we are visiting `Vec<&Foo>`,
// go on to visit `&Foo`
self.depth += 1;
debug!("depth is {:?}",self.depth);
debug!("depth is {:?}", self.depth);
intravisit::walk_ty(self, arg);
self.depth += 1;

}
}

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


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