Skip to content

Commit 6d115f5

Browse files
committed
Refactor out another repeating pattern
1 parent 5441523 commit 6d115f5

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

compiler/rustc_interface/src/interface.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
338338

339339
let sysroot = filesearch::materialize_sysroot(config.opts.maybe_sysroot.clone());
340340

341-
let (codegen_backend, target_cfg) = match config.make_codegen_backend {
341+
let (codegen_backend, target_override) = match config.make_codegen_backend {
342342
None => {
343343
// Build a target without override, so that it can override the backend if needed
344344
let target =
@@ -365,36 +365,24 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
365365
);
366366
}
367367

368-
// Re-build target with the (potential) override
369-
let target = config::build_target_config(
370-
&early_dcx,
371-
&config.opts,
372-
target_override,
373-
&sysroot,
374-
);
375-
376-
(backend, target)
368+
(backend, target_override)
377369
}
378370
Some(make_codegen_backend) => {
379371
// N.B. `make_codegen_backend` takes precedence over `target.default_codegen_backend`,
380372
// which is ignored in this case.
381-
382373
let backend = make_codegen_backend(&config.opts);
383374

384375
// target_override is documented to be called before init(), so this is okay
385376
let target_override = backend.target_override(&config.opts);
386377

387-
let target = config::build_target_config(
388-
&early_dcx,
389-
&config.opts,
390-
target_override,
391-
&sysroot,
392-
);
393-
394-
(backend, target)
378+
(backend, target_override)
395379
}
396380
};
397381

382+
// Re-build target with the (potential) override
383+
let target_cfg =
384+
config::build_target_config(&early_dcx, &config.opts, target_override, &sysroot);
385+
398386
let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
399387

400388
let bundle = match rustc_errors::fluent_bundle(

0 commit comments

Comments
 (0)