@@ -390,6 +390,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
390390 infer_args,
391391 ) ;
392392
393+ if let Err ( err) = & arg_count. correct
394+ && let Some ( reported) = err. reported
395+ {
396+ self . set_tainted_by_errors ( reported) ;
397+ }
398+
393399 // Skip processing if type has no generic parameters.
394400 // Traits always have `Self` as a generic parameter, which means they will not return early
395401 // here and so associated type bindings will be handled regardless of whether there are any
@@ -568,6 +574,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
568574 span,
569575 modifier : constness. as_str ( ) ,
570576 } ) ;
577+ self . set_tainted_by_errors ( e) ;
571578 arg_count. correct =
572579 Err ( GenericArgCountMismatch { reported : Some ( e) , invalid_args : vec ! [ ] } ) ;
573580 }
@@ -966,7 +973,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
966973 }
967974 }
968975 }
969- err. emit ( )
976+ let reported = err. emit ( ) ;
977+ self . set_tainted_by_errors ( reported) ;
978+ reported
970979 }
971980
972981 // Search for a bound on a type parameter which includes the associated item
@@ -1043,6 +1052,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10431052 span,
10441053 binding,
10451054 ) ;
1055+ self . set_tainted_by_errors ( reported) ;
10461056 return Err ( reported) ;
10471057 } ;
10481058 debug ! ( ?bound) ;
@@ -1120,6 +1130,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11201130 ) ) ;
11211131 }
11221132 let reported = err. emit ( ) ;
1133+ self . set_tainted_by_errors ( reported) ;
11231134 if !where_bounds. is_empty ( ) {
11241135 return Err ( reported) ;
11251136 }
@@ -1374,6 +1385,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13741385 assoc_ident. name ,
13751386 )
13761387 } ;
1388+ self . set_tainted_by_errors ( reported) ;
13771389 return Err ( reported) ;
13781390 }
13791391 } ;
@@ -1616,12 +1628,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16161628 let kind = tcx. def_kind_descr ( kind, item) ;
16171629 let msg = format ! ( "{kind} `{name}` is private" ) ;
16181630 let def_span = tcx. def_span ( item) ;
1619- tcx. dcx ( )
1631+ let reported = tcx
1632+ . dcx ( )
16201633 . struct_span_err ( span, msg)
16211634 . with_code ( rustc_errors:: error_code!( E0624 ) )
16221635 . with_span_label ( span, format ! ( "private {kind}" ) )
16231636 . with_span_label ( def_span, format ! ( "{kind} defined here" ) )
16241637 . emit ( ) ;
1638+ self . set_tainted_by_errors ( reported) ;
16251639 }
16261640 tcx. check_stability ( item, Some ( block) , span, None ) ;
16271641 }
@@ -1862,7 +1876,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
18621876 err. span_label ( span, format ! ( "not allowed on {what}" ) ) ;
18631877 }
18641878 extend ( & mut err) ;
1865- err. emit ( ) ;
1879+ self . set_tainted_by_errors ( err. emit ( ) ) ;
18661880 emitted = true ;
18671881 }
18681882
@@ -2184,7 +2198,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21842198 {
21852199 err. span_note ( impl_. self_ty . span , "not a concrete type" ) ;
21862200 }
2187- Ty :: new_error ( tcx, err. emit ( ) )
2201+ let reported = err. emit ( ) ;
2202+ self . set_tainted_by_errors ( reported) ;
2203+ Ty :: new_error ( tcx, reported)
21882204 } else {
21892205 ty
21902206 }
@@ -2586,7 +2602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25862602 ) ;
25872603 }
25882604
2589- diag. emit ( ) ;
2605+ self . set_tainted_by_errors ( diag. emit ( ) ) ;
25902606 }
25912607
25922608 // Find any late-bound regions declared in return type that do
@@ -2686,7 +2702,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
26862702 err. note ( "consider introducing a named lifetime parameter" ) ;
26872703 }
26882704
2689- err. emit ( ) ;
2705+ self . set_tainted_by_errors ( err. emit ( ) ) ;
26902706 }
26912707 }
26922708
@@ -2725,7 +2741,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27252741 // error.
27262742 let r = derived_region_bounds[ 0 ] ;
27272743 if derived_region_bounds[ 1 ..] . iter ( ) . any ( |r1| r != * r1) {
2728- tcx. dcx ( ) . emit_err ( AmbiguousLifetimeBound { span } ) ;
2744+ self . set_tainted_by_errors ( tcx. dcx ( ) . emit_err ( AmbiguousLifetimeBound { span } ) ) ;
27292745 }
27302746 Some ( r)
27312747 }
0 commit comments