Skip to content

Commit bccc0ee

Browse files
committed
actually fix it so cargo fix kinda works with new wrapper stuff
1 parent d2ab686 commit bccc0ee

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

src/cargo/core/compiler/build_context/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
6969
}
7070
})?;
7171
rustc.push_wrapper(RustcWrapper::new(tool));
72-
// } else if build_config.cargo_as_rustc_wrapper {
73-
// let mut wrapper = RustcWrapper::new(env::current_exe()?);
74-
// let prog = dbg!(rustc.path.as_os_str().to_owned());
75-
// wrapper.env("RUSTC", prog);
76-
// rustc.push_wrapper(wrapper);
72+
} else if build_config.cargo_as_rustc_wrapper {
73+
let mut wrapper = RustcWrapper::new(env::current_exe()?);
74+
let prog = rustc.path.as_os_str().to_owned();
75+
wrapper.env("RUSTC", prog);
76+
for (k, v) in build_config.extra_rustc_env.iter() {
77+
wrapper.env(k, v);
78+
}
79+
rustc.push_wrapper(wrapper);
7780
}
7881

7982
let host_config = TargetConfig::new(config, &rustc.host)?;

src/cargo/core/compiler/compilation.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,11 @@ pub struct Compilation<'cfg> {
7575

7676
impl<'cfg> Compilation<'cfg> {
7777
pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult<Compilation<'cfg>> {
78-
// If we're using cargo as a rustc wrapper then we're in a situation
79-
// like `cargo fix`. For now just disregard the `RUSTC_WRAPPER` env var
80-
// (which is typically set to `sccache` for now). Eventually we'll
81-
// probably want to implement `RUSTC_WRAPPER` for `cargo fix`, but we'll
82-
// leave that open as a bug for now.
83-
let mut rustc = if bcx.build_config.cargo_as_rustc_wrapper {
84-
let mut rustc = bcx.rustc.process_no_wrapper();
85-
let prog = rustc.get_program().to_owned();
86-
rustc.env("RUSTC", prog);
87-
rustc.program(env::current_exe()?);
88-
rustc
89-
} else {
90-
bcx.rustc.process()
91-
};
78+
let mut rustc = bcx.rustc.process();
9279

9380
if bcx.config.extra_verbose() {
9481
rustc.display_env_vars();
9582
}
96-
for (k, v) in bcx.build_config.extra_rustc_env.iter() {
97-
rustc.env(k, v);
98-
}
9983
for arg in bcx.build_config.extra_rustc_args.iter() {
10084
rustc.arg(arg);
10185
}

src/cargo/ops/fix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl Default for PrepareFor {
593593
impl FixArgs {
594594
fn get() -> FixArgs {
595595
let mut ret = FixArgs::default();
596-
for arg in env::args_os().skip(1) {
596+
for arg in env::args_os().skip(2) {
597597
let path = PathBuf::from(arg);
598598
if path.extension().and_then(|s| s.to_str()) == Some("rs") && path.exists() {
599599
ret.file = Some(path);

0 commit comments

Comments
 (0)