about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-09-19 12:44:38 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-09-26 09:38:26 -0400
commit85d12e2f0b5aa76f535d1d519925a86eecdb73b4 (patch)
treea5527c1455b45565ff69f6a8dc2c3f65120ea6f2 /src
parentb5469c5fd75cec185dc2c79a4986decaa1f9be40 (diff)
downloadrust-85d12e2f0b5aa76f535d1d519925a86eecdb73b4.tar.gz
rust-85d12e2f0b5aa76f535d1d519925a86eecdb73b4.zip
remove handling of verify from taintset
This lets us remove `for_each_region` and makes things simpler.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/region_constraints/mod.rs12
-rw-r--r--src/librustc/infer/region_constraints/taint.rs50
2 files changed, 25 insertions, 37 deletions
diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs
index d8f3b9a05bd..0297340e402 100644
--- a/src/librustc/infer/region_constraints/mod.rs
+++ b/src/librustc/infer/region_constraints/mod.rs
@@ -882,18 +882,6 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
 }
 
 impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
-    fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) {
-        match self {
-            &VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs {
-                f(r);
-            },
-
-            &VerifyBound::AnyBound(ref bs) | &VerifyBound::AllBounds(ref bs) => for b in bs {
-                b.for_each_region(f);
-            },
-        }
-    }
-
     pub fn must_hold(&self) -> bool {
         match self {
             &VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic),
diff --git a/src/librustc/infer/region_constraints/taint.rs b/src/librustc/infer/region_constraints/taint.rs
index ee45f7bd828..4f513cd5d48 100644
--- a/src/librustc/infer/region_constraints/taint.rs
+++ b/src/librustc/infer/region_constraints/taint.rs
@@ -13,34 +13,39 @@ use super::*;
 #[derive(Debug)]
 pub(super) struct TaintSet<'tcx> {
     directions: TaintDirections,
-    regions: FxHashSet<ty::Region<'tcx>>
+    regions: FxHashSet<ty::Region<'tcx>>,
 }
 
 impl<'tcx> TaintSet<'tcx> {
-    pub(super) fn new(directions: TaintDirections,
-                      initial_region: ty::Region<'tcx>)
-                      -> Self {
+    pub(super) fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self {
         let mut regions = FxHashSet();
         regions.insert(initial_region);
-        TaintSet { directions: directions, regions: regions }
+        TaintSet {
+            directions: directions,
+            regions: regions,
+        }
     }
 
-    pub(super) fn fixed_point(&mut self,
-                              tcx: TyCtxt<'_, '_, 'tcx>,
-                              undo_log: &[UndoLogEntry<'tcx>],
-                              verifys: &[Verify<'tcx>]) {
+    pub(super) fn fixed_point(
+        &mut self,
+        tcx: TyCtxt<'_, '_, 'tcx>,
+        undo_log: &[UndoLogEntry<'tcx>],
+        verifys: &[Verify<'tcx>],
+    ) {
         let mut prev_len = 0;
         while prev_len < self.len() {
-            debug!("tainted: prev_len = {:?} new_len = {:?}",
-                   prev_len, self.len());
+            debug!(
+                "tainted: prev_len = {:?} new_len = {:?}",
+                prev_len,
+                self.len()
+            );
 
             prev_len = self.len();
 
             for undo_entry in undo_log {
                 match undo_entry {
                     &AddConstraint(Constraint::VarSubVar(a, b)) => {
-                        self.add_edge(tcx.mk_region(ReVar(a)),
-                                      tcx.mk_region(ReVar(b)));
+                        self.add_edge(tcx.mk_region(ReVar(a)), tcx.mk_region(ReVar(b)));
                     }
                     &AddConstraint(Constraint::RegSubVar(a, b)) => {
                         self.add_edge(a, tcx.mk_region(ReVar(b)));
@@ -55,15 +60,13 @@ impl<'tcx> TaintSet<'tcx> {
                         self.add_edge(a, tcx.mk_region(ReVar(b)));
                     }
                     &AddVerify(i) => {
-                        verifys[i].bound.for_each_region(&mut |b| {
-                            self.add_edge(verifys[i].region, b);
-                        });
+                        span_bug!(
+                            verifys[i].origin.span(),
+                            "we never add verifications while doing higher-ranked things",
+                        )
                     }
-                    &Purged |
-                    &AddCombination(..) |
-                    &AddVar(..) |
-                    &OpenSnapshot |
-                    &CommitedSnapshot => {}
+                    &Purged | &AddCombination(..) | &AddVar(..) | &OpenSnapshot
+                    | &CommitedSnapshot => {}
                 }
             }
         }
@@ -77,9 +80,7 @@ impl<'tcx> TaintSet<'tcx> {
         self.regions.len()
     }
 
-    fn add_edge(&mut self,
-                source: ty::Region<'tcx>,
-                target: ty::Region<'tcx>) {
+    fn add_edge(&mut self, source: ty::Region<'tcx>, target: ty::Region<'tcx>) {
         if self.directions.incoming {
             if self.regions.contains(&target) {
                 self.regions.insert(source);
@@ -93,4 +94,3 @@ impl<'tcx> TaintSet<'tcx> {
         }
     }
 }
-