@@ -45,8 +45,7 @@ use self::combine::CombineFields;
4545use self :: error_reporting:: TypeErrCtxt ;
4646use self :: free_regions:: RegionRelations ;
4747use self :: lexical_region_resolve:: LexicalRegionResolutions ;
48- use self :: outlives:: env:: OutlivesEnvironment ;
49- use self :: region_constraints:: { GenericKind , RegionConstraintData , VarInfos , VerifyBound } ;
48+ use self :: region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
5049use self :: region_constraints:: {
5150 RegionConstraintCollector , RegionConstraintStorage , RegionSnapshot ,
5251} ;
@@ -1213,95 +1212,6 @@ impl<'tcx> InferCtxt<'tcx> {
12131212 self . tainted_by_errors . set ( Some ( e) ) ;
12141213 }
12151214
1216- pub fn skip_region_resolution ( & self ) {
1217- let ( var_infos, _) = {
1218- let mut inner = self . inner . borrow_mut ( ) ;
1219- let inner = & mut * inner;
1220- // Note: `inner.region_obligations` may not be empty, because we
1221- // didn't necessarily call `process_registered_region_obligations`.
1222- // This is okay, because that doesn't introduce new vars.
1223- inner
1224- . region_constraint_storage
1225- . take ( )
1226- . expect ( "regions already resolved" )
1227- . with_log ( & mut inner. undo_log )
1228- . into_infos_and_data ( )
1229- } ;
1230-
1231- let lexical_region_resolutions = LexicalRegionResolutions {
1232- values : rustc_index:: vec:: IndexVec :: from_elem_n (
1233- crate :: infer:: lexical_region_resolve:: VarValue :: Value ( self . tcx . lifetimes . re_erased ) ,
1234- var_infos. len ( ) ,
1235- ) ,
1236- } ;
1237-
1238- let old_value = self . lexical_region_resolutions . replace ( Some ( lexical_region_resolutions) ) ;
1239- assert ! ( old_value. is_none( ) ) ;
1240- }
1241-
1242- /// Process the region constraints and return any errors that
1243- /// result. After this, no more unification operations should be
1244- /// done -- or the compiler will panic -- but it is legal to use
1245- /// `resolve_vars_if_possible` as well as `fully_resolve`.
1246- pub fn resolve_regions (
1247- & self ,
1248- outlives_env : & OutlivesEnvironment < ' tcx > ,
1249- ) -> Vec < RegionResolutionError < ' tcx > > {
1250- let ( var_infos, data) = {
1251- let mut inner = self . inner . borrow_mut ( ) ;
1252- let inner = & mut * inner;
1253- assert ! (
1254- self . tainted_by_errors( ) . is_some( ) || inner. region_obligations. is_empty( ) ,
1255- "region_obligations not empty: {:#?}" ,
1256- inner. region_obligations
1257- ) ;
1258- inner
1259- . region_constraint_storage
1260- . take ( )
1261- . expect ( "regions already resolved" )
1262- . with_log ( & mut inner. undo_log )
1263- . into_infos_and_data ( )
1264- } ;
1265-
1266- let region_rels = & RegionRelations :: new ( self . tcx , outlives_env. free_region_map ( ) ) ;
1267-
1268- let ( lexical_region_resolutions, errors) =
1269- lexical_region_resolve:: resolve ( outlives_env. param_env , region_rels, var_infos, data) ;
1270-
1271- let old_value = self . lexical_region_resolutions . replace ( Some ( lexical_region_resolutions) ) ;
1272- assert ! ( old_value. is_none( ) ) ;
1273-
1274- errors
1275- }
1276- /// Obtains (and clears) the current set of region
1277- /// constraints. The inference context is still usable: further
1278- /// unifications will simply add new constraints.
1279- ///
1280- /// This method is not meant to be used with normal lexical region
1281- /// resolution. Rather, it is used in the NLL mode as a kind of
1282- /// interim hack: basically we run normal type-check and generate
1283- /// region constraints as normal, but then we take them and
1284- /// translate them into the form that the NLL solver
1285- /// understands. See the NLL module for mode details.
1286- pub fn take_and_reset_region_constraints ( & self ) -> RegionConstraintData < ' tcx > {
1287- assert ! (
1288- self . inner. borrow( ) . region_obligations. is_empty( ) ,
1289- "region_obligations not empty: {:#?}" ,
1290- self . inner. borrow( ) . region_obligations
1291- ) ;
1292-
1293- self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . take_and_reset_data ( )
1294- }
1295-
1296- /// Gives temporary access to the region constraint data.
1297- pub fn with_region_constraints < R > (
1298- & self ,
1299- op : impl FnOnce ( & RegionConstraintData < ' tcx > ) -> R ,
1300- ) -> R {
1301- let mut inner = self . inner . borrow_mut ( ) ;
1302- op ( inner. unwrap_region_constraints ( ) . data ( ) )
1303- }
1304-
13051215 pub fn region_var_origin ( & self , vid : ty:: RegionVid ) -> RegionVariableOrigin {
13061216 let mut inner = self . inner . borrow_mut ( ) ;
13071217 let inner = & mut * inner;
@@ -1754,56 +1664,6 @@ impl<'cx, 'tcx> Drop for CanonicalizationCtxtGuard<'cx, 'tcx> {
17541664}
17551665
17561666impl < ' tcx > TypeErrCtxt < ' _ , ' tcx > {
1757- /// Processes registered region obliations and resolves regions, reporting
1758- /// any errors if any were raised. Prefer using this function over manually
1759- /// calling `resolve_regions_and_report_errors`.
1760- pub fn check_region_obligations_and_report_errors (
1761- & self ,
1762- generic_param_scope : LocalDefId ,
1763- outlives_env : & OutlivesEnvironment < ' tcx > ,
1764- ) -> Result < ( ) , ErrorGuaranteed > {
1765- self . process_registered_region_obligations (
1766- outlives_env. region_bound_pairs ( ) ,
1767- outlives_env. param_env ,
1768- ) ;
1769-
1770- self . resolve_regions_and_report_errors ( generic_param_scope, outlives_env)
1771- }
1772-
1773- /// Process the region constraints and report any errors that
1774- /// result. After this, no more unification operations should be
1775- /// done -- or the compiler will panic -- but it is legal to use
1776- /// `resolve_vars_if_possible` as well as `fully_resolve`.
1777- ///
1778- /// Make sure to call [`InferCtxt::process_registered_region_obligations`]
1779- /// first, or preferably use [`TypeErrCtxt::check_region_obligations_and_report_errors`]
1780- /// to do both of these operations together.
1781- pub fn resolve_regions_and_report_errors (
1782- & self ,
1783- generic_param_scope : LocalDefId ,
1784- outlives_env : & OutlivesEnvironment < ' tcx > ,
1785- ) -> Result < ( ) , ErrorGuaranteed > {
1786- let errors = self . resolve_regions ( outlives_env) ;
1787-
1788- if let None = self . tainted_by_errors ( ) {
1789- // As a heuristic, just skip reporting region errors
1790- // altogether if other errors have been reported while
1791- // this infcx was in use. This is totally hokey but
1792- // otherwise we have a hard time separating legit region
1793- // errors from silly ones.
1794- self . report_region_errors ( generic_param_scope, & errors) ;
1795- }
1796-
1797- if errors. is_empty ( ) {
1798- Ok ( ( ) )
1799- } else {
1800- Err ( self
1801- . tcx
1802- . sess
1803- . delay_span_bug ( rustc_span:: DUMMY_SP , "error should have been emitted" ) )
1804- }
1805- }
1806-
18071667 // [Note-Type-error-reporting]
18081668 // An invariant is that anytime the expected or actual type is Error (the special
18091669 // error type, meaning that an error occurred when typechecking this expression),
0 commit comments