File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -218,13 +218,23 @@ cfg_if! {
218
218
if #[ cfg( feature = "cpp_demangle" ) ] {
219
219
impl <' a> fmt:: Debug for SymbolName <' a> {
220
220
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
221
+ use std:: fmt:: Write ;
222
+
221
223
if let Some ( ref s) = self . demangled {
222
- s. fmt( f)
223
- } else if let Some ( ref cpp) = self . cpp_demangled. 0 {
224
- fmt:: Display :: fmt( cpp, f)
225
- } else {
226
- String :: from_utf8_lossy( self . bytes) . fmt( f)
224
+ return s. fmt( f)
225
+ }
226
+
227
+ // This may to print if the demangled symbol isn't actually
228
+ // valid, so handle the error here gracefully by not propagating
229
+ // it outwards.
230
+ if let Some ( ref cpp) = self . cpp_demangled. 0 {
231
+ let mut s = String :: new( ) ;
232
+ if write!( s, "{}" , cpp) . is_ok( ) {
233
+ return s. fmt( f)
234
+ }
227
235
}
236
+
237
+ String :: from_utf8_lossy( self . bytes) . fmt( f)
228
238
}
229
239
}
230
240
} else {
You can’t perform that action at this time.
0 commit comments