@@ -897,13 +897,18 @@ impl<'tcx> InferOk<'tcx, ()> {
897897}
898898
899899#[ 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 ,
902903 type_snapshot : type_variable:: Snapshot < ' tcx > ,
903904 const_snapshot : usize ,
904905 int_snapshot : usize ,
905906 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 > ,
907912 region_obligations_snapshot : usize ,
908913 universe : ty:: UniverseIndex ,
909914 was_in_snapshot : bool ,
@@ -1018,6 +1023,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10181023 result
10191024 }
10201025
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+
10211039 fn start_snapshot ( & self ) -> CombinedSnapshot < ' a , ' tcx > {
10221040 debug ! ( "start_snapshot()" ) ;
10231041
@@ -1029,11 +1047,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10291047 let undo_snapshot = Snapshot { undo_len : inner. undo_log . logs . len ( ) , _marker : PhantomData } ;
10301048 CombinedSnapshot {
10311049 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 ( ) ,
10371050 region_obligations_snapshot : inner. region_obligations . len ( ) ,
10381051 universe : self . universe ( ) ,
10391052 was_in_snapshot : in_snapshot,
@@ -1048,11 +1061,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10481061 debug ! ( "rollback_to(cause={})" , cause) ;
10491062 let CombinedSnapshot {
10501063 undo_snapshot,
1051- type_snapshot : _,
1052- const_snapshot : _,
1053- int_snapshot : _,
1054- float_snapshot : _,
1055- region_constraints_snapshot : _,
10561064 region_obligations_snapshot,
10571065 universe,
10581066 was_in_snapshot,
@@ -1093,11 +1101,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10931101 debug ! ( "commit_from()" ) ;
10941102 let CombinedSnapshot {
10951103 undo_snapshot,
1096- type_snapshot : _,
1097- const_snapshot : _,
1098- int_snapshot : _,
1099- float_snapshot : _,
1100- region_constraints_snapshot : _,
11011104 region_obligations_snapshot : _,
11021105 universe : _,
11031106 was_in_snapshot,
@@ -1156,6 +1159,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11561159 r
11571160 }
11581161
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+
11591173 /// If `should_skip` is true, then execute `f` then unroll any bindings it creates.
11601174 pub fn probe_maybe_skip_leak_check < R , F > ( & self , should_skip : bool , f : F ) -> R
11611175 where
0 commit comments