@@ -6,6 +6,7 @@ pub use self::RegionVariableOrigin::*;
6
6
pub use self :: SubregionOrigin :: * ;
7
7
pub use self :: ValuePairs :: * ;
8
8
pub use combine:: ObligationEmittingRelation ;
9
+ use rustc_data_structures:: undo_log:: UndoLogs ;
9
10
10
11
use self :: opaque_types:: OpaqueTypeStorage ;
11
12
pub ( crate ) use self :: undo_log:: { InferCtxtUndoLogs , Snapshot , UndoLog } ;
@@ -297,9 +298,6 @@ pub struct InferCtxt<'tcx> {
297
298
// FIXME(matthewjasper) Merge into `tainted_by_errors`
298
299
err_count_on_creation : usize ,
299
300
300
- /// This flag is true while there is an active snapshot.
301
- in_snapshot : Cell < bool > ,
302
-
303
301
/// What is the innermost universe we have created? Starts out as
304
302
/// `UniverseIndex::root()` but grows from there as we enter
305
303
/// universal quantifiers.
@@ -643,7 +641,6 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
643
641
reported_closure_mismatch : Default :: default ( ) ,
644
642
tainted_by_errors : Cell :: new ( None ) ,
645
643
err_count_on_creation : tcx. sess . err_count ( ) ,
646
- in_snapshot : Cell :: new ( false ) ,
647
644
universe : Cell :: new ( ty:: UniverseIndex :: ROOT ) ,
648
645
intercrate,
649
646
next_trait_solver,
@@ -679,7 +676,6 @@ pub struct CombinedSnapshot<'tcx> {
679
676
undo_snapshot : Snapshot < ' tcx > ,
680
677
region_constraints_snapshot : RegionSnapshot ,
681
678
universe : ty:: UniverseIndex ,
682
- was_in_snapshot : bool ,
683
679
}
684
680
685
681
impl < ' tcx > InferCtxt < ' tcx > {
@@ -702,10 +698,6 @@ impl<'tcx> InferCtxt<'tcx> {
702
698
}
703
699
}
704
700
705
- pub fn is_in_snapshot ( & self ) -> bool {
706
- self . in_snapshot . get ( )
707
- }
708
-
709
701
pub fn freshen < T : TypeFoldable < TyCtxt < ' tcx > > > ( & self , t : T ) -> T {
710
702
t. fold_with ( & mut self . freshener ( ) )
711
703
}
@@ -766,31 +758,30 @@ impl<'tcx> InferCtxt<'tcx> {
766
758
}
767
759
}
768
760
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
+
769
769
fn start_snapshot ( & self ) -> CombinedSnapshot < ' tcx > {
770
770
debug ! ( "start_snapshot()" ) ;
771
771
772
- let in_snapshot = self . in_snapshot . replace ( true ) ;
773
-
774
772
let mut inner = self . inner . borrow_mut ( ) ;
775
773
776
774
CombinedSnapshot {
777
775
undo_snapshot : inner. undo_log . start_snapshot ( ) ,
778
776
region_constraints_snapshot : inner. unwrap_region_constraints ( ) . start_snapshot ( ) ,
779
777
universe : self . universe ( ) ,
780
- was_in_snapshot : in_snapshot,
781
778
}
782
779
}
783
780
784
781
#[ instrument( skip( self , snapshot) , level = "debug" ) ]
785
782
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
+
794
785
self . universe . set ( universe) ;
795
786
796
787
let mut inner = self . inner . borrow_mut ( ) ;
@@ -800,14 +791,8 @@ impl<'tcx> InferCtxt<'tcx> {
800
791
801
792
#[ instrument( skip( self , snapshot) , level = "debug" ) ]
802
793
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;
811
796
812
797
self . inner . borrow_mut ( ) . commit ( undo_snapshot) ;
813
798
}
0 commit comments