about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-09-14 10:01:12 +0530
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-09-14 10:01:12 +0530
commit696a26882278ac631e11dee457dfe8e6dfbd0891 (patch)
treea8443c5bf05486b1dab4c1c8993327832dc45feb
parentf8df89a5cbf868677c342e3fa06dc6ca9a784e59 (diff)
downloadrust-696a26882278ac631e11dee457dfe8e6dfbd0891.tar.gz
rust-696a26882278ac631e11dee457dfe8e6dfbd0891.zip
fix depth for structs
-rw-r--r--src/librustc/infer/error_reporting/different_lifetimes.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs
index bf1428cabd6..536715ffadb 100644
--- a/src/librustc/infer/error_reporting/different_lifetimes.rs
+++ b/src/librustc/infer/error_reporting/different_lifetimes.rs
@@ -287,6 +287,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
                                           found_it: false,
                                           bound_region: self.bound_region,
                                           hir_map: self.hir_map,
+                                          depth: self.depth,
                                       };
                 intravisit::walk_ty(subvisitor, arg); // call walk_ty; as visit_ty is empty,
                 // this will visit only outermost type
@@ -313,6 +314,7 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
     hir_map: &'a hir::map::Map<'gcx>,
     found_it: bool,
     bound_region: ty::BoundRegion,
+    depth: u32,
 }
 
 impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
@@ -326,7 +328,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
         match (self.infcx.tcx.named_region(hir_id), self.bound_region) {
             // the lifetime of the TyPath!
             (Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
-                if debruijn_index.depth == 1 && anon_index == br_index {
+                if debruijn_index.depth == self.depth && anon_index == br_index {
                     self.found_it = true;
                     return;
                 }
@@ -349,7 +351,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
                 debug!("self.infcx.tcx.hir.local_def_id(id)={:?}",
                        self.infcx.tcx.hir.local_def_id(id));
                 debug!("def_id={:?}", def_id);
-                if debruijn_index.depth == 1 && self.infcx.tcx.hir.local_def_id(id) == def_id {
+                if debruijn_index.depth == self.depth &&
+                   self.infcx.tcx.hir.local_def_id(id) == def_id {
                     self.found_it = true;
                     return; // we can stop visiting now
                 }