@@ -84,20 +84,6 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
8484 ut:: InPlace < T , & ' a mut ut:: UnificationStorage < T > , & ' a mut InferCtxtUndoLogs < ' tcx > > ,
8585> ;
8686
87- /// How we should handle region solving.
88- ///
89- /// This is used so that the region values inferred by HIR region solving are
90- /// not exposed, and so that we can avoid doing work in HIR typeck that MIR
91- /// typeck will also do.
92- #[ derive( Copy , Clone , Debug , Default ) ]
93- pub enum RegionckMode {
94- /// The default mode: report region errors, don't erase regions.
95- #[ default]
96- Solve ,
97- /// Erase the results of region after solving.
98- Erase ,
99- }
100-
10187/// This type contains all the things within `InferCtxt` that sit within a
10288/// `RefCell` and are involved with taking/rolling back snapshots. Snapshot
10389/// operations are hot enough that we want only one call to `borrow_mut` per
@@ -1248,6 +1234,33 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12481234 self . tainted_by_errors_flag . set ( true )
12491235 }
12501236
1237+ pub fn skip_region_resolution ( & self ) {
1238+ let ( var_infos, _) = {
1239+ let mut inner = self . inner . borrow_mut ( ) ;
1240+ let inner = & mut * inner;
1241+ // Note: `inner.region_obligations` may not be empty, because we
1242+ // didn't necessarily call `process_registered_region_obligations`.
1243+ // This is okay, because that doesn't introduce new vars.
1244+ inner
1245+ . region_constraint_storage
1246+ . take ( )
1247+ . expect ( "regions already resolved" )
1248+ . with_log ( & mut inner. undo_log )
1249+ . into_infos_and_data ( )
1250+ } ;
1251+
1252+ let lexical_region_resolutions = LexicalRegionResolutions {
1253+ error_region : self . tcx . lifetimes . re_static ,
1254+ values : rustc_index:: vec:: IndexVec :: from_elem_n (
1255+ crate :: infer:: lexical_region_resolve:: VarValue :: Value ( self . tcx . lifetimes . re_erased ) ,
1256+ var_infos. len ( ) ,
1257+ ) ,
1258+ } ;
1259+
1260+ let old_value = self . lexical_region_resolutions . replace ( Some ( lexical_region_resolutions) ) ;
1261+ assert ! ( old_value. is_none( ) ) ;
1262+ }
1263+
12511264 /// Process the region constraints and return any any errors that
12521265 /// result. After this, no more unification operations should be
12531266 /// done -- or the compiler will panic -- but it is legal to use
@@ -1256,7 +1269,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12561269 & self ,
12571270 region_context : DefId ,
12581271 outlives_env : & OutlivesEnvironment < ' tcx > ,
1259- mode : RegionckMode ,
12601272 ) -> Vec < RegionResolutionError < ' tcx > > {
12611273 let ( var_infos, data) = {
12621274 let mut inner = self . inner . borrow_mut ( ) ;
@@ -1278,7 +1290,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12781290 & RegionRelations :: new ( self . tcx , region_context, outlives_env. free_region_map ( ) ) ;
12791291
12801292 let ( lexical_region_resolutions, errors) =
1281- lexical_region_resolve:: resolve ( region_rels, var_infos, data, mode ) ;
1293+ lexical_region_resolve:: resolve ( region_rels, var_infos, data) ;
12821294
12831295 let old_value = self . lexical_region_resolutions . replace ( Some ( lexical_region_resolutions) ) ;
12841296 assert ! ( old_value. is_none( ) ) ;
@@ -1294,9 +1306,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12941306 & self ,
12951307 region_context : DefId ,
12961308 outlives_env : & OutlivesEnvironment < ' tcx > ,
1297- mode : RegionckMode ,
12981309 ) {
1299- let errors = self . resolve_regions ( region_context, outlives_env, mode ) ;
1310+ let errors = self . resolve_regions ( region_context, outlives_env) ;
13001311
13011312 if !self . is_tainted_by_errors ( ) {
13021313 // As a heuristic, just skip reporting region errors
0 commit comments