]> git.lizzy.rs Git - rust.git/commitdiff
correct depth initialisation
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Mon, 11 Sep 2017 18:28:29 +0000 (23:58 +0530)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Tue, 12 Sep 2017 04:36:29 +0000 (10:06 +0530)
src/librustc/infer/error_reporting/anon_anon_conflict.rs

index 634f57886607139709d4f51025ba7ba065674ccb..420ac040b309d0a81c16ae95031abfee19e34a33 100644 (file)
@@ -192,7 +192,7 @@ fn find_visitor_found_type(&self,
             hir_map: &self.tcx.hir,
             bound_region: *br,
             found_type: None,
-            depth: 0,
+            depth: 1,
         };
         nested_visitor.visit_ty(arg);
         nested_visitor.found_type
@@ -233,6 +233,14 @@ fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
         };
 
         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
@@ -266,38 +274,13 @@ fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
                 }
             }
 
-            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;
+
     }
 }
 
@@ -325,7 +308,6 @@ fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
             _ => 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)) => {