]> git.lizzy.rs Git - rust.git/commitdiff
remove `pop_placeholders`
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Sat, 6 Jun 2020 14:41:48 +0000 (16:41 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Sat, 20 Jun 2020 08:58:05 +0000 (10:58 +0200)
src/librustc_infer/infer/higher_ranked/mod.rs
src/librustc_infer/infer/region_constraints/leak_check.rs
src/librustc_infer/infer/region_constraints/mod.rs
src/librustc_infer/infer/undo_log.rs

index ef18918c1772f7ddfccdda79da9c630d2abd7a4f..0499dc9ed2232ee8f2f39015a672fa00d6973cc0 100644 (file)
@@ -63,14 +63,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// placeholder region. This is the first step of checking subtyping
     /// when higher-ranked things are involved.
     ///
-    /// **Important:** you must call this function from within a snapshot.
-    /// Moreover, before committing the snapshot, you must eventually call
-    /// either `plug_leaks` or `pop_placeholders` to remove the placeholder
-    /// regions. If you rollback the snapshot (or are using a probe), then
-    /// the pop occurs as part of the rollback, so an explicit call is not
-    /// needed (but is also permitted).
-    ///
-    /// For more information about how placeholders and HRTBs work, see
+    /// **Important:** You have to be careful to not leak these placeholders,
+    /// for more information about how placeholders and HRTBs work, see
     /// the [rustc dev guide].
     ///
     /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
index 473550d5433df3c14e8a4ad95c9ec75cde957ede..91c39a0e78ffb732ef8340a2cc8b4512b6983013 100644 (file)
@@ -128,7 +128,7 @@ fn fixed_point<'a>(
                         verifys[i].origin.span(),
                         "we never add verifications while doing higher-ranked things",
                     ),
-                    &Purged | &AddCombination(..) | &AddVar(..) => {}
+                    &AddCombination(..) | &AddVar(..) => {}
                 }
             }
         }
index 42a6a6ff40afd9986dd96eadedbc8f2b9cd61ad5..2902c41a6bcae779c85d64979c53082c3a6b57d8 100644 (file)
@@ -289,14 +289,6 @@ pub(crate) enum UndoLog<'tcx> {
 
     /// We added a GLB/LUB "combination variable".
     AddCombination(CombineMapType, TwoRegions<'tcx>),
-
-    /// During freshening, we sometimes purge entries from the undo
-    /// log in a kind of minisnapshot (unlike other snapshots, this
-    /// purging actually takes place *on success*). In that case, we
-    /// replace the corresponding entry with `Noop` so as to avoid the
-    /// need to do a bunch of swapping. (We can't use `swap_remove` as
-    /// the order of the vector is important.)
-    Purged,
 }
 
 #[derive(Copy, Clone, PartialEq)]
@@ -357,9 +349,6 @@ pub(crate) fn with_log<'a>(
 
     fn rollback_undo_entry(&mut self, undo_entry: UndoLog<'tcx>) {
         match undo_entry {
-            Purged => {
-                // nothing to do here
-            }
             AddVar(vid) => {
                 self.var_infos.pop().unwrap();
                 assert_eq!(self.var_infos.len(), vid.index() as usize);
@@ -488,62 +477,6 @@ pub fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin {
         self.var_infos[vid].origin
     }
 
-    /// Removes all the edges to/from the placeholder regions that are
-    /// in `placeholders`. This is used after a higher-ranked operation
-    /// completes to remove all trace of the placeholder regions
-    /// created in that time.
-    pub fn pop_placeholders(&mut self, placeholders: &FxHashSet<ty::Region<'tcx>>) {
-        debug!("pop_placeholders(placeholders={:?})", placeholders);
-
-        assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
-
-        let constraints_to_kill: Vec<usize> = self
-            .undo_log
-            .iter()
-            .enumerate()
-            .rev()
-            .filter(|&(_, undo_entry)| match undo_entry {
-                super::UndoLog::RegionConstraintCollector(undo_entry) => {
-                    kill_constraint(placeholders, undo_entry)
-                }
-                _ => false,
-            })
-            .map(|(index, _)| index)
-            .collect();
-
-        for index in constraints_to_kill {
-            let undo_entry = match &mut self.undo_log[index] {
-                super::UndoLog::RegionConstraintCollector(undo_entry) => {
-                    mem::replace(undo_entry, Purged)
-                }
-                _ => unreachable!(),
-            };
-            self.rollback_undo_entry(undo_entry);
-        }
-
-        return;
-
-        fn kill_constraint<'tcx>(
-            placeholders: &FxHashSet<ty::Region<'tcx>>,
-            undo_entry: &UndoLog<'tcx>,
-        ) -> bool {
-            match undo_entry {
-                &AddConstraint(Constraint::VarSubVar(..)) => false,
-                &AddConstraint(Constraint::RegSubVar(a, _)) => placeholders.contains(&a),
-                &AddConstraint(Constraint::VarSubReg(_, b)) => placeholders.contains(&b),
-                &AddConstraint(Constraint::RegSubReg(a, b)) => {
-                    placeholders.contains(&a) || placeholders.contains(&b)
-                }
-                &AddGiven(..) => false,
-                &AddVerify(_) => false,
-                &AddCombination(_, ref two_regions) => {
-                    placeholders.contains(&two_regions.a) || placeholders.contains(&two_regions.b)
-                }
-                &AddVar(..) | &Purged => false,
-            }
-        }
-    }
-
     fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
         // cannot add constraints once regions are resolved
         debug!("RegionConstraintCollector: add_constraint({:?})", constraint);
index e7f1869955d20cd84944370a6908fc48326f8d64..2cfd6bb904c410558a310f727d1914cc45922e34 100644 (file)
@@ -198,10 +198,6 @@ fn assert_open_snapshot(&self, snapshot: &Snapshot<'tcx>) {
         assert!(self.logs.len() >= snapshot.undo_len);
         assert!(self.num_open_snapshots > 0);
     }
-
-    pub(crate) fn iter(&self) -> std::slice::Iter<'_, UndoLog<'tcx>> {
-        self.logs.iter()
-    }
 }
 
 impl<'tcx> std::ops::Index<usize> for InferCtxtUndoLogs<'tcx> {