about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorJames Dietz <jamesthespeedy@gmail.com>2023-05-04 20:54:17 -0400
committerJames Dietz <jamesthespeedy@gmail.com>2023-05-04 20:54:17 -0400
commitf239cd6a35776cbc91400a9e498d8b7487fe4975 (patch)
tree009f7eef0587668576a522f4038c2c6f70a4433b /compiler/rustc_codegen_llvm/src/llvm_util.rs
parentcb74cd524f2798a098943425c271d9eada8d901e (diff)
downloadrust-f239cd6a35776cbc91400a9e498d8b7487fe4975.tar.gz
rust-f239cd6a35776cbc91400a9e498d8b7487fe4975.zip
added SAFETY comment
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index a5d4ca30fab..2fbdab9f8ce 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -330,6 +330,9 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
     let tm = create_informational_target_machine(sess);
     match req {
         PrintRequest::TargetCPUs => {
+            // SAFETY generate a C compatible string from a byte slice to pass
+            // the target CPU name into LLVM, the lifetime of the reference is
+            // at least as long as the C function
             let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
                 .unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
             unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };