From 3a747279da227d88d447cdcbcf6b6a0b885246de Mon Sep 17 00:00:00 2001 From: Mark Hildebrand Date: Fri, 21 Aug 2026 15:15:56 -0700 Subject: [PATCH 1/2] Make `UnalignedSlice` Send and Sync. --- diskann-vector/src/unaligned.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diskann-vector/src/unaligned.rs b/diskann-vector/src/unaligned.rs index 26dec240a3..6318c9c855 100644 --- a/diskann-vector/src/unaligned.rs +++ b/diskann-vector/src/unaligned.rs @@ -22,6 +22,14 @@ pub struct UnalignedSlice<'a, T> { _lifetime: PhantomData<&'a T>, } +/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be sent to other threads when `&T` is +/// send - implying the bound `T: Sync`. +unsafe impl Send for UnalignedSlice<'_, T> where T: Sync {} + +/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be shared with other threads when `&T` +/// is send, implying the bound `T: Sync`. +unsafe impl Sync for UnalignedSlice<'_, T> where T: Sync {} + impl<'a, T> UnalignedSlice<'a, T> { /// Construct a new [`UnalignedSlice`] over the region `[ptr, ptr.add(len))`. /// From cee6bb072e7333d35af3cec26a60e3556794d138 Mon Sep 17 00:00:00 2001 From: Mark Hildebrand Date: Mon, 24 Aug 2026 14:19:43 -0700 Subject: [PATCH 2/2] Copilot correction Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- diskann-vector/src/unaligned.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diskann-vector/src/unaligned.rs b/diskann-vector/src/unaligned.rs index 6318c9c855..9a65211870 100644 --- a/diskann-vector/src/unaligned.rs +++ b/diskann-vector/src/unaligned.rs @@ -22,8 +22,8 @@ pub struct UnalignedSlice<'a, T> { _lifetime: PhantomData<&'a T>, } -/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be sent to other threads when `&T` is -/// send - implying the bound `T: Sync`. +/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be sent to other threads when `&T: Send`, +/// which holds iff `T: Sync`. unsafe impl Send for UnalignedSlice<'_, T> where T: Sync {} /// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be shared with other threads when `&T`