about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>2020-02-25 15:39:01 +0100
committerMarkus Westerlind <markus.westerlind@distilnetworks.com>2020-05-05 11:24:36 +0200
commite6d7f1584d3107ae1de210619d05f3be0d023ae3 (patch)
treee90c1a7012557d75f2193fe81983e6c0d9a3212e
parentf45d852dcc399991a3bcd2cf58921735e560b22c (diff)
downloadrust-e6d7f1584d3107ae1de210619d05f3be0d023ae3.tar.gz
rust-e6d7f1584d3107ae1de210619d05f3be0d023ae3.zip
simplify
-rw-r--r--src/librustc_infer/infer/mod.rs11
-rw-r--r--src/librustc_infer/infer/type_variable.rs15
2 files changed, 6 insertions, 20 deletions
diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs
index e594bf450dd..a2cf772e86e 100644
--- a/src/librustc_infer/infer/mod.rs
+++ b/src/librustc_infer/infer/mod.rs
@@ -347,7 +347,7 @@ pub(crate) type UnificationTable<'a, 'tcx, T> =
     ut::UnificationTable<ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut Logs<'tcx>>>;
 
 struct RollbackView<'tcx, 'a> {
-    type_variables: type_variable::RollbackView<'tcx, 'a>,
+    type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
     const_unification_table: &'a mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
     int_unification_table: &'a mut ut::UnificationStorage<ty::IntVid>,
     float_unification_table: &'a mut ut::UnificationStorage<ty::FloatVid>,
@@ -420,7 +420,8 @@ impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
     }
 
     fn start_snapshot(&mut self) -> Self::Snapshot {
-        unreachable!()
+        self.num_open_snapshots += 1;
+        Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
     }
 
     fn rollback_to<R>(&mut self, values: impl FnOnce() -> R, snapshot: Self::Snapshot)
@@ -1056,10 +1057,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
 
         let mut inner = self.inner.borrow_mut();
 
-        inner.undo_log.num_open_snapshots += 1;
-        let undo_snapshot = Snapshot { undo_len: inner.undo_log.logs.len(), _marker: PhantomData };
         CombinedSnapshot {
-            undo_snapshot,
+            undo_snapshot: inner.undo_log.start_snapshot(),
             universe: self.universe(),
             was_in_snapshot: in_snapshot,
             // Borrow tables "in progress" (i.e., during typeck)
@@ -1089,7 +1088,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         } = &mut *self.inner.borrow_mut();
         undo_log.rollback_to(
             || RollbackView {
-                type_variables: type_variable::RollbackView::from(type_variables),
+                type_variables,
                 const_unification_table,
                 int_unification_table,
                 float_unification_table,
diff --git a/src/librustc_infer/infer/type_variable.rs b/src/librustc_infer/infer/type_variable.rs
index 3858c50b92c..26673cff1e8 100644
--- a/src/librustc_infer/infer/type_variable.rs
+++ b/src/librustc_infer/infer/type_variable.rs
@@ -43,20 +43,7 @@ impl<'tcx> From<Instantiate> for UndoLog<'tcx> {
     }
 }
 
-pub(crate) struct RollbackView<'tcx, 'a> {
-    pub(crate) eq_relations: &'a mut ut::UnificationStorage<TyVidEqKey<'tcx>>,
-    pub(crate) sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
-    pub(crate) values: &'a mut Vec<TypeVariableData>,
-}
-
-impl<'tcx, 'a> From<&'a mut TypeVariableStorage<'tcx>> for RollbackView<'tcx, 'a> {
-    fn from(l: &'a mut TypeVariableStorage<'tcx>) -> Self {
-        let TypeVariableStorage { eq_relations, sub_relations, values } = l;
-        Self { eq_relations, sub_relations, values }
-    }
-}
-
-impl<'tcx> Rollback<UndoLog<'tcx>> for RollbackView<'tcx, '_> {
+impl<'tcx> Rollback<UndoLog<'tcx>> for TypeVariableStorage<'tcx> {
     fn reverse(&mut self, undo: UndoLog<'tcx>) {
         match undo {
             UndoLog::EqRelation(undo) => self.eq_relations.reverse(undo),