Improve Debug formatting of the thread name.

This commit is contained in:
Vytautas Astrauskas 2020-04-24 16:47:18 -07:00
parent 04abf066f1
commit bc9d007e3e

View file

@ -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, "<invalid thread name>")?;
}
write!(f, "{}", String::from_utf8_lossy(name))?;
} else {
write!(f, "unnamed")?;
write!(f, "<unnamed>")?;
}
write!(f, "({:?}, {:?})", self.state, self.join_status)
}