about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>2020-02-26 10:43:24 +0100
committerMarkus Westerlind <markus.westerlind@distilnetworks.com>2020-05-05 11:25:12 +0200
commit729d16f0104887a0b37b8e5bb9f0f495e4efdd10 (patch)
treebd6c8da061ee2934a6ae9ceb17ba23597aa4bce0 /src
parent6e06535468932c2dd9e5731d40fe94fe913bf2e4 (diff)
downloadrust-729d16f0104887a0b37b8e5bb9f0f495e4efdd10.tar.gz
rust-729d16f0104887a0b37b8e5bb9f0f495e4efdd10.zip
Prevent modifications without an undo log
Diffstat (limited to 'src')
-rw-r--r--src/librustc_infer/infer/mod.rs12
-rw-r--r--src/librustc_infer/infer/region_constraints/mod.rs2
-rw-r--r--src/librustc_infer/infer/type_variable.rs30
-rw-r--r--src/librustc_infer/infer/undo_log.rs6
4 files changed, 25 insertions, 25 deletions
diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs
index 7bf13c90bf7..93b6a0220bf 100644
--- a/src/librustc_infer/infer/mod.rs
+++ b/src/librustc_infer/infer/mod.rs
@@ -155,13 +155,13 @@ pub struct InferCtxtInner<'tcx> {
     type_variables: type_variable::TypeVariableStorage<'tcx>,
 
     /// Map from const parameter variable to the kind of const it represents.
-    const_unification_table: ut::UnificationStorage<ty::ConstVid<'tcx>>,
+    const_unification_table: ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
 
     /// Map from integral variable to the kind of integer it represents.
-    int_unification_table: ut::UnificationStorage<ty::IntVid>,
+    int_unification_table: ut::UnificationTableStorage<ty::IntVid>,
 
     /// Map from floating variable to the kind of float it represents.
-    float_unification_table: ut::UnificationStorage<ty::FloatVid>,
+    float_unification_table: ut::UnificationTableStorage<ty::FloatVid>,
 
     /// Tracks the set of region variables and the constraints between them.
     /// This is initially `Some(_)` but when
@@ -212,9 +212,9 @@ impl<'tcx> InferCtxtInner<'tcx> {
             projection_cache: Default::default(),
             type_variables: type_variable::TypeVariableStorage::new(),
             undo_log: InferCtxtUndoLogs::default(),
-            const_unification_table: ut::UnificationStorage::new(),
-            int_unification_table: ut::UnificationStorage::new(),
-            float_unification_table: ut::UnificationStorage::new(),
+            const_unification_table: ut::UnificationTableStorage::new(),
+            int_unification_table: ut::UnificationTableStorage::new(),
+            float_unification_table: ut::UnificationTableStorage::new(),
             region_constraints: Some(RegionConstraintStorage::new()),
             region_obligations: vec![],
         }
diff --git a/src/librustc_infer/infer/region_constraints/mod.rs b/src/librustc_infer/infer/region_constraints/mod.rs
index ead2494756c..74d31e744fc 100644
--- a/src/librustc_infer/infer/region_constraints/mod.rs
+++ b/src/librustc_infer/infer/region_constraints/mod.rs
@@ -54,7 +54,7 @@ pub struct RegionConstraintStorage<'tcx> {
     /// is iterating to a fixed point, because otherwise we sometimes
     /// would wind up with a fresh stream of region variables that
     /// have been equated but appear distinct.
-    pub(super) unification_table: ut::UnificationStorage<ty::RegionVid>,
+    pub(super) unification_table: ut::UnificationTableStorage<ty::RegionVid>,
 
     /// a flag set to true when we perform any unifications; this is used
     /// to micro-optimize `take_and_reset_data`
diff --git a/src/librustc_infer/infer/type_variable.rs b/src/librustc_infer/infer/type_variable.rs
index 69afb605b34..78803eea3bc 100644
--- a/src/librustc_infer/infer/type_variable.rs
+++ b/src/librustc_infer/infer/type_variable.rs
@@ -54,12 +54,12 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for TypeVariableStorage<'tcx> {
 }
 
 pub struct TypeVariableStorage<'tcx> {
-    values: Vec<TypeVariableData>,
+    values: sv::SnapshotVecStorage<Delegate>,
 
     /// Two variables are unified in `eq_relations` when we have a
     /// constraint `?X == ?Y`. This table also stores, for each key,
     /// the known value.
-    eq_relations: ut::UnificationStorage<TyVidEqKey<'tcx>>,
+    eq_relations: ut::UnificationTableStorage<TyVidEqKey<'tcx>>,
 
     /// Two variables are unified in `sub_relations` when we have a
     /// constraint `?X <: ?Y` *or* a constraint `?Y <: ?X`. This second
@@ -78,15 +78,15 @@ pub struct TypeVariableStorage<'tcx> {
     /// This is reasonable because, in Rust, subtypes have the same
     /// "skeleton" and hence there is no possible type such that
     /// (e.g.)  `Box<?3> <: ?3` for any `?3`.
-    sub_relations: ut::UnificationStorage<ty::TyVid>,
+    sub_relations: ut::UnificationTableStorage<ty::TyVid>,
 }
 
 pub struct TypeVariableTable<'tcx, 'a> {
-    values: &'a mut Vec<TypeVariableData>,
+    values: &'a mut sv::SnapshotVecStorage<Delegate>,
 
-    eq_relations: &'a mut ut::UnificationStorage<TyVidEqKey<'tcx>>,
+    eq_relations: &'a mut ut::UnificationTableStorage<TyVidEqKey<'tcx>>,
 
-    sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
+    sub_relations: &'a mut ut::UnificationTableStorage<ty::TyVid>,
 
     undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
 }
@@ -159,9 +159,9 @@ pub(crate) struct Delegate;
 impl<'tcx> TypeVariableStorage<'tcx> {
     pub fn new() -> TypeVariableStorage<'tcx> {
         TypeVariableStorage {
-            values: Vec::new(),
-            eq_relations: ut::UnificationStorage::new(),
-            sub_relations: ut::UnificationStorage::new(),
+            values: sv::SnapshotVecStorage::new(),
+            eq_relations: ut::UnificationTableStorage::new(),
+            sub_relations: ut::UnificationTableStorage::new(),
         }
     }
 
@@ -180,7 +180,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
     /// Note that this function does not return care whether
     /// `vid` has been unified with something else or not.
     pub fn var_diverges(&self, vid: ty::TyVid) -> bool {
-        self.values.get(vid.index as usize).unwrap().diverging
+        self.values.get(vid.index as usize).diverging
     }
 
     /// Returns the origin that was given when `vid` was created.
@@ -188,7 +188,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
     /// Note that this function does not return care whether
     /// `vid` has been unified with something else or not.
     pub fn var_origin(&self, vid: ty::TyVid) -> &TypeVariableOrigin {
-        &self.values.get(vid.index as usize).unwrap().origin
+        &self.values.get(vid.index as usize).origin
     }
 
     /// Records that `a == b`, depending on `dir`.
@@ -330,15 +330,15 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
     fn values(
         &mut self,
     ) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut InferCtxtUndoLogs<'tcx>> {
-        sv::SnapshotVec::with_log(self.values, self.undo_log)
+        self.values.with_log(self.undo_log)
     }
 
     fn eq_relations(&mut self) -> super::UnificationTable<'_, 'tcx, TyVidEqKey<'tcx>> {
-        ut::UnificationTable::with_log(self.eq_relations, self.undo_log)
+        self.eq_relations.with_log(self.undo_log)
     }
 
     fn sub_relations(&mut self) -> super::UnificationTable<'_, 'tcx, ty::TyVid> {
-        ut::UnificationTable::with_log(self.sub_relations, self.undo_log)
+        self.sub_relations.with_log(self.undo_log)
     }
 
     /// Returns a range of the type variables created during the snapshot.
@@ -351,7 +351,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
         (
             range.start..range.end,
             (range.start.index..range.end.index)
-                .map(|index| self.values.get(index as usize).unwrap().origin)
+                .map(|index| self.values.get(index as usize).origin)
                 .collect(),
         )
     }
diff --git a/src/librustc_infer/infer/undo_log.rs b/src/librustc_infer/infer/undo_log.rs
index beb71e9e2e8..a63f1b030bb 100644
--- a/src/librustc_infer/infer/undo_log.rs
+++ b/src/librustc_infer/infer/undo_log.rs
@@ -98,9 +98,9 @@ impl<'tcx> From<traits::UndoLog<'tcx>> for UndoLog<'tcx> {
 
 pub(super) struct RollbackView<'tcx, 'a> {
     pub(super) type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
-    pub(super) const_unification_table: &'a mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
-    pub(super) int_unification_table: &'a mut ut::UnificationStorage<ty::IntVid>,
-    pub(super) float_unification_table: &'a mut ut::UnificationStorage<ty::FloatVid>,
+    pub(super) const_unification_table: &'a mut ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
+    pub(super) int_unification_table: &'a mut ut::UnificationTableStorage<ty::IntVid>,
+    pub(super) float_unification_table: &'a mut ut::UnificationTableStorage<ty::FloatVid>,
     pub(super) region_constraints: &'a mut RegionConstraintStorage<'tcx>,
     pub(super) projection_cache: &'a mut traits::ProjectionCacheStorage<'tcx>,
     pub(super) region_obligations: &'a mut Vec<(hir::HirId, RegionObligation<'tcx>)>,