Skip to content

Commit 58b9e6e

Browse files
committed
Completely remove dummy_config
1 parent 4adcdf1 commit 58b9e6e

File tree

1 file changed

+36
-55
lines changed
  • compiler/rustc_driver/src

1 file changed

+36
-55
lines changed

compiler/rustc_driver/src/lib.rs

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -195,41 +195,48 @@ fn run_compiler(
195195
};
196196

197197
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-
};
221198

222199
if let Some(ref code) = matches.opt_str("explain") {
223200
handle_explain(diagnostics_registry(), code, sopts.error_format);
224201
return Ok(());
225202
}
226203

204+
let cfg = interface::parse_cfgspecs(matches.opt_strs("cfg"));
227205
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+
}
230237
None => match matches.free.len() {
231238
0 => {
232-
let config = dummy_config(sopts, cfg, diagnostic_output, make_codegen_backend);
239+
callbacks.config(&mut config);
233240
interface::run_compiler(config, |compiler| {
234241
let sopts = &compiler.session().opts;
235242
if sopts.describe_lints {
@@ -251,8 +258,8 @@ fn run_compiler(
251258
&***compiler.codegen_backend(),
252259
compiler.session(),
253260
None,
254-
&odir,
255-
&ofile,
261+
&compiler.output_dir(),
262+
&compiler.output_file(),
256263
);
257264

258265
if should_stop == Compilation::Stop {
@@ -264,7 +271,7 @@ fn run_compiler(
264271
}
265272
1 => panic!("make_input should have provided valid inputs"),
266273
_ => early_error(
267-
sopts.error_format,
274+
config.opts.error_format,
268275
&format!(
269276
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
270277
matches.free[0], matches.free[1],
@@ -273,32 +280,6 @@ fn run_compiler(
273280
},
274281
};
275282

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-
302283
interface::run_compiler(config, |compiler| {
303284
let sess = compiler.session();
304285
let should_stop = RustcDefaultCalls::print_crate_info(

0 commit comments

Comments
 (0)