@@ -56,7 +56,7 @@ impl<'tcx> UniverseInfo<'tcx> {
56
56
) {
57
57
match self . 0 {
58
58
UniverseInfoInner :: RelateTys { expected, found } => {
59
- let err = mbcx. infcx . report_mismatched_types (
59
+ let err = mbcx. infcx . err_ctxt ( ) . report_mismatched_types (
60
60
& cause,
61
61
expected,
62
62
found,
@@ -238,20 +238,11 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
238
238
placeholder_region : ty:: Region < ' tcx > ,
239
239
error_region : Option < ty:: Region < ' tcx > > ,
240
240
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
241
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
242
- cause. span ,
243
- & self . canonical_query ,
244
- |ref infcx, key, _| {
245
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
246
- type_op_prove_predicate_with_cause ( infcx, & mut * fulfill_cx, key, cause) ;
247
- try_extract_error_from_fulfill_cx (
248
- fulfill_cx,
249
- infcx,
250
- placeholder_region,
251
- error_region,
252
- )
253
- } ,
254
- )
241
+ let ( ref infcx, key, _) =
242
+ mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
243
+ let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
244
+ type_op_prove_predicate_with_cause ( infcx, & mut * fulfill_cx, key, cause) ;
245
+ try_extract_error_from_fulfill_cx ( fulfill_cx, infcx, placeholder_region, error_region)
255
246
}
256
247
}
257
248
@@ -288,37 +279,24 @@ where
288
279
placeholder_region : ty:: Region < ' tcx > ,
289
280
error_region : Option < ty:: Region < ' tcx > > ,
290
281
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
291
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
292
- cause. span ,
293
- & self . canonical_query ,
294
- |ref infcx, key, _| {
295
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
296
-
297
- let mut selcx = SelectionContext :: new ( infcx) ;
298
-
299
- // FIXME(lqd): Unify and de-duplicate the following with the actual
300
- // `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
301
- // `ObligationCause`. The normalization results are currently different between
302
- // `AtExt::normalize` used in the query and `normalize` called below: the former fails
303
- // to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test. Check
304
- // after #85499 lands to see if its fixes have erased this difference.
305
- let ( param_env, value) = key. into_parts ( ) ;
306
- let Normalized { value : _, obligations } = rustc_trait_selection:: traits:: normalize (
307
- & mut selcx,
308
- param_env,
309
- cause,
310
- value. value ,
311
- ) ;
312
- fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
313
-
314
- try_extract_error_from_fulfill_cx (
315
- fulfill_cx,
316
- infcx,
317
- placeholder_region,
318
- error_region,
319
- )
320
- } ,
321
- )
282
+ let ( ref infcx, key, _) =
283
+ mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
284
+ let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
285
+
286
+ let mut selcx = SelectionContext :: new ( infcx) ;
287
+
288
+ // FIXME(lqd): Unify and de-duplicate the following with the actual
289
+ // `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
290
+ // `ObligationCause`. The normalization results are currently different between
291
+ // `AtExt::normalize` used in the query and `normalize` called below: the former fails
292
+ // to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test. Check
293
+ // after #85499 lands to see if its fixes have erased this difference.
294
+ let ( param_env, value) = key. into_parts ( ) ;
295
+ let Normalized { value : _, obligations } =
296
+ rustc_trait_selection:: traits:: normalize ( & mut selcx, param_env, cause, value. value ) ;
297
+ fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
298
+
299
+ try_extract_error_from_fulfill_cx ( fulfill_cx, infcx, placeholder_region, error_region)
322
300
}
323
301
}
324
302
@@ -349,21 +327,11 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
349
327
placeholder_region : ty:: Region < ' tcx > ,
350
328
error_region : Option < ty:: Region < ' tcx > > ,
351
329
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
352
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
353
- cause. span ,
354
- & self . canonical_query ,
355
- |ref infcx, key, _| {
356
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
357
- type_op_ascribe_user_type_with_span ( infcx, & mut * fulfill_cx, key, Some ( cause. span ) )
358
- . ok ( ) ?;
359
- try_extract_error_from_fulfill_cx (
360
- fulfill_cx,
361
- infcx,
362
- placeholder_region,
363
- error_region,
364
- )
365
- } ,
366
- )
330
+ let ( ref infcx, key, _) =
331
+ mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
332
+ let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
333
+ type_op_ascribe_user_type_with_span ( infcx, & mut * fulfill_cx, key, Some ( cause. span ) ) . ok ( ) ?;
334
+ try_extract_error_from_fulfill_cx ( fulfill_cx, infcx, placeholder_region, error_region)
367
335
}
368
336
}
369
337
@@ -407,7 +375,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
407
375
#[ instrument( skip( fulfill_cx, infcx) , level = "debug" ) ]
408
376
fn try_extract_error_from_fulfill_cx < ' tcx > (
409
377
mut fulfill_cx : Box < dyn TraitEngine < ' tcx > + ' tcx > ,
410
- infcx : & InferCtxt < ' _ , ' tcx > ,
378
+ infcx : & InferCtxt < ' tcx > ,
411
379
placeholder_region : ty:: Region < ' tcx > ,
412
380
error_region : Option < ty:: Region < ' tcx > > ,
413
381
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
@@ -427,7 +395,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
427
395
}
428
396
429
397
fn try_extract_error_from_region_constraints < ' tcx > (
430
- infcx : & InferCtxt < ' _ , ' tcx > ,
398
+ infcx : & InferCtxt < ' tcx > ,
431
399
placeholder_region : ty:: Region < ' tcx > ,
432
400
error_region : Option < ty:: Region < ' tcx > > ,
433
401
region_constraints : & RegionConstraintData < ' tcx > ,
@@ -449,42 +417,38 @@ fn try_extract_error_from_region_constraints<'tcx>(
449
417
} ) ?;
450
418
451
419
debug ! ( ?sub_region, "cause = {:#?}" , cause) ;
452
- let nice_error = match ( error_region, * sub_region) {
453
- ( Some ( error_region) , ty:: ReVar ( vid) ) => NiceRegionError :: new (
454
- infcx,
455
- RegionResolutionError :: SubSupConflict (
456
- vid,
457
- region_var_origin ( vid) ,
458
- cause. clone ( ) ,
459
- error_region,
460
- cause. clone ( ) ,
461
- placeholder_region,
462
- vec ! [ ] ,
463
- ) ,
464
- ) ,
465
- ( Some ( error_region) , _) => NiceRegionError :: new (
466
- infcx,
467
- RegionResolutionError :: ConcreteFailure ( cause. clone ( ) , error_region, placeholder_region) ,
420
+ let error = match ( error_region, * sub_region) {
421
+ ( Some ( error_region) , ty:: ReVar ( vid) ) => RegionResolutionError :: SubSupConflict (
422
+ vid,
423
+ region_var_origin ( vid) ,
424
+ cause. clone ( ) ,
425
+ error_region,
426
+ cause. clone ( ) ,
427
+ placeholder_region,
428
+ vec ! [ ] ,
468
429
) ,
430
+ ( Some ( error_region) , _) => {
431
+ RegionResolutionError :: ConcreteFailure ( cause. clone ( ) , error_region, placeholder_region)
432
+ }
469
433
// Note universe here is wrong...
470
- ( None , ty:: ReVar ( vid) ) => NiceRegionError :: new (
471
- infcx,
472
- RegionResolutionError :: UpperBoundUniverseConflict (
473
- vid,
474
- region_var_origin ( vid) ,
475
- universe_of_region ( vid) ,
476
- cause. clone ( ) ,
477
- placeholder_region,
478
- ) ,
479
- ) ,
480
- ( None , _) => NiceRegionError :: new (
481
- infcx,
482
- RegionResolutionError :: ConcreteFailure ( cause. clone ( ) , sub_region, placeholder_region) ,
434
+ ( None , ty:: ReVar ( vid) ) => RegionResolutionError :: UpperBoundUniverseConflict (
435
+ vid,
436
+ region_var_origin ( vid) ,
437
+ universe_of_region ( vid) ,
438
+ cause. clone ( ) ,
439
+ placeholder_region,
483
440
) ,
441
+ ( None , _) => {
442
+ RegionResolutionError :: ConcreteFailure ( cause. clone ( ) , sub_region, placeholder_region)
443
+ }
484
444
} ;
485
- nice_error . try_report_from_nll ( ) . or_else ( || {
445
+ NiceRegionError :: new ( & infcx . err_ctxt ( ) , error ) . try_report_from_nll ( ) . or_else ( || {
486
446
if let SubregionOrigin :: Subtype ( trace) = cause {
487
- Some ( infcx. report_and_explain_type_error ( * trace, TypeError :: RegionsPlaceholderMismatch ) )
447
+ Some (
448
+ infcx
449
+ . err_ctxt ( )
450
+ . report_and_explain_type_error ( * trace, TypeError :: RegionsPlaceholderMismatch ) ,
451
+ )
488
452
} else {
489
453
None
490
454
}
0 commit comments