@@ -8,10 +8,8 @@ use rustc_hir as hir;
88use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId } ;
99use rustc_hir:: lang_items:: LangItem ;
1010use rustc_hir:: ItemKind ;
11- use rustc_infer:: infer:: outlives:: env:: { OutlivesEnvironment , RegionBoundPairs } ;
12- use rustc_infer:: infer:: outlives:: obligations:: TypeOutlives ;
11+ use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
1312use rustc_infer:: infer:: { self , InferCtxt , TyCtxtInferExt } ;
14- use rustc_middle:: mir:: ConstraintCategory ;
1513use rustc_middle:: query:: Providers ;
1614use rustc_middle:: ty:: trait_def:: TraitSpecializationKind ;
1715use rustc_middle:: ty:: {
@@ -674,10 +672,12 @@ fn ty_known_to_outlive<'tcx>(
674672 ty : Ty < ' tcx > ,
675673 region : ty:: Region < ' tcx > ,
676674) -> bool {
677- resolve_regions_with_wf_tys ( tcx, id, param_env, wf_tys, |infcx, region_bound_pairs| {
678- let origin = infer:: RelateParamBound ( DUMMY_SP , ty, None ) ;
679- let outlives = & mut TypeOutlives :: new ( infcx, tcx, region_bound_pairs, None , param_env) ;
680- outlives. type_must_outlive ( origin, ty, region, ConstraintCategory :: BoringNoLocation ) ;
675+ test_region_obligations ( tcx, id, param_env, wf_tys, |infcx| {
676+ infcx. register_region_obligation ( infer:: RegionObligation {
677+ sub_region : region,
678+ sup_type : ty,
679+ origin : infer:: RelateParamBound ( DUMMY_SP , ty, None ) ,
680+ } ) ;
681681 } )
682682}
683683
@@ -691,40 +691,32 @@ fn region_known_to_outlive<'tcx>(
691691 region_a : ty:: Region < ' tcx > ,
692692 region_b : ty:: Region < ' tcx > ,
693693) -> bool {
694- resolve_regions_with_wf_tys ( tcx, id, param_env, wf_tys, |mut infcx, _| {
695- use rustc_infer:: infer:: outlives:: obligations:: TypeOutlivesDelegate ;
696- let origin = infer:: RelateRegionParamBound ( DUMMY_SP ) ;
697- // `region_a: region_b` -> `region_b <= region_a`
698- infcx. push_sub_region_constraint (
699- origin,
700- region_b,
701- region_a,
702- ConstraintCategory :: BoringNoLocation ,
703- ) ;
694+ test_region_obligations ( tcx, id, param_env, wf_tys, |infcx| {
695+ infcx. sub_regions ( infer:: RelateRegionParamBound ( DUMMY_SP ) , region_b, region_a) ;
704696 } )
705697}
706698
707699/// Given a known `param_env` and a set of well formed types, set up an
708700/// `InferCtxt`, call the passed function (to e.g. set up region constraints
709701/// to be tested), then resolve region and return errors
710- fn resolve_regions_with_wf_tys < ' tcx > (
702+ fn test_region_obligations < ' tcx > (
711703 tcx : TyCtxt < ' tcx > ,
712704 id : LocalDefId ,
713705 param_env : ty:: ParamEnv < ' tcx > ,
714706 wf_tys : & FxIndexSet < Ty < ' tcx > > ,
715- add_constraints : impl for < ' a > FnOnce ( & ' a InferCtxt < ' tcx > , & ' a RegionBoundPairs < ' tcx > ) ,
707+ add_constraints : impl FnOnce ( & InferCtxt < ' tcx > ) ,
716708) -> bool {
717709 // Unfortunately, we have to use a new `InferCtxt` each call, because
718710 // region constraints get added and solved there and we need to test each
719711 // call individually.
720712 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
713+
714+ add_constraints ( & infcx) ;
715+
721716 let outlives_environment = OutlivesEnvironment :: with_bounds (
722717 param_env,
723718 infcx. implied_bounds_tys ( param_env, id, wf_tys. clone ( ) ) ,
724719 ) ;
725- let region_bound_pairs = outlives_environment. region_bound_pairs ( ) ;
726-
727- add_constraints ( & infcx, region_bound_pairs) ;
728720
729721 let errors = infcx. resolve_regions_normalizing_outlives_obligations ( & outlives_environment) ;
730722 debug ! ( ?errors, "errors" ) ;
0 commit comments