Skip to content

Commit

Permalink
Auto merge of #9818 - hi-rustin:rustin-patch-fix, r=alexcrichton
Browse files Browse the repository at this point in the history
unset the FIX_ENV when executing the real rustc

close #9706
  • Loading branch information
bors committed Aug 23, 2021
2 parents bcfd893 + 4c11002 commit 3f68ff4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult<bool> {
let workspace_rustc = std::env::var("RUSTC_WORKSPACE_WRAPPER")
.map(PathBuf::from)
.ok();
let rustc = ProcessBuilder::new(&args.rustc).wrapped(workspace_rustc.as_ref());
let mut rustc = ProcessBuilder::new(&args.rustc).wrapped(workspace_rustc.as_ref());
rustc.env_remove(FIX_ENV);

trace!("start rustfixing {:?}", args.file);
let fixes = rustfix_crate(&lock_addr, &rustc, &args.file, &args, config)?;
Expand Down
49 changes: 49 additions & 0 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,3 +1696,52 @@ fn abnormal_exit() {
.with_stderr_contains("Original diagnostics will follow.")
.run();
}

#[cargo_test]
fn fix_with_run_cargo_in_proc_macros() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[lib]
proc-macro = true
"#,
)
.file(
"src/lib.rs",
r#"
use proc_macro::*;
#[proc_macro]
pub fn foo(_input: TokenStream) -> TokenStream {
let output = std::process::Command::new("cargo")
.args(&["metadata", "--format-version=1"])
.output()
.unwrap();
eprintln!("{}", std::str::from_utf8(&output.stderr).unwrap());
println!("{}", std::str::from_utf8(&output.stdout).unwrap());
"".parse().unwrap()
}
"#,
)
.file(
"src/bin/main.rs",
r#"
use foo::foo;
fn main() {
foo!("bar")
}
"#,
)
.build();
p.cargo("fix --allow-no-vcs")
.masquerade_as_nightly_cargo()
.with_stderr_does_not_contain("error: could not find .rs file in rustc args")
.run();
}

0 comments on commit 3f68ff4

Please sign in to comment.