Skip to content

Commit 3f68ff4

Browse files
committed
Auto merge of #9818 - hi-rustin:rustin-patch-fix, r=alexcrichton
unset the FIX_ENV when executing the real rustc close #9706
2 parents bcfd893 + 4c11002 commit 3f68ff4

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/cargo/ops/fix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult<bool> {
346346
let workspace_rustc = std::env::var("RUSTC_WORKSPACE_WRAPPER")
347347
.map(PathBuf::from)
348348
.ok();
349-
let rustc = ProcessBuilder::new(&args.rustc).wrapped(workspace_rustc.as_ref());
349+
let mut rustc = ProcessBuilder::new(&args.rustc).wrapped(workspace_rustc.as_ref());
350+
rustc.env_remove(FIX_ENV);
350351

351352
trace!("start rustfixing {:?}", args.file);
352353
let fixes = rustfix_crate(&lock_addr, &rustc, &args.file, &args, config)?;

tests/testsuite/fix.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,3 +1696,52 @@ fn abnormal_exit() {
16961696
.with_stderr_contains("Original diagnostics will follow.")
16971697
.run();
16981698
}
1699+
1700+
#[cargo_test]
1701+
fn fix_with_run_cargo_in_proc_macros() {
1702+
let p = project()
1703+
.file(
1704+
"Cargo.toml",
1705+
r#"
1706+
[package]
1707+
name = "foo"
1708+
version = "0.1.0"
1709+
edition = "2018"
1710+
1711+
[lib]
1712+
proc-macro = true
1713+
"#,
1714+
)
1715+
.file(
1716+
"src/lib.rs",
1717+
r#"
1718+
use proc_macro::*;
1719+
1720+
#[proc_macro]
1721+
pub fn foo(_input: TokenStream) -> TokenStream {
1722+
let output = std::process::Command::new("cargo")
1723+
.args(&["metadata", "--format-version=1"])
1724+
.output()
1725+
.unwrap();
1726+
eprintln!("{}", std::str::from_utf8(&output.stderr).unwrap());
1727+
println!("{}", std::str::from_utf8(&output.stdout).unwrap());
1728+
"".parse().unwrap()
1729+
}
1730+
"#,
1731+
)
1732+
.file(
1733+
"src/bin/main.rs",
1734+
r#"
1735+
use foo::foo;
1736+
1737+
fn main() {
1738+
foo!("bar")
1739+
}
1740+
"#,
1741+
)
1742+
.build();
1743+
p.cargo("fix --allow-no-vcs")
1744+
.masquerade_as_nightly_cargo()
1745+
.with_stderr_does_not_contain("error: could not find .rs file in rustc args")
1746+
.run();
1747+
}

0 commit comments

Comments
 (0)