Skip to content

Commit e6d7f15

Browse files
author
Markus Westerlind
committed
simplify
1 parent f45d852 commit e6d7f15

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/librustc_infer/infer/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub(crate) type UnificationTable<'a, 'tcx, T> =
347347
ut::UnificationTable<ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut Logs<'tcx>>>;
348348

349349
struct RollbackView<'tcx, 'a> {
350-
type_variables: type_variable::RollbackView<'tcx, 'a>,
350+
type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
351351
const_unification_table: &'a mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
352352
int_unification_table: &'a mut ut::UnificationStorage<ty::IntVid>,
353353
float_unification_table: &'a mut ut::UnificationStorage<ty::FloatVid>,
@@ -420,7 +420,8 @@ impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
420420
}
421421

422422
fn start_snapshot(&mut self) -> Self::Snapshot {
423-
unreachable!()
423+
self.num_open_snapshots += 1;
424+
Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
424425
}
425426

426427
fn rollback_to<R>(&mut self, values: impl FnOnce() -> R, snapshot: Self::Snapshot)
@@ -1056,10 +1057,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10561057

10571058
let mut inner = self.inner.borrow_mut();
10581059

1059-
inner.undo_log.num_open_snapshots += 1;
1060-
let undo_snapshot = Snapshot { undo_len: inner.undo_log.logs.len(), _marker: PhantomData };
10611060
CombinedSnapshot {
1062-
undo_snapshot,
1061+
undo_snapshot: inner.undo_log.start_snapshot(),
10631062
universe: self.universe(),
10641063
was_in_snapshot: in_snapshot,
10651064
// Borrow tables "in progress" (i.e., during typeck)
@@ -1089,7 +1088,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10891088
} = &mut *self.inner.borrow_mut();
10901089
undo_log.rollback_to(
10911090
|| RollbackView {
1092-
type_variables: type_variable::RollbackView::from(type_variables),
1091+
type_variables,
10931092
const_unification_table,
10941093
int_unification_table,
10951094
float_unification_table,

src/librustc_infer/infer/type_variable.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,7 @@ impl<'tcx> From<Instantiate> for UndoLog<'tcx> {
4343
}
4444
}
4545

46-
pub(crate) struct RollbackView<'tcx, 'a> {
47-
pub(crate) eq_relations: &'a mut ut::UnificationStorage<TyVidEqKey<'tcx>>,
48-
pub(crate) sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
49-
pub(crate) values: &'a mut Vec<TypeVariableData>,
50-
}
51-
52-
impl<'tcx, 'a> From<&'a mut TypeVariableStorage<'tcx>> for RollbackView<'tcx, 'a> {
53-
fn from(l: &'a mut TypeVariableStorage<'tcx>) -> Self {
54-
let TypeVariableStorage { eq_relations, sub_relations, values } = l;
55-
Self { eq_relations, sub_relations, values }
56-
}
57-
}
58-
59-
impl<'tcx> Rollback<UndoLog<'tcx>> for RollbackView<'tcx, '_> {
46+
impl<'tcx> Rollback<UndoLog<'tcx>> for TypeVariableStorage<'tcx> {
6047
fn reverse(&mut self, undo: UndoLog<'tcx>) {
6148
match undo {
6249
UndoLog::EqRelation(undo) => self.eq_relations.reverse(undo),

0 commit comments

Comments
 (0)