]> git.lizzy.rs Git - rust.git/commitdiff
extend E0623 for earlybound and latebound for structs
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Wed, 13 Sep 2017 19:34:47 +0000 (01:04 +0530)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Thu, 14 Sep 2017 04:26:44 +0000 (09:56 +0530)
src/librustc/infer/error_reporting/different_lifetimes.rs

index 051263dfb53ef30f5e8f5283c7550d25049b3f70..bf1428cabd63c0b7c8ea806312186efa74f294dc 100644 (file)
@@ -321,24 +321,46 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
     }
 
     fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
-        let br_index = match self.bound_region {
-            ty::BrAnon(index) => index,
-            _ => return,
-        };
 
         let hir_id = self.infcx.tcx.hir.node_to_hir_id(lifetime.id);
-        match self.infcx.tcx.named_region(hir_id) {
+        match (self.infcx.tcx.named_region(hir_id), self.bound_region) {
             // the lifetime of the TyPath!
-            Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)) => {
+            (Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
                 if debruijn_index.depth == 1 && anon_index == br_index {
                     self.found_it = true;
+                    return;
+                }
+            }
+
+            (Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
+                debug!("EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
+                                        def_id={:?}",
+                       self.infcx.tcx.hir.local_def_id(id),
+                       def_id);
+                if self.infcx.tcx.hir.local_def_id(id) == def_id {
+                    self.found_it = true;
+                    return; // we can stop visiting now
                 }
             }
-            Some(rl::Region::Static) |
-            Some(rl::Region::EarlyBound(_, _)) |
-            Some(rl::Region::LateBound(_, _)) |
-            Some(rl::Region::Free(_, _)) |
-            None => {
+
+            (Some(rl::Region::LateBound(debruijn_index, id)), ty::BrNamed(def_id, _)) => {
+                debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
+                       debruijn_index.depth);
+                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 {
+                    self.found_it = true;
+                    return; // we can stop visiting now
+                }
+            }
+
+            (Some(rl::Region::Static), _) |
+            (Some(rl::Region::EarlyBound(_, _)), _) |
+            (Some(rl::Region::LateBound(_, _)), _) |
+            (Some(rl::Region::LateBoundAnon(_, _)), _) |
+            (Some(rl::Region::Free(_, _)), _) |
+            (None, _) => {
                 debug!("no arg found");
             }
         }