@@ -782,15 +782,19 @@ fn format_object(rustfmt: Rustfmt, fmt_config: &FmtConfig, the_type: String) ->
782
782
format ! ( "{}{{}}" , trimmed)
783
783
} ;
784
784
785
- let formatted = match rustfmt. format ( object. clone ( ) , config) {
786
- Ok ( lines) => match lines. rfind ( '{' ) {
785
+ let formatted = match std :: panic :: catch_unwind ( || rustfmt. format ( object. clone ( ) , config) ) {
786
+ Ok ( Ok ( lines) ) => match lines. rfind ( '{' ) {
787
787
Some ( pos) => lines[ 0 ..pos] . into ( ) ,
788
788
None => lines,
789
789
} ,
790
- Err ( e) => {
790
+ Ok ( Err ( e) ) => {
791
791
error ! ( "format_object: error: {:?}, input: {:?}" , e, object) ;
792
792
trimmed. to_string ( )
793
793
}
794
+ Err ( _) => {
795
+ error ! ( "format_object: rustfmt panicked on input: {:?}" , object) ;
796
+ trimmed. to_string ( )
797
+ }
794
798
} ;
795
799
796
800
// If it's a tuple, remove the trailing ';' and hide non-pub components
@@ -2035,6 +2039,7 @@ pub mod test {
2035
2039
2036
2040
#[ test]
2037
2041
fn test_tooltip ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2042
+ let _ = env_logger:: try_init ( ) ;
2038
2043
use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2039
2044
use std:: env;
2040
2045
@@ -2125,6 +2130,7 @@ pub mod test {
2125
2130
#[ test]
2126
2131
#[ ignore]
2127
2132
fn test_tooltip_std ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2133
+ let _ = env_logger:: try_init ( ) ;
2128
2134
use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2129
2135
use std:: env;
2130
2136
0 commit comments