Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong size used in bounds #219

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading