@@ -7,12 +7,10 @@ pub use self::SubregionOrigin::*;
7
7
pub use self :: ValuePairs :: * ;
8
8
pub use relate:: combine:: ObligationEmittingRelation ;
9
9
use rustc_data_structures:: captures:: Captures ;
10
- use rustc_data_structures:: undo_log:: UndoLogs ;
11
10
use rustc_middle:: infer:: unify_key:: EffectVarValue ;
12
11
use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
13
12
14
13
use self :: opaque_types:: OpaqueTypeStorage ;
15
- pub ( crate ) use self :: undo_log:: { InferCtxtUndoLogs , Snapshot , UndoLog } ;
16
14
17
15
use crate :: traits:: {
18
16
self , ObligationCause , ObligationInspector , PredicateObligations , TraitEngine , TraitEngineExt ,
@@ -50,28 +48,26 @@ use self::error_reporting::TypeErrCtxt;
50
48
use self :: free_regions:: RegionRelations ;
51
49
use self :: lexical_region_resolve:: LexicalRegionResolutions ;
52
50
use self :: region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
53
- use self :: region_constraints:: {
54
- RegionConstraintCollector , RegionConstraintStorage , RegionSnapshot ,
55
- } ;
51
+ use self :: region_constraints:: { RegionConstraintCollector , RegionConstraintStorage } ;
56
52
pub use self :: relate:: combine:: CombineFields ;
57
53
pub use self :: relate:: StructurallyRelateAliases ;
54
+ use self :: snapshot:: undo_log:: InferCtxtUndoLogs ;
58
55
use self :: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
59
56
60
57
pub mod at;
61
58
pub mod canonical;
62
59
pub mod error_reporting;
63
60
pub mod free_regions;
64
61
mod freshen;
65
- mod fudge;
66
62
mod lexical_region_resolve;
67
63
pub mod opaque_types;
68
64
pub mod outlives;
69
65
mod projection;
70
66
pub mod region_constraints;
71
67
mod relate;
72
68
pub mod resolve;
69
+ pub ( crate ) mod snapshot;
73
70
pub mod type_variable;
74
- mod undo_log;
75
71
76
72
#[ must_use]
77
73
#[ derive( Debug ) ]
@@ -738,13 +734,6 @@ impl<'tcx> InferOk<'tcx, ()> {
738
734
}
739
735
}
740
736
741
- #[ must_use = "once you start a snapshot, you should always consume it" ]
742
- pub struct CombinedSnapshot < ' tcx > {
743
- undo_snapshot : Snapshot < ' tcx > ,
744
- region_constraints_snapshot : RegionSnapshot ,
745
- universe : ty:: UniverseIndex ,
746
- }
747
-
748
737
impl < ' tcx > InferCtxt < ' tcx > {
749
738
pub fn dcx ( & self ) -> & ' tcx DiagCtxt {
750
739
self . tcx . dcx ( )
@@ -842,90 +831,6 @@ impl<'tcx> InferCtxt<'tcx> {
842
831
}
843
832
}
844
833
845
- pub fn in_snapshot ( & self ) -> bool {
846
- UndoLogs :: < UndoLog < ' tcx > > :: in_snapshot ( & self . inner . borrow_mut ( ) . undo_log )
847
- }
848
-
849
- pub fn num_open_snapshots ( & self ) -> usize {
850
- UndoLogs :: < UndoLog < ' tcx > > :: num_open_snapshots ( & self . inner . borrow_mut ( ) . undo_log )
851
- }
852
-
853
- fn start_snapshot ( & self ) -> CombinedSnapshot < ' tcx > {
854
- debug ! ( "start_snapshot()" ) ;
855
-
856
- let mut inner = self . inner . borrow_mut ( ) ;
857
-
858
- CombinedSnapshot {
859
- undo_snapshot : inner. undo_log . start_snapshot ( ) ,
860
- region_constraints_snapshot : inner. unwrap_region_constraints ( ) . start_snapshot ( ) ,
861
- universe : self . universe ( ) ,
862
- }
863
- }
864
-
865
- #[ instrument( skip( self , snapshot) , level = "debug" ) ]
866
- fn rollback_to ( & self , snapshot : CombinedSnapshot < ' tcx > ) {
867
- let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe } = snapshot;
868
-
869
- self . universe . set ( universe) ;
870
-
871
- let mut inner = self . inner . borrow_mut ( ) ;
872
- inner. rollback_to ( undo_snapshot) ;
873
- inner. unwrap_region_constraints ( ) . rollback_to ( region_constraints_snapshot) ;
874
- }
875
-
876
- #[ instrument( skip( self , snapshot) , level = "debug" ) ]
877
- fn commit_from ( & self , snapshot : CombinedSnapshot < ' tcx > ) {
878
- let CombinedSnapshot { undo_snapshot, region_constraints_snapshot : _, universe : _ } =
879
- snapshot;
880
-
881
- self . inner . borrow_mut ( ) . commit ( undo_snapshot) ;
882
- }
883
-
884
- /// Execute `f` and commit the bindings if closure `f` returns `Ok(_)`.
885
- #[ instrument( skip( self , f) , level = "debug" ) ]
886
- pub fn commit_if_ok < T , E , F > ( & self , f : F ) -> Result < T , E >
887
- where
888
- F : FnOnce ( & CombinedSnapshot < ' tcx > ) -> Result < T , E > ,
889
- {
890
- let snapshot = self . start_snapshot ( ) ;
891
- let r = f ( & snapshot) ;
892
- debug ! ( "commit_if_ok() -- r.is_ok() = {}" , r. is_ok( ) ) ;
893
- match r {
894
- Ok ( _) => {
895
- self . commit_from ( snapshot) ;
896
- }
897
- Err ( _) => {
898
- self . rollback_to ( snapshot) ;
899
- }
900
- }
901
- r
902
- }
903
-
904
- /// Execute `f` then unroll any bindings it creates.
905
- #[ instrument( skip( self , f) , level = "debug" ) ]
906
- pub fn probe < R , F > ( & self , f : F ) -> R
907
- where
908
- F : FnOnce ( & CombinedSnapshot < ' tcx > ) -> R ,
909
- {
910
- let snapshot = self . start_snapshot ( ) ;
911
- let r = f ( & snapshot) ;
912
- self . rollback_to ( snapshot) ;
913
- r
914
- }
915
-
916
- /// Scan the constraints produced since `snapshot` and check whether
917
- /// we added any region constraints.
918
- pub fn region_constraints_added_in_snapshot ( & self , snapshot : & CombinedSnapshot < ' tcx > ) -> bool {
919
- self . inner
920
- . borrow_mut ( )
921
- . unwrap_region_constraints ( )
922
- . region_constraints_added_in_snapshot ( & snapshot. undo_snapshot )
923
- }
924
-
925
- pub fn opaque_types_added_in_snapshot ( & self , snapshot : & CombinedSnapshot < ' tcx > ) -> bool {
926
- self . inner . borrow ( ) . undo_log . opaque_types_in_snapshot ( & snapshot. undo_snapshot )
927
- }
928
-
929
834
pub fn can_sub < T > ( & self , param_env : ty:: ParamEnv < ' tcx > , expected : T , actual : T ) -> bool
930
835
where
931
836
T : at:: ToTrace < ' tcx > ,
0 commit comments