@@ -897,13 +897,18 @@ impl<'tcx> InferOk<'tcx, ()> {
897
897
}
898
898
899
899
#[ must_use = "once you start a snapshot, you should always consume it" ]
900
- pub struct CombinedSnapshot < ' a , ' tcx > {
901
- undo_snapshot : Snapshot < ' tcx > ,
900
+ pub struct FullSnapshot < ' a , ' tcx > {
901
+ snapshot : CombinedSnapshot < ' a , ' tcx > ,
902
+ region_constraints_snapshot : RegionSnapshot ,
902
903
type_snapshot : type_variable:: Snapshot < ' tcx > ,
903
904
const_snapshot : usize ,
904
905
int_snapshot : usize ,
905
906
float_snapshot : usize ,
906
- region_constraints_snapshot : RegionSnapshot ,
907
+ }
908
+
909
+ #[ must_use = "once you start a snapshot, you should always consume it" ]
910
+ pub struct CombinedSnapshot < ' a , ' tcx > {
911
+ undo_snapshot : Snapshot < ' tcx > ,
907
912
region_obligations_snapshot : usize ,
908
913
universe : ty:: UniverseIndex ,
909
914
was_in_snapshot : bool ,
@@ -1018,6 +1023,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1018
1023
result
1019
1024
}
1020
1025
1026
+ fn start_full_snapshot ( & self ) -> FullSnapshot < ' a , ' tcx > {
1027
+ let snapshot = self . start_snapshot ( ) ;
1028
+ let mut inner = self . inner . borrow_mut ( ) ;
1029
+ FullSnapshot {
1030
+ snapshot,
1031
+ type_snapshot : inner. type_variables ( ) . snapshot ( ) ,
1032
+ const_snapshot : inner. const_unification_table ( ) . len ( ) ,
1033
+ int_snapshot : inner. int_unification_table ( ) . len ( ) ,
1034
+ float_snapshot : inner. float_unification_table ( ) . len ( ) ,
1035
+ region_constraints_snapshot : inner. unwrap_region_constraints ( ) . start_snapshot ( ) ,
1036
+ }
1037
+ }
1038
+
1021
1039
fn start_snapshot ( & self ) -> CombinedSnapshot < ' a , ' tcx > {
1022
1040
debug ! ( "start_snapshot()" ) ;
1023
1041
@@ -1029,11 +1047,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1029
1047
let undo_snapshot = Snapshot { undo_len : inner. undo_log . logs . len ( ) , _marker : PhantomData } ;
1030
1048
CombinedSnapshot {
1031
1049
undo_snapshot,
1032
- type_snapshot : inner. type_variables ( ) . snapshot ( ) ,
1033
- const_snapshot : inner. const_unification_table ( ) . len ( ) ,
1034
- int_snapshot : inner. int_unification_table ( ) . len ( ) ,
1035
- float_snapshot : inner. float_unification_table ( ) . len ( ) ,
1036
- region_constraints_snapshot : inner. unwrap_region_constraints ( ) . start_snapshot ( ) ,
1037
1050
region_obligations_snapshot : inner. region_obligations . len ( ) ,
1038
1051
universe : self . universe ( ) ,
1039
1052
was_in_snapshot : in_snapshot,
@@ -1048,11 +1061,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1048
1061
debug ! ( "rollback_to(cause={})" , cause) ;
1049
1062
let CombinedSnapshot {
1050
1063
undo_snapshot,
1051
- type_snapshot : _,
1052
- const_snapshot : _,
1053
- int_snapshot : _,
1054
- float_snapshot : _,
1055
- region_constraints_snapshot : _,
1056
1064
region_obligations_snapshot,
1057
1065
universe,
1058
1066
was_in_snapshot,
@@ -1093,11 +1101,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1093
1101
debug ! ( "commit_from()" ) ;
1094
1102
let CombinedSnapshot {
1095
1103
undo_snapshot,
1096
- type_snapshot : _,
1097
- const_snapshot : _,
1098
- int_snapshot : _,
1099
- float_snapshot : _,
1100
- region_constraints_snapshot : _,
1101
1104
region_obligations_snapshot : _,
1102
1105
universe : _,
1103
1106
was_in_snapshot,
@@ -1156,6 +1159,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1156
1159
r
1157
1160
}
1158
1161
1162
+ pub fn probe_full < R , F > ( & self , f : F ) -> R
1163
+ where
1164
+ F : FnOnce ( & FullSnapshot < ' a , ' tcx > ) -> R ,
1165
+ {
1166
+ debug ! ( "probe()" ) ;
1167
+ let snapshot = self . start_full_snapshot ( ) ;
1168
+ let r = f ( & snapshot) ;
1169
+ self . rollback_to ( "probe" , snapshot. snapshot ) ;
1170
+ r
1171
+ }
1172
+
1159
1173
/// If `should_skip` is true, then execute `f` then unroll any bindings it creates.
1160
1174
pub fn probe_maybe_skip_leak_check < R , F > ( & self , should_skip : bool , f : F ) -> R
1161
1175
where
0 commit comments