From e3d761a020cc86981e0ffa11da9208013ad86c41 Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Fri, 5 Jul 2024 14:51:17 +0200 Subject: [PATCH] Update changelog --- CHANGELOG.md | 18 ++++++++++++ Cargo.toml | 8 +++--- stabby-abi/Cargo.toml | 4 +-- stabby-abi/src/enums/mod.rs | 6 ++-- stabby-abi/src/istable.rs | 14 ++++----- stabby-abi/src/lib.rs | 6 ++-- stabby-abi/src/num.rs | 4 +-- stabby-abi/src/padding.rs | 2 +- stabby-abi/src/result.rs | 2 +- stabby-abi/src/stable_impls/mod.rs | 44 ++++++++++++++--------------- stabby-abi/src/typenum2/unsigned.rs | 4 +-- stabby-macros/Cargo.toml | 2 +- stabby-macros/src/enums.rs | 6 ++-- stabby-macros/src/structs.rs | 4 +-- stabby-macros/src/unions.rs | 2 +- stabby/Cargo.toml | 6 ++-- stabby/src/tests/layouts.rs | 2 +- 17 files changed, 76 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4509238..fe43955 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# 36.1.1-rc1 (api=2.0.0, abi=2.0.0) +- BREAKING CHANGES: A large rework of allocation occurred, breaking both API and ABI compatibility with the previous version: + - `RustAlloc` is the new default allocator of `stabby`: this allocator is a simple pointer to a v-table allowing cross-ffi use of Rust's `alloc::GlobalAlloc`. + - This allocator is global, thread-safe, and guaranteed to work properly with pointers passed across the FFI. + - Benchmarks indicate that performance between `RustAlloc` and `LibcAlloc` is equivalent. + - However, it is non-zero-sized, and therefore makes types that don't always shove it into their `AllocPrefix` are slightly bigger when using `RustAlloc` rather than `LibcAlloc`. + - The reason for this change is that `LibcAlloc` isn't available on certain platforms, whereas `RustAlloc` is available on any platform supported by Rust. Importantly, the `wasm32` architecture was unsupported until now. + - The `libc_alloc` module was replaced by the `allocators` module to improve readability. + - While the previous `IAlloc` version was fine to interface with `libc::malloc`'s API, it actually had a few big holes that required patching for custom allocators to be able to do interesting stuff. + - This was unearthed by implementing `RustAlloc` + - The `AllocPrefix`'s location relative to prefixed allocations (such as those used by all of `stabby`'s container types) has changed for types with alignments greater than pointer-size. + - The prefix was previously placed as if the allocation held `Tuple2`, meaning that for larger alignments, there could be padding between the prefix and the pointed value. + - This padding has been removed, as it could cause soundness issues when the pointer was opacified, such as for trait objects. +- `stabby::collections::arc_btree`'s types are now ABI-stable. +- `#[stabby::stabby]` can now understand when a type refers to itself to avoid forming proof cycles. +- The `experimental-ctypes` feature-flag was added to mark the integration between `stabby` and `safer-ffi` as experimental. + - Experimental feature-flags and any API/ABI they annotate are allowed to be broken without triggering a `major` update, but a `minor` instead. If you rely on these features, pinning your minor is advised. + # 6.2.2 (api=1.1.1, abi=1.0.0) - Relax many dependency requirements to help avoid conflicts with crates that pin them diff --git a/Cargo.toml b/Cargo.toml index 8363137..4b1aec7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,12 +33,12 @@ license = " EPL-2.0 OR Apache-2.0" categories = ["development-tools::ffi", "no-std::no-alloc"] repository = "https://github.com/ZettaScaleLabs/stabby" readme = "stabby/README.md" -version = "6.2.2" # Track +version = "36.1.1-rc1" # Track [workspace.dependencies] -stabby-macros = { path = "./stabby-macros/", version = "6.2.2", default-features = false } # Track -stabby-abi = { path = "./stabby-abi/", version = "6.2.2", default-features = false } # Track -stabby = { path = "./stabby/", version = "6.2.2", default-features = false } # Track +stabby-macros = { path = "./stabby-macros/", version = "36.1.1-rc1", default-features = false } # Track +stabby-abi = { path = "./stabby-abi/", version = "36.1.1-rc1", default-features = false } # Track +stabby = { path = "./stabby/", version = "36.1.1-rc1", default-features = false } # Track abi_stable = "0.11.0" libc = "0.2" diff --git a/stabby-abi/Cargo.toml b/stabby-abi/Cargo.toml index 7f62ea0..ef99ea4 100644 --- a/stabby-abi/Cargo.toml +++ b/stabby-abi/Cargo.toml @@ -25,9 +25,9 @@ description = "stabby's core ABI, you shouldn't add this crate to your dependenc [features] default = ["std"] -std = ["libc", "alloc-rs"] +std = ["alloc-rs"] alloc-rs = [] -ctypes = ["stabby-macros/ctypes"] +experimental-ctypes = ["stabby-macros/experimental-ctypes"] libc = ["dep:libc"] test = [] serde = ["dep:serde"] diff --git a/stabby-abi/src/enums/mod.rs b/stabby-abi/src/enums/mod.rs index 57d34a1..92cdcda 100644 --- a/stabby-abi/src/enums/mod.rs +++ b/stabby-abi/src/enums/mod.rs @@ -55,7 +55,7 @@ unsafe impl IStable for BitDeterminant { type UnusedBits = Array; type HasExactlyOneNiche = Saturator; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = u8; primitive_report!("BitDeterminant"); } @@ -97,7 +97,7 @@ unsafe impl IStable for ValueIsErr IStable for Not { type UnusedBits = Determinant::UnusedBits; type HasExactlyOneNiche = Determinant::HasExactlyOneNiche; type ContainsIndirections = Determinant::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Determinant::CType; primitive_report!("Not", Determinant); } diff --git a/stabby-abi/src/istable.rs b/stabby-abi/src/istable.rs index 6d824c7..11c03e9 100644 --- a/stabby-abi/src/istable.rs +++ b/stabby-abi/src/istable.rs @@ -44,7 +44,7 @@ pub unsafe trait IStable: Sized { type HasExactlyOneNiche: ISaturatingAdd; /// Whether or not the type contains indirections (pointers, indices in independent data-structures...) type ContainsIndirections: Bit; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] /// A support mechanism for [`safer-ffi`](https://crates.io/crates/safer-ffi), allowing all [`IStable`] types to also be `safer_ffi::ReprC` type CType: IStable; /// A compile-time generated report of the fields of the type, allowing for compatibility inspection. @@ -124,7 +124,7 @@ unsafe impl IStable for NotPod { type ForbiddenValues = T::ForbiddenValues; type HasExactlyOneNiche = T::HasExactlyOneNiche; type UnusedBits = T::UnusedBits; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = T::CType; primitive_report!("NotPod", T); } @@ -190,7 +190,7 @@ unsafe impl< type UnusedBits = UnusedBits; type HasExactlyOneNiche = HasExactlyOneNiche; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("NicheExporter"); } @@ -389,7 +389,7 @@ unsafe impl IStable for FieldPair { as IStable>::HasExactlyOneNiche, >; type ContainsIndirections = ::Or; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("FP"); } @@ -521,7 +521,7 @@ unsafe impl IStable for Union { type Align = ::Max; type HasExactlyOneNiche = B0; type ContainsIndirections = ::Or; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = <::Divide as IUnsignedBase>::Array< ::AsUint, >; @@ -542,7 +542,7 @@ unsafe impl IStable for AlignedAfter { >; type HasExactlyOneNiche = T::HasExactlyOneNiche; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("FP"); } @@ -555,7 +555,7 @@ unsafe impl IStable for Struct { <::NextMultipleOf - T::Size) as IUnsignedBase>::PaddingBitMask as IBitMask>::Shift>; type HasExactlyOneNiche = Saturator; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("FP"); } diff --git a/stabby-abi/src/lib.rs b/stabby-abi/src/lib.rs index 379bdfb..8132838 100644 --- a/stabby-abi/src/lib.rs +++ b/stabby-abi/src/lib.rs @@ -264,7 +264,7 @@ unsafe impl IStable for StableLike { type UnusedBits = As::UnusedBits; type HasExactlyOneNiche = As::HasExactlyOneNiche; type ContainsIndirections = As::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = As::CType; const ID: u64 = crate::report::gen_id(Self::REPORT); const REPORT: &'static report::TypeReport = As::REPORT; @@ -298,7 +298,7 @@ unsafe impl< type UnusedBits = End; type HasExactlyOneNiche = HasExactlyOneNiche; type ContainsIndirections = ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("NoNiches"); } @@ -351,7 +351,7 @@ unsafe impl IStable for StableIf { type UnusedBits = T::UnusedBits; type HasExactlyOneNiche = T::HasExactlyOneNiche; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = T::CType; const REPORT: &'static report::TypeReport = T::REPORT; const ID: u64 = crate::report::gen_id(Self::REPORT); diff --git a/stabby-abi/src/num.rs b/stabby-abi/src/num.rs index 84666a6..f0ea4bf 100644 --- a/stabby-abi/src/num.rs +++ b/stabby-abi/src/num.rs @@ -78,7 +78,7 @@ macro_rules! define_non_max { type UnusedBits = <$NonZeroU8 as crate::IStable>::UnusedBits; type HasExactlyOneNiche = <$NonZeroU8 as crate::IStable>::HasExactlyOneNiche; type ContainsIndirections = <$NonZeroU8 as crate::IStable>::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = <$NonZeroU8 as crate::IStable>::CType; const ID: u64 = $crate::report::gen_id(Self::REPORT); const REPORT: &'static $crate::report::TypeReport = &$crate::report::TypeReport { @@ -159,7 +159,7 @@ macro_rules! define_non_x { type UnusedBits = <$NonZeroU8 as crate::IStable>::UnusedBits; type HasExactlyOneNiche = <$NonZeroU8 as crate::IStable>::HasExactlyOneNiche; type ContainsIndirections = <$NonZeroU8 as crate::IStable>::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = <$NonZeroU8 as crate::IStable>::CType; const ID: u64 = $crate::report::gen_id(Self::REPORT); const REPORT: &'static $crate::report::TypeReport = &$crate::report::TypeReport { diff --git a/stabby-abi/src/padding.rs b/stabby-abi/src/padding.rs index b42cda9..fe16ebe 100644 --- a/stabby-abi/src/padding.rs +++ b/stabby-abi/src/padding.rs @@ -35,7 +35,7 @@ unsafe impl IStable for Padded { >; type HasExactlyOneNiche = Saturator; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Tuple<::CType, T::CType>; const REPORT: &'static report::TypeReport = T::REPORT; const ID: u64 = crate::report::gen_id(Self::REPORT); diff --git a/stabby-abi/src/result.rs b/stabby-abi/src/result.rs index 0815cdc..42f4389 100644 --- a/stabby-abi/src/result.rs +++ b/stabby-abi/src/result.rs @@ -53,7 +53,7 @@ where <>::NicheExporter as IStable>::ForbiddenValues; type UnusedBits = <, ::AsUint> as IStable>::UnusedBits as IBitMask>::BitOr<<<>::NicheExporter as IStable>::UnusedBits as IBitMask>::Shift<< as IStable>::Size as Unsigned>::NextMultipleOf>>; type HasExactlyOneNiche = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::Size, ::Align> as IStable>::CType; const REPORT: &'static crate::report::TypeReport = &crate::report::TypeReport { name: Str::new("Result"), diff --git a/stabby-abi/src/stable_impls/mod.rs b/stabby-abi/src/stable_impls/mod.rs index e8ed5bc..f1644e6 100644 --- a/stabby-abi/src/stable_impls/mod.rs +++ b/stabby-abi/src/stable_impls/mod.rs @@ -20,7 +20,7 @@ macro_rules! same_as { type Size = <$t as IStable>::Size; type UnusedBits = <$t as IStable>::UnusedBits; type ForbiddenValues = <$t as IStable>::ForbiddenValues; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = <$t as IStable>::CType; primitive_report!($($name)*); }; @@ -30,7 +30,7 @@ macro_rules! same_as { type UnusedBits = <$t as IStable>::UnusedBits; type ForbiddenValues = <$t as IStable>::ForbiddenValues; type HasExactlyOneNiche = <$t as IStable>::HasExactlyOneNiche; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = <$t as IStable>::CType; }; } @@ -233,7 +233,7 @@ unsafe impl IStable for () { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("()"); } @@ -244,7 +244,7 @@ unsafe impl IStable for core::marker::PhantomData { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("core::marker::PhantomData"); } @@ -255,7 +255,7 @@ unsafe impl IStable for core::marker::PhantomPinned { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); primitive_report!("core::marker::PhantomPinned"); } @@ -266,7 +266,7 @@ unsafe impl IStable for bool { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("bool"); } @@ -278,7 +278,7 @@ unsafe impl IStable for u8 { type Size = U1; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("u8"); } @@ -290,7 +290,7 @@ unsafe impl IStable for core::num::NonZeroU8 { type ForbiddenValues = nz_holes!(U0); type HasExactlyOneNiche = B1; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("core::num::NonZeroU8"); } @@ -301,7 +301,7 @@ unsafe impl IStable for u16 { type Size = U2; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("u16"); } @@ -313,7 +313,7 @@ unsafe impl IStable for core::num::NonZeroU16 { type Size = U2; type HasExactlyOneNiche = B1; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("core::num::NonZeroU16"); } @@ -324,7 +324,7 @@ unsafe impl IStable for u32 { type Size = U4; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("u32"); } @@ -336,7 +336,7 @@ unsafe impl IStable for core::num::NonZeroU32 { type Size = U4; type HasExactlyOneNiche = B1; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("core::num::NonZeroU32"); } @@ -347,7 +347,7 @@ unsafe impl IStable for u64 { type Size = U8; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("u64"); } @@ -359,7 +359,7 @@ unsafe impl IStable for core::num::NonZeroU64 { type Size = U8; type HasExactlyOneNiche = B1; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; primitive_report!("core::num::NonZeroU64"); } @@ -384,7 +384,7 @@ unsafe impl IStable for u128 { type Align = U8; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; #[rustversion::before(1.77)] #[cfg(not(target_arch = "aarch64"))] @@ -409,7 +409,7 @@ unsafe impl IStable for core::num::NonZeroU128 { type Size = U16; type HasExactlyOneNiche = B1; type Align = ::Align; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = ::AsUint; type ContainsIndirections = B0; primitive_report!("core::num::NonZeroU128"); @@ -634,7 +634,7 @@ unsafe impl IStable for HasExactlyOneNiche, type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = T::CType; const REPORT: &'static report::TypeReport = &report::TypeReport { name: Str::new("Option"), @@ -675,7 +675,7 @@ unsafe impl IStable type ForbiddenValues = End; type UnusedBits = End; type HasExactlyOneNiche = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Ok::CType; type ContainsIndirections = ::Or; const REPORT: &'static report::TypeReport = &report::TypeReport { @@ -710,7 +710,7 @@ unsafe impl IStable type ForbiddenValues = End; type UnusedBits = End; type HasExactlyOneNiche = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Err::CType; type ContainsIndirections = ::Or; const REPORT: &'static report::TypeReport = &report::TypeReport { @@ -735,7 +735,7 @@ unsafe impl IStable for NameAggregator { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = (); const REPORT: &'static report::TypeReport = &report::TypeReport { name: Str::new("signature"), @@ -863,7 +863,7 @@ macro_rules! sliceimpl { <<$size as Unsigned>::Equal as Bit>::SaddTernary, >; type ContainsIndirections = T::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = [T::CType; <$size as Unsigned>::USIZE]; primitive_report!(ARRAY_NAME[<$size as Unsigned>::USIZE], T); } @@ -894,7 +894,7 @@ unsafe impl IStable for core::cmp::Ordering { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = u8; primitive_report!("core::cmp::Ordering"); } diff --git a/stabby-abi/src/typenum2/unsigned.rs b/stabby-abi/src/typenum2/unsigned.rs index 301c6d5..dbe1364 100644 --- a/stabby-abi/src/typenum2/unsigned.rs +++ b/stabby-abi/src/typenum2/unsigned.rs @@ -44,7 +44,7 @@ unsafe impl IStable for PadByte { type UnusedBits = Array; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = u8; primitive_report!("PadByte"); } @@ -434,7 +434,7 @@ unsafe impl IStable for OneMoreByte { type UnusedBits = ::BitOr>; type HasExactlyOneNiche = L::HasExactlyOneNiche; type ContainsIndirections = L::ContainsIndirections; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Tuple; primitive_report!("OneMoreByte"); } diff --git a/stabby-macros/Cargo.toml b/stabby-macros/Cargo.toml index 4116946..f3aa053 100644 --- a/stabby-macros/Cargo.toml +++ b/stabby-macros/Cargo.toml @@ -24,7 +24,7 @@ readme = { workspace = true } description = "the macros that make working with stabby possible, you shouldn't add this crate to your dependencies, only `stabby`." [features] -ctypes = [] +experimental-ctypes = [] [dependencies] proc-macro2 = { workspace = true } diff --git a/stabby-macros/src/enums.rs b/stabby-macros/src/enums.rs index a85793b..be6f9d8 100644 --- a/stabby-macros/src/enums.rs +++ b/stabby-macros/src/enums.rs @@ -273,7 +273,7 @@ pub fn stabby( layout = quote!(#st::Tuple<#reprid, #layout>); report.tyty = crate::Tyty::Enum(trepr); let report_bounds = report.bounds(); - let ctype = cfg!(feature = "ctypes").then(|| { + let ctype = cfg!(feature = "experimental-ctypes").then(|| { let ctype = report.crepr(); quote! {type CType = #ctype;} }); @@ -286,7 +286,7 @@ pub fn stabby( let reprc_bug = format!( "{ident}'s CType was mis-evaluated by stabby, this is definitely a bug and may cause UB, please file an issue" ); - let ctype_assert = cfg!(feature = "ctypes").then(|| { + let ctype_assert = cfg!(feature = "experimental-ctypes").then(|| { quote! {if core::mem::size_of::() != core::mem::size_of::<::CType>() || core::mem::align_of::() != core::mem::align_of::<::CType>() { panic!(#reprc_bug) }} @@ -559,7 +559,7 @@ pub(crate) fn repr_stabby( } } }); - let ctype = cfg!(feature = "ctypes").then(|| { + let ctype = cfg!(feature = "experimental-ctypes").then(|| { quote! {type CType = <#layout as #st::IStable>::CType;} }); let assertions= generics.params.is_empty().then(||{ diff --git a/stabby-macros/src/structs.rs b/stabby-macros/src/structs.rs index 9164524..54dc928 100644 --- a/stabby-macros/src/structs.rs +++ b/stabby-macros/src/structs.rs @@ -146,11 +146,11 @@ pub fn stabby( } }); let report_bounds = report.bounds(); - let ctype = cfg!(feature = "ctypes").then(|| { + let ctype = cfg!(feature = "experimental-ctypes").then(|| { let ctype = report.crepr(); quote! {type CType = #ctype;} }); - let ctype_assert = cfg!(feature = "ctypes").then(|| { + let ctype_assert = cfg!(feature = "experimental-ctypes").then(|| { quote! {if core::mem::size_of::() != core::mem::size_of::<::CType>() || core::mem::align_of::() != core::mem::align_of::<::CType>() { panic!(#reprc_bug) }} diff --git a/stabby-macros/src/unions.rs b/stabby-macros/src/unions.rs index e253f05..25098e3 100644 --- a/stabby-macros/src/unions.rs +++ b/stabby-macros/src/unions.rs @@ -75,7 +75,7 @@ pub fn stabby( report.add_field(field.ident.as_ref().unwrap().to_string(), ty); } let report_bounds = report.bounds(); - let ctype = cfg!(feature = "ctypes").then(|| { + let ctype = cfg!(feature = "experimental-ctypes").then(|| { quote! {type CType = <#layout as #st::IStable>::CType;} }); quote! { diff --git a/stabby/Cargo.toml b/stabby/Cargo.toml index d948d71..c16888d 100644 --- a/stabby/Cargo.toml +++ b/stabby/Cargo.toml @@ -24,10 +24,10 @@ readme = { workspace = true } description = "A Stable ABI for Rust with compact sum-types." [features] -default = ["std", "libc", "serde"] -std = ["libc", "stabby-abi/std", "alloc-rs"] +default = ["std", "serde"] +std = ["stabby-abi/std", "alloc-rs"] alloc-rs = ["stabby-abi/alloc-rs"] -ctypes = ["stabby-abi/ctypes"] +experimental-ctypes = ["stabby-abi/experimental-ctypes"] libloading = ["dep:libloading", "std"] libc = ["stabby-abi/libc"] serde = ["stabby-abi/serde"] diff --git a/stabby/src/tests/layouts.rs b/stabby/src/tests/layouts.rs index 858a879..b16b3ff 100644 --- a/stabby/src/tests/layouts.rs +++ b/stabby/src/tests/layouts.rs @@ -250,7 +250,7 @@ unsafe impl stabby::abi::IStable for Align128 { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B0; - #[cfg(feature = "ctypes")] + #[cfg(feature = "experimental-ctypes")] type CType = Align128; const REPORT: &'static stabby::abi::report::TypeReport = &stabby::abi::report::TypeReport { name: stabby::abi::str::Str::new("Align128"),