]> git.lizzy.rs Git - rust.git/commitdiff
extend E0623 for fns
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Tue, 15 Aug 2017 04:51:31 +0000 (10:21 +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 c86bc71d310a8f2cc905f9a2db89504cba28d981..bb4782d2c8f5c0ab7c7524eaada08048f6dd51f0 100644 (file)
@@ -192,6 +192,7 @@ fn find_visitor_found_type(&self,
             hir_map: &self.tcx.hir,
             bound_region: *br,
             found_type: None,
+            depth: 0,
         };
         nested_visitor.visit_ty(arg);
         nested_visitor.found_type
@@ -214,6 +215,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
     // The type where the anonymous lifetime appears
     // for e.g. Vec<`&u8`> and <`&u8`>
     found_type: Option<&'gcx hir::Ty>,
+    depth: u32,
 }
 
 impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
@@ -263,11 +265,35 @@ fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
                     self.found_type = Some(arg);
                 }
             }
+
+            hir::TyBareFn(ref fndecl) => {
+                fndecl.lifetimes.iter().filter_map(|lf| {
+                    match self.infcx.tcx.named_region_map.defs.get(&lf.lifetime.id) {
+
+                        Some(&rl::Region::LateBoundAnon(debuijn_index, anon_index)) => {
+                        if debuijn_index.depth == self.depth && anon_index == br_index {
+                            self.found_type = Some(arg);
+                            return; // we can stop visiting now
+                        }else{}
+                    }
+                    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;
         intravisit::walk_ty(self, arg);
+        self.depth += 1;
     }
 }