@@ -19,6 +19,7 @@ use crossbeam_channel::{Sender, TryRecvError};
1919#[ cfg( feature = "indicatif" ) ]
2020use indicatif:: { MultiProgress , ProgressBar , ProgressDrawTarget , ProgressStyle } ;
2121use spanned:: Span ;
22+ use std:: borrow:: Cow ;
2223use std:: fmt:: { Debug , Display } ;
2324use std:: io:: Write as _;
2425use std:: path:: Path ;
@@ -765,19 +766,25 @@ fn print_error(error: &Error, path: &Path) {
765766 } )
766767 . collect :: < Vec < _ > > ( ) ;
767768 // This will print a suitable error header.
769+
770+ let error_msg: Cow < str > = match msgs. len ( ) {
771+ 1 => "there was 1 unmatched diagnostic" . into ( ) ,
772+ n => format ! ( "there were {n} unmatched diagnostics" ) . into ( ) ,
773+ } ;
768774 create_error (
769- format ! ( "there were {} unmatched diagnostics" , msgs . len ( ) ) ,
775+ error_msg ,
770776 & [ & msgs
771777 . iter ( )
772778 . map ( |( msg, lc) | ( msg. as_ref ( ) , lc. clone ( ) ) )
773779 . collect :: < Vec < _ > > ( ) ] ,
774780 path,
775781 ) ;
776782 } else {
777- print_error_header ( format_args ! (
778- "there were {} unmatched diagnostics that occurred outside the testfile and had no pattern" ,
779- msgs. len( ) ,
780- ) ) ;
783+ let error_msg: Cow < str > = match msgs. len ( ) {
784+ 1 => "there was 1 unmatched diagnostic that occurred outside the testfile and had no pattern" . into ( ) ,
785+ n => format ! ( "there were {n} unmatched diagnostics that occurred outside the testfile and had no pattern" ) . into ( ) ,
786+ } ;
787+ print_error_header ( error_msg) ;
781788 for Message {
782789 level,
783790 message,
0 commit comments