@@ -88,7 +88,6 @@ use std::fs;
88
88
use std:: path:: Path ;
89
89
use std:: process;
90
90
use std:: sync:: Arc ;
91
- use std:: thread:: ThreadId ;
92
91
use std:: time:: { Duration , Instant } ;
93
92
use std:: u32;
94
93
@@ -129,17 +128,13 @@ bitflags::bitflags! {
129
128
Self :: QUERY_PROVIDERS . bits |
130
129
Self :: QUERY_BLOCKED . bits |
131
130
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;
136
131
}
137
132
}
138
133
139
134
// keep this in sync with the `-Z self-profile-events` help message in librustc_session/options.rs
140
135
const EVENT_FILTERS_BY_NAME : & [ ( & str , EventFilter ) ] = & [
141
- ( "none" , EventFilter :: NONE ) ,
142
- ( "all" , EventFilter :: ALL ) ,
136
+ ( "none" , EventFilter :: empty ( ) ) ,
137
+ ( "all" , EventFilter :: all ( ) ) ,
143
138
( "default" , EventFilter :: DEFAULT ) ,
144
139
( "generic-activity" , EventFilter :: GENERIC_ACTIVITIES ) ,
145
140
( "query-provider" , EventFilter :: QUERY_PROVIDERS ) ,
@@ -149,10 +144,6 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
149
144
( "query-keys" , EventFilter :: QUERY_KEYS ) ,
150
145
] ;
151
146
152
- fn thread_id_to_u32 ( tid : ThreadId ) -> u32 {
153
- unsafe { std:: mem:: transmute :: < ThreadId , u64 > ( tid) as u32 }
154
- }
155
-
156
147
/// Something that uniquely identifies a query invocation.
157
148
pub struct QueryInvocationId ( pub u32 ) ;
158
149
@@ -185,7 +176,7 @@ impl SelfProfilerRef {
185
176
// If there is no SelfProfiler then the filter mask is set to NONE,
186
177
// ensuring that nothing ever tries to actually access it.
187
178
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 ( ) ) ;
189
180
190
181
SelfProfilerRef {
191
182
profiler,
@@ -318,7 +309,7 @@ impl SelfProfilerRef {
318
309
) {
319
310
drop ( self . exec ( event_filter, |profiler| {
320
311
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 ;
322
313
323
314
profiler. profiler . record_instant_event (
324
315
event_kind ( profiler) ,
@@ -477,7 +468,7 @@ impl<'a> TimingGuard<'a> {
477
468
event_kind : StringId ,
478
469
event_id : EventId ,
479
470
) -> 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 ;
481
472
let raw_profiler = & profiler. profiler ;
482
473
let timing_guard =
483
474
raw_profiler. start_recording_interval_event ( event_kind, event_id, thread_id) ;
0 commit comments