From 76b0a8a02ee07e9e80df3b4ac1fb5192f4ef2044 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 16 Apr 2018 19:22:53 +0300 Subject: [PATCH] rustc is rustc.exe on windows --- src/cargo/ops/cargo_compile.rs | 4 +++- src/cargo/util/config.rs | 6 +++++- src/cargo/util/paths.rs | 3 +-- src/cargo/util/rustc.rs | 17 ++++++++++------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index fbf6acb3024..32d2cd2003c 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -260,7 +260,9 @@ pub fn compile_ws<'a>( bail!("jobs must be at least 1") } - let rustc_info_cache = ws.target_dir().join(".rustc_info.json").into_path_unlocked(); + let rustc_info_cache = ws.target_dir() + .join(".rustc_info.json") + .into_path_unlocked(); let mut build_config = BuildConfig::new(config, jobs, &target, Some(rustc_info_cache))?; build_config.release = release; build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench; diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index c7a37e744e2..ac8bf21f6a4 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -171,7 +171,11 @@ impl Config { Rustc::new( self.get_tool("rustc")?, self.maybe_get_tool("rustc_wrapper")?, - &self.home().join("bin").join("rustc").into_path_unlocked(), + &self.home() + .join("bin") + .join("rustc") + .into_path_unlocked() + .with_extension(env::consts::EXE_EXTENSION), if self.cache_rustc_info { cache_location } else { diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 350663620ae..de87a6a3cb0 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -158,8 +158,7 @@ pub fn append(path: &Path, contents: &[u8]) -> CargoResult<()> { } pub fn mtime(path: &Path) -> CargoResult { - let meta = - fs::metadata(path).chain_err(|| format!("failed to stat `{}`", path.display()))?; + let meta = fs::metadata(path).chain_err(|| format!("failed to stat `{}`", path.display()))?; Ok(FileTime::from_last_modification_time(&meta)) } diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index 25bb9b5ba95..883563d2fd9 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -219,21 +219,24 @@ fn rustc_fingerprint(path: &Path, rustup_rustc: &Path) -> CargoResult { // If we don't see rustup env vars, but it looks like the compiler // is managed by rustup, we conservatively bail out. let maybe_rustup = rustup_rustc == path; - match (maybe_rustup, env::var("RUSTUP_HOME"), env::var("RUSTUP_TOOLCHAIN")) { + match ( + maybe_rustup, + env::var("RUSTUP_HOME"), + env::var("RUSTUP_TOOLCHAIN"), + ) { (_, Ok(rustup_home), Ok(rustup_toolchain)) => { debug!("adding rustup info to rustc fingerprint"); rustup_toolchain.hash(&mut hasher); rustup_home.hash(&mut hasher); - let rustup_rustc = Path::new(&rustup_home) + let real_rustc = Path::new(&rustup_home) .join("toolchains") .join(rustup_toolchain) .join("bin") - .join("rustc"); - paths::mtime(&rustup_rustc)?.hash(&mut hasher); - } - (true, _, _) => { - bail!("probably rustup rustc, but without rustup's env vars") + .join("rustc") + .with_extension(env::consts::EXE_EXTENSION); + paths::mtime(&real_rustc)?.hash(&mut hasher); } + (true, _, _) => bail!("probably rustup rustc, but without rustup's env vars"), _ => (), }