@@ -63,6 +63,7 @@ use crate::hir;
63
63
use crate :: infer:: outlives:: env:: RegionBoundPairs ;
64
64
use crate :: infer:: outlives:: verify:: VerifyBoundCx ;
65
65
use crate :: infer:: { self , GenericKind , InferCtxt , RegionObligation , SubregionOrigin , VerifyBound } ;
66
+ use crate :: traits;
66
67
use crate :: traits:: ObligationCause ;
67
68
use crate :: ty:: outlives:: Component ;
68
69
use crate :: ty:: subst:: GenericArgKind ;
@@ -154,6 +155,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
154
155
155
156
let my_region_obligations = self . take_registered_region_obligations ( ) ;
156
157
158
+ let mut elaborator = traits:: Elaborator :: new ( self . tcx ) ;
159
+
157
160
for ( body_id, RegionObligation { sup_type, sub_region, origin } ) in my_region_obligations {
158
161
debug ! (
159
162
"process_registered_region_obligations: sup_type={:?} sub_region={:?} origin={:?}" ,
@@ -169,6 +172,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
169
172
& region_bound_pairs,
170
173
implicit_region_bound,
171
174
param_env,
175
+ & mut elaborator,
172
176
) ;
173
177
outlives. type_must_outlive ( origin, sup_type, sub_region) ;
174
178
} else {
@@ -191,15 +195,16 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
191
195
ty : Ty < ' tcx > ,
192
196
region : ty:: Region < ' tcx > ,
193
197
) {
194
- let outlives = & mut TypeOutlives :: new (
198
+ let ty = self . resolve_vars_if_possible ( & ty) ;
199
+ TypeOutlives :: new (
195
200
self ,
196
201
self . tcx ,
197
202
region_bound_pairs,
198
203
implicit_region_bound,
199
204
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) ;
203
208
}
204
209
}
205
210
@@ -209,15 +214,15 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
209
214
/// via a "delegate" of type `D` -- this is usually the `infcx`, which
210
215
/// accrues them into the `region_obligations` code, but for NLL we
211
216
/// use something else.
212
- pub struct TypeOutlives < ' cx , ' tcx , D >
217
+ pub struct TypeOutlives < ' cx , ' tcx , ' e , D >
213
218
where
214
219
D : TypeOutlivesDelegate < ' tcx > ,
215
220
{
216
221
// See the comments on `process_registered_region_obligations` for the meaning
217
222
// of these fields.
218
223
delegate : D ,
219
224
tcx : TyCtxt < ' tcx > ,
220
- verify_bound : VerifyBoundCx < ' cx , ' tcx > ,
225
+ verify_bound : VerifyBoundCx < ' cx , ' tcx , ' e > ,
221
226
}
222
227
223
228
pub trait TypeOutlivesDelegate < ' tcx > {
@@ -237,7 +242,7 @@ pub trait TypeOutlivesDelegate<'tcx> {
237
242
) ;
238
243
}
239
244
240
- impl < ' cx , ' tcx , D > TypeOutlives < ' cx , ' tcx , D >
245
+ impl < ' cx , ' tcx , ' e , D > TypeOutlives < ' cx , ' tcx , ' e , D >
241
246
where
242
247
D : TypeOutlivesDelegate < ' tcx > ,
243
248
{
@@ -247,6 +252,7 @@ where
247
252
region_bound_pairs : & ' cx RegionBoundPairs < ' tcx > ,
248
253
implicit_region_bound : Option < ty:: Region < ' tcx > > ,
249
254
param_env : ty:: ParamEnv < ' tcx > ,
255
+ elaborator : & ' e mut traits:: Elaborator < ' tcx > ,
250
256
) -> Self {
251
257
Self {
252
258
delegate,
@@ -256,6 +262,7 @@ where
256
262
region_bound_pairs,
257
263
implicit_region_bound,
258
264
param_env,
265
+ elaborator,
259
266
) ,
260
267
}
261
268
}
@@ -273,7 +280,9 @@ where
273
280
origin : infer:: SubregionOrigin < ' tcx > ,
274
281
ty : Ty < ' tcx > ,
275
282
region : ty:: Region < ' tcx > ,
276
- ) {
283
+ ) where
284
+ ' tcx : ' e ,
285
+ {
277
286
debug ! ( "type_must_outlive(ty={:?}, region={:?}, origin={:?})" , ty, region, origin) ;
278
287
279
288
assert ! ( !ty. has_escaping_bound_vars( ) ) ;
@@ -288,7 +297,9 @@ where
288
297
origin : infer:: SubregionOrigin < ' tcx > ,
289
298
components : & [ Component < ' tcx > ] ,
290
299
region : ty:: Region < ' tcx > ,
291
- ) {
300
+ ) where
301
+ ' tcx : ' e ,
302
+ {
292
303
for component in components {
293
304
let origin = origin. clone ( ) ;
294
305
match component {
@@ -338,7 +349,9 @@ where
338
349
origin : infer:: SubregionOrigin < ' tcx > ,
339
350
region : ty:: Region < ' tcx > ,
340
351
projection_ty : ty:: ProjectionTy < ' tcx > ,
341
- ) {
352
+ ) where
353
+ ' tcx : ' e ,
354
+ {
342
355
debug ! (
343
356
"projection_must_outlive(region={:?}, projection_ty={:?}, origin={:?})" ,
344
357
region, projection_ty, origin
0 commit comments