Delete support for rust versions without c_char in core

This commit is contained in:
David Tolnay 2024-07-08 20:52:50 -07:00
parent 1565becf8d
commit a68d06a614
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
5 changed files with 2 additions and 87 deletions

View File

@ -33,7 +33,6 @@ fn main() {
println!("cargo:rustc-check-cfg=cfg(compile_error_if_std)");
println!("cargo:rustc-check-cfg=cfg(cxx_experimental_no_alloc)");
println!("cargo:rustc-check-cfg=cfg(error_in_core)");
println!("cargo:rustc-check-cfg=cfg(no_core_ffi_c_char)");
println!("cargo:rustc-check-cfg=cfg(skip_ui_tests)");
}
@ -45,11 +44,6 @@ fn main() {
);
}
if rustc.minor < 64 {
// core::ffi::c_char
println!("cargo:rustc-cfg=no_core_ffi_c_char");
}
if rustc.minor >= 81 {
// core::error::Error
println!("cargo:rustc-cfg=error_in_core");

View File

@ -1,77 +0,0 @@
#![allow(clippy::duplicated_attributes)] // clippy bug: https://github.com/rust-lang/rust-clippy/issues/12538
#[allow(missing_docs)]
pub type c_char = c_char_definition::c_char;
// Validate that our definition is consistent with libstd's definition, without
// introducing a dependency on libstd in ordinary builds.
#[cfg(all(test, feature = "std"))]
const _: self::c_char = 0 as std::os::raw::c_char;
#[cfg(not(no_core_ffi_c_char))]
mod c_char_definition {
pub use core::ffi::c_char;
}
#[cfg(no_core_ffi_c_char)]
#[allow(dead_code)]
mod c_char_definition {
// These are the targets on which c_char is unsigned.
#[cfg(any(
all(
target_os = "linux",
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "s390x",
target_arch = "riscv64",
target_arch = "riscv32"
)
),
all(
target_os = "android",
any(target_arch = "aarch64", target_arch = "arm")
),
all(target_os = "l4re", target_arch = "x86_64"),
all(
target_os = "freebsd",
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "riscv64"
)
),
all(
target_os = "netbsd",
any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc")
),
all(target_os = "openbsd", target_arch = "aarch64"),
all(
target_os = "vxworks",
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc64",
target_arch = "powerpc"
)
),
all(target_os = "fuchsia", target_arch = "aarch64")
))]
pub use self::unsigned::c_char;
// On every other target, c_char is signed.
pub use self::signed::*;
mod unsigned {
pub type c_char = u8;
}
mod signed {
pub type c_char = i8;
}
}

View File

@ -449,7 +449,6 @@ compile_error! {
#[macro_use]
mod macros;
mod c_char;
mod cxx_vector;
mod exception;
mod extern_type;
@ -504,7 +503,6 @@ pub type Vector<T> = CxxVector<T>;
// Not public API.
#[doc(hidden)]
pub mod private {
pub use crate::c_char::c_char;
pub use crate::cxx_vector::VectorElement;
pub use crate::extern_type::{verify_extern_kind, verify_extern_type};
pub use crate::function::FatFunction;

View File

@ -1,9 +1,9 @@
#![cfg(feature = "alloc")]
use crate::c_char::c_char;
use crate::rust_string::RustString;
use crate::rust_vec::RustVec;
use alloc::vec::Vec;
use core::ffi::c_char;
use core::mem;
use core::ptr;

View File

@ -13,7 +13,7 @@ impl ToTokens for Type {
Type::Ident(ident) => {
if ident.rust == Char {
let span = ident.rust.span();
tokens.extend(quote_spanned!(span=> ::cxx::private::));
tokens.extend(quote_spanned!(span=> ::cxx::core::ffi::));
} else if ident.rust == CxxString {
let span = ident.rust.span();
tokens.extend(quote_spanned!(span=> ::cxx::));