@@ -149,13 +149,13 @@ trait TypeOpInfo<'tcx> {
149149
150150 fn base_universe ( & self ) -> ty:: UniverseIndex ;
151151
152- fn nice_error (
152+ fn nice_error < ' cx > (
153153 & self ,
154- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
154+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
155155 cause : ObligationCause < ' tcx > ,
156156 placeholder_region : ty:: Region < ' tcx > ,
157157 error_region : Option < ty:: Region < ' tcx > > ,
158- ) -> Option < Diag < ' tcx > > ;
158+ ) -> Option < Diag < ' cx > > ;
159159
160160 #[ instrument( level = "debug" , skip( self , mbcx) ) ]
161161 fn report_error (
@@ -231,18 +231,25 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
231231 self . base_universe
232232 }
233233
234- fn nice_error (
234+ fn nice_error < ' cx > (
235235 & self ,
236- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
236+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
237237 cause : ObligationCause < ' tcx > ,
238238 placeholder_region : ty:: Region < ' tcx > ,
239239 error_region : Option < ty:: Region < ' tcx > > ,
240- ) -> Option < Diag < ' tcx > > {
240+ ) -> Option < Diag < ' cx > > {
241241 let ( infcx, key, _) =
242242 mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
243243 let ocx = ObligationCtxt :: new ( & infcx) ;
244244 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)
246253 }
247254}
248255
@@ -268,13 +275,13 @@ where
268275 self . base_universe
269276 }
270277
271- fn nice_error (
278+ fn nice_error < ' cx > (
272279 & self ,
273- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
280+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
274281 cause : ObligationCause < ' tcx > ,
275282 placeholder_region : ty:: Region < ' tcx > ,
276283 error_region : Option < ty:: Region < ' tcx > > ,
277- ) -> Option < Diag < ' tcx > > {
284+ ) -> Option < Diag < ' cx > > {
278285 let ( infcx, key, _) =
279286 mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
280287 let ocx = ObligationCtxt :: new ( & infcx) ;
@@ -288,7 +295,14 @@ where
288295 let ( param_env, value) = key. into_parts ( ) ;
289296 let _ = ocx. normalize ( & cause, param_env, value. value ) ;
290297
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)
292306 }
293307}
294308
@@ -308,18 +322,25 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
308322 self . base_universe
309323 }
310324
311- fn nice_error (
325+ fn nice_error < ' cx > (
312326 & self ,
313- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
327+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
314328 cause : ObligationCause < ' tcx > ,
315329 placeholder_region : ty:: Region < ' tcx > ,
316330 error_region : Option < ty:: Region < ' tcx > > ,
317- ) -> Option < Diag < ' tcx > > {
331+ ) -> Option < Diag < ' cx > > {
318332 let ( infcx, key, _) =
319333 mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
320334 let ocx = ObligationCtxt :: new ( & infcx) ;
321335 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)
323344 }
324345}
325346
@@ -334,13 +355,13 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
334355 self . base_universe . unwrap ( )
335356 }
336357
337- fn nice_error (
358+ fn nice_error < ' cx > (
338359 & self ,
339- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' _ , ' tcx > ,
360+ mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' cx , ' tcx > ,
340361 _cause : ObligationCause < ' tcx > ,
341362 placeholder_region : ty:: Region < ' tcx > ,
342363 error_region : Option < ty:: Region < ' tcx > > ,
343- ) -> Option < Diag < ' tcx > > {
364+ ) -> Option < Diag < ' cx > > {
344365 try_extract_error_from_region_constraints (
345366 mbcx. infcx ,
346367 mbcx. mir_def_id ( ) ,
@@ -358,12 +379,12 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
358379}
359380
360381#[ 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 > ,
363384 generic_param_scope : LocalDefId ,
364385 placeholder_region : ty:: Region < ' tcx > ,
365386 error_region : Option < ty:: Region < ' tcx > > ,
366- ) -> Option < Diag < ' tcx > > {
387+ ) -> Option < Diag < ' a > > {
367388 // We generally shouldn't have errors here because the query was
368389 // already run, but there's no point using `span_delayed_bug`
369390 // when we're going to emit an error here anyway.
@@ -381,15 +402,15 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
381402}
382403
383404#[ 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 > ,
386407 generic_param_scope : LocalDefId ,
387408 placeholder_region : ty:: Region < ' tcx > ,
388409 error_region : Option < ty:: Region < ' tcx > > ,
389410 region_constraints : & RegionConstraintData < ' tcx > ,
390411 mut region_var_origin : impl FnMut ( RegionVid ) -> RegionVariableOrigin ,
391412 mut universe_of_region : impl FnMut ( RegionVid ) -> UniverseIndex ,
392- ) -> Option < Diag < ' tcx > > {
413+ ) -> Option < Diag < ' a > > {
393414 let placeholder_universe = match placeholder_region. kind ( ) {
394415 ty:: RePlaceholder ( p) => p. universe ,
395416 ty:: ReVar ( vid) => universe_of_region ( vid) ,
0 commit comments