From 8764ecd0c14f9f3f083b84de893ab8e6f71100bc Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 10 May 2025 21:09:16 +1000 Subject: Add a searchable tag `PTR_LEN_STR` to explain `*const c_uchar` bindings This module comment describes why it's OK for LLVM bindings to declare a parameter type of `*const c_uchar` for pointer/length strings, even though the corresponding parameter on the C/C++ side uses `const char *`. Adding a searchable term to each such parameter should make it easier for future maintainers to understand why `*const c_uchar` is being used instead of `*const c_char`. --- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_codegen_llvm/src') diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index a249cb86ed4..feaae19f0cd 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1,7 +1,7 @@ //! Bindings to the LLVM-C API (`LLVM*`), and to our own `extern "C"` wrapper //! functions around the unstable LLVM C++ API (`LLVMRust*`). //! -//! ## Passing pointer/length strings as `*const c_uchar` +//! ## Passing pointer/length strings as `*const c_uchar` (PTR_LEN_STR) //! //! Normally it's a good idea for Rust-side bindings to match the corresponding //! C-side function declarations as closely as possible. But when passing `&str` @@ -1766,7 +1766,7 @@ unsafe extern "C" { pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>( Builder: &DIBuilder<'ll>, ParentScope: Option<&'ll Metadata>, - Name: *const c_uchar, + Name: *const c_uchar, // See "PTR_LEN_STR". NameLen: size_t, ExportSymbols: llvm::Bool, ) -> &'ll Metadata; -- cgit 1.4.1-3-g733a5