@@ -421,16 +421,16 @@ pub struct DiagCtxt {
421
421
struct DiagCtxtInner {
422
422
flags : DiagCtxtFlags ,
423
423
424
- /// The number of lint errors that have been emitted.
424
+ /// The number of lint errors that have been emitted, including duplicates .
425
425
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.
430
427
err_count : usize ,
428
+
429
+ /// The error count shown to the user at the end.
431
430
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.
433
432
deduplicated_warn_count : usize ,
433
+
434
434
/// Has this diagnostic context printed any diagnostics? (I.e. has
435
435
/// `self.emitter.emit_diagnostic()` been called?
436
436
has_printed : bool ,
@@ -927,42 +927,38 @@ impl DiagCtxt {
927
927
self . struct_bug ( msg) . emit ( )
928
928
}
929
929
930
+ /// This excludes lint errors and delayed bugs.
930
931
#[ inline]
931
932
pub fn err_count ( & self ) -> usize {
932
933
self . inner . borrow ( ) . err_count
933
934
}
934
935
936
+ /// This excludes lint errors and delayed bugs.
935
937
pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
936
938
self . inner . borrow ( ) . has_errors ( ) . then ( || {
937
939
#[ allow( deprecated) ]
938
940
ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
939
941
} )
940
942
}
941
943
944
+ /// This excludes delayed bugs. Unless absolutely necessary, prefer
945
+ /// `has_errors` to this method.
942
946
pub fn has_errors_or_lint_errors ( & self ) -> Option < ErrorGuaranteed > {
943
947
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 ( || {
956
950
#[ allow( deprecated) ]
957
951
ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
958
952
} )
959
953
}
960
954
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 > {
962
958
let inner = self . inner . borrow ( ) ;
963
- let will_fail =
959
+ let result =
964
960
inner. has_errors ( ) || inner. lint_err_count > 0 || !inner. span_delayed_bugs . is_empty ( ) ;
965
- will_fail . then ( || {
961
+ result . then ( || {
966
962
#[ allow( deprecated) ]
967
963
ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
968
964
} )
@@ -1162,7 +1158,7 @@ impl DiagCtxt {
1162
1158
let mut inner = self . inner . borrow_mut ( ) ;
1163
1159
1164
1160
if loud && lint_level. is_error ( ) {
1165
- inner. err_count += 1 ;
1161
+ inner. lint_err_count += 1 ;
1166
1162
inner. panic_if_treat_err_as_bug ( ) ;
1167
1163
}
1168
1164
0 commit comments