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 ;
85pub 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 :: * ;
1612
1713use crate :: traits:: {
1814 self , ObligationCause , ObligationInspector , PredicateObligations , TraitEngine , TraitEngineExt ,
1915} ;
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 ;
2123use rustc_data_structures:: fx:: FxIndexMap ;
2224use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
2325use rustc_data_structures:: sync:: Lrc ;
@@ -27,7 +29,9 @@ use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
2729use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2830use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
2931use rustc_middle:: infer:: unify_key:: ConstVariableValue ;
32+ use rustc_middle:: infer:: unify_key:: EffectVarValue ;
3033use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind , ToType } ;
34+ use rustc_middle:: infer:: unify_key:: { ConstVidKey , EffectVidKey } ;
3135use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult } ;
3236use rustc_middle:: mir:: ConstraintCategory ;
3337use rustc_middle:: traits:: { select, DefiningAnchor } ;
@@ -36,42 +40,30 @@ use rustc_middle::ty::fold::BoundVarReplacerDelegate;
3640use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
3741use rustc_middle:: ty:: relate:: RelateResult ;
3842use rustc_middle:: ty:: visit:: TypeVisitableExt ;
39- pub use rustc_middle:: ty:: IntVarValue ;
4043use rustc_middle:: ty:: { self , GenericParamDefKind , InferConst , InferTy , Ty , TyCtxt } ;
4144use rustc_middle:: ty:: { ConstVid , EffectVid , FloatVid , IntVid , TyVid } ;
4245use rustc_middle:: ty:: { GenericArg , GenericArgKind , GenericArgs , GenericArgsRef } ;
4346use rustc_span:: symbol:: Symbol ;
4447use rustc_span:: Span ;
45-
48+ use snapshot :: undo_log :: InferCtxtUndoLogs ;
4649use std:: cell:: { Cell , RefCell } ;
4750use 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 } ;
5952
6053pub mod at;
6154pub mod canonical;
6255pub mod error_reporting;
6356pub mod free_regions;
6457mod freshen;
65- mod fudge;
6658mod lexical_region_resolve;
6759pub mod opaque_types;
6860pub mod outlives;
6961mod projection;
7062pub mod region_constraints;
7163mod relate;
7264pub mod resolve;
65+ pub ( crate ) mod snapshot;
7366pub mod type_variable;
74- mod undo_log;
7567
7668#[ must_use]
7769#[ derive( Debug ) ]
@@ -738,13 +730,6 @@ impl<'tcx> InferOk<'tcx, ()> {
738730 }
739731}
740732
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-
748733impl < ' tcx > InferCtxt < ' tcx > {
749734 pub fn dcx ( & self ) -> & ' tcx DiagCtxt {
750735 self . tcx . dcx ( )
@@ -842,90 +827,6 @@ impl<'tcx> InferCtxt<'tcx> {
842827 }
843828 }
844829
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-
929830 pub fn can_sub < T > ( & self , param_env : ty:: ParamEnv < ' tcx > , expected : T , actual : T ) -> bool
930831 where
931832 T : at:: ToTrace < ' tcx > ,
0 commit comments