@@ -759,13 +759,20 @@ impl DiagCtxt {
759759 self . inner . borrow_mut ( ) . emit_stashed_diagnostics ( )
760760 }
761761
762- /// This excludes lint errors, delayed bugs, and stashed errors.
762+ /// This excludes lint errors, delayed bugs and stashed errors.
763763 #[ inline]
764- pub fn err_count ( & self ) -> usize {
764+ pub fn err_count_excluding_lint_errs ( & self ) -> usize {
765765 self . inner . borrow ( ) . err_guars . len ( )
766766 }
767767
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
769776 /// absolutely necessary, avoid using this. It's dubious because stashed
770777 /// errors can later be cancelled, so the presence of a stashed error at
771778 /// some point of time doesn't guarantee anything -- there are no
@@ -774,21 +781,21 @@ impl DiagCtxt {
774781 self . inner . borrow ( ) . stashed_err_count
775782 }
776783
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 ( )
780788 }
781789
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 ( )
786793 }
787794
788795 /// 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 ( )
792799 }
793800
794801 pub fn print_error_count ( & self , registry : & Registry ) {
@@ -1333,7 +1340,7 @@ impl DiagCtxtInner {
13331340 DelayedBug => {
13341341 // If we have already emitted at least one error, we don't need
13351342 // 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 ( ) {
13371344 Some ( guar)
13381345 } else {
13391346 let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
@@ -1450,17 +1457,16 @@ impl DiagCtxtInner {
14501457 . is_some_and ( |c| self . err_guars . len ( ) + self . lint_err_guars . len ( ) + 1 >= c. get ( ) )
14511458 }
14521459
1453- fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
1460+ fn has_errors_excluding_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
14541461 self . err_guars . get ( 0 ) . copied ( )
14551462 }
14561463
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 ( ) )
14591466 }
14601467
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 ( ) )
14641470 }
14651471
14661472 /// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
0 commit comments