@@ -390,6 +390,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
390
390
infer_args,
391
391
) ;
392
392
393
+ if let Err ( err) = & arg_count. correct
394
+ && let Some ( reported) = err. reported
395
+ {
396
+ self . set_tainted_by_errors ( reported) ;
397
+ }
398
+
393
399
// Skip processing if type has no generic parameters.
394
400
// Traits always have `Self` as a generic parameter, which means they will not return early
395
401
// 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 {
568
574
span,
569
575
modifier : constness. as_str ( ) ,
570
576
} ) ;
577
+ self . set_tainted_by_errors ( e) ;
571
578
arg_count. correct =
572
579
Err ( GenericArgCountMismatch { reported : Some ( e) , invalid_args : vec ! [ ] } ) ;
573
580
}
@@ -966,7 +973,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
966
973
}
967
974
}
968
975
}
969
- err. emit ( )
976
+ let reported = err. emit ( ) ;
977
+ self . set_tainted_by_errors ( reported) ;
978
+ reported
970
979
}
971
980
972
981
// Search for a bound on a type parameter which includes the associated item
@@ -1043,6 +1052,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1043
1052
span,
1044
1053
binding,
1045
1054
) ;
1055
+ self . set_tainted_by_errors ( reported) ;
1046
1056
return Err ( reported) ;
1047
1057
} ;
1048
1058
debug ! ( ?bound) ;
@@ -1120,6 +1130,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1120
1130
) ) ;
1121
1131
}
1122
1132
let reported = err. emit ( ) ;
1133
+ self . set_tainted_by_errors ( reported) ;
1123
1134
if !where_bounds. is_empty ( ) {
1124
1135
return Err ( reported) ;
1125
1136
}
@@ -1374,6 +1385,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1374
1385
assoc_ident. name ,
1375
1386
)
1376
1387
} ;
1388
+ self . set_tainted_by_errors ( reported) ;
1377
1389
return Err ( reported) ;
1378
1390
}
1379
1391
} ;
@@ -1616,12 +1628,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1616
1628
let kind = tcx. def_kind_descr ( kind, item) ;
1617
1629
let msg = format ! ( "{kind} `{name}` is private" ) ;
1618
1630
let def_span = tcx. def_span ( item) ;
1619
- tcx. dcx ( )
1631
+ let reported = tcx
1632
+ . dcx ( )
1620
1633
. struct_span_err ( span, msg)
1621
1634
. with_code ( rustc_errors:: error_code!( E0624 ) )
1622
1635
. with_span_label ( span, format ! ( "private {kind}" ) )
1623
1636
. with_span_label ( def_span, format ! ( "{kind} defined here" ) )
1624
1637
. emit ( ) ;
1638
+ self . set_tainted_by_errors ( reported) ;
1625
1639
}
1626
1640
tcx. check_stability ( item, Some ( block) , span, None ) ;
1627
1641
}
@@ -1862,7 +1876,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1862
1876
err. span_label ( span, format ! ( "not allowed on {what}" ) ) ;
1863
1877
}
1864
1878
extend ( & mut err) ;
1865
- err. emit ( ) ;
1879
+ self . set_tainted_by_errors ( err. emit ( ) ) ;
1866
1880
emitted = true ;
1867
1881
}
1868
1882
@@ -2184,7 +2198,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2184
2198
{
2185
2199
err. span_note ( impl_. self_ty . span , "not a concrete type" ) ;
2186
2200
}
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)
2188
2204
} else {
2189
2205
ty
2190
2206
}
@@ -2586,7 +2602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2586
2602
) ;
2587
2603
}
2588
2604
2589
- diag. emit ( ) ;
2605
+ self . set_tainted_by_errors ( diag. emit ( ) ) ;
2590
2606
}
2591
2607
2592
2608
// Find any late-bound regions declared in return type that do
@@ -2686,7 +2702,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2686
2702
err. note ( "consider introducing a named lifetime parameter" ) ;
2687
2703
}
2688
2704
2689
- err. emit ( ) ;
2705
+ self . set_tainted_by_errors ( err. emit ( ) ) ;
2690
2706
}
2691
2707
}
2692
2708
@@ -2725,7 +2741,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2725
2741
// error.
2726
2742
let r = derived_region_bounds[ 0 ] ;
2727
2743
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 } ) ) ;
2729
2745
}
2730
2746
Some ( r)
2731
2747
}
0 commit comments