From bc9d007e3eccae1bbb7b90bbfd2c2d583e44166f Mon Sep 17 00:00:00 2001 From: Vytautas Astrauskas Date: Fri, 24 Apr 2020 16:47:18 -0700 Subject: [PATCH] Improve Debug formatting of the thread name. --- src/thread.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/thread.rs b/src/thread.rs index eb7af536cf11..ecdaced3f8c5 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -132,13 +132,9 @@ impl<'mir, 'tcx> Thread<'mir, 'tcx> { impl<'mir, 'tcx> std::fmt::Debug for Thread<'mir, 'tcx> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(ref name) = self.thread_name { - if let Ok(name_str) = std::str::from_utf8(name) { - write!(f, "{}", name_str)?; - } else { - write!(f, "")?; - } + write!(f, "{}", String::from_utf8_lossy(name))?; } else { - write!(f, "unnamed")?; + write!(f, "")?; } write!(f, "({:?}, {:?})", self.state, self.join_status) }