@@ -11,6 +11,7 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
11
11
use rustc_data_structures:: OnDrop ;
12
12
use rustc_data_structures:: sync:: Lrc ;
13
13
use rustc_data_structures:: fx:: { FxHashSet , FxHashMap } ;
14
+ use rustc_errors:: registry:: Registry ;
14
15
use rustc_parse:: new_parser_from_source_str;
15
16
use rustc:: ty;
16
17
use std:: path:: PathBuf ;
@@ -141,19 +142,24 @@ pub struct Config {
141
142
/// The second parameter is local providers and the third parameter is external providers.
142
143
pub override_queries :
143
144
Option < fn ( & Session , & mut ty:: query:: Providers < ' _ > , & mut ty:: query:: Providers < ' _ > ) > ,
145
+
146
+ /// Registry of diagnostics codes.
147
+ pub registry : Registry ,
144
148
}
145
149
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 ;
150
155
let ( sess, codegen_backend, source_map) = util:: create_session (
151
156
config. opts ,
152
157
config. crate_cfg ,
153
158
config. diagnostic_output ,
154
159
config. file_loader ,
155
160
config. input_path . clone ( ) ,
156
161
config. lint_caps ,
162
+ registry. clone ( ) ,
157
163
) ;
158
164
159
165
let compiler = Compiler {
@@ -171,17 +177,13 @@ where
171
177
} ;
172
178
173
179
let _sess_abort_error = OnDrop ( || {
174
- compiler. sess . diagnostic ( ) . print_error_count ( & util :: diagnostics_registry ( ) ) ;
180
+ compiler. sess . diagnostic ( ) . print_error_count ( registry ) ;
175
181
} ) ;
176
182
177
183
f ( & compiler)
178
184
}
179
185
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 {
185
187
let stderr = config. stderr . take ( ) ;
186
188
util:: spawn_thread_pool (
187
189
config. opts . edition ,
@@ -191,11 +193,7 @@ where
191
193
)
192
194
}
193
195
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 {
199
197
// the 1 here is duplicating code in config.opts.debugging_opts.threads
200
198
// which also defaults to 1; it ultimately doesn't matter as the default
201
199
// isn't threaded, and just ignores this parameter
0 commit comments