@@ -132,33 +132,27 @@ fn get_stack_size() -> Option<usize> {
132132 env:: var_os ( "RUST_MIN_STACK" ) . is_none ( ) . then_some ( STACK_SIZE )
133133}
134134
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-
147135#[ cfg( not( parallel_compiler) ) ]
148136pub fn run_in_thread_pool_with_globals < F : FnOnce ( ) -> R + Send , R : Send > (
149137 edition : Edition ,
150138 _threads : usize ,
151139 f : F ,
152140) -> R {
141+ // The thread pool is a single thread in the non-parallel compiler.
153142 let mut cfg = thread:: Builder :: new ( ) . name ( "rustc" . to_string ( ) ) ;
154-
155143 if let Some ( size) = get_stack_size ( ) {
156144 cfg = cfg. stack_size ( size) ;
157145 }
158146
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) ;
160148
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+ }
162156}
163157
164158/// Creates a new thread and forwards information in thread locals to it.
0 commit comments