@@ -142,7 +142,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
142
142
143
143
crate :: callbacks:: setup_callbacks ( ) ;
144
144
145
- scoped_thread ( cfg , || {
145
+ let main_handler = move || {
146
146
rustc_ast:: with_session_globals ( edition, || {
147
147
ty:: tls:: GCX_PTR . set ( & Lock :: new ( 0 ) , || {
148
148
if let Some ( stderr) = stderr {
@@ -151,7 +151,9 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
151
151
f ( )
152
152
} )
153
153
} )
154
- } )
154
+ } ;
155
+
156
+ scoped_thread ( cfg, main_handler)
155
157
}
156
158
157
159
#[ cfg( parallel_compiler) ]
@@ -161,12 +163,9 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
161
163
stderr : & Option < Arc < Mutex < Vec < u8 > > > > ,
162
164
f : F ,
163
165
) -> R {
164
- use rayon:: { ThreadBuilder , ThreadPool , ThreadPoolBuilder } ;
165
-
166
- let gcx_ptr = & Lock :: new ( 0 ) ;
167
166
crate :: callbacks:: setup_callbacks ( ) ;
168
167
169
- let mut config = ThreadPoolBuilder :: new ( )
168
+ let mut config = rayon :: ThreadPoolBuilder :: new ( )
170
169
. thread_name ( |_| "rustc" . to_string ( ) )
171
170
. acquire_thread_handler ( jobserver:: acquire_thread)
172
171
. release_thread_handler ( jobserver:: release_thread)
@@ -177,7 +176,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
177
176
config = config. stack_size ( size) ;
178
177
}
179
178
180
- let with_pool = move |pool : & ThreadPool | pool. install ( move || f ( ) ) ;
179
+ let with_pool = move |pool : & rayon :: ThreadPool | pool. install ( move || f ( ) ) ;
181
180
182
181
rustc_ast:: with_session_globals ( edition, || {
183
182
rustc_ast:: SESSION_GLOBALS . with ( |ast_session_globals| {
@@ -190,10 +189,12 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
190
189
let main_handler = move |thread : ThreadBuilder | {
191
190
rustc_ast:: SESSION_GLOBALS . set ( ast_session_globals, || {
192
191
rustc_span:: SESSION_GLOBALS . set ( span_session_globals, || {
193
- if let Some ( stderr) = stderr {
194
- io:: set_panic ( Some ( box Sink ( stderr. clone ( ) ) ) ) ;
195
- }
196
- ty:: tls:: GCX_PTR . set ( gcx_ptr, || thread. run ( ) )
192
+ ty:: tls:: GCX_PTR . set ( & Lock :: new ( 0 ) , || {
193
+ if let Some ( stderr) = stderr {
194
+ io:: set_panic ( Some ( box Sink ( stderr. clone ( ) ) ) ) ;
195
+ }
196
+ thread. run ( )
197
+ } )
197
198
} )
198
199
} )
199
200
} ;
0 commit comments