@@ -424,7 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424
424
. map ( |vars| self . resolve_vars_if_possible ( vars) ) ,
425
425
) ;
426
426
427
- self . report_arg_errors (
427
+ self . set_tainted_by_errors ( self . report_arg_errors (
428
428
compatibility_diagonal,
429
429
formal_and_expected_inputs,
430
430
provided_args,
@@ -433,7 +433,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
433
433
fn_def_id,
434
434
call_span,
435
435
call_expr,
436
- ) ;
436
+ ) ) ;
437
437
}
438
438
}
439
439
@@ -447,7 +447,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
447
447
fn_def_id : Option < DefId > ,
448
448
call_span : Span ,
449
449
call_expr : & ' tcx hir:: Expr < ' tcx > ,
450
- ) {
450
+ ) -> ErrorGuaranteed {
451
451
// Next, let's construct the error
452
452
let ( error_span, full_call_span, call_name, is_method) = match & call_expr. kind {
453
453
hir:: ExprKind :: Call (
@@ -486,10 +486,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
486
486
}
487
487
488
488
let tcx = self . tcx ;
489
- // FIXME: taint after emitting errors and pass through an `ErrorGuaranteed`
490
- self . set_tainted_by_errors (
491
- tcx. dcx ( ) . span_delayed_bug ( call_span, "no errors reported for args" ) ,
492
- ) ;
493
489
494
490
// Get the argument span in the context of the call span so that
495
491
// suggestions and labels are (more) correct when an arg is a
@@ -696,8 +692,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
696
692
Some ( mismatch_idx) ,
697
693
is_method,
698
694
) ;
699
- err. emit ( ) ;
700
- return ;
695
+ return err. emit ( ) ;
701
696
}
702
697
}
703
698
}
@@ -721,11 +716,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
721
716
if cfg ! ( debug_assertions) {
722
717
span_bug ! ( error_span, "expected errors from argument matrix" ) ;
723
718
} else {
724
- tcx. dcx ( ) . emit_err ( errors:: ArgMismatchIndeterminate { span : error_span } ) ;
719
+ return tcx. dcx ( ) . emit_err ( errors:: ArgMismatchIndeterminate { span : error_span } ) ;
725
720
}
726
- return ;
727
721
}
728
722
723
+ let mut reported = None ;
729
724
errors. retain ( |error| {
730
725
let Error :: Invalid ( provided_idx, expected_idx, Compatibility :: Incompatible ( Some ( e) ) ) =
731
726
error
@@ -736,16 +731,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
736
731
let trace =
737
732
mk_trace ( provided_span, formal_and_expected_inputs[ * expected_idx] , provided_ty) ;
738
733
if !matches ! ( trace. cause. as_failure_code( * e) , FailureCode :: Error0308 ) {
739
- self . err_ctxt ( ) . report_and_explain_type_error ( trace, * e) . emit ( ) ;
734
+ reported = Some ( self . err_ctxt ( ) . report_and_explain_type_error ( trace, * e) . emit ( ) ) ;
740
735
return false ;
741
736
}
742
737
true
743
738
} ) ;
744
739
745
740
// We're done if we found errors, but we already emitted them.
746
- if errors. is_empty ( ) {
747
- return ;
741
+ if let Some ( reported) = reported {
742
+ assert ! ( errors. is_empty( ) ) ;
743
+ return reported;
748
744
}
745
+ assert ! ( !errors. is_empty( ) ) ;
749
746
750
747
// Okay, now that we've emitted the special errors separately, we
751
748
// are only left missing/extra/swapped and mismatched arguments, both
@@ -802,8 +799,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
802
799
Some ( expected_idx. as_usize ( ) ) ,
803
800
is_method,
804
801
) ;
805
- err. emit ( ) ;
806
- return ;
802
+ return err. emit ( ) ;
807
803
}
808
804
809
805
let mut err = if formal_and_expected_inputs. len ( ) == provided_args. len ( ) {
@@ -1251,7 +1247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1251
1247
) ;
1252
1248
}
1253
1249
1254
- err. emit ( ) ;
1250
+ err. emit ( )
1255
1251
}
1256
1252
1257
1253
fn suggest_ptr_null_mut (
0 commit comments