@@ -421,16 +421,16 @@ pub struct DiagCtxt {
421421struct DiagCtxtInner {
422422 flags : DiagCtxtFlags ,
423423
424- /// The number of lint errors that have been emitted.
424+ /// The number of lint errors that have been emitted, including duplicates .
425425 lint_err_count : usize ,
426- /// The number of errors that have been emitted, including duplicates.
427- ///
428- /// This is not necessarily the count that's reported to the user once
429- /// compilation ends.
426+ /// The number of non-lint errors that have been emitted, including duplicates.
430427 err_count : usize ,
428+
429+ /// The error count shown to the user at the end.
431430 deduplicated_err_count : usize ,
432- /// The warning count, used for a recap upon finishing
431+ /// The warning count shown to the user at the end.
433432 deduplicated_warn_count : usize ,
433+
434434 /// Has this diagnostic context printed any diagnostics? (I.e. has
435435 /// `self.emitter.emit_diagnostic()` been called?
436436 has_printed : bool ,
@@ -927,42 +927,38 @@ impl DiagCtxt {
927927 self . struct_bug ( msg) . emit ( )
928928 }
929929
930+ /// This excludes lint errors and delayed bugs.
930931 #[ inline]
931932 pub fn err_count ( & self ) -> usize {
932933 self . inner . borrow ( ) . err_count
933934 }
934935
936+ /// This excludes lint errors and delayed bugs.
935937 pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
936938 self . inner . borrow ( ) . has_errors ( ) . then ( || {
937939 #[ allow( deprecated) ]
938940 ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
939941 } )
940942 }
941943
944+ /// This excludes delayed bugs. Unless absolutely necessary, prefer
945+ /// `has_errors` to this method.
942946 pub fn has_errors_or_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
943947 let inner = self . inner . borrow ( ) ;
944- let has_errors_or_lint_errors = inner. has_errors ( ) || inner. lint_err_count > 0 ;
945- has_errors_or_lint_errors. then ( || {
946- #[ allow( deprecated) ]
947- ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
948- } )
949- }
950-
951- pub fn has_errors_or_span_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
952- let inner = self . inner . borrow ( ) ;
953- let has_errors_or_span_delayed_bugs =
954- inner. has_errors ( ) || !inner. span_delayed_bugs . is_empty ( ) ;
955- has_errors_or_span_delayed_bugs. then ( || {
948+ let result = inner. has_errors ( ) || inner. lint_err_count > 0 ;
949+ result. then ( || {
956950 #[ allow( deprecated) ]
957951 ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
958952 } )
959953 }
960954
961- pub fn is_compilation_going_to_fail ( & self ) -> Option < ErrorGuaranteed > {
955+ /// Unless absolutely necessary, prefer `has_errors` or
956+ /// `has_errors_or_lint_errors` to this method.
957+ pub fn has_errors_or_lint_errors_or_delayed_bugs ( & self ) -> Option < ErrorGuaranteed > {
962958 let inner = self . inner . borrow ( ) ;
963- let will_fail =
959+ let result =
964960 inner. has_errors ( ) || inner. lint_err_count > 0 || !inner. span_delayed_bugs . is_empty ( ) ;
965- will_fail . then ( || {
961+ result . then ( || {
966962 #[ allow( deprecated) ]
967963 ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
968964 } )
@@ -1162,7 +1158,7 @@ impl DiagCtxt {
11621158 let mut inner = self . inner . borrow_mut ( ) ;
11631159
11641160 if loud && lint_level. is_error ( ) {
1165- inner. err_count += 1 ;
1161+ inner. lint_err_count += 1 ;
11661162 inner. panic_if_treat_err_as_bug ( ) ;
11671163 }
11681164
0 commit comments