@@ -603,7 +603,10 @@ impl<'test> TestCx<'test> {
603
603
) ;
604
604
} else {
605
605
for pattern in missing_patterns {
606
- self . error ( & format ! ( "error pattern '{}' not found!" , pattern) ) ;
606
+ println ! (
607
+ "\n {prefix}: error pattern '{pattern}' not found!" ,
608
+ prefix = self . error_prefix( )
609
+ ) ;
607
610
}
608
611
self . fatal_proc_rec ( "multiple error patterns not found" , proc_res) ;
609
612
}
@@ -762,11 +765,12 @@ impl<'test> TestCx<'test> {
762
765
}
763
766
764
767
if !unexpected. is_empty ( ) || !not_found. is_empty ( ) {
765
- self . error ( & format ! (
766
- "{} unexpected diagnostics reported, {} expected diagnostics not reported" ,
767
- unexpected. len( ) ,
768
- not_found. len( )
769
- ) ) ;
768
+ println ! (
769
+ "\n {prefix}: {unexpected} unexpected diagnostics reported, {not_found} expected diagnostics not reported" ,
770
+ prefix = self . error_prefix( ) ,
771
+ unexpected = unexpected. len( ) ,
772
+ not_found = not_found. len( ) ,
773
+ ) ;
770
774
771
775
// Emit locations in a format that is short (relative paths) but "clickable" in editors.
772
776
// Also normalize path separators to `/`.
@@ -1993,16 +1997,19 @@ impl<'test> TestCx<'test> {
1993
1997
output_base_name ( self . config , self . testpaths , self . safe_revision ( ) )
1994
1998
}
1995
1999
1996
- fn error ( & self , err : & str ) {
2000
+ /// Prefix to print before error messages. Normally just `error`, but also
2001
+ /// includes the revision name for tests that use revisions.
2002
+ #[ must_use]
2003
+ fn error_prefix ( & self ) -> String {
1997
2004
match self . revision {
1998
- Some ( rev) => println ! ( "\n error in revision `{}`: {}" , rev , err ) ,
1999
- None => println ! ( "\n error: {}" , err ) ,
2005
+ Some ( rev) => format ! ( "error in revision `{rev}`" ) ,
2006
+ None => format ! ( "error" ) ,
2000
2007
}
2001
2008
}
2002
2009
2003
2010
#[ track_caller]
2004
2011
fn fatal ( & self , err : & str ) -> ! {
2005
- self . error ( err ) ;
2012
+ println ! ( " \n {prefix}: {err}" , prefix = self . error_prefix ( ) ) ;
2006
2013
error ! ( "fatal error, panic: {:?}" , err) ;
2007
2014
panic ! ( "fatal error" ) ;
2008
2015
}
@@ -2020,7 +2027,7 @@ impl<'test> TestCx<'test> {
2020
2027
proc_res : & ProcRes ,
2021
2028
callback_before_unwind : impl FnOnce ( ) ,
2022
2029
) -> ! {
2023
- self . error ( err ) ;
2030
+ println ! ( " \n {prefix}: {err}" , prefix = self . error_prefix ( ) ) ;
2024
2031
2025
2032
// Some callers want to print additional notes after the main error message.
2026
2033
if let Some ( note) = extra_note {
0 commit comments