@@ -754,13 +754,20 @@ impl DiagCtxt {
754754 self . inner . borrow_mut ( ) . emit_stashed_diagnostics ( )
755755 }
756756
757- /// This excludes lint errors, delayed bugs, and stashed errors.
757+ /// This excludes lint errors, delayed bugs and stashed errors.
758758 #[ inline]
759- pub fn err_count ( & self ) -> usize {
759+ pub fn err_count_excluding_lint_errs ( & self ) -> usize {
760760 self . inner . borrow ( ) . err_guars . len ( )
761761 }
762762
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
764771 /// absolutely necessary, avoid using this. It's dubious because stashed
765772 /// errors can later be cancelled, so the presence of a stashed error at
766773 /// some point of time doesn't guarantee anything -- there are no
@@ -769,21 +776,21 @@ impl DiagCtxt {
769776 self . inner . borrow ( ) . stashed_err_count
770777 }
771778
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 ( )
775783 }
776784
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 ( )
781788 }
782789
783790 /// 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 ( )
787794 }
788795
789796 pub fn print_error_count ( & self , registry : & Registry ) {
@@ -1328,7 +1335,7 @@ impl DiagCtxtInner {
13281335 DelayedBug => {
13291336 // If we have already emitted at least one error, we don't need
13301337 // 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 ( ) {
13321339 Some ( guar)
13331340 } else {
13341341 let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
@@ -1444,17 +1451,16 @@ impl DiagCtxtInner {
14441451 . is_some_and ( |c| self . err_guars . len ( ) + self . lint_err_guars . len ( ) + 1 >= c. get ( ) )
14451452 }
14461453
1447- fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
1454+ fn has_errors_excluding_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
14481455 self . err_guars . get ( 0 ) . copied ( )
14491456 }
14501457
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 ( ) )
14531460 }
14541461
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 ( ) )
14581464 }
14591465
14601466 /// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
0 commit comments