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