@@ -11,6 +11,7 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
1111use rustc_data_structures:: OnDrop ;
1212use rustc_data_structures:: sync:: Lrc ;
1313use rustc_data_structures:: fx:: { FxHashSet , FxHashMap } ;
14+ use rustc_errors:: registry:: Registry ;
1415use rustc_parse:: new_parser_from_source_str;
1516use rustc:: ty;
1617use std:: path:: PathBuf ;
@@ -141,19 +142,24 @@ pub struct Config {
141142 /// The second parameter is local providers and the third parameter is external providers.
142143 pub override_queries :
143144 Option < fn ( & Session , & mut ty:: query:: Providers < ' _ > , & mut ty:: query:: Providers < ' _ > ) > ,
145+
146+ /// Registry of diagnostics codes.
147+ pub registry : Registry ,
144148}
145149
146- pub fn run_compiler_in_existing_thread_pool < F , R > ( config : Config , f : F ) -> R
147- where
148- F : FnOnce ( & Compiler ) -> R ,
149- {
150+ pub fn run_compiler_in_existing_thread_pool < R > (
151+ config : Config ,
152+ f : impl FnOnce ( & Compiler ) -> R ,
153+ ) -> R {
154+ let registry = & config. registry ;
150155 let ( sess, codegen_backend, source_map) = util:: create_session (
151156 config. opts ,
152157 config. crate_cfg ,
153158 config. diagnostic_output ,
154159 config. file_loader ,
155160 config. input_path . clone ( ) ,
156161 config. lint_caps ,
162+ registry. clone ( ) ,
157163 ) ;
158164
159165 let compiler = Compiler {
@@ -171,17 +177,13 @@ where
171177 } ;
172178
173179 let _sess_abort_error = OnDrop ( || {
174- compiler. sess . diagnostic ( ) . print_error_count ( & util :: diagnostics_registry ( ) ) ;
180+ compiler. sess . diagnostic ( ) . print_error_count ( registry ) ;
175181 } ) ;
176182
177183 f ( & compiler)
178184}
179185
180- pub fn run_compiler < F , R > ( mut config : Config , f : F ) -> R
181- where
182- F : FnOnce ( & Compiler ) -> R + Send ,
183- R : Send ,
184- {
186+ pub fn run_compiler < R : Send > ( mut config : Config , f : impl FnOnce ( & Compiler ) -> R + Send ) -> R {
185187 let stderr = config. stderr . take ( ) ;
186188 util:: spawn_thread_pool (
187189 config. opts . edition ,
@@ -191,11 +193,7 @@ where
191193 )
192194}
193195
194- pub fn default_thread_pool < F , R > ( edition : edition:: Edition , f : F ) -> R
195- where
196- F : FnOnce ( ) -> R + Send ,
197- R : Send ,
198- {
196+ pub fn default_thread_pool < R : Send > ( edition : edition:: Edition , f : impl FnOnce ( ) -> R + Send ) -> R {
199197 // the 1 here is duplicating code in config.opts.debugging_opts.threads
200198 // which also defaults to 1; it ultimately doesn't matter as the default
201199 // isn't threaded, and just ignores this parameter
0 commit comments