@@ -76,35 +76,37 @@ use crate::infer::outlives::env::RegionBoundPairs;
7676use crate :: infer:: outlives:: verify:: VerifyBoundCx ;
7777use crate :: infer:: resolve:: OpportunisticRegionResolver ;
7878use crate :: infer:: snapshot:: undo_log:: UndoLog ;
79- use crate :: infer:: { self , GenericKind , InferCtxt , RegionObligation , SubregionOrigin , VerifyBound } ;
79+ use crate :: infer:: {
80+ self , GenericKind , InferCtxt , SubregionOrigin , TypeOutlivesConstraint , VerifyBound ,
81+ } ;
8082use crate :: traits:: { ObligationCause , ObligationCauseCode } ;
8183
8284impl < ' tcx > InferCtxt < ' tcx > {
83- pub fn outlives_predicate_with_cause (
85+ pub fn register_outlives_constraint (
8486 & self ,
8587 ty:: OutlivesPredicate ( arg, r2) : ty:: OutlivesPredicate < ' tcx , ty:: GenericArg < ' tcx > > ,
8688 cause : & ObligationCause < ' tcx > ,
8789 ) {
8890 match arg. unpack ( ) {
8991 ty:: GenericArgKind :: Lifetime ( r1) => {
90- self . region_outlives_predicate ( ty:: OutlivesPredicate ( r1, r2) , cause) ;
92+ self . register_region_outlives_constraint ( ty:: OutlivesPredicate ( r1, r2) , cause) ;
9193 }
9294 ty:: GenericArgKind :: Type ( ty1) => {
93- self . type_outlives_predicate_with_cause ( ty1, r2, cause) ;
95+ self . register_type_outlives_constraint ( ty1, r2, cause) ;
9496 }
9597 ty:: GenericArgKind :: Const ( _) => unreachable ! ( ) ,
9698 }
9799 }
98100
99- pub fn region_outlives_predicate (
101+ pub fn register_region_outlives_constraint (
100102 & self ,
101103 ty:: OutlivesPredicate ( r_a, r_b) : ty:: RegionOutlivesPredicate < ' tcx > ,
102104 cause : & ObligationCause < ' tcx > ,
103105 ) {
104106 let origin = SubregionOrigin :: from_obligation_cause ( cause, || {
105107 SubregionOrigin :: RelateRegionParamBound ( cause. span , None )
106108 } ) ;
107- // `b : a ` ==> `a <= b `
109+ // `'a: 'b ` ==> `'b <= 'a `
108110 self . sub_regions ( origin, r_b, r_a) ;
109111 }
110112
@@ -114,13 +116,16 @@ impl<'tcx> InferCtxt<'tcx> {
114116 /// available (see `region_obligations` field for more
115117 /// information).
116118 #[ instrument( level = "debug" , skip( self ) ) ]
117- pub fn type_outlives_predicate ( & self , obligation : RegionObligation < ' tcx > ) {
119+ pub fn register_type_outlives_constraint_inner (
120+ & self ,
121+ obligation : TypeOutlivesConstraint < ' tcx > ,
122+ ) {
118123 let mut inner = self . inner . borrow_mut ( ) ;
119- inner. undo_log . push ( UndoLog :: PushRegionObligation ) ;
124+ inner. undo_log . push ( UndoLog :: PushTypeOutlivesConstraint ) ;
120125 inner. region_obligations . push ( obligation) ;
121126 }
122127
123- pub fn type_outlives_predicate_with_cause (
128+ pub fn register_type_outlives_constraint (
124129 & self ,
125130 sup_type : Ty < ' tcx > ,
126131 sub_region : Region < ' tcx > ,
@@ -152,11 +157,15 @@ impl<'tcx> InferCtxt<'tcx> {
152157 )
153158 } ) ;
154159
155- self . type_outlives_predicate ( RegionObligation { sup_type, sub_region, origin } ) ;
160+ self . register_type_outlives_constraint_inner ( TypeOutlivesConstraint {
161+ sup_type,
162+ sub_region,
163+ origin,
164+ } ) ;
156165 }
157166
158167 /// Trait queries just want to pass back type obligations "as is"
159- pub fn take_registered_region_obligations ( & self ) -> Vec < RegionObligation < ' tcx > > {
168+ pub fn take_registered_region_obligations ( & self ) -> Vec < TypeOutlivesConstraint < ' tcx > > {
160169 std:: mem:: take ( & mut self . inner . borrow_mut ( ) . region_obligations )
161170 }
162171
@@ -194,7 +203,7 @@ impl<'tcx> InferCtxt<'tcx> {
194203 ) ;
195204 }
196205
197- for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
206+ for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
198207 let outlives = ty:: Binder :: dummy ( ty:: OutlivesPredicate ( sup_type, sub_region) ) ;
199208 let ty:: OutlivesPredicate ( sup_type, sub_region) =
200209 deeply_normalize_ty ( outlives, origin. clone ( ) )
0 commit comments