@@ -134,16 +134,20 @@ impl<'mir, 'tcx> Thread<'mir, 'tcx> {
134
134
}
135
135
false
136
136
}
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
+ }
137
146
}
138
147
139
148
impl < ' mir , ' tcx > std:: fmt:: Debug for Thread < ' mir , ' tcx > {
140
149
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)
147
151
}
148
152
}
149
153
@@ -314,11 +318,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
314
318
315
319
/// Get the name of the active thread.
316
320
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 ( )
322
322
}
323
323
324
324
/// Allocate a new blockset id.
0 commit comments