Skip to content

Commit cb74cd5

Browse files
committed
change expect() to unwrap_or_else() and update msg
1 parent 9aa596a commit cb74cd5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
331331
match req {
332332
PrintRequest::TargetCPUs => {
333333
let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
334-
.expect("failed to convert to cstring");
334+
.unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
335335
unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };
336336
}
337337
PrintRequest::TargetFeatures => print_target_features(sess, tm),

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,14 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
324324
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
325325
}
326326
for (auto &CPU : CPUTable) {
327-
printf(" %-*s", MaxCPULen, CPU.Key);
328327
// Compare cpu against current target to label the default
329328
if (strcmp(CPU.Key, TargetCPU) == 0) {
330-
printf(" - this is the default target cpu for the current target");
329+
printf(" %-*s - This is the default target CPU"
330+
" for the current build target (currently %s).",
331+
MaxCPULen, CPU.Key, Target->getTargetTriple().str().c_str());
332+
}
333+
else {
334+
printf(" %-*s", MaxCPULen, CPU.Key);
331335
}
332336
printf("\n");
333337
}

0 commit comments

Comments
 (0)