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