Skip to content

Commit 56b18ce

Browse files
committed
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.
1 parent 0a423a7 commit 56b18ce

File tree

2 files changed

+26
-32
lines changed

2 files changed

+26
-32
lines changed

src/tools/compiletest/src/main.rs

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![crate_name = "compiletest"]
22
#![feature(test)]
3-
#![feature(path_buf_capacity)]
43
#![feature(vec_remove_item)]
54
#![deny(warnings, rust_2018_idioms)]
65

@@ -857,35 +856,34 @@ fn is_pc_windows_msvc_target(target: &String) -> bool {
857856
}
858857

859858
fn find_cdb(target: &String) -> Option<OsString> {
860-
if cfg!(windows) && is_pc_windows_msvc_target(target) {
861-
let pf86 = env::var_os("ProgramFiles(x86)").or(env::var_os("ProgramFiles"))?;
862-
let cdb_arch = if cfg!(target_arch="x86") {
863-
"x86"
864-
} else if cfg!(target_arch="x86_64") {
865-
"x64"
866-
} else if cfg!(target_arch="aarch64") {
867-
"arm64"
868-
} else if cfg!(target_arch="arm") {
869-
"arm"
870-
} else {
871-
return None; // No compatible CDB.exe in the Windows 10 SDK
872-
};
859+
if !(cfg!(windows) && is_pc_windows_msvc_target(target)) {
860+
return None;
861+
}
862+
863+
let pf86 = env::var_os("ProgramFiles(x86)").or(env::var_os("ProgramFiles"))?;
864+
let cdb_arch = if cfg!(target_arch="x86") {
865+
"x86"
866+
} else if cfg!(target_arch="x86_64") {
867+
"x64"
868+
} else if cfg!(target_arch="aarch64") {
869+
"arm64"
870+
} else if cfg!(target_arch="arm") {
871+
"arm"
872+
} else {
873+
return None; // No compatible CDB.exe in the Windows 10 SDK
874+
};
873875

874-
let mut path = PathBuf::with_capacity(64);
875-
path.push(pf86);
876-
path.push(r"Windows Kits\10\Debuggers"); // We could check 8.1 etc. too?
877-
path.push(cdb_arch);
878-
path.push(r"cdb.exe");
876+
let mut path = PathBuf::new();
877+
path.push(pf86);
878+
path.push(r"Windows Kits\10\Debuggers"); // We could check 8.1 etc. too?
879+
path.push(cdb_arch);
880+
path.push(r"cdb.exe");
879881

880-
if path.exists() {
881-
Some(path.into_os_string())
882-
} else {
883-
None
884-
}
885-
}
886-
else {
887-
None
882+
if !path.exists() {
883+
return None;
888884
}
885+
886+
Some(path.into_os_string())
889887
}
890888

891889
/// Returns Path to CDB

src/tools/compiletest/src/runtest.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,7 @@ pub fn compute_stamp_hash(config: &Config) -> String {
244244
config.stage_id.hash(&mut hash);
245245

246246
if config.mode == DebugInfoCdb {
247-
match config.cdb {
248-
None => env::var_os("ProgramFiles(x86)").hash(&mut hash),
249-
Some(ref s) if s.is_empty() => env::var_os("ProgramFiles(x86)").hash(&mut hash),
250-
Some(ref s) => s.hash(&mut hash),
251-
}
247+
config.cdb.hash(&mut hash);
252248
}
253249

254250
if config.mode == DebugInfoGdb || config.mode == DebugInfoGdbLldb {

0 commit comments

Comments
 (0)