@@ -254,11 +254,16 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
254
254
self . threads [ thread_id] . state = ThreadState :: Enabled ;
255
255
}
256
256
257
- /// Get the borrow of the currently active thread.
257
+ /// Get a mutable borrow of the currently active thread.
258
258
fn active_thread_mut ( & mut self ) -> & mut Thread < ' mir , ' tcx > {
259
259
& mut self . threads [ self . active_thread ]
260
260
}
261
261
262
+ /// Get a shared borrow of the currently active thread.
263
+ fn active_thread_ref ( & self ) -> & Thread < ' mir , ' tcx > {
264
+ & self . threads [ self . active_thread ]
265
+ }
266
+
262
267
/// Mark the thread as detached, which means that no other thread will try
263
268
/// to join it and the thread is responsible for cleaning up.
264
269
fn detach_thread ( & mut self , id : ThreadId ) -> InterpResult < ' tcx > {
@@ -304,9 +309,9 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
304
309
}
305
310
306
311
/// Get the name of the active thread.
307
- fn get_thread_name ( & mut self ) -> InterpResult < ' tcx , Vec < u8 > > {
308
- if let Some ( ref thread_name) = self . active_thread_mut ( ) . thread_name {
309
- Ok ( thread_name. clone ( ) )
312
+ fn get_thread_name ( & self ) -> InterpResult < ' tcx , & [ u8 ] > {
313
+ if let Some ( ref thread_name) = self . active_thread_ref ( ) . thread_name {
314
+ Ok ( thread_name)
310
315
} else {
311
316
throw_ub_format ! ( "thread {:?} has no name set" , self . active_thread)
312
317
}
@@ -557,8 +562,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
557
562
}
558
563
559
564
#[ inline]
560
- fn get_active_thread_name ( & mut self ) -> InterpResult < ' tcx , Vec < u8 > > {
561
- let this = self . eval_context_mut ( ) ;
565
+ fn get_active_thread_name < ' c > ( & ' c self ) -> InterpResult < ' tcx , & ' c [ u8 ] >
566
+ where
567
+ ' mir : ' c ,
568
+ {
569
+ let this = self . eval_context_ref ( ) ;
562
570
this. machine . threads . get_thread_name ( )
563
571
}
564
572
0 commit comments