about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJames Dietz <jamesthespeedy@gmail.com>2023-04-30 09:47:29 -0400
committerJames Dietz <jamesthespeedy@gmail.com>2023-05-04 20:29:38 -0400
commitcb74cd524f2798a098943425c271d9eada8d901e (patch)
tree0a72e6703f165d0af0a02b089b8127f3e87d15a5
parent9aa596a014d2582c1c51166953bd3fd85c71cca8 (diff)
downloadrust-cb74cd524f2798a098943425c271d9eada8d901e.tar.gz
rust-cb74cd524f2798a098943425c271d9eada8d901e.zip
change expect() to unwrap_or_else() and update msg
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs2
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp8
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 1baef931ff9..a5d4ca30fab 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -331,7 +331,7 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
     match req {
         PrintRequest::TargetCPUs => {
             let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
-                .expect("failed to convert to cstring");
+                .unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
             unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };
         }
         PrintRequest::TargetFeatures => print_target_features(sess, tm),
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index 03e76380c24..e88a3cdf620 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -324,10 +324,14 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
       MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
   }
   for (auto &CPU : CPUTable) {
-    printf("    %-*s", MaxCPULen, CPU.Key);
     // Compare cpu against current target to label the default
     if (strcmp(CPU.Key, TargetCPU) == 0) {
-      printf("   - this is the default target cpu for the current target");
+      printf("    %-*s - This is the default target CPU"
+      " for the current build target (currently %s).",
+        MaxCPULen, CPU.Key, Target->getTargetTriple().str().c_str());
+    }
+    else {
+      printf("    %-*s", MaxCPULen, CPU.Key);
     }
     printf("\n");
   }