Skip to content

Commit 44f5ec7

Browse files
committed
Avoid an explicit cast from *const c_uchar to *const c_char
As noted in the `ffi` module docs, passing pointer/length byte strings from Rust to C++ is easier if we declare them as `*const c_uchar` on the Rust side, but `const char *` (possibly signed) on the C++ side. This is allowed because both pointer types are ABI-compatible, regardless of char signedness.
1 parent 8d0a049 commit 44f5ec7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::{CStr, c_char};
1+
use std::ffi::CStr;
22
use std::marker::PhantomData;
33
use std::ptr::NonNull;
44

@@ -71,7 +71,7 @@ impl OwnedTargetMachine {
7171
output_obj_file.as_ptr(),
7272
debug_info_compression.as_ptr(),
7373
use_emulated_tls,
74-
args_cstr_buff.as_ptr() as *const c_char,
74+
args_cstr_buff.as_ptr(),
7575
args_cstr_buff.len(),
7676
use_wasm_eh,
7777
)

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ unsafe extern "C" {
24382438
OutputObjFile: *const c_char,
24392439
DebugInfoCompression: *const c_char,
24402440
UseEmulatedTls: bool,
2441-
ArgsCstrBuff: *const c_char,
2441+
ArgsCstrBuff: *const c_uchar, // See "PTR_LEN_STR".
24422442
ArgsCstrBuffLen: usize,
24432443
UseWasmEH: bool,
24442444
) -> *mut TargetMachine;

0 commit comments

Comments
 (0)