@@ -754,13 +754,20 @@ impl DiagCtxt {
754
754
self . inner . borrow_mut ( ) . emit_stashed_diagnostics ( )
755
755
}
756
756
757
- /// This excludes lint errors, delayed bugs, and stashed errors.
757
+ /// This excludes lint errors, delayed bugs and stashed errors.
758
758
#[ inline]
759
- pub fn err_count ( & self ) -> usize {
759
+ pub fn err_count_excluding_lint_errs ( & self ) -> usize {
760
760
self . inner . borrow ( ) . err_guars . len ( )
761
761
}
762
762
763
- /// This excludes normal errors, lint errors and delayed bugs. Unless
763
+ /// This excludes delayed bugs and stashed errors.
764
+ #[ inline]
765
+ pub fn err_count ( & self ) -> usize {
766
+ let inner = self . inner . borrow ( ) ;
767
+ inner. err_guars . len ( ) + inner. lint_err_guars . len ( )
768
+ }
769
+
770
+ /// This excludes normal errors, lint errors, and delayed bugs. Unless
764
771
/// absolutely necessary, avoid using this. It's dubious because stashed
765
772
/// errors can later be cancelled, so the presence of a stashed error at
766
773
/// some point of time doesn't guarantee anything -- there are no
@@ -769,21 +776,21 @@ impl DiagCtxt {
769
776
self . inner . borrow ( ) . stashed_err_count
770
777
}
771
778
772
- /// This excludes lint errors, delayed bugs, and stashed errors.
773
- pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
774
- self . inner . borrow ( ) . has_errors ( )
779
+ /// This excludes lint errors, delayed bugs, and stashed errors. Unless
780
+ /// absolutely necessary, prefer `has_errors` to this method.
781
+ pub fn has_errors_excluding_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
782
+ self . inner . borrow ( ) . has_errors_excluding_lint_errors ( )
775
783
}
776
784
777
- /// This excludes delayed bugs and stashed errors. Unless absolutely
778
- /// necessary, prefer `has_errors` to this method.
779
- pub fn has_errors_or_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
780
- self . inner . borrow ( ) . has_errors_or_lint_errors ( )
785
+ /// This excludes delayed bugs and stashed errors.
786
+ pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
787
+ self . inner . borrow ( ) . has_errors ( )
781
788
}
782
789
783
790
/// This excludes stashed errors. Unless absolutely necessary, prefer
784
- /// `has_errors` or `has_errors_or_lint_errors` to this method.
785
- pub fn has_errors_or_lint_errors_or_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
786
- self . inner . borrow ( ) . has_errors_or_lint_errors_or_delayed_bugs ( )
791
+ /// `has_errors` to this method.
792
+ pub fn has_errors_or_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
793
+ self . inner . borrow ( ) . has_errors_or_delayed_bugs ( )
787
794
}
788
795
789
796
pub fn print_error_count ( & self , registry : & Registry ) {
@@ -1328,7 +1335,7 @@ impl DiagCtxtInner {
1328
1335
DelayedBug => {
1329
1336
// If we have already emitted at least one error, we don't need
1330
1337
// to record the delayed bug, because it'll never be used.
1331
- return if let Some ( guar) = self . has_errors_or_lint_errors ( ) {
1338
+ return if let Some ( guar) = self . has_errors ( ) {
1332
1339
Some ( guar)
1333
1340
} else {
1334
1341
let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
@@ -1444,17 +1451,16 @@ impl DiagCtxtInner {
1444
1451
. is_some_and ( |c| self . err_guars . len ( ) + self . lint_err_guars . len ( ) + 1 >= c. get ( ) )
1445
1452
}
1446
1453
1447
- fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
1454
+ fn has_errors_excluding_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
1448
1455
self . err_guars . get ( 0 ) . copied ( )
1449
1456
}
1450
1457
1451
- fn has_errors_or_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
1452
- self . has_errors ( ) . or_else ( || self . lint_err_guars . get ( 0 ) . copied ( ) )
1458
+ fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
1459
+ self . has_errors_excluding_lint_errors ( ) . or_else ( || self . lint_err_guars . get ( 0 ) . copied ( ) )
1453
1460
}
1454
1461
1455
- fn has_errors_or_lint_errors_or_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
1456
- self . has_errors_or_lint_errors ( )
1457
- . or_else ( || self . delayed_bugs . get ( 0 ) . map ( |( _, guar) | guar) . copied ( ) )
1462
+ fn has_errors_or_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
1463
+ self . has_errors ( ) . or_else ( || self . delayed_bugs . get ( 0 ) . map ( |( _, guar) | guar) . copied ( ) )
1458
1464
}
1459
1465
1460
1466
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
0 commit comments