@@ -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 ;
@@ -731,10 +729,12 @@ fn ty_known_to_outlive<'tcx>(
731729 ty : Ty < ' tcx > ,
732730 region : ty:: Region < ' tcx > ,
733731) -> 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 ) ;
732+ test_region_obligations ( tcx, id, param_env, wf_tys, |infcx| {
733+ infcx. register_region_obligation ( infer:: RegionObligation {
734+ sub_region : region,
735+ sup_type : ty,
736+ origin : infer:: RelateParamBound ( DUMMY_SP , ty, None ) ,
737+ } ) ;
738738 } )
739739}
740740
@@ -748,40 +748,32 @@ fn region_known_to_outlive<'tcx>(
748748 region_a : ty:: Region < ' tcx > ,
749749 region_b : ty:: Region < ' tcx > ,
750750) -> 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- ) ;
751+ test_region_obligations ( tcx, id, param_env, wf_tys, |infcx| {
752+ infcx. sub_regions ( infer:: RelateRegionParamBound ( DUMMY_SP ) , region_b, region_a) ;
761753 } )
762754}
763755
764756/// Given a known `param_env` and a set of well formed types, set up an
765757/// `InferCtxt`, call the passed function (to e.g. set up region constraints
766758/// to be tested), then resolve region and return errors
767- fn resolve_regions_with_wf_tys < ' tcx > (
759+ fn test_region_obligations < ' tcx > (
768760 tcx : TyCtxt < ' tcx > ,
769761 id : LocalDefId ,
770762 param_env : ty:: ParamEnv < ' tcx > ,
771763 wf_tys : & FxIndexSet < Ty < ' tcx > > ,
772- add_constraints : impl for < ' a > FnOnce ( & ' a InferCtxt < ' tcx > , & ' a RegionBoundPairs < ' tcx > ) ,
764+ add_constraints : impl FnOnce ( & InferCtxt < ' tcx > ) ,
773765) -> bool {
774766 // Unfortunately, we have to use a new `InferCtxt` each call, because
775767 // region constraints get added and solved there and we need to test each
776768 // call individually.
777769 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
770+
771+ add_constraints ( & infcx) ;
772+
778773 let outlives_environment = OutlivesEnvironment :: with_bounds (
779774 param_env,
780775 infcx. implied_bounds_tys ( param_env, id, wf_tys) ,
781776 ) ;
782- let region_bound_pairs = outlives_environment. region_bound_pairs ( ) ;
783-
784- add_constraints ( & infcx, region_bound_pairs) ;
785777
786778 let errors = infcx. resolve_regions ( & outlives_environment) ;
787779 debug ! ( ?errors, "errors" ) ;
0 commit comments