@@ -389,6 +389,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
389389 infer_args,
390390 ) ;
391391
392+ if let Err ( err) = & arg_count. correct
393+ && let Some ( reported) = err. reported
394+ {
395+ self . set_tainted_by_errors ( reported) ;
396+ }
397+
392398 // Skip processing if type has no generic parameters.
393399 // Traits always have `Self` as a generic parameter, which means they will not return early
394400 // here and so associated type bindings will be handled regardless of whether there are any
@@ -567,6 +573,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
567573 span,
568574 modifier : constness. as_str ( ) ,
569575 } ) ;
576+ self . set_tainted_by_errors ( e) ;
570577 arg_count. correct =
571578 Err ( GenericArgCountMismatch { reported : Some ( e) , invalid_args : vec ! [ ] } ) ;
572579 }
@@ -965,7 +972,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
965972 }
966973 }
967974 }
968- err. emit ( )
975+ let reported = err. emit ( ) ;
976+ self . set_tainted_by_errors ( reported) ;
977+ reported
969978 }
970979
971980 // Search for a bound on a type parameter which includes the associated item
@@ -1042,6 +1051,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10421051 span,
10431052 binding,
10441053 ) ;
1054+ self . set_tainted_by_errors ( reported) ;
10451055 return Err ( reported) ;
10461056 } ;
10471057 debug ! ( ?bound) ;
@@ -1119,6 +1129,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11191129 ) ) ;
11201130 }
11211131 let reported = err. emit ( ) ;
1132+ self . set_tainted_by_errors ( reported) ;
11221133 if !where_bounds. is_empty ( ) {
11231134 return Err ( reported) ;
11241135 }
@@ -1373,6 +1384,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13731384 assoc_ident. name ,
13741385 )
13751386 } ;
1387+ self . set_tainted_by_errors ( reported) ;
13761388 return Err ( reported) ;
13771389 }
13781390 } ;
@@ -1615,12 +1627,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16151627 let kind = tcx. def_kind_descr ( kind, item) ;
16161628 let msg = format ! ( "{kind} `{name}` is private" ) ;
16171629 let def_span = tcx. def_span ( item) ;
1618- tcx. dcx ( )
1630+ let reported = tcx
1631+ . dcx ( )
16191632 . struct_span_err ( span, msg)
16201633 . with_code ( rustc_errors:: error_code!( E0624 ) )
16211634 . with_span_label ( span, format ! ( "private {kind}" ) )
16221635 . with_span_label ( def_span, format ! ( "{kind} defined here" ) )
16231636 . emit ( ) ;
1637+ self . set_tainted_by_errors ( reported) ;
16241638 }
16251639 tcx. check_stability ( item, Some ( block) , span, None ) ;
16261640 }
@@ -1861,7 +1875,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
18611875 err. span_label ( span, format ! ( "not allowed on {what}" ) ) ;
18621876 }
18631877 extend ( & mut err) ;
1864- err. emit ( ) ;
1878+ self . set_tainted_by_errors ( err. emit ( ) ) ;
18651879 emitted = true ;
18661880 }
18671881
@@ -2183,7 +2197,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21832197 {
21842198 err. span_note ( impl_. self_ty . span , "not a concrete type" ) ;
21852199 }
2186- Ty :: new_error ( tcx, err. emit ( ) )
2200+ let reported = err. emit ( ) ;
2201+ self . set_tainted_by_errors ( reported) ;
2202+ Ty :: new_error ( tcx, reported)
21872203 } else {
21882204 ty
21892205 }
@@ -2702,7 +2718,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27022718 ) ;
27032719 }
27042720
2705- diag. emit ( ) ;
2721+ self . set_tainted_by_errors ( diag. emit ( ) ) ;
27062722 }
27072723
27082724 // Find any late-bound regions declared in return type that do
@@ -2802,7 +2818,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28022818 err. note ( "consider introducing a named lifetime parameter" ) ;
28032819 }
28042820
2805- err. emit ( ) ;
2821+ self . set_tainted_by_errors ( err. emit ( ) ) ;
28062822 }
28072823 }
28082824
@@ -2841,7 +2857,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28412857 // error.
28422858 let r = derived_region_bounds[ 0 ] ;
28432859 if derived_region_bounds[ 1 ..] . iter ( ) . any ( |r1| r != * r1) {
2844- tcx. dcx ( ) . emit_err ( AmbiguousLifetimeBound { span } ) ;
2860+ self . set_tainted_by_errors ( tcx. dcx ( ) . emit_err ( AmbiguousLifetimeBound { span } ) ) ;
28452861 }
28462862 Some ( r)
28472863 }
0 commit comments