Skip to content

Commit

Permalink
remove unnecessary is wrapper struct
Browse files Browse the repository at this point in the history
  • Loading branch information
yaahc committed Aug 4, 2019
1 parent f4dcb2b commit 79480cc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
11 changes: 1 addition & 10 deletions src/cargo/core/compiler/build_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ pub struct BuildConfig {
/// Output a build plan to stdout instead of actually compiling.
pub build_plan: bool,
/// An optional override of the rustc path for primary units only
pub primary_unit_rustc: Option<PrimaryUnitRustc>,
pub primary_unit_rustc: Option<ProcessBuilder>,
pub rustfix_diagnostic_server: RefCell<Option<RustfixDiagnosticServer>>,
/// Whether or not Cargo should cache compiler output on disk.
cache_messages: bool,
}

/// Configuration for subcommand specific rustc override
#[derive(Debug, Clone)]
pub struct PrimaryUnitRustc {
/// ProcessBuilder to use instead of the default provided by `Rustc`
pub proc: ProcessBuilder,
/// Configure whether or not to use this as a wrapper around the original rustc process
pub is_wrapper: bool,
}

impl BuildConfig {
/// Parses all config files to learn about build configuration. Currently
/// configured options are:
Expand Down
8 changes: 1 addition & 7 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,7 @@ impl<'cfg> Compilation<'cfg> {
pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult<Compilation<'cfg>> {
let mut rustc = bcx.rustc.process();

let mut primary_unit_rustc_process =
bcx.build_config.primary_unit_rustc.clone().map(|mut r| {
if r.is_wrapper {
r.proc.arg(&bcx.rustc.path);
}
r.proc
});
let mut primary_unit_rustc_process = bcx.build_config.primary_unit_rustc.clone();

if bcx.config.extra_verbose() {
rustc.display_env_vars();
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use log::debug;
use same_file::is_same_file;
use serde::Serialize;

pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, PrimaryUnitRustc};
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat};
pub use self::build_context::{BuildContext, FileFlavor, TargetConfig, TargetInfo};
use self::build_plan::BuildPlan;
pub use self::compilation::{Compilation, Doctest};
Expand Down
9 changes: 4 additions & 5 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ use log::{debug, trace, warn};
use rustfix::diagnostics::Diagnostic;
use rustfix::{self, CodeFix};

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

let rustc = opts.compile_opts.config.load_global_rustc(Some(ws))?;
wrapper.arg(&rustc.path);

// primary crates are compiled using a cargo subprocess to do extra work of applying fixes and
// repeating build until there are no more changes to be applied
opts.compile_opts.build_config.primary_unit_rustc = Some(PrimaryUnitRustc {
proc: wrapper,
is_wrapper: true,
});
opts.compile_opts.build_config.primary_unit_rustc = Some(wrapper);

ops::compile(ws, &opts.compile_opts)?;
Ok(())
Expand Down

0 comments on commit 79480cc

Please sign in to comment.