@@ -197,12 +197,7 @@ fn run_compiler(
197
197
let sopts = config:: build_session_options ( & matches) ;
198
198
let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
199
199
200
- // We wrap `make_codegen_backend` in another `Option` such that `dummy_config` can take
201
- // ownership of it when necessary, while also allowing the non-dummy config to take ownership
202
- // when `dummy_config` is not used.
203
- let mut make_codegen_backend = Some ( make_codegen_backend) ;
204
-
205
- let mut dummy_config = |sopts, cfg, diagnostic_output| {
200
+ let mut dummy_config = |sopts, cfg, diagnostic_output, make_codegen_backend| {
206
201
let mut config = interface:: Config {
207
202
opts : sopts,
208
203
crate_cfg : cfg,
@@ -217,7 +212,7 @@ fn run_compiler(
217
212
parse_sess_created : None ,
218
213
register_lints : None ,
219
214
override_queries : None ,
220
- make_codegen_backend : make_codegen_backend . take ( ) . unwrap ( ) ,
215
+ make_codegen_backend,
221
216
registry : diagnostics_registry ( ) ,
222
217
} ;
223
218
callbacks. config ( & mut config) ;
@@ -234,7 +229,7 @@ fn run_compiler(
234
229
Some ( v) => v,
235
230
None => match matches. free . len ( ) {
236
231
0 => {
237
- let config = dummy_config ( sopts, cfg, diagnostic_output) ;
232
+ let config = dummy_config ( sopts, cfg, diagnostic_output, make_codegen_backend ) ;
238
233
interface:: run_compiler ( config, |compiler| {
239
234
let sopts = & compiler. session ( ) . opts ;
240
235
if sopts. describe_lints {
@@ -281,10 +276,7 @@ fn run_compiler(
281
276
if let Some ( err) = input_err {
282
277
// Immediately stop compilation if there was an issue reading
283
278
// the input (for example if the input stream is not UTF-8).
284
- interface:: run_compiler ( dummy_config ( sopts, cfg, diagnostic_output) , |compiler| {
285
- compiler. session ( ) . err ( & err. to_string ( ) ) ;
286
- } ) ;
287
- return Err ( ErrorReported ) ;
279
+ early_error ( sopts. error_format , & err. to_string ( ) ) ;
288
280
}
289
281
290
282
let mut config = interface:: Config {
@@ -301,7 +293,7 @@ fn run_compiler(
301
293
parse_sess_created : None ,
302
294
register_lints : None ,
303
295
override_queries : None ,
304
- make_codegen_backend : make_codegen_backend . unwrap ( ) ,
296
+ make_codegen_backend,
305
297
registry : diagnostics_registry ( ) ,
306
298
} ;
307
299
0 commit comments