@@ -84,20 +84,6 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
84
84
ut:: InPlace < T , & ' a mut ut:: UnificationStorage < T > , & ' a mut InferCtxtUndoLogs < ' tcx > > ,
85
85
> ;
86
86
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
-
101
87
/// This type contains all the things within `InferCtxt` that sit within a
102
88
/// `RefCell` and are involved with taking/rolling back snapshots. Snapshot
103
89
/// operations are hot enough that we want only one call to `borrow_mut` per
@@ -1248,6 +1234,33 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1248
1234
self . tainted_by_errors_flag . set ( true )
1249
1235
}
1250
1236
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
+
1251
1264
/// Process the region constraints and return any any errors that
1252
1265
/// result. After this, no more unification operations should be
1253
1266
/// done -- or the compiler will panic -- but it is legal to use
@@ -1256,7 +1269,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1256
1269
& self ,
1257
1270
region_context : DefId ,
1258
1271
outlives_env : & OutlivesEnvironment < ' tcx > ,
1259
- mode : RegionckMode ,
1260
1272
) -> Vec < RegionResolutionError < ' tcx > > {
1261
1273
let ( var_infos, data) = {
1262
1274
let mut inner = self . inner . borrow_mut ( ) ;
@@ -1278,7 +1290,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1278
1290
& RegionRelations :: new ( self . tcx , region_context, outlives_env. free_region_map ( ) ) ;
1279
1291
1280
1292
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) ;
1282
1294
1283
1295
let old_value = self . lexical_region_resolutions . replace ( Some ( lexical_region_resolutions) ) ;
1284
1296
assert ! ( old_value. is_none( ) ) ;
@@ -1294,9 +1306,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1294
1306
& self ,
1295
1307
region_context : DefId ,
1296
1308
outlives_env : & OutlivesEnvironment < ' tcx > ,
1297
- mode : RegionckMode ,
1298
1309
) {
1299
- let errors = self . resolve_regions ( region_context, outlives_env, mode ) ;
1310
+ let errors = self . resolve_regions ( region_context, outlives_env) ;
1300
1311
1301
1312
if !self . is_tainted_by_errors ( ) {
1302
1313
// As a heuristic, just skip reporting region errors
0 commit comments