]> git.lizzy.rs Git - rust.git/commitdiff
Add type variable table to InferenceTableSnapshot
authorTianyi Song <42670338+tysg@users.noreply.github.com>
Sat, 5 Mar 2022 09:59:28 +0000 (17:59 +0800)
committerTianyi Song <42670338+tysg@users.noreply.github.com>
Sat, 5 Mar 2022 09:59:28 +0000 (17:59 +0800)
crates/hir_ty/src/infer/unify.rs

index 21b48b9d80256f8447dba1a3ef5f60e9c53342ba..8a6c34b493255698fe1e1d0bad10bb0b1a7357ad 100644 (file)
@@ -140,7 +140,8 @@ pub(crate) struct InferenceTable<'a> {
 
 pub(crate) struct InferenceTableSnapshot {
     var_table_snapshot: chalk_solve::infer::InferenceSnapshot<Interner>,
-    // FIXME: snapshot type_variable_table, pending_obligations?
+    // FIXME: snapshot pending_obligations?
+    type_variable_table_snapshot: Vec<TypeVariableData>,
 }
 
 impl<'a> InferenceTable<'a> {
@@ -356,12 +357,14 @@ pub(crate) fn resolve_ty_shallow(&mut self, ty: &Ty) -> Ty {
     }
 
     pub(crate) fn snapshot(&mut self) -> InferenceTableSnapshot {
-        let snapshot = self.var_unification_table.snapshot();
-        InferenceTableSnapshot { var_table_snapshot: snapshot }
+        let var_table_snapshot = self.var_unification_table.snapshot();
+        let type_variable_table_snapshot = self.type_variable_table.clone();
+        InferenceTableSnapshot { var_table_snapshot, type_variable_table_snapshot }
     }
 
     pub(crate) fn rollback_to(&mut self, snapshot: InferenceTableSnapshot) {
         self.var_unification_table.rollback_to(snapshot.var_table_snapshot);
+        self.type_variable_table = snapshot.type_variable_table_snapshot;
     }
 
     /// Checks an obligation without registering it. Useful mostly to check