1
- pub use self :: at:: DefineOpaqueTypes ;
2
- pub use self :: freshen:: TypeFreshener ;
3
- pub use self :: lexical_region_resolve:: RegionResolutionError ;
4
- pub use self :: BoundRegionConversionTime :: * ;
5
- pub use self :: RegionVariableOrigin :: * ;
6
- pub use self :: SubregionOrigin :: * ;
7
- pub use self :: ValuePairs :: * ;
1
+ pub use at:: DefineOpaqueTypes ;
2
+ pub use freshen:: TypeFreshener ;
3
+ pub use lexical_region_resolve:: RegionResolutionError ;
4
+ pub use relate:: combine:: CombineFields ;
8
5
pub use relate:: combine:: ObligationEmittingRelation ;
9
- use rustc_data_structures:: captures:: Captures ;
10
- use rustc_data_structures:: undo_log:: UndoLogs ;
11
- use rustc_middle:: infer:: unify_key:: EffectVarValue ;
12
- use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
13
-
14
- use self :: opaque_types:: OpaqueTypeStorage ;
15
- pub ( crate ) use self :: undo_log:: { InferCtxtUndoLogs , Snapshot , UndoLog } ;
6
+ pub use relate:: StructurallyRelateAliases ;
7
+ pub use rustc_middle:: ty:: IntVarValue ;
8
+ pub use BoundRegionConversionTime :: * ;
9
+ pub use RegionVariableOrigin :: * ;
10
+ pub use SubregionOrigin :: * ;
11
+ pub use ValuePairs :: * ;
16
12
17
13
use crate :: traits:: {
18
14
self , ObligationCause , ObligationInspector , PredicateObligations , TraitEngine , TraitEngineExt ,
19
15
} ;
20
-
16
+ use error_reporting:: TypeErrCtxt ;
17
+ use free_regions:: RegionRelations ;
18
+ use lexical_region_resolve:: LexicalRegionResolutions ;
19
+ use opaque_types:: OpaqueTypeStorage ;
20
+ use region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
21
+ use region_constraints:: { RegionConstraintCollector , RegionConstraintStorage } ;
22
+ use rustc_data_structures:: captures:: Captures ;
21
23
use rustc_data_structures:: fx:: FxIndexMap ;
22
24
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
23
25
use rustc_data_structures:: sync:: Lrc ;
@@ -27,7 +29,9 @@ use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
27
29
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
28
30
use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
29
31
use rustc_middle:: infer:: unify_key:: ConstVariableValue ;
32
+ use rustc_middle:: infer:: unify_key:: EffectVarValue ;
30
33
use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind , ToType } ;
34
+ use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
31
35
use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
32
36
use rustc_middle:: mir:: ConstraintCategory ;
33
37
use rustc_middle:: traits:: { select, DefiningAnchor } ;
@@ -36,42 +40,30 @@ use rustc_middle::ty::fold::BoundVarReplacerDelegate;
36
40
use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
37
41
use rustc_middle:: ty:: relate:: RelateResult ;
38
42
use rustc_middle:: ty:: visit:: TypeVisitableExt ;
39
- pub use rustc_middle:: ty:: IntVarValue ;
40
43
use rustc_middle:: ty:: { self , GenericParamDefKind , InferConst , InferTy , Ty , TyCtxt } ;
41
44
use rustc_middle:: ty:: { ConstVid , EffectVid , FloatVid , IntVid , TyVid } ;
42
45
use rustc_middle:: ty:: { GenericArg , GenericArgKind , GenericArgs , GenericArgsRef } ;
43
46
use rustc_span:: symbol:: Symbol ;
44
47
use rustc_span:: Span ;
45
-
48
+ use snapshot :: undo_log :: InferCtxtUndoLogs ;
46
49
use std:: cell:: { Cell , RefCell } ;
47
50
use std:: fmt;
48
-
49
- use self :: error_reporting:: TypeErrCtxt ;
50
- use self :: free_regions:: RegionRelations ;
51
- use self :: lexical_region_resolve:: LexicalRegionResolutions ;
52
- use self :: region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
53
- use self :: region_constraints:: {
54
- RegionConstraintCollector , RegionConstraintStorage , RegionSnapshot ,
55
- } ;
56
- pub use self :: relate:: combine:: CombineFields ;
57
- pub use self :: relate:: StructurallyRelateAliases ;
58
- use self :: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
51
+ use type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
59
52
60
53
pub mod at;
61
54
pub mod canonical;
62
55
pub mod error_reporting;
63
56
pub mod free_regions;
64
57
mod freshen;
65
- mod fudge;
66
58
mod lexical_region_resolve;
67
59
pub mod opaque_types;
68
60
pub mod outlives;
69
61
mod projection;
70
62
pub mod region_constraints;
71
63
mod relate;
72
64
pub mod resolve;
65
+ pub ( crate ) mod snapshot;
73
66
pub mod type_variable;
74
- mod undo_log;
75
67
76
68
#[ must_use]
77
69
#[ derive( Debug ) ]
@@ -738,13 +730,6 @@ impl<'tcx> InferOk<'tcx, ()> {
738
730
}
739
731
}
740
732
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
733
impl < ' tcx > InferCtxt < ' tcx > {
749
734
pub fn dcx ( & self ) -> & ' tcx DiagCtxt {
750
735
self . tcx . dcx ( )
@@ -842,90 +827,6 @@ impl<'tcx> InferCtxt<'tcx> {
842
827
}
843
828
}
844
829
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
830
pub fn can_sub < T > ( & self , param_env : ty:: ParamEnv < ' tcx > , expected : T , actual : T ) -> bool
930
831
where
931
832
T : at:: ToTrace < ' tcx > ,
0 commit comments