@@ -88,7 +88,6 @@ use std::fs;
8888use std:: path:: Path ;
8989use std:: process;
9090use std:: sync:: Arc ;
91- use std:: thread:: ThreadId ;
9291use std:: time:: { Duration , Instant } ;
9392use std:: u32;
9493
@@ -129,17 +128,13 @@ bitflags::bitflags! {
129128 Self :: QUERY_PROVIDERS . bits |
130129 Self :: QUERY_BLOCKED . bits |
131130 Self :: INCR_CACHE_LOADS . bits;
132-
133- // empty() and none() aren't const-fns unfortunately
134- const NONE = 0 ;
135- const ALL = !Self :: NONE . bits;
136131 }
137132}
138133
139134// keep this in sync with the `-Z self-profile-events` help message in librustc_session/options.rs
140135const EVENT_FILTERS_BY_NAME : & [ ( & str , EventFilter ) ] = & [
141- ( "none" , EventFilter :: NONE ) ,
142- ( "all" , EventFilter :: ALL ) ,
136+ ( "none" , EventFilter :: empty ( ) ) ,
137+ ( "all" , EventFilter :: all ( ) ) ,
143138 ( "default" , EventFilter :: DEFAULT ) ,
144139 ( "generic-activity" , EventFilter :: GENERIC_ACTIVITIES ) ,
145140 ( "query-provider" , EventFilter :: QUERY_PROVIDERS ) ,
@@ -149,10 +144,6 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
149144 ( "query-keys" , EventFilter :: QUERY_KEYS ) ,
150145] ;
151146
152- fn thread_id_to_u32 ( tid : ThreadId ) -> u32 {
153- unsafe { std:: mem:: transmute :: < ThreadId , u64 > ( tid) as u32 }
154- }
155-
156147/// Something that uniquely identifies a query invocation.
157148pub struct QueryInvocationId ( pub u32 ) ;
158149
@@ -185,7 +176,7 @@ impl SelfProfilerRef {
185176 // If there is no SelfProfiler then the filter mask is set to NONE,
186177 // ensuring that nothing ever tries to actually access it.
187178 let event_filter_mask =
188- profiler. as_ref ( ) . map ( |p| p. event_filter_mask ) . unwrap_or ( EventFilter :: NONE ) ;
179+ profiler. as_ref ( ) . map ( |p| p. event_filter_mask ) . unwrap_or ( EventFilter :: empty ( ) ) ;
189180
190181 SelfProfilerRef {
191182 profiler,
@@ -318,7 +309,7 @@ impl SelfProfilerRef {
318309 ) {
319310 drop ( self . exec ( event_filter, |profiler| {
320311 let event_id = StringId :: new_virtual ( query_invocation_id. 0 ) ;
321- let thread_id = thread_id_to_u32 ( std:: thread:: current ( ) . id ( ) ) ;
312+ let thread_id = std:: thread:: current ( ) . id ( ) . as_u64 ( ) as u32 ;
322313
323314 profiler. profiler . record_instant_event (
324315 event_kind ( profiler) ,
@@ -477,7 +468,7 @@ impl<'a> TimingGuard<'a> {
477468 event_kind : StringId ,
478469 event_id : EventId ,
479470 ) -> TimingGuard < ' a > {
480- let thread_id = thread_id_to_u32 ( std:: thread:: current ( ) . id ( ) ) ;
471+ let thread_id = std:: thread:: current ( ) . id ( ) . as_u64 ( ) as u32 ;
481472 let raw_profiler = & profiler. profiler ;
482473 let timing_guard =
483474 raw_profiler. start_recording_interval_event ( event_kind, event_id, thread_id) ;
0 commit comments