@@ -149,13 +149,13 @@ trait TypeOpInfo<'tcx> {
149
149
150
150
fn base_universe ( & self ) -> ty:: UniverseIndex ;
151
151
152
- fn nice_error (
152
+ fn nice_error < ' cx > (
153
153
& self ,
154
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
154
+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
155
155
cause : ObligationCause < ' tcx > ,
156
156
placeholder_region : ty:: Region < ' tcx > ,
157
157
error_region : Option < ty:: Region < ' tcx > > ,
158
- ) -> Option < Diag < ' tcx > > ;
158
+ ) -> Option < Diag < ' cx > > ;
159
159
160
160
#[ instrument( level = "debug" , skip( self , mbcx) ) ]
161
161
fn report_error (
@@ -231,18 +231,25 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
231
231
self . base_universe
232
232
}
233
233
234
- fn nice_error (
234
+ fn nice_error < ' cx > (
235
235
& self ,
236
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
236
+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
237
237
cause : ObligationCause < ' tcx > ,
238
238
placeholder_region : ty:: Region < ' tcx > ,
239
239
error_region : Option < ty:: Region < ' tcx > > ,
240
- ) -> Option < Diag < ' tcx > > {
240
+ ) -> Option < Diag < ' cx > > {
241
241
let ( infcx, key, _) =
242
242
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
243
243
let ocx = ObligationCtxt :: new ( & infcx) ;
244
244
type_op_prove_predicate_with_cause ( & ocx, key, cause) ;
245
- try_extract_error_from_fulfill_cx ( & ocx, mbcx. mir_def_id ( ) , placeholder_region, error_region)
245
+ let diag = try_extract_error_from_fulfill_cx (
246
+ & ocx,
247
+ mbcx. mir_def_id ( ) ,
248
+ placeholder_region,
249
+ error_region,
250
+ ) ?
251
+ . with_dcx ( mbcx. dcx ( ) ) ;
252
+ Some ( diag)
246
253
}
247
254
}
248
255
@@ -268,13 +275,13 @@ where
268
275
self . base_universe
269
276
}
270
277
271
- fn nice_error (
278
+ fn nice_error < ' cx > (
272
279
& self ,
273
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
280
+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
274
281
cause : ObligationCause < ' tcx > ,
275
282
placeholder_region : ty:: Region < ' tcx > ,
276
283
error_region : Option < ty:: Region < ' tcx > > ,
277
- ) -> Option < Diag < ' tcx > > {
284
+ ) -> Option < Diag < ' cx > > {
278
285
let ( infcx, key, _) =
279
286
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
280
287
let ocx = ObligationCtxt :: new ( & infcx) ;
@@ -288,7 +295,14 @@ where
288
295
let ( param_env, value) = key. into_parts ( ) ;
289
296
let _ = ocx. normalize ( & cause, param_env, value. value ) ;
290
297
291
- try_extract_error_from_fulfill_cx ( & ocx, mbcx. mir_def_id ( ) , placeholder_region, error_region)
298
+ let diag = try_extract_error_from_fulfill_cx (
299
+ & ocx,
300
+ mbcx. mir_def_id ( ) ,
301
+ placeholder_region,
302
+ error_region,
303
+ ) ?
304
+ . with_dcx ( mbcx. dcx ( ) ) ;
305
+ Some ( diag)
292
306
}
293
307
}
294
308
@@ -308,18 +322,25 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
308
322
self . base_universe
309
323
}
310
324
311
- fn nice_error (
325
+ fn nice_error < ' cx > (
312
326
& self ,
313
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
327
+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
314
328
cause : ObligationCause < ' tcx > ,
315
329
placeholder_region : ty:: Region < ' tcx > ,
316
330
error_region : Option < ty:: Region < ' tcx > > ,
317
- ) -> Option < Diag < ' tcx > > {
331
+ ) -> Option < Diag < ' cx > > {
318
332
let ( infcx, key, _) =
319
333
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
320
334
let ocx = ObligationCtxt :: new ( & infcx) ;
321
335
type_op_ascribe_user_type_with_span ( & ocx, key, Some ( cause. span ) ) . ok ( ) ?;
322
- try_extract_error_from_fulfill_cx ( & ocx, mbcx. mir_def_id ( ) , placeholder_region, error_region)
336
+ let diag = try_extract_error_from_fulfill_cx (
337
+ & ocx,
338
+ mbcx. mir_def_id ( ) ,
339
+ placeholder_region,
340
+ error_region,
341
+ ) ?
342
+ . with_dcx ( mbcx. dcx ( ) ) ;
343
+ Some ( diag)
323
344
}
324
345
}
325
346
@@ -334,13 +355,13 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
334
355
self . base_universe . unwrap ( )
335
356
}
336
357
337
- fn nice_error (
358
+ fn nice_error < ' cx > (
338
359
& self ,
339
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
360
+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
340
361
_cause : ObligationCause < ' tcx > ,
341
362
placeholder_region : ty:: Region < ' tcx > ,
342
363
error_region : Option < ty:: Region < ' tcx > > ,
343
- ) -> Option < Diag < ' tcx > > {
364
+ ) -> Option < Diag < ' cx > > {
344
365
try_extract_error_from_region_constraints (
345
366
mbcx. infcx ,
346
367
mbcx. mir_def_id ( ) ,
@@ -358,12 +379,12 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
358
379
}
359
380
360
381
#[ instrument( skip( ocx) , level = "debug" ) ]
361
- fn try_extract_error_from_fulfill_cx < ' tcx > (
362
- ocx : & ObligationCtxt < ' _ , ' tcx > ,
382
+ fn try_extract_error_from_fulfill_cx < ' a , ' tcx > (
383
+ ocx : & ObligationCtxt < ' a , ' tcx > ,
363
384
generic_param_scope : LocalDefId ,
364
385
placeholder_region : ty:: Region < ' tcx > ,
365
386
error_region : Option < ty:: Region < ' tcx > > ,
366
- ) -> Option < Diag < ' tcx > > {
387
+ ) -> Option < Diag < ' a > > {
367
388
// We generally shouldn't have errors here because the query was
368
389
// already run, but there's no point using `span_delayed_bug`
369
390
// when we're going to emit an error here anyway.
@@ -381,15 +402,15 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
381
402
}
382
403
383
404
#[ instrument( level = "debug" , skip( infcx, region_var_origin, universe_of_region) ) ]
384
- fn try_extract_error_from_region_constraints < ' tcx > (
385
- infcx : & InferCtxt < ' tcx > ,
405
+ fn try_extract_error_from_region_constraints < ' a , ' tcx > (
406
+ infcx : & ' a InferCtxt < ' tcx > ,
386
407
generic_param_scope : LocalDefId ,
387
408
placeholder_region : ty:: Region < ' tcx > ,
388
409
error_region : Option < ty:: Region < ' tcx > > ,
389
410
region_constraints : & RegionConstraintData < ' tcx > ,
390
411
mut region_var_origin : impl FnMut ( RegionVid ) -> RegionVariableOrigin ,
391
412
mut universe_of_region : impl FnMut ( RegionVid ) -> UniverseIndex ,
392
- ) -> Option < Diag < ' tcx > > {
413
+ ) -> Option < Diag < ' a > > {
393
414
let placeholder_universe = match placeholder_region. kind ( ) {
394
415
ty:: RePlaceholder ( p) => p. universe ,
395
416
ty:: ReVar ( vid) => universe_of_region ( vid) ,
0 commit comments