diff options
| author | Shotaro Yamada <sinkuu@sinkuu.xyz> | 2019-10-04 09:56:45 +0900 |
|---|---|---|
| committer | Shotaro Yamada <sinkuu@sinkuu.xyz> | 2019-10-04 10:38:52 +0900 |
| commit | 20b73514395bb442fb16ce913b6c2b3965ff3156 (patch) | |
| tree | f86c10e8097ee9464d26d6bab5993c33aec6025f /clippy_dev | |
| parent | 737f0a6bb508706b75e21194e3010aa3865e779a (diff) | |
| download | rust-20b73514395bb442fb16ce913b6c2b3965ff3156.tar.gz rust-20b73514395bb442fb16ce913b6c2b3965ff3156.zip | |
Workaround cargo bug on Windows
Diffstat (limited to 'clippy_dev')
| -rw-r--r-- | clippy_dev/src/fmt.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clippy_dev/src/fmt.rs b/clippy_dev/src/fmt.rs index 9f0b68baf9d..d5d56322f2a 100644 --- a/clippy_dev/src/fmt.rs +++ b/clippy_dev/src/fmt.rs @@ -140,13 +140,13 @@ fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> { args.push("--"); args.push("--check"); } - let success = exec(context, "cargo", path, &args)?; + let success = exec(context, &bin_path("cargo"), path, &args)?; Ok(success) } fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> { - let program = "rustfmt"; + let program = bin_path("rustfmt"); let dir = std::env::current_dir()?; let args = &["+nightly", "--version"]; @@ -173,7 +173,7 @@ fn rustfmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> { if context.check { args.push("--check".as_ref()); } - let success = exec(context, "rustfmt", std::env::current_dir()?, &args)?; + let success = exec(context, &bin_path("rustfmt"), std::env::current_dir()?, &args)?; if !success { eprintln!("rustfmt failed on {}", path.display()); } @@ -198,3 +198,12 @@ fn project_root() -> Result<PathBuf, CliError> { Err(CliError::ProjectRootNotFound) } + +// Workaround for https://github.com/rust-lang/cargo/issues/7475. +// FIXME: replace `&bin_path("command")` with `"command"` once the issue is fixed +fn bin_path(bin: &str) -> String { + let mut p = PathBuf::from(std::env::var_os("CARGO_HOME").unwrap()); + p.push("bin"); + p.push(bin); + p.display().to_string() +} |
