@@ -195,41 +195,48 @@ fn run_compiler(
195
195
} ;
196
196
197
197
let sopts = config:: build_session_options ( & matches) ;
198
- let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
199
-
200
- let mut dummy_config = |sopts, cfg, diagnostic_output, make_codegen_backend| {
201
- let mut config = interface:: Config {
202
- opts : sopts,
203
- crate_cfg : cfg,
204
- input : Input :: File ( PathBuf :: new ( ) ) ,
205
- input_path : None ,
206
- output_file : None ,
207
- output_dir : None ,
208
- file_loader : None ,
209
- diagnostic_output,
210
- stderr : None ,
211
- lint_caps : Default :: default ( ) ,
212
- parse_sess_created : None ,
213
- register_lints : None ,
214
- override_queries : None ,
215
- make_codegen_backend,
216
- registry : diagnostics_registry ( ) ,
217
- } ;
218
- callbacks. config ( & mut config) ;
219
- config
220
- } ;
221
198
222
199
if let Some ( ref code) = matches. opt_str ( "explain" ) {
223
200
handle_explain ( diagnostics_registry ( ) , code, sopts. error_format ) ;
224
201
return Ok ( ( ) ) ;
225
202
}
226
203
204
+ let cfg = interface:: parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
227
205
let ( odir, ofile) = make_output ( & matches) ;
228
- let ( input, input_file_path, input_err) = match make_input ( & matches. free ) {
229
- Some ( v) => v,
206
+ let mut config = interface:: Config {
207
+ opts : sopts,
208
+ crate_cfg : cfg,
209
+ input : Input :: File ( PathBuf :: new ( ) ) ,
210
+ input_path : None ,
211
+ output_file : ofile,
212
+ output_dir : odir,
213
+ file_loader,
214
+ diagnostic_output,
215
+ stderr : None ,
216
+ lint_caps : Default :: default ( ) ,
217
+ parse_sess_created : None ,
218
+ register_lints : None ,
219
+ override_queries : None ,
220
+ make_codegen_backend,
221
+ registry : diagnostics_registry ( ) ,
222
+ } ;
223
+
224
+ match make_input ( & matches. free ) {
225
+ Some ( ( input, input_file_path, input_err) ) => {
226
+ if let Some ( err) = input_err {
227
+ // Immediately stop compilation if there was an issue reading
228
+ // the input (for example if the input stream is not UTF-8).
229
+ early_error ( config. opts . error_format , & err. to_string ( ) ) ;
230
+ }
231
+
232
+ config. input = input;
233
+ config. input_path = input_file_path;
234
+
235
+ callbacks. config ( & mut config) ;
236
+ }
230
237
None => match matches. free . len ( ) {
231
238
0 => {
232
- let config = dummy_config ( sopts , cfg , diagnostic_output , make_codegen_backend ) ;
239
+ callbacks . config ( & mut config ) ;
233
240
interface:: run_compiler ( config, |compiler| {
234
241
let sopts = & compiler. session ( ) . opts ;
235
242
if sopts. describe_lints {
@@ -251,8 +258,8 @@ fn run_compiler(
251
258
& * * * compiler. codegen_backend ( ) ,
252
259
compiler. session ( ) ,
253
260
None ,
254
- & odir ,
255
- & ofile ,
261
+ & compiler . output_dir ( ) ,
262
+ & compiler . output_file ( ) ,
256
263
) ;
257
264
258
265
if should_stop == Compilation :: Stop {
@@ -264,7 +271,7 @@ fn run_compiler(
264
271
}
265
272
1 => panic ! ( "make_input should have provided valid inputs" ) ,
266
273
_ => early_error (
267
- sopts . error_format ,
274
+ config . opts . error_format ,
268
275
& format ! (
269
276
"multiple input filenames provided (first two filenames are `{}` and `{}`)" ,
270
277
matches. free[ 0 ] , matches. free[ 1 ] ,
@@ -273,32 +280,6 @@ fn run_compiler(
273
280
} ,
274
281
} ;
275
282
276
- if let Some ( err) = input_err {
277
- // Immediately stop compilation if there was an issue reading
278
- // the input (for example if the input stream is not UTF-8).
279
- early_error ( sopts. error_format , & err. to_string ( ) ) ;
280
- }
281
-
282
- let mut config = interface:: Config {
283
- opts : sopts,
284
- crate_cfg : cfg,
285
- input,
286
- input_path : input_file_path,
287
- output_file : ofile,
288
- output_dir : odir,
289
- file_loader,
290
- diagnostic_output,
291
- stderr : None ,
292
- lint_caps : Default :: default ( ) ,
293
- parse_sess_created : None ,
294
- register_lints : None ,
295
- override_queries : None ,
296
- make_codegen_backend,
297
- registry : diagnostics_registry ( ) ,
298
- } ;
299
-
300
- callbacks. config ( & mut config) ;
301
-
302
283
interface:: run_compiler ( config, |compiler| {
303
284
let sess = compiler. session ( ) ;
304
285
let should_stop = RustcDefaultCalls :: print_crate_info (
0 commit comments