@@ -134,16 +134,20 @@ impl<'mir, 'tcx> Thread<'mir, 'tcx> {
134134 }
135135 false
136136 }
137+
138+ /// Get the name of the current thread, or `<unnamed>` if it was not set.
139+ fn thread_name ( & self ) -> & [ u8 ] {
140+ if let Some ( ref thread_name) = self . thread_name {
141+ thread_name
142+ } else {
143+ b"<unnamed>"
144+ }
145+ }
137146}
138147
139148impl < ' mir , ' tcx > std:: fmt:: Debug for Thread < ' mir , ' tcx > {
140149 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
141- if let Some ( ref name) = self . thread_name {
142- write ! ( f, "{}" , String :: from_utf8_lossy( name) ) ?;
143- } else {
144- write ! ( f, "<unnamed>" ) ?;
145- }
146- write ! ( f, "({:?}, {:?})" , self . state, self . join_status)
150+ write ! ( f, "{}({:?}, {:?})" , String :: from_utf8_lossy( self . thread_name( ) ) , self . state, self . join_status)
147151 }
148152}
149153
@@ -314,11 +318,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
314318
315319 /// Get the name of the active thread.
316320 fn get_thread_name ( & self ) -> & [ u8 ] {
317- if let Some ( ref thread_name) = self . active_thread_ref ( ) . thread_name {
318- thread_name
319- } else {
320- b"<unnamed>"
321- }
321+ self . active_thread_ref ( ) . thread_name ( )
322322 }
323323
324324 /// Allocate a new blockset id.
0 commit comments