diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs index 5a7391bb5d8..aca9a8ad25e 100644 --- a/src/cargo/core/compiler/build_context/mod.rs +++ b/src/cargo/core/compiler/build_context/mod.rs @@ -71,8 +71,6 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> { rustc.push_wrapper(RustcWrapper::new(tool)); } else if build_config.cargo_as_rustc_wrapper { let mut wrapper = RustcWrapper::new(env::current_exe()?); - let prog = rustc.path.as_os_str().to_owned(); - wrapper.env("RUSTC", prog); for (k, v) in build_config.extra_rustc_env.iter() { wrapper.env(k, v); } diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index 9d0f67cff16..6d8a4c78fc2 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -207,7 +207,7 @@ pub fn fix_maybe_exec_rustc() -> CargoResult { let args = FixArgs::get(); trace!("cargo-fix as rustc got file {:?}", args.file); - let rustc = env::var_os("RUSTC").expect("failed to find RUSTC env var"); + let rustc = args.rustc.as_ref().expect("fix wrapper rustc was not set"); // Our goal is to fix only the crates that the end user is interested in. // That's very likely to only mean the crates in the workspace the user is @@ -576,6 +576,7 @@ struct FixArgs { enabled_edition: Option, other: Vec, primary_package: bool, + rustc: Option, } enum PrepareFor { @@ -593,6 +594,7 @@ impl Default for PrepareFor { impl FixArgs { fn get() -> FixArgs { let mut ret = FixArgs::default(); + ret.rustc = env::args_os().nth(1).map(PathBuf::from); for arg in env::args_os().skip(2) { let path = PathBuf::from(arg); if path.extension().and_then(|s| s.to_str()) == Some("rs") && path.exists() {