about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndy Russell <arussell123@gmail.com>2019-03-01 21:26:10 -0500
committerAndy Russell <arussell123@gmail.com>2019-03-01 21:27:43 -0500
commit5360ded0e50b332b8f7dfc725e3a59d34d4265a8 (patch)
tree74b709dd8c3f7a7ac17f78c8bcabafa1ee37386c
parent7f19f161f24c9a02ff8c3f73122d0b015039221f (diff)
downloadrust-5360ded0e50b332b8f7dfc725e3a59d34d4265a8.tar.gz
rust-5360ded0e50b332b8f7dfc725e3a59d34d4265a8.zip
fix an issue with path probing on Windows
The old logic would incorrectly look for "python2.exe" when searching
for "python2.7.exe".
-rw-r--r--src/bootstrap/sanity.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index ff4fb85bbfa..1a26309b471 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -34,15 +34,17 @@ impl Finder {
 
     fn maybe_have<S: AsRef<OsStr>>(&mut self, cmd: S) -> Option<PathBuf> {
         let cmd: OsString = cmd.as_ref().into();
-        let path = self.path.clone();
+        let path = &self.path;
         self.cache.entry(cmd.clone()).or_insert_with(|| {
-            for path in env::split_paths(&path) {
+            for path in env::split_paths(path) {
                 let target = path.join(&cmd);
-                let mut cmd_alt = cmd.clone();
-                cmd_alt.push(".exe");
-                if target.is_file() || // some/path/git
-                target.with_extension("exe").exists() || // some/path/git.exe
-                target.join(&cmd_alt).exists() { // some/path/git/git.exe
+                let mut cmd_exe = cmd.clone();
+                cmd_exe.push(".exe");
+
+                if target.is_file()                   // some/path/git
+                    || path.join(&cmd_exe).exists()   // some/path/git.exe
+                    || target.join(&cmd_exe).exists() // some/path/git/git.exe
+                {
                     return Some(target);
                 }
             }