about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorMaulingMonkey <git@maulingmonkey.com>2019-05-20 15:00:36 -0700
committerMaulingMonkey <git@maulingmonkey.com>2019-05-20 15:00:36 -0700
commit56b18ce6370a7e3376fce2d1c404532a887eb5b6 (patch)
treef1ed9e1d2f2a7d089d5a695fc0f0d79e4ca85f9c /src/tools/compiletest
parent0a423a70bb303195f09753dfdc5a7c4e149e29ff (diff)
downloadrust-56b18ce6370a7e3376fce2d1c404532a887eb5b6.tar.gz
rust-56b18ce6370a7e3376fce2d1c404532a887eb5b6.zip
Address CDB review feedback
- Don't add path_buf_capacity feature.
- Convert `find_cdb` to early return style, reducing indentation
- Simplify `compute_stamp_hash` for CDB to just hash it's path, if any.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/main.rs52
-rw-r--r--src/tools/compiletest/src/runtest.rs6
2 files changed, 26 insertions, 32 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 48ecd5a9142..d0dc9d11d39 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -1,6 +1,5 @@
 #![crate_name = "compiletest"]
 #![feature(test)]
-#![feature(path_buf_capacity)]
 #![feature(vec_remove_item)]
 #![deny(warnings, rust_2018_idioms)]
 
@@ -857,35 +856,34 @@ fn is_pc_windows_msvc_target(target: &String) -> bool {
 }
 
 fn find_cdb(target: &String) -> Option<OsString> {
-    if cfg!(windows) && is_pc_windows_msvc_target(target) {
-        let pf86 = env::var_os("ProgramFiles(x86)").or(env::var_os("ProgramFiles"))?;
-        let cdb_arch = if cfg!(target_arch="x86") {
-            "x86"
-        } else if cfg!(target_arch="x86_64") {
-            "x64"
-        } else if cfg!(target_arch="aarch64") {
-            "arm64"
-        } else if cfg!(target_arch="arm") {
-            "arm"
-        } else {
-            return None; // No compatible CDB.exe in the Windows 10 SDK
-        };
+    if !(cfg!(windows) && is_pc_windows_msvc_target(target)) {
+        return None;
+    }
+
+    let pf86 = env::var_os("ProgramFiles(x86)").or(env::var_os("ProgramFiles"))?;
+    let cdb_arch = if cfg!(target_arch="x86") {
+        "x86"
+    } else if cfg!(target_arch="x86_64") {
+        "x64"
+    } else if cfg!(target_arch="aarch64") {
+        "arm64"
+    } else if cfg!(target_arch="arm") {
+        "arm"
+    } else {
+        return None; // No compatible CDB.exe in the Windows 10 SDK
+    };
 
-        let mut path = PathBuf::with_capacity(64);
-        path.push(pf86);
-        path.push(r"Windows Kits\10\Debuggers"); // We could check 8.1 etc. too?
-        path.push(cdb_arch);
-        path.push(r"cdb.exe");
+    let mut path = PathBuf::new();
+    path.push(pf86);
+    path.push(r"Windows Kits\10\Debuggers"); // We could check 8.1 etc. too?
+    path.push(cdb_arch);
+    path.push(r"cdb.exe");
 
-        if path.exists() {
-            Some(path.into_os_string())
-        } else {
-            None
-        }
-    }
-    else {
-        None
+    if !path.exists() {
+        return None;
     }
+
+    Some(path.into_os_string())
 }
 
 /// Returns Path to CDB
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index c940e2de665..d87bd66a1ac 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -244,11 +244,7 @@ pub fn compute_stamp_hash(config: &Config) -> String {
     config.stage_id.hash(&mut hash);
 
     if config.mode == DebugInfoCdb {
-        match config.cdb {
-            None => env::var_os("ProgramFiles(x86)").hash(&mut hash),
-            Some(ref s) if s.is_empty() => env::var_os("ProgramFiles(x86)").hash(&mut hash),
-            Some(ref s) => s.hash(&mut hash),
-        }
+        config.cdb.hash(&mut hash);
     }
 
     if config.mode == DebugInfoGdb || config.mode == DebugInfoGdbLldb {