]> git.lizzy.rs Git - rust.git/commitdiff
refactor: Rename Logs to InferCtxtUndoLogs
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>
Tue, 25 Feb 2020 15:41:29 +0000 (16:41 +0100)
committerMarkus Westerlind <markus.westerlind@distilnetworks.com>
Tue, 5 May 2020 09:24:36 +0000 (11:24 +0200)
Cargo.lock
src/librustc_infer/infer/mod.rs
src/librustc_infer/infer/region_constraints/mod.rs
src/librustc_infer/infer/type_variable.rs
src/librustc_infer/traits/project.rs

index c5e25b0a2c7227be8f44e3525731d3d8fedc0938..45c298ea8bfcde783128aa4f746b20365364824e 100644 (file)
@@ -485,7 +485,7 @@ version = "0.0.212"
 dependencies = [
  "cargo_metadata 0.9.1",
  "if_chain",
- "itertools 0.8.0",
+ "itertools 0.9.0",
  "lazy_static 1.4.0",
  "pulldown-cmark 0.7.1",
  "quine-mc_cluskey",
@@ -1629,6 +1629,15 @@ dependencies = [
  "either",
 ]
 
+[[package]]
+name = "itertools"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
+dependencies = [
+ "either",
+]
+
 [[package]]
 name = "itoa"
 version = "0.4.4"
@@ -2179,6 +2188,7 @@ dependencies = [
  "rustc-workspace-hack",
  "rustc_version",
  "serde",
+ "serde_json",
  "shell-escape",
  "vergen",
 ]
index a2cf772e86ec1f925810bd5b7770cb7030fbcd44..90bc1ddc3eb6318833e5052b0f1ab0cf6d4a1892 100644 (file)
@@ -147,7 +147,6 @@ pub struct InferCtxtInner<'tcx> {
     /// that might instantiate a general type variable have an order,
     /// represented by its upper and lower bounds.
     type_variables: type_variable::TypeVariableStorage<'tcx>,
-    undo_log: Logs<'tcx>,
 
     /// Map from const parameter variable to the kind of const it represents.
     const_unification_table: ut::UnificationStorage<ty::ConstVid<'tcx>>,
@@ -197,6 +196,8 @@ pub struct InferCtxtInner<'tcx> {
     /// obligations within. This is expected to be done 'late enough'
     /// that all type inference variables have been bound and so forth.
     region_obligations: Vec<(hir::HirId, RegionObligation<'tcx>)>,
+
+    undo_log: InferCtxtUndoLogs<'tcx>,
 }
 
 impl<'tcx> InferCtxtInner<'tcx> {
@@ -204,7 +205,7 @@ fn new() -> InferCtxtInner<'tcx> {
         InferCtxtInner {
             projection_cache: Default::default(),
             type_variables: type_variable::TypeVariableStorage::new(),
-            undo_log: Logs::default(),
+            undo_log: InferCtxtUndoLogs::default(),
             const_unification_table: ut::UnificationStorage::new(),
             int_unification_table: ut::UnificationStorage::new(),
             float_unification_table: ut::UnificationStorage::new(),
@@ -228,7 +229,11 @@ fn type_variables(&mut self) -> type_variable::TypeVariableTable<'tcx, '_> {
     fn int_unification_table(
         &mut self,
     ) -> ut::UnificationTable<
-        ut::InPlace<ty::IntVid, &mut ut::UnificationStorage<ty::IntVid>, &mut Logs<'tcx>>,
+        ut::InPlace<
+            ty::IntVid,
+            &mut ut::UnificationStorage<ty::IntVid>,
+            &mut InferCtxtUndoLogs<'tcx>,
+        >,
     > {
         ut::UnificationTable::with_log(&mut self.int_unification_table, &mut self.undo_log)
     }
@@ -236,7 +241,11 @@ fn int_unification_table(
     fn float_unification_table(
         &mut self,
     ) -> ut::UnificationTable<
-        ut::InPlace<ty::FloatVid, &mut ut::UnificationStorage<ty::FloatVid>, &mut Logs<'tcx>>,
+        ut::InPlace<
+            ty::FloatVid,
+            &mut ut::UnificationStorage<ty::FloatVid>,
+            &mut InferCtxtUndoLogs<'tcx>,
+        >,
     > {
         ut::UnificationTable::with_log(&mut self.float_unification_table, &mut self.undo_log)
     }
@@ -247,7 +256,7 @@ fn const_unification_table(
         ut::InPlace<
             ty::ConstVid<'tcx>,
             &mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
-            &mut Logs<'tcx>,
+            &mut InferCtxtUndoLogs<'tcx>,
         >,
     > {
         ut::UnificationTable::with_log(&mut self.const_unification_table, &mut self.undo_log)
@@ -343,8 +352,9 @@ fn from(l: traits::UndoLog<'tcx>) -> Self {
     }
 }
 
-pub(crate) type UnificationTable<'a, 'tcx, T> =
-    ut::UnificationTable<ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut Logs<'tcx>>>;
+pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
+    ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
+>;
 
 struct RollbackView<'tcx, 'a> {
     type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
@@ -375,18 +385,18 @@ fn reverse(&mut self, undo: UndoLog<'tcx>) {
     }
 }
 
-pub(crate) struct Logs<'tcx> {
+pub(crate) struct InferCtxtUndoLogs<'tcx> {
     logs: Vec<UndoLog<'tcx>>,
     num_open_snapshots: usize,
 }
 
-impl Default for Logs<'_> {
+impl Default for InferCtxtUndoLogs<'_> {
     fn default() -> Self {
         Self { logs: Default::default(), num_open_snapshots: Default::default() }
     }
 }
 
-impl<'tcx, T> UndoLogs<T> for Logs<'tcx>
+impl<'tcx, T> UndoLogs<T> for InferCtxtUndoLogs<'tcx>
 where
     UndoLog<'tcx>: From<T>,
 {
@@ -413,7 +423,7 @@ fn extend<J>(&mut self, undos: J)
     }
 }
 
-impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
+impl<'tcx> Snapshots<UndoLog<'tcx>> for InferCtxtUndoLogs<'tcx> {
     type Snapshot = Snapshot<'tcx>;
     fn actions_since_snapshot(&self, snapshot: &Self::Snapshot) -> &[UndoLog<'tcx>] {
         &self.logs[snapshot.undo_len..]
@@ -464,7 +474,7 @@ fn commit(&mut self, snapshot: Self::Snapshot) {
     }
 }
 
-impl<'tcx> Logs<'tcx> {
+impl<'tcx> InferCtxtUndoLogs<'tcx> {
     pub(crate) fn region_constraints(
         &self,
         after: usize,
index 7b660ce436559c5e224927da4448b6d0015d0fbe..5f6f82ddaf98021f7ac43ac19f85c0748cb93b4e 100644 (file)
@@ -4,7 +4,9 @@
 use self::UndoLog::*;
 
 use super::unify_key;
-use super::{Logs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin};
+use super::{
+    InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin,
+};
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::sync::Lrc;
@@ -61,7 +63,7 @@ pub struct RegionConstraintStorage<'tcx> {
 
 pub struct RegionConstraintCollector<'tcx, 'a> {
     storage: &'a mut RegionConstraintStorage<'tcx>,
-    undo_log: &'a mut Logs<'tcx>,
+    undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
 }
 
 impl std::ops::Deref for RegionConstraintCollector<'tcx, '_> {
@@ -346,7 +348,7 @@ pub fn new() -> Self {
 
     pub(crate) fn with_log<'a>(
         &'a mut self,
-        undo_log: &'a mut Logs<'tcx>,
+        undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
     ) -> RegionConstraintCollector<'tcx, 'a> {
         RegionConstraintCollector { storage: self, undo_log }
     }
index 26673cff1e8f63456a424a0e977d69af5f9276f8..69afb605b344fb7336ed36f141b30385cfeca4a1 100644 (file)
@@ -3,7 +3,7 @@
 use rustc_span::symbol::Symbol;
 use rustc_span::Span;
 
-use crate::infer::Logs;
+use crate::infer::InferCtxtUndoLogs;
 
 use rustc_data_structures::snapshot_vec as sv;
 use rustc_data_structures::unify as ut;
@@ -88,7 +88,7 @@ pub struct TypeVariableTable<'tcx, 'a> {
 
     sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
 
-    undo_log: &'a mut Logs<'tcx>,
+    undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
 }
 
 #[derive(Copy, Clone, Debug)]
@@ -167,7 +167,7 @@ pub fn new() -> TypeVariableStorage<'tcx> {
 
     pub(crate) fn with_log<'a>(
         &'a mut self,
-        undo_log: &'a mut Logs<'tcx>,
+        undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
     ) -> TypeVariableTable<'tcx, 'a> {
         let TypeVariableStorage { values, eq_relations, sub_relations } = self;
         TypeVariableTable { values, eq_relations, sub_relations, undo_log }
@@ -327,7 +327,9 @@ pub fn snapshot(&mut self) -> Snapshot<'tcx> {
         Snapshot { value_count: self.eq_relations().len() as u32, _marker: PhantomData }
     }
 
-    fn values(&mut self) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut Logs<'tcx>> {
+    fn values(
+        &mut self,
+    ) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut InferCtxtUndoLogs<'tcx>> {
         sv::SnapshotVec::with_log(self.values, self.undo_log)
     }
 
index 0c51dafef6fb69b3fdb860bb7af40874da35604b..8cf3987b902ee5cf9e913c87bdbf47e875b0f17f 100644 (file)
@@ -2,7 +2,7 @@
 
 use super::PredicateObligation;
 
-use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
+use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
 use rustc_middle::ty::fold::TypeFoldable;
 use rustc_middle::ty::{self, Ty};
 
@@ -63,7 +63,7 @@ pub fn with<U>(self, value: U) -> Normalized<'tcx, U> {
 // reduce the amount of duplication. Let's see what we get with the Chalk reforms.
 pub struct ProjectionCache<'tcx, 'a> {
     map: &'a mut SnapshotMapStorage<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>,
-    undo_log: &'a mut Logs<'tcx>,
+    undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
 }
 
 #[derive(Default)]
@@ -93,7 +93,7 @@ pub enum ProjectionCacheEntry<'tcx> {
 impl<'tcx> ProjectionCacheStorage<'tcx> {
     pub(crate) fn with_log<'a>(
         &'a mut self,
-        undo_log: &'a mut Logs<'tcx>,
+        undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
     ) -> ProjectionCache<'tcx, 'a> {
         ProjectionCache { map: &mut self.map, undo_log }
     }
@@ -102,7 +102,12 @@ pub(crate) fn with_log<'a>(
 impl<'tcx> ProjectionCache<'tcx, '_> {
     fn map(
         &mut self,
-    ) -> SnapshotMapRef<'_, ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>, Logs<'tcx>> {
+    ) -> SnapshotMapRef<
+        '_,
+        ProjectionCacheKey<'tcx>,
+        ProjectionCacheEntry<'tcx>,
+        InferCtxtUndoLogs<'tcx>,
+    > {
         self.map.with_log(self.undo_log)
     }