Make RustString an extern type to avoid improper_ctypes warnings
This commit is contained in:
@@ -1766,11 +1766,9 @@ unsafe extern "C" {
|
||||
pub fn LLVMRustGetLastError() -> *const c_char;
|
||||
|
||||
/// Prints the timing information collected by `-Ztime-llvm-passes`.
|
||||
#[expect(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustPrintPassTimings(OutStr: &RustString);
|
||||
|
||||
/// Prints the statistics collected by `-Zprint-codegen-stats`.
|
||||
#[expect(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustPrintStatistics(OutStr: &RustString);
|
||||
|
||||
/// Prepares inline assembly.
|
||||
@@ -1791,7 +1789,6 @@ unsafe extern "C" {
|
||||
ConstraintsLen: size_t,
|
||||
) -> bool;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustCoverageWriteFilenamesToBuffer(
|
||||
Filenames: *const *const c_char,
|
||||
FilenamesLen: size_t,
|
||||
@@ -1800,7 +1797,6 @@ unsafe extern "C" {
|
||||
BufferOut: &RustString,
|
||||
);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustCoverageWriteFunctionMappingsToBuffer(
|
||||
VirtualFileMappingIDs: *const c_uint,
|
||||
NumVirtualFileMappingIDs: size_t,
|
||||
@@ -1824,13 +1820,10 @@ unsafe extern "C" {
|
||||
) -> &Value;
|
||||
pub(crate) fn LLVMRustCoverageHashBytes(Bytes: *const c_char, NumBytes: size_t) -> u64;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustCoverageWriteCovmapSectionNameToString(M: &Module, OutStr: &RustString);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustCoverageWriteCovfunSectionNameToString(M: &Module, OutStr: &RustString);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustCoverageWriteCovmapVarNameToString(OutStr: &RustString);
|
||||
|
||||
pub(crate) fn LLVMRustCoverageMappingVersion() -> u32;
|
||||
@@ -2185,14 +2178,11 @@ unsafe extern "C" {
|
||||
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
|
||||
pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
|
||||
|
||||
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub(crate) fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString);
|
||||
pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
|
||||
pub fn LLVMRustGetTargetFeature(
|
||||
@@ -2297,10 +2287,8 @@ unsafe extern "C" {
|
||||
pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
|
||||
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
|
||||
DI: &'a DiagnosticInfo,
|
||||
pass_name_out: &RustString,
|
||||
@@ -2318,7 +2306,6 @@ unsafe extern "C" {
|
||||
message_out: &mut Option<&'a Twine>,
|
||||
);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
|
||||
pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
|
||||
|
||||
@@ -2327,7 +2314,6 @@ unsafe extern "C" {
|
||||
cookie_out: &mut c_uint,
|
||||
) -> &'a SMDiagnostic;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustUnpackSMDiagnostic(
|
||||
d: &SMDiagnostic,
|
||||
message_out: &RustString,
|
||||
@@ -2374,7 +2360,6 @@ unsafe extern "C" {
|
||||
pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
|
||||
pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
|
||||
pub fn LLVMRustModuleCost(M: &Module) -> u64;
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString);
|
||||
|
||||
pub fn LLVMRustThinLTOBufferCreate(
|
||||
@@ -2427,7 +2412,6 @@ unsafe extern "C" {
|
||||
bytecode_len: usize,
|
||||
) -> bool;
|
||||
pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustComputeLTOCacheKey(
|
||||
key_out: &RustString,
|
||||
mod_id: *const c_char,
|
||||
@@ -2450,7 +2434,6 @@ unsafe extern "C" {
|
||||
pgo_available: bool,
|
||||
);
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
|
||||
|
||||
pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
@@ -301,15 +300,11 @@ pub fn set_value_name(value: &Value, name: &[u8]) {
|
||||
}
|
||||
|
||||
pub fn build_string(f: impl FnOnce(&RustString)) -> Result<String, FromUtf8Error> {
|
||||
let sr = RustString { bytes: RefCell::new(Vec::new()) };
|
||||
f(&sr);
|
||||
String::from_utf8(sr.bytes.into_inner())
|
||||
String::from_utf8(RustString::build_byte_buffer(f))
|
||||
}
|
||||
|
||||
pub fn build_byte_buffer(f: impl FnOnce(&RustString)) -> Vec<u8> {
|
||||
let sr = RustString { bytes: RefCell::new(Vec::new()) };
|
||||
f(&sr);
|
||||
sr.bytes.into_inner()
|
||||
RustString::build_byte_buffer(f)
|
||||
}
|
||||
|
||||
pub fn twine_to_string(tr: &Twine) -> String {
|
||||
|
||||
Reference in New Issue
Block a user