@@ -196,7 +196,7 @@ pub struct InferCtxtInner<'tcx> {
196196 /// for each body-id in this map, which will process the
197197 /// obligations within. This is expected to be done 'late enough'
198198 /// 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 > ) > ,
200200}
201201
202202impl < ' tcx > InferCtxtInner < ' tcx > {
@@ -213,6 +213,10 @@ impl<'tcx> InferCtxtInner<'tcx> {
213213 }
214214 }
215215
216+ pub fn region_obligations ( & self ) -> & [ ( hir:: HirId , RegionObligation < ' tcx > ) ] {
217+ & self . region_obligations
218+ }
219+
216220 pub ( crate ) fn projection_cache ( & mut self ) -> traits:: ProjectionCache < ' tcx , ' _ > {
217221 self . projection_cache . with_log ( & mut self . undo_log )
218222 }
@@ -270,6 +274,7 @@ pub(crate) enum UndoLog<'tcx> {
270274 RegionConstraintCollector ( region_constraints:: UndoLog < ' tcx > ) ,
271275 RegionUnificationTable ( sv:: UndoLog < ut:: Delegate < ty:: RegionVid > > ) ,
272276 ProjectionCache ( traits:: UndoLog < ' tcx > ) ,
277+ PushRegionObligation ,
273278}
274279
275280impl < ' tcx > From < region_constraints:: UndoLog < ' tcx > > for UndoLog < ' tcx > {
@@ -348,6 +353,7 @@ struct RollbackView<'tcx, 'a> {
348353 float_unification_table : & ' a mut ut:: UnificationStorage < ty:: FloatVid > ,
349354 region_constraints : & ' a mut RegionConstraintStorage < ' tcx > ,
350355 projection_cache : & ' a mut traits:: ProjectionCacheStorage < ' tcx > ,
356+ region_obligations : & ' a mut Vec < ( hir:: HirId , RegionObligation < ' tcx > ) > ,
351357}
352358
353359impl < ' tcx > Rollback < UndoLog < ' tcx > > for RollbackView < ' tcx , ' _ > {
@@ -362,6 +368,9 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for RollbackView<'tcx, '_> {
362368 self . region_constraints . unification_table . reverse ( undo)
363369 }
364370 UndoLog :: ProjectionCache ( undo) => self . projection_cache . reverse ( undo) ,
371+ UndoLog :: PushRegionObligation => {
372+ self . region_obligations . pop ( ) ;
373+ }
365374 }
366375 }
367376}
@@ -915,7 +924,6 @@ pub struct FullSnapshot<'a, 'tcx> {
915924#[ must_use = "once you start a snapshot, you should always consume it" ]
916925pub struct CombinedSnapshot < ' a , ' tcx > {
917926 undo_snapshot : Snapshot < ' tcx > ,
918- region_obligations_snapshot : usize ,
919927 universe : ty:: UniverseIndex ,
920928 was_in_snapshot : bool ,
921929 _in_progress_tables : Option < Ref < ' a , ty:: TypeckTables < ' tcx > > > ,
@@ -1052,7 +1060,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10521060 let undo_snapshot = Snapshot { undo_len : inner. undo_log . logs . len ( ) , _marker : PhantomData } ;
10531061 CombinedSnapshot {
10541062 undo_snapshot,
1055- region_obligations_snapshot : inner. region_obligations . len ( ) ,
10561063 universe : self . universe ( ) ,
10571064 was_in_snapshot : in_snapshot,
10581065 // Borrow tables "in progress" (i.e., during typeck)
@@ -1063,13 +1070,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10631070
10641071 fn rollback_to ( & self , cause : & str , snapshot : CombinedSnapshot < ' a , ' tcx > ) {
10651072 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;
10731075
10741076 self . in_snapshot . set ( was_in_snapshot) ;
10751077 self . universe . set ( universe) ;
@@ -1093,21 +1095,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10931095 float_unification_table,
10941096 region_constraints : region_constraints. as_mut ( ) . unwrap ( ) ,
10951097 projection_cache,
1098+ region_obligations,
10961099 } ,
10971100 undo_snapshot,
10981101 ) ;
1099- region_obligations. truncate ( region_obligations_snapshot) ;
11001102 }
11011103
11021104 fn commit_from ( & self , snapshot : CombinedSnapshot < ' a , ' tcx > ) {
11031105 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;
11111108
11121109 self . in_snapshot . set ( was_in_snapshot) ;
11131110
0 commit comments