Skip to content

Commit 79480cc

Browse files
committed
remove unnecessary is wrapper struct
1 parent f4dcb2b commit 79480cc

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

src/cargo/core/compiler/build_config.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,12 @@ pub struct BuildConfig {
2525
/// Output a build plan to stdout instead of actually compiling.
2626
pub build_plan: bool,
2727
/// An optional override of the rustc path for primary units only
28-
pub primary_unit_rustc: Option<PrimaryUnitRustc>,
28+
pub primary_unit_rustc: Option<ProcessBuilder>,
2929
pub rustfix_diagnostic_server: RefCell<Option<RustfixDiagnosticServer>>,
3030
/// Whether or not Cargo should cache compiler output on disk.
3131
cache_messages: bool,
3232
}
3333

34-
/// Configuration for subcommand specific rustc override
35-
#[derive(Debug, Clone)]
36-
pub struct PrimaryUnitRustc {
37-
/// ProcessBuilder to use instead of the default provided by `Rustc`
38-
pub proc: ProcessBuilder,
39-
/// Configure whether or not to use this as a wrapper around the original rustc process
40-
pub is_wrapper: bool,
41-
}
42-
4334
impl BuildConfig {
4435
/// Parses all config files to learn about build configuration. Currently
4536
/// configured options are:

src/cargo/core/compiler/compilation.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,7 @@ impl<'cfg> Compilation<'cfg> {
7878
pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult<Compilation<'cfg>> {
7979
let mut rustc = bcx.rustc.process();
8080

81-
let mut primary_unit_rustc_process =
82-
bcx.build_config.primary_unit_rustc.clone().map(|mut r| {
83-
if r.is_wrapper {
84-
r.proc.arg(&bcx.rustc.path);
85-
}
86-
r.proc
87-
});
81+
let mut primary_unit_rustc_process = bcx.build_config.primary_unit_rustc.clone();
8882

8983
if bcx.config.extra_verbose() {
9084
rustc.display_env_vars();

src/cargo/core/compiler/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use log::debug;
2424
use same_file::is_same_file;
2525
use serde::Serialize;
2626

27-
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, PrimaryUnitRustc};
27+
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat};
2828
pub use self::build_context::{BuildContext, FileFlavor, TargetConfig, TargetInfo};
2929
use self::build_plan::BuildPlan;
3030
pub use self::compilation::{Compilation, Doctest};

src/cargo/ops/fix.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use log::{debug, trace, warn};
5151
use rustfix::diagnostics::Diagnostic;
5252
use rustfix::{self, CodeFix};
5353

54-
use crate::core::compiler::PrimaryUnitRustc;
5554
use crate::core::Workspace;
5655
use crate::ops::{self, CompileOptions};
5756
use crate::util::diagnostic_server::{Message, RustfixDiagnosticServer};
@@ -131,12 +130,12 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions<'_>) -> CargoResult<()> {
131130
server.configure(&mut wrapper);
132131
}
133132

133+
let rustc = opts.compile_opts.config.load_global_rustc(Some(ws))?;
134+
wrapper.arg(&rustc.path);
135+
134136
// primary crates are compiled using a cargo subprocess to do extra work of applying fixes and
135137
// repeating build until there are no more changes to be applied
136-
opts.compile_opts.build_config.primary_unit_rustc = Some(PrimaryUnitRustc {
137-
proc: wrapper,
138-
is_wrapper: true,
139-
});
138+
opts.compile_opts.build_config.primary_unit_rustc = Some(wrapper);
140139

141140
ops::compile(ws, &opts.compile_opts)?;
142141
Ok(())

0 commit comments

Comments
 (0)