@@ -63,6 +63,7 @@ use crate::hir;
6363use crate :: infer:: outlives:: env:: RegionBoundPairs ;
6464use crate :: infer:: outlives:: verify:: VerifyBoundCx ;
6565use crate :: infer:: { self , GenericKind , InferCtxt , RegionObligation , SubregionOrigin , VerifyBound } ;
66+ use crate :: traits;
6667use crate :: traits:: ObligationCause ;
6768use crate :: ty:: outlives:: Component ;
6869use crate :: ty:: subst:: GenericArgKind ;
@@ -154,6 +155,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
154155
155156 let my_region_obligations = self . take_registered_region_obligations ( ) ;
156157
158+ let mut elaborator = traits:: Elaborator :: new ( self . tcx ) ;
159+
157160 for ( body_id, RegionObligation { sup_type, sub_region, origin } ) in my_region_obligations {
158161 debug ! (
159162 "process_registered_region_obligations: sup_type={:?} sub_region={:?} origin={:?}" ,
@@ -169,6 +172,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
169172 & region_bound_pairs,
170173 implicit_region_bound,
171174 param_env,
175+ & mut elaborator,
172176 ) ;
173177 outlives. type_must_outlive ( origin, sup_type, sub_region) ;
174178 } else {
@@ -191,15 +195,16 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
191195 ty : Ty < ' tcx > ,
192196 region : ty:: Region < ' tcx > ,
193197 ) {
194- let outlives = & mut TypeOutlives :: new (
198+ let ty = self . resolve_vars_if_possible ( & ty) ;
199+ TypeOutlives :: new (
195200 self ,
196201 self . tcx ,
197202 region_bound_pairs,
198203 implicit_region_bound,
199204 param_env,
200- ) ;
201- let ty = self . resolve_vars_if_possible ( & ty ) ;
202- outlives . type_must_outlive ( origin, ty, region) ;
205+ & mut traits :: Elaborator :: new ( self . tcx ) ,
206+ )
207+ . type_must_outlive ( origin, ty, region) ;
203208 }
204209}
205210
@@ -209,15 +214,15 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
209214/// via a "delegate" of type `D` -- this is usually the `infcx`, which
210215/// accrues them into the `region_obligations` code, but for NLL we
211216/// use something else.
212- pub struct TypeOutlives < ' cx , ' tcx , D >
217+ pub struct TypeOutlives < ' cx , ' tcx , ' e , D >
213218where
214219 D : TypeOutlivesDelegate < ' tcx > ,
215220{
216221 // See the comments on `process_registered_region_obligations` for the meaning
217222 // of these fields.
218223 delegate : D ,
219224 tcx : TyCtxt < ' tcx > ,
220- verify_bound : VerifyBoundCx < ' cx , ' tcx > ,
225+ verify_bound : VerifyBoundCx < ' cx , ' tcx , ' e > ,
221226}
222227
223228pub trait TypeOutlivesDelegate < ' tcx > {
@@ -237,7 +242,7 @@ pub trait TypeOutlivesDelegate<'tcx> {
237242 ) ;
238243}
239244
240- impl < ' cx , ' tcx , D > TypeOutlives < ' cx , ' tcx , D >
245+ impl < ' cx , ' tcx , ' e , D > TypeOutlives < ' cx , ' tcx , ' e , D >
241246where
242247 D : TypeOutlivesDelegate < ' tcx > ,
243248{
@@ -247,6 +252,7 @@ where
247252 region_bound_pairs : & ' cx RegionBoundPairs < ' tcx > ,
248253 implicit_region_bound : Option < ty:: Region < ' tcx > > ,
249254 param_env : ty:: ParamEnv < ' tcx > ,
255+ elaborator : & ' e mut traits:: Elaborator < ' tcx > ,
250256 ) -> Self {
251257 Self {
252258 delegate,
@@ -256,6 +262,7 @@ where
256262 region_bound_pairs,
257263 implicit_region_bound,
258264 param_env,
265+ elaborator,
259266 ) ,
260267 }
261268 }
@@ -273,7 +280,9 @@ where
273280 origin : infer:: SubregionOrigin < ' tcx > ,
274281 ty : Ty < ' tcx > ,
275282 region : ty:: Region < ' tcx > ,
276- ) {
283+ ) where
284+ ' tcx : ' e ,
285+ {
277286 debug ! ( "type_must_outlive(ty={:?}, region={:?}, origin={:?})" , ty, region, origin) ;
278287
279288 assert ! ( !ty. has_escaping_bound_vars( ) ) ;
@@ -288,7 +297,9 @@ where
288297 origin : infer:: SubregionOrigin < ' tcx > ,
289298 components : & [ Component < ' tcx > ] ,
290299 region : ty:: Region < ' tcx > ,
291- ) {
300+ ) where
301+ ' tcx : ' e ,
302+ {
292303 for component in components {
293304 let origin = origin. clone ( ) ;
294305 match component {
@@ -338,7 +349,9 @@ where
338349 origin : infer:: SubregionOrigin < ' tcx > ,
339350 region : ty:: Region < ' tcx > ,
340351 projection_ty : ty:: ProjectionTy < ' tcx > ,
341- ) {
352+ ) where
353+ ' tcx : ' e ,
354+ {
342355 debug ! (
343356 "projection_must_outlive(region={:?}, projection_ty={:?}, origin={:?})" ,
344357 region, projection_ty, origin
0 commit comments