@@ -414,12 +414,18 @@ impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
414
414
unreachable ! ( )
415
415
}
416
416
417
- fn rollback_to ( & mut self , values : & mut impl Rollback < UndoLog < ' tcx > > , snapshot : Self :: Snapshot ) {
417
+ fn rollback_to < R > ( & mut self , values : impl FnOnce ( ) -> R , snapshot : Self :: Snapshot )
418
+ where
419
+ R : Rollback < UndoLog < ' tcx > > ,
420
+ {
418
421
debug ! ( "rollback_to({})" , snapshot. undo_len) ;
419
422
self . assert_open_snapshot ( & snapshot) ;
420
423
421
- while self . logs . len ( ) > snapshot. undo_len {
422
- values. reverse ( self . logs . pop ( ) . unwrap ( ) ) ;
424
+ if self . logs . len ( ) > snapshot. undo_len {
425
+ let mut values = values ( ) ;
426
+ while self . logs . len ( ) > snapshot. undo_len {
427
+ values. reverse ( self . logs . pop ( ) . unwrap ( ) ) ;
428
+ }
423
429
}
424
430
425
431
if self . num_open_snapshots == 1 {
@@ -1072,19 +1078,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1072
1078
self . universe . set ( universe) ;
1073
1079
self . skip_leak_check . set ( was_skip_leak_check) ;
1074
1080
1075
- let mut inner = self . inner . borrow_mut ( ) ;
1076
- let inner = & mut * inner;
1077
1081
let InferCtxtInner {
1078
1082
type_variables,
1079
1083
const_unification_table,
1080
1084
int_unification_table,
1081
1085
float_unification_table,
1082
1086
region_constraints,
1083
1087
projection_cache,
1088
+ region_obligations,
1089
+ undo_log,
1084
1090
..
1085
- } = inner;
1086
- inner . undo_log . rollback_to (
1087
- & mut RollbackView {
1091
+ } = & mut * self . inner . borrow_mut ( ) ;
1092
+ undo_log. rollback_to (
1093
+ || RollbackView {
1088
1094
type_variables : type_variable:: RollbackView :: from ( type_variables) ,
1089
1095
const_unification_table,
1090
1096
int_unification_table,
@@ -1094,7 +1100,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1094
1100
} ,
1095
1101
undo_snapshot,
1096
1102
) ;
1097
- inner . region_obligations . truncate ( region_obligations_snapshot) ;
1103
+ region_obligations. truncate ( region_obligations_snapshot) ;
1098
1104
}
1099
1105
1100
1106
fn commit_from ( & self , snapshot : CombinedSnapshot < ' a , ' tcx > ) {
0 commit comments