@@ -132,33 +132,27 @@ fn get_stack_size() -> Option<usize> {
132
132
env:: var_os ( "RUST_MIN_STACK" ) . is_none ( ) . then_some ( STACK_SIZE )
133
133
}
134
134
135
- /// Like a `thread::Builder::spawn` followed by a `join()`, but avoids the need
136
- /// for `'static` bounds.
137
- #[ cfg( not( parallel_compiler) ) ]
138
- fn scoped_thread < F : FnOnce ( ) -> R + Send , R : Send > ( cfg : thread:: Builder , f : F ) -> R {
139
- // SAFETY: join() is called immediately, so any closure captures are still
140
- // alive.
141
- match unsafe { cfg. spawn_unchecked ( f) } . unwrap ( ) . join ( ) {
142
- Ok ( v) => v,
143
- Err ( e) => panic:: resume_unwind ( e) ,
144
- }
145
- }
146
-
147
135
#[ cfg( not( parallel_compiler) ) ]
148
136
pub fn run_in_thread_pool_with_globals < F : FnOnce ( ) -> R + Send , R : Send > (
149
137
edition : Edition ,
150
138
_threads : usize ,
151
139
f : F ,
152
140
) -> R {
141
+ // The thread pool is a single thread in the non-parallel compiler.
153
142
let mut cfg = thread:: Builder :: new ( ) . name ( "rustc" . to_string ( ) ) ;
154
-
155
143
if let Some ( size) = get_stack_size ( ) {
156
144
cfg = cfg. stack_size ( size) ;
157
145
}
158
146
159
- let main_handler = move || rustc_span:: create_session_globals_then ( edition, f) ;
147
+ let f = move || rustc_span:: create_session_globals_then ( edition, f) ;
160
148
161
- scoped_thread ( cfg, main_handler)
149
+ // This avoids the need for `'static` bounds.
150
+ //
151
+ // SAFETY: join() is called immediately, so any closure captures are still alive.
152
+ match unsafe { cfg. spawn_unchecked ( f) } . unwrap ( ) . join ( ) {
153
+ Ok ( v) => v,
154
+ Err ( e) => panic:: resume_unwind ( e) ,
155
+ }
162
156
}
163
157
164
158
/// Creates a new thread and forwards information in thread locals to it.
0 commit comments