@@ -10,10 +10,8 @@ use rustc_hir as hir;
1010use  rustc_hir:: def_id:: { DefId ,  LocalDefId ,  LocalModDefId } ; 
1111use  rustc_hir:: lang_items:: LangItem ; 
1212use  rustc_hir:: ItemKind ; 
13- use  rustc_infer:: infer:: outlives:: env:: { OutlivesEnvironment ,  RegionBoundPairs } ; 
14- use  rustc_infer:: infer:: outlives:: obligations:: TypeOutlives ; 
13+ use  rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ; 
1514use  rustc_infer:: infer:: { self ,  InferCtxt ,  TyCtxtInferExt } ; 
16- use  rustc_middle:: mir:: ConstraintCategory ; 
1715use  rustc_middle:: query:: Providers ; 
1816use  rustc_middle:: ty:: print:: with_no_trimmed_paths; 
1917use  rustc_middle:: ty:: trait_def:: TraitSpecializationKind ; 
@@ -26,6 +24,7 @@ use rustc_session::parse::feature_err;
2624use  rustc_span:: symbol:: { sym,  Ident ,  Symbol } ; 
2725use  rustc_span:: { Span ,  DUMMY_SP } ; 
2826use  rustc_target:: spec:: abi:: Abi ; 
27+ use  rustc_trait_selection:: regions:: InferCtxtRegionExt ; 
2928use  rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt ; 
3029use  rustc_trait_selection:: traits:: misc:: { 
3130    type_allowed_to_implement_const_param_ty,  ConstParamTyImplementationError , 
@@ -136,7 +135,7 @@ where
136135        infcx. implied_bounds_tys_compat ( param_env,  body_def_id,  & assumed_wf_types,  false ) ; 
137136    let  outlives_env = OutlivesEnvironment :: with_bounds ( param_env,  implied_bounds) ; 
138137
139-     let  errors = infcx. resolve_regions ( & outlives_env) ; 
138+     let  errors = infcx. resolve_regions_normalizing_outlives_obligations ( & outlives_env) ; 
140139    if  errors. is_empty ( )  { 
141140        return  Ok ( ( ) ) ; 
142141    } 
@@ -177,7 +176,8 @@ where
177176        let  implied_bounds =
178177            infcx_compat. implied_bounds_tys_compat ( param_env,  body_def_id,  & assumed_wf_types,  true ) ; 
179178        let  outlives_env = OutlivesEnvironment :: with_bounds ( param_env,  implied_bounds) ; 
180-         let  errors_compat = infcx_compat. resolve_regions ( & outlives_env) ; 
179+         let  errors_compat =
180+             infcx_compat. resolve_regions_normalizing_outlives_obligations ( & outlives_env) ; 
181181        if  errors_compat. is_empty ( )  { 
182182            Ok ( ( ) ) 
183183        }  else  { 
@@ -731,10 +731,12 @@ fn ty_known_to_outlive<'tcx>(
731731    ty :  Ty < ' tcx > , 
732732    region :  ty:: Region < ' tcx > , 
733733)  -> bool  { 
734-     resolve_regions_with_wf_tys ( tcx,  id,  param_env,  wf_tys,  |infcx,  region_bound_pairs| { 
735-         let  origin = infer:: RelateParamBound ( DUMMY_SP ,  ty,  None ) ; 
736-         let  outlives = & mut  TypeOutlives :: new ( infcx,  tcx,  region_bound_pairs,  None ,  param_env) ; 
737-         outlives. type_must_outlive ( origin,  ty,  region,  ConstraintCategory :: BoringNoLocation ) ; 
734+     test_region_obligations ( tcx,  id,  param_env,  wf_tys,  |infcx| { 
735+         infcx. register_region_obligation ( infer:: RegionObligation  { 
736+             sub_region :  region, 
737+             sup_type :  ty, 
738+             origin :  infer:: RelateParamBound ( DUMMY_SP ,  ty,  None ) , 
739+         } ) ; 
738740    } ) 
739741} 
740742
@@ -748,42 +750,34 @@ fn region_known_to_outlive<'tcx>(
748750    region_a :  ty:: Region < ' tcx > , 
749751    region_b :  ty:: Region < ' tcx > , 
750752)  -> bool  { 
751-     resolve_regions_with_wf_tys ( tcx,  id,  param_env,  wf_tys,  |mut  infcx,  _| { 
752-         use  rustc_infer:: infer:: outlives:: obligations:: TypeOutlivesDelegate ; 
753-         let  origin = infer:: RelateRegionParamBound ( DUMMY_SP ) ; 
754-         // `region_a: region_b` -> `region_b <= region_a` 
755-         infcx. push_sub_region_constraint ( 
756-             origin, 
757-             region_b, 
758-             region_a, 
759-             ConstraintCategory :: BoringNoLocation , 
760-         ) ; 
753+     test_region_obligations ( tcx,  id,  param_env,  wf_tys,  |infcx| { 
754+         infcx. sub_regions ( infer:: RelateRegionParamBound ( DUMMY_SP ) ,  region_b,  region_a) ; 
761755    } ) 
762756} 
763757
764758/// Given a known `param_env` and a set of well formed types, set up an 
765759/// `InferCtxt`, call the passed function (to e.g. set up region constraints 
766760/// to be tested), then resolve region and return errors 
767- fn  resolve_regions_with_wf_tys < ' tcx > ( 
761+ fn  test_region_obligations < ' tcx > ( 
768762    tcx :  TyCtxt < ' tcx > , 
769763    id :  LocalDefId , 
770764    param_env :  ty:: ParamEnv < ' tcx > , 
771765    wf_tys :  & FxIndexSet < Ty < ' tcx > > , 
772-     add_constraints :  impl  for < ' a >   FnOnce ( & ' a   InferCtxt < ' tcx > ,   & ' a   RegionBoundPairs < ' tcx > ) , 
766+     add_constraints :  impl  FnOnce ( & InferCtxt < ' tcx > ) , 
773767)  -> bool  { 
774768    // Unfortunately, we have to use a new `InferCtxt` each call, because 
775769    // region constraints get added and solved there and we need to test each 
776770    // call individually. 
777771    let  infcx = tcx. infer_ctxt ( ) . build ( ) ; 
772+ 
773+     add_constraints ( & infcx) ; 
774+ 
778775    let  outlives_environment = OutlivesEnvironment :: with_bounds ( 
779776        param_env, 
780777        infcx. implied_bounds_tys ( param_env,  id,  wf_tys) , 
781778    ) ; 
782-     let  region_bound_pairs = outlives_environment. region_bound_pairs ( ) ; 
783- 
784-     add_constraints ( & infcx,  region_bound_pairs) ; 
785779
786-     let  errors = infcx. resolve_regions ( & outlives_environment) ; 
780+     let  errors = infcx. resolve_regions_normalizing_outlives_obligations ( & outlives_environment) ; 
787781    debug ! ( ?errors,  "errors" ) ; 
788782
789783    // If we were able to prove that the type outlives the region without 
0 commit comments