Skip to content

Commit

Permalink
Fix wrong size used in bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Jun 24, 2024
1 parent 3bc3848 commit 19a3eac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 7 additions & 5 deletions src/stabby/boxed_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use crate::{
::{ReprC, __HasNiche__},
};
pub use stabby::boxed::{Box, BoxedSlice, BoxedStr};
use stabby::{abi::U1, alloc::IAlloc, IStable};
use stabby::{alloc::IAlloc, IStable};

type USIZE = <usize as IStable>::Size;

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for Box<T, Alloc>
where
Box<T, Alloc>: IStable<Size = U1>,
Box<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = *const CVoid;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -16,7 +18,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for Box<T, Alloc>
where
Box<T, Alloc>: IStable<Size = U1>,
Box<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it.is_null()
Expand All @@ -25,7 +27,7 @@ where

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for BoxedSlice<T, Alloc>
where
Box<T, Alloc>: IStable<Size = U1>,
Box<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = Tuple2_Layout<*const CVoid, *const CVoid>;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -36,7 +38,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for BoxedSlice<T, Alloc>
where
Box<T, Alloc>: IStable<Size = U1>,
Box<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it._0.is_null() || it._1.is_null()
Expand Down
20 changes: 11 additions & 9 deletions src/stabby/sync_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use crate::{
::{ReprC, __HasNiche__},
};
pub use stabby::sync::{Arc, ArcSlice, ArcStr, Weak, WeakSlice, WeakStr};
use stabby::{abi::U1, alloc::IAlloc, IStable};
use stabby::{alloc::IAlloc, IStable};

type USIZE = <usize as IStable>::Size;

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for Arc<T, Alloc>
where
Arc<T, Alloc>: IStable<Size = U1>,
Arc<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = *const CVoid;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -16,7 +18,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for Arc<T, Alloc>
where
Arc<T, Alloc>: IStable<Size = U1>,
Arc<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it.is_null()
Expand All @@ -25,7 +27,7 @@ where

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for ArcSlice<T, Alloc>
where
Arc<T, Alloc>: IStable<Size = U1>,
Arc<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = Tuple2_Layout<*const CVoid, *const CVoid>;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -36,7 +38,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for ArcSlice<T, Alloc>
where
Arc<T, Alloc>: IStable<Size = U1>,
Arc<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it._0.is_null() || it._1.is_null()
Expand All @@ -62,7 +64,7 @@ where

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for Weak<T, Alloc>
where
Weak<T, Alloc>: IStable<Size = U1>,
Weak<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = *const CVoid;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -71,7 +73,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for Weak<T, Alloc>
where
Weak<T, Alloc>: IStable<Size = U1>,
Weak<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it.is_null()
Expand All @@ -80,7 +82,7 @@ where

unsafe impl<T: IStable, Alloc: IStable + IAlloc> ReprC for WeakSlice<T, Alloc>
where
Weak<T, Alloc>: IStable<Size = U1>,
Weak<T, Alloc>: IStable<Size = USIZE>,
{
type CLayout = Tuple2_Layout<*const CVoid, *const CVoid>;
fn is_valid(it: &'_ Self::CLayout) -> bool {
Expand All @@ -91,7 +93,7 @@ where
}
unsafe impl<T: IStable, Alloc: IStable + IAlloc> __HasNiche__ for WeakSlice<T, Alloc>
where
Weak<T, Alloc>: IStable<Size = U1>,
Weak<T, Alloc>: IStable<Size = USIZE>,
{
fn is_niche(it: &'_ <Self as ReprC>::CLayout) -> bool {
it._0.is_null() || it._1.is_null()
Expand Down

0 comments on commit 19a3eac

Please sign in to comment.