@@ -6,6 +6,7 @@ pub use self::RegionVariableOrigin::*;
66pub use self :: SubregionOrigin :: * ;
77pub use self :: ValuePairs :: * ;
88pub use combine:: ObligationEmittingRelation ;
9+ use rustc_data_structures:: undo_log:: UndoLogs ;
910
1011use self :: opaque_types:: OpaqueTypeStorage ;
1112pub ( crate ) use self :: undo_log:: { InferCtxtUndoLogs , Snapshot , UndoLog } ;
@@ -297,9 +298,6 @@ pub struct InferCtxt<'tcx> {
297298 // FIXME(matthewjasper) Merge into `tainted_by_errors`
298299 err_count_on_creation : usize ,
299300
300- /// This flag is true while there is an active snapshot.
301- in_snapshot : Cell < bool > ,
302-
303301 /// What is the innermost universe we have created? Starts out as
304302 /// `UniverseIndex::root()` but grows from there as we enter
305303 /// universal quantifiers.
@@ -643,7 +641,6 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
643641 reported_closure_mismatch : Default :: default ( ) ,
644642 tainted_by_errors : Cell :: new ( None ) ,
645643 err_count_on_creation : tcx. sess . err_count ( ) ,
646- in_snapshot : Cell :: new ( false ) ,
647644 universe : Cell :: new ( ty:: UniverseIndex :: ROOT ) ,
648645 intercrate,
649646 next_trait_solver,
@@ -679,7 +676,6 @@ pub struct CombinedSnapshot<'tcx> {
679676 undo_snapshot : Snapshot < ' tcx > ,
680677 region_constraints_snapshot : RegionSnapshot ,
681678 universe : ty:: UniverseIndex ,
682- was_in_snapshot : bool ,
683679}
684680
685681impl < ' tcx > InferCtxt < ' tcx > {
@@ -702,10 +698,6 @@ impl<'tcx> InferCtxt<'tcx> {
702698 }
703699 }
704700
705- pub fn is_in_snapshot ( & self ) -> bool {
706- self . in_snapshot . get ( )
707- }
708-
709701 pub fn freshen < T : TypeFoldable < TyCtxt < ' tcx > > > ( & self , t : T ) -> T {
710702 t. fold_with ( & mut self . freshener ( ) )
711703 }
@@ -766,31 +758,30 @@ impl<'tcx> InferCtxt<'tcx> {
766758 }
767759 }
768760
761+ pub fn in_snapshot ( & self ) -> bool {
762+ UndoLogs :: < UndoLog < ' tcx > > :: in_snapshot ( & self . inner . borrow_mut ( ) . undo_log )
763+ }
764+
765+ pub fn num_open_snapshots ( & self ) -> usize {
766+ UndoLogs :: < UndoLog < ' tcx > > :: num_open_snapshots ( & self . inner . borrow_mut ( ) . undo_log )
767+ }
768+
769769 fn start_snapshot ( & self ) -> CombinedSnapshot < ' tcx > {
770770 debug ! ( "start_snapshot()" ) ;
771771
772- let in_snapshot = self . in_snapshot . replace ( true ) ;
773-
774772 let mut inner = self . inner . borrow_mut ( ) ;
775773
776774 CombinedSnapshot {
777775 undo_snapshot : inner. undo_log . start_snapshot ( ) ,
778776 region_constraints_snapshot : inner. unwrap_region_constraints ( ) . start_snapshot ( ) ,
779777 universe : self . universe ( ) ,
780- was_in_snapshot : in_snapshot,
781778 }
782779 }
783780
784781 #[ instrument( skip( self , snapshot) , level = "debug" ) ]
785782 fn rollback_to ( & self , cause : & str , snapshot : CombinedSnapshot < ' tcx > ) {
786- let CombinedSnapshot {
787- undo_snapshot,
788- region_constraints_snapshot,
789- universe,
790- was_in_snapshot,
791- } = snapshot;
792-
793- self . in_snapshot . set ( was_in_snapshot) ;
783+ let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe } = snapshot;
784+
794785 self . universe . set ( universe) ;
795786
796787 let mut inner = self . inner . borrow_mut ( ) ;
@@ -800,14 +791,8 @@ impl<'tcx> InferCtxt<'tcx> {
800791
801792 #[ instrument( skip( self , snapshot) , level = "debug" ) ]
802793 fn commit_from ( & self , snapshot : CombinedSnapshot < ' tcx > ) {
803- let CombinedSnapshot {
804- undo_snapshot,
805- region_constraints_snapshot : _,
806- universe : _,
807- was_in_snapshot,
808- } = snapshot;
809-
810- self . in_snapshot . set ( was_in_snapshot) ;
794+ let CombinedSnapshot { undo_snapshot, region_constraints_snapshot : _, universe : _ } =
795+ snapshot;
811796
812797 self . inner . borrow_mut ( ) . commit ( undo_snapshot) ;
813798 }
0 commit comments