@@ -488,7 +488,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
488
488
let remaining_errors_if_fallback_to = |fallback| {
489
489
self . probe ( |_| {
490
490
let obligations = self . fulfillment_cx . borrow ( ) . pending_obligations ( ) ;
491
- let ocx = ObligationCtxt :: new ( & self . infcx ) ;
491
+ let ocx = ObligationCtxt :: new_with_diagnostics ( & self . infcx ) ;
492
492
ocx. register_obligations ( obligations. iter ( ) . cloned ( ) ) ;
493
493
494
494
for & diverging_vid in diverging_vids {
@@ -506,14 +506,18 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
506
506
// then this code will be broken by the never type fallback change.qba
507
507
let unit_errors = remaining_errors_if_fallback_to ( self . tcx . types . unit ) ;
508
508
if unit_errors. is_empty ( )
509
- && let never_errors = remaining_errors_if_fallback_to ( self . tcx . types . never )
510
- && ! never_errors. is_empty ( )
509
+ && let mut never_errors = remaining_errors_if_fallback_to ( self . tcx . types . never )
510
+ && let [ ref mut never_error , .. ] = never_errors. as_mut_slice ( )
511
511
{
512
+ self . adjust_fulfillment_error_for_expr_obligation ( never_error) ;
512
513
self . tcx . emit_node_span_lint (
513
514
lint:: builtin:: DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK ,
514
515
self . tcx . local_def_id_to_hir_id ( self . body_id ) ,
515
516
self . tcx . def_span ( self . body_id ) ,
516
- errors:: DependencyOnUnitNeverTypeFallback { } ,
517
+ errors:: DependencyOnUnitNeverTypeFallback {
518
+ obligation_span : never_error. obligation . cause . span ,
519
+ obligation : never_error. obligation . predicate ,
520
+ } ,
517
521
)
518
522
}
519
523
}
0 commit comments