diff --git a/arrow/src/alloc/mod.rs b/arrow/src/alloc/mod.rs index 418bc95fd2e..526850685c4 100644 --- a/arrow/src/alloc/mod.rs +++ b/arrow/src/alloc/mod.rs @@ -127,9 +127,9 @@ pub unsafe fn reallocate( /// The owner of an allocation. /// The trait implementation is responsible for dropping the allocations once no more references exist. -pub trait Allocation: RefUnwindSafe {} +pub trait Allocation: RefUnwindSafe + Send + Sync {} -impl Allocation for T {} +impl Allocation for T {} /// Mode of deallocating memory regions pub(crate) enum Deallocation { diff --git a/arrow/src/buffer/immutable.rs b/arrow/src/buffer/immutable.rs index f5d59c5ed55..cb686bd8441 100644 --- a/arrow/src/buffer/immutable.rs +++ b/arrow/src/buffer/immutable.rs @@ -257,11 +257,6 @@ impl std::ops::Deref for Buffer { } } -unsafe impl Sync for Buffer {} -// false positive, see https://github.com/apache/arrow-rs/pull/1169 -#[allow(clippy::non_send_fields_in_send_ty)] -unsafe impl Send for Buffer {} - impl From for Buffer { #[inline] fn from(buffer: MutableBuffer) -> Self { diff --git a/arrow/src/bytes.rs b/arrow/src/bytes.rs index 7b57552e60f..75137a55295 100644 --- a/arrow/src/bytes.rs +++ b/arrow/src/bytes.rs @@ -101,6 +101,11 @@ impl Bytes { } } +// Deallocation is Send + Sync, repeating the bound here makes that refactoring safe +// The only field that is not automatically Send+Sync then is the NonNull ptr +unsafe impl Send for Bytes where Deallocation: Send {} +unsafe impl Sync for Bytes where Deallocation: Sync {} + impl Drop for Bytes { #[inline] fn drop(&mut self) { diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs index 84905af20a6..9be20ccd696 100644 --- a/arrow/src/ffi.rs +++ b/arrow/src/ffi.rs @@ -409,6 +409,9 @@ impl Drop for FFI_ArrowArray { } } +unsafe impl Send for FFI_ArrowArray {} +unsafe impl Sync for FFI_ArrowArray {} + // callback used to drop [FFI_ArrowArray] when it is exported unsafe extern "C" fn release_array(array: *mut FFI_ArrowArray) { if array.is_null() {