From bccc0ee4e361f5ef34357097f7c21decd4c983bf Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Sun, 24 Mar 2019 09:29:57 -0700 Subject: [PATCH] actually fix it so cargo fix kinda works with new wrapper stuff --- src/cargo/core/compiler/build_context/mod.rs | 13 ++++++++----- src/cargo/core/compiler/compilation.rs | 18 +----------------- src/cargo/ops/fix.rs | 2 +- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs index 8632b50dc8e..5a7391bb5d8 100644 --- a/src/cargo/core/compiler/build_context/mod.rs +++ b/src/cargo/core/compiler/build_context/mod.rs @@ -69,11 +69,14 @@ 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 = dbg!(rustc.path.as_os_str().to_owned()); - // wrapper.env("RUSTC", prog); - // rustc.push_wrapper(wrapper); + } 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); + } + rustc.push_wrapper(wrapper); } let host_config = TargetConfig::new(config, &rustc.host)?; diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs index 354d6b568f4..0f162b72bc0 100644 --- a/src/cargo/core/compiler/compilation.rs +++ b/src/cargo/core/compiler/compilation.rs @@ -75,27 +75,11 @@ pub struct Compilation<'cfg> { impl<'cfg> Compilation<'cfg> { pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult> { - // If we're using cargo as a rustc wrapper then we're in a situation - // like `cargo fix`. For now just disregard the `RUSTC_WRAPPER` env var - // (which is typically set to `sccache` for now). Eventually we'll - // probably want to implement `RUSTC_WRAPPER` for `cargo fix`, but we'll - // leave that open as a bug for now. - let mut rustc = if bcx.build_config.cargo_as_rustc_wrapper { - let mut rustc = bcx.rustc.process_no_wrapper(); - let prog = rustc.get_program().to_owned(); - rustc.env("RUSTC", prog); - rustc.program(env::current_exe()?); - rustc - } else { - bcx.rustc.process() - }; + let mut rustc = bcx.rustc.process(); if bcx.config.extra_verbose() { rustc.display_env_vars(); } - for (k, v) in bcx.build_config.extra_rustc_env.iter() { - rustc.env(k, v); - } for arg in bcx.build_config.extra_rustc_args.iter() { rustc.arg(arg); } diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index 0d2bfbcee3d..9d0f67cff16 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -593,7 +593,7 @@ impl Default for PrepareFor { impl FixArgs { fn get() -> FixArgs { let mut ret = FixArgs::default(); - for arg in env::args_os().skip(1) { + 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() { ret.file = Some(path);