From a68d06a614837f89804c9e4a83da117bdfb8264d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 8 Jul 2024 20:52:50 -0700 Subject: [PATCH] Delete support for rust versions without c_char in core --- build.rs | 6 ---- src/c_char.rs | 77 ----------------------------------------- src/lib.rs | 2 -- src/symbols/rust_vec.rs | 2 +- syntax/tokens.rs | 2 +- 5 files changed, 2 insertions(+), 87 deletions(-) delete mode 100644 src/c_char.rs diff --git a/build.rs b/build.rs index 941a842a..87dcc545 100644 --- a/build.rs +++ b/build.rs @@ -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"); diff --git a/src/c_char.rs b/src/c_char.rs deleted file mode 100644 index 1042b40f..00000000 --- a/src/c_char.rs +++ /dev/null @@ -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; - } -} diff --git a/src/lib.rs b/src/lib.rs index 9301cb83..0eafcc96 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 = CxxVector; // 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; diff --git a/src/symbols/rust_vec.rs b/src/symbols/rust_vec.rs index d7d2e34a..eaf025ef 100644 --- a/src/symbols/rust_vec.rs +++ b/src/symbols/rust_vec.rs @@ -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; diff --git a/syntax/tokens.rs b/syntax/tokens.rs index 05eddc70..fea85150 100644 --- a/syntax/tokens.rs +++ b/syntax/tokens.rs @@ -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::));