@@ -197,12 +197,7 @@ fn run_compiler(
197197 let sopts = config:: build_session_options ( & matches) ;
198198 let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
199199
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| {
206201 let mut config = interface:: Config {
207202 opts : sopts,
208203 crate_cfg : cfg,
@@ -217,7 +212,7 @@ fn run_compiler(
217212 parse_sess_created : None ,
218213 register_lints : None ,
219214 override_queries : None ,
220- make_codegen_backend : make_codegen_backend . take ( ) . unwrap ( ) ,
215+ make_codegen_backend,
221216 registry : diagnostics_registry ( ) ,
222217 } ;
223218 callbacks. config ( & mut config) ;
@@ -234,7 +229,7 @@ fn run_compiler(
234229 Some ( v) => v,
235230 None => match matches. free . len ( ) {
236231 0 => {
237- let config = dummy_config ( sopts, cfg, diagnostic_output) ;
232+ let config = dummy_config ( sopts, cfg, diagnostic_output, make_codegen_backend ) ;
238233 interface:: run_compiler ( config, |compiler| {
239234 let sopts = & compiler. session ( ) . opts ;
240235 if sopts. describe_lints {
@@ -281,10 +276,7 @@ fn run_compiler(
281276 if let Some ( err) = input_err {
282277 // Immediately stop compilation if there was an issue reading
283278 // 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 ( ) ) ;
288280 }
289281
290282 let mut config = interface:: Config {
@@ -301,7 +293,7 @@ fn run_compiler(
301293 parse_sess_created : None ,
302294 register_lints : None ,
303295 override_queries : None ,
304- make_codegen_backend : make_codegen_backend . unwrap ( ) ,
296+ make_codegen_backend,
305297 registry : diagnostics_registry ( ) ,
306298 } ;
307299
0 commit comments