@@ -312,6 +312,9 @@ struct HandlerInner {
312
312
/// The stashed diagnostics count towards the total error count.
313
313
/// When `.abort_if_errors()` is called, these are also emitted.
314
314
stashed_diagnostics : FxIndexMap < ( Span , StashKey ) , Diagnostic > ,
315
+
316
+ /// The warning count, used for a recap upon finishing
317
+ deduplicated_warn_count : usize ,
315
318
}
316
319
317
320
/// A key denoting where from a diagnostic was stashed.
@@ -414,6 +417,7 @@ impl Handler {
414
417
flags,
415
418
err_count : 0 ,
416
419
deduplicated_err_count : 0 ,
420
+ deduplicated_warn_count : 0 ,
417
421
emitter,
418
422
delayed_span_bugs : Vec :: new ( ) ,
419
423
taught_diagnostics : Default :: default ( ) ,
@@ -439,6 +443,7 @@ impl Handler {
439
443
let mut inner = self . inner . borrow_mut ( ) ;
440
444
inner. err_count = 0 ;
441
445
inner. deduplicated_err_count = 0 ;
446
+ inner. deduplicated_warn_count = 0 ;
442
447
443
448
// actually free the underlying memory (which `clear` would not do)
444
449
inner. delayed_span_bugs = Default :: default ( ) ;
@@ -745,6 +750,8 @@ impl HandlerInner {
745
750
self . emitter . emit_diagnostic ( diagnostic) ;
746
751
if diagnostic. is_error ( ) {
747
752
self . deduplicated_err_count += 1 ;
753
+ } else if diagnostic. level == Warning {
754
+ self . deduplicated_warn_count += 1 ;
748
755
}
749
756
}
750
757
if diagnostic. is_error ( ) {
@@ -763,16 +770,30 @@ impl HandlerInner {
763
770
fn print_error_count ( & mut self , registry : & Registry ) {
764
771
self . emit_stashed_diagnostics ( ) ;
765
772
766
- let s = match self . deduplicated_err_count {
767
- 0 => return ,
773
+ let warnings = match self . deduplicated_warn_count {
774
+ 0 => String :: new ( ) ,
775
+ 1 => "1 warning emitted" . to_string ( ) ,
776
+ count => format ! ( "{} warnings emitted" , count) ,
777
+ } ;
778
+ let errors = match self . deduplicated_err_count {
779
+ 0 => String :: new ( ) ,
768
780
1 => "aborting due to previous error" . to_string ( ) ,
769
781
count => format ! ( "aborting due to {} previous errors" , count) ,
770
782
} ;
771
783
if self . treat_err_as_bug ( ) {
772
784
return ;
773
785
}
774
786
775
- let _ = self . fatal ( & s) ;
787
+ match ( errors. len ( ) , warnings. len ( ) ) {
788
+ ( 0 , 0 ) => return ,
789
+ ( 0 , _) => self . emit_diagnostic ( & Diagnostic :: new ( Level :: Warning , & warnings) ) ,
790
+ ( _, 0 ) => {
791
+ let _ = self . fatal ( & errors) ;
792
+ }
793
+ ( _, _) => {
794
+ let _ = self . fatal ( & format ! ( "{}; {}" , & errors, & warnings) ) ;
795
+ }
796
+ }
776
797
777
798
let can_show_explain = self . emitter . should_show_explain ( ) ;
778
799
let are_there_diagnostics = !self . emitted_diagnostic_codes . is_empty ( ) ;
0 commit comments