@@ -389,6 +389,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
389
389
infer_args,
390
390
) ;
391
391
392
+ if let Err ( err) = & arg_count. correct
393
+ && let Some ( reported) = err. reported
394
+ {
395
+ self . set_tainted_by_errors ( reported) ;
396
+ }
397
+
392
398
// Skip processing if type has no generic parameters.
393
399
// Traits always have `Self` as a generic parameter, which means they will not return early
394
400
// 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 {
567
573
span,
568
574
modifier : constness. as_str ( ) ,
569
575
} ) ;
576
+ self . set_tainted_by_errors ( e) ;
570
577
arg_count. correct =
571
578
Err ( GenericArgCountMismatch { reported : Some ( e) , invalid_args : vec ! [ ] } ) ;
572
579
}
@@ -965,7 +972,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
965
972
}
966
973
}
967
974
}
968
- err. emit ( )
975
+ let reported = err. emit ( ) ;
976
+ self . set_tainted_by_errors ( reported) ;
977
+ reported
969
978
}
970
979
971
980
// Search for a bound on a type parameter which includes the associated item
@@ -1042,6 +1051,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1042
1051
span,
1043
1052
binding,
1044
1053
) ;
1054
+ self . set_tainted_by_errors ( reported) ;
1045
1055
return Err ( reported) ;
1046
1056
} ;
1047
1057
debug ! ( ?bound) ;
@@ -1119,6 +1129,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1119
1129
) ) ;
1120
1130
}
1121
1131
let reported = err. emit ( ) ;
1132
+ self . set_tainted_by_errors ( reported) ;
1122
1133
if !where_bounds. is_empty ( ) {
1123
1134
return Err ( reported) ;
1124
1135
}
@@ -1373,6 +1384,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1373
1384
assoc_ident. name ,
1374
1385
)
1375
1386
} ;
1387
+ self . set_tainted_by_errors ( reported) ;
1376
1388
return Err ( reported) ;
1377
1389
}
1378
1390
} ;
@@ -1615,12 +1627,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1615
1627
let kind = tcx. def_kind_descr ( kind, item) ;
1616
1628
let msg = format ! ( "{kind} `{name}` is private" ) ;
1617
1629
let def_span = tcx. def_span ( item) ;
1618
- tcx. dcx ( )
1630
+ let reported = tcx
1631
+ . dcx ( )
1619
1632
. struct_span_err ( span, msg)
1620
1633
. with_code ( rustc_errors:: error_code!( E0624 ) )
1621
1634
. with_span_label ( span, format ! ( "private {kind}" ) )
1622
1635
. with_span_label ( def_span, format ! ( "{kind} defined here" ) )
1623
1636
. emit ( ) ;
1637
+ self . set_tainted_by_errors ( reported) ;
1624
1638
}
1625
1639
tcx. check_stability ( item, Some ( block) , span, None ) ;
1626
1640
}
@@ -1861,7 +1875,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1861
1875
err. span_label ( span, format ! ( "not allowed on {what}" ) ) ;
1862
1876
}
1863
1877
extend ( & mut err) ;
1864
- err. emit ( ) ;
1878
+ self . set_tainted_by_errors ( err. emit ( ) ) ;
1865
1879
emitted = true ;
1866
1880
}
1867
1881
@@ -2183,7 +2197,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2183
2197
{
2184
2198
err. span_note ( impl_. self_ty . span , "not a concrete type" ) ;
2185
2199
}
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)
2187
2203
} else {
2188
2204
ty
2189
2205
}
@@ -2702,7 +2718,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2702
2718
) ;
2703
2719
}
2704
2720
2705
- diag. emit ( ) ;
2721
+ self . set_tainted_by_errors ( diag. emit ( ) ) ;
2706
2722
}
2707
2723
2708
2724
// Find any late-bound regions declared in return type that do
@@ -2802,7 +2818,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2802
2818
err. note ( "consider introducing a named lifetime parameter" ) ;
2803
2819
}
2804
2820
2805
- err. emit ( ) ;
2821
+ self . set_tainted_by_errors ( err. emit ( ) ) ;
2806
2822
}
2807
2823
}
2808
2824
@@ -2841,7 +2857,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2841
2857
// error.
2842
2858
let r = derived_region_bounds[ 0 ] ;
2843
2859
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 } ) ) ;
2845
2861
}
2846
2862
Some ( r)
2847
2863
}
0 commit comments