@@ -196,7 +196,7 @@ pub struct InferCtxtInner<'tcx> {
196
196
/// for each body-id in this map, which will process the
197
197
/// obligations within. This is expected to be done 'late enough'
198
198
/// that all type inference variables have been bound and so forth.
199
- pub region_obligations : Vec < ( hir:: HirId , RegionObligation < ' tcx > ) > ,
199
+ region_obligations : Vec < ( hir:: HirId , RegionObligation < ' tcx > ) > ,
200
200
}
201
201
202
202
impl < ' tcx > InferCtxtInner < ' tcx > {
@@ -213,6 +213,10 @@ impl<'tcx> InferCtxtInner<'tcx> {
213
213
}
214
214
}
215
215
216
+ pub fn region_obligations ( & self ) -> & [ ( hir:: HirId , RegionObligation < ' tcx > ) ] {
217
+ & self . region_obligations
218
+ }
219
+
216
220
pub ( crate ) fn projection_cache ( & mut self ) -> traits:: ProjectionCache < ' tcx , ' _ > {
217
221
self . projection_cache . with_log ( & mut self . undo_log )
218
222
}
@@ -270,6 +274,7 @@ pub(crate) enum UndoLog<'tcx> {
270
274
RegionConstraintCollector ( region_constraints:: UndoLog < ' tcx > ) ,
271
275
RegionUnificationTable ( sv:: UndoLog < ut:: Delegate < ty:: RegionVid > > ) ,
272
276
ProjectionCache ( traits:: UndoLog < ' tcx > ) ,
277
+ PushRegionObligation ,
273
278
}
274
279
275
280
impl < ' tcx > From < region_constraints:: UndoLog < ' tcx > > for UndoLog < ' tcx > {
@@ -348,6 +353,7 @@ struct RollbackView<'tcx, 'a> {
348
353
float_unification_table : & ' a mut ut:: UnificationStorage < ty:: FloatVid > ,
349
354
region_constraints : & ' a mut RegionConstraintStorage < ' tcx > ,
350
355
projection_cache : & ' a mut traits:: ProjectionCacheStorage < ' tcx > ,
356
+ region_obligations : & ' a mut Vec < ( hir:: HirId , RegionObligation < ' tcx > ) > ,
351
357
}
352
358
353
359
impl < ' tcx > Rollback < UndoLog < ' tcx > > for RollbackView < ' tcx , ' _ > {
@@ -362,6 +368,9 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for RollbackView<'tcx, '_> {
362
368
self . region_constraints . unification_table . reverse ( undo)
363
369
}
364
370
UndoLog :: ProjectionCache ( undo) => self . projection_cache . reverse ( undo) ,
371
+ UndoLog :: PushRegionObligation => {
372
+ self . region_obligations . pop ( ) ;
373
+ }
365
374
}
366
375
}
367
376
}
@@ -915,7 +924,6 @@ pub struct FullSnapshot<'a, 'tcx> {
915
924
#[ must_use = "once you start a snapshot, you should always consume it" ]
916
925
pub struct CombinedSnapshot < ' a , ' tcx > {
917
926
undo_snapshot : Snapshot < ' tcx > ,
918
- region_obligations_snapshot : usize ,
919
927
universe : ty:: UniverseIndex ,
920
928
was_in_snapshot : bool ,
921
929
_in_progress_tables : Option < Ref < ' a , ty:: TypeckTables < ' tcx > > > ,
@@ -1052,7 +1060,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1052
1060
let undo_snapshot = Snapshot { undo_len : inner. undo_log . logs . len ( ) , _marker : PhantomData } ;
1053
1061
CombinedSnapshot {
1054
1062
undo_snapshot,
1055
- region_obligations_snapshot : inner. region_obligations . len ( ) ,
1056
1063
universe : self . universe ( ) ,
1057
1064
was_in_snapshot : in_snapshot,
1058
1065
// Borrow tables "in progress" (i.e., during typeck)
@@ -1063,13 +1070,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1063
1070
1064
1071
fn rollback_to ( & self , cause : & str , snapshot : CombinedSnapshot < ' a , ' tcx > ) {
1065
1072
debug ! ( "rollback_to(cause={})" , cause) ;
1066
- let CombinedSnapshot {
1067
- undo_snapshot,
1068
- region_obligations_snapshot,
1069
- universe,
1070
- was_in_snapshot,
1071
- _in_progress_tables,
1072
- } = snapshot;
1073
+ let CombinedSnapshot { undo_snapshot, universe, was_in_snapshot, _in_progress_tables } =
1074
+ snapshot;
1073
1075
1074
1076
self . in_snapshot . set ( was_in_snapshot) ;
1075
1077
self . universe . set ( universe) ;
@@ -1093,21 +1095,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1093
1095
float_unification_table,
1094
1096
region_constraints : region_constraints. as_mut ( ) . unwrap ( ) ,
1095
1097
projection_cache,
1098
+ region_obligations,
1096
1099
} ,
1097
1100
undo_snapshot,
1098
1101
) ;
1099
- region_obligations. truncate ( region_obligations_snapshot) ;
1100
1102
}
1101
1103
1102
1104
fn commit_from ( & self , snapshot : CombinedSnapshot < ' a , ' tcx > ) {
1103
1105
debug ! ( "commit_from()" ) ;
1104
- let CombinedSnapshot {
1105
- undo_snapshot,
1106
- region_obligations_snapshot : _,
1107
- universe : _,
1108
- was_in_snapshot,
1109
- _in_progress_tables,
1110
- } = snapshot;
1106
+ let CombinedSnapshot { undo_snapshot, universe : _, was_in_snapshot, _in_progress_tables } =
1107
+ snapshot;
1111
1108
1112
1109
self . in_snapshot . set ( was_in_snapshot) ;
1113
1110
0 commit comments