From 7dc671d02f824c76f5df66da1b510cd95a762d2b Mon Sep 17 00:00:00 2001 From: yangjie01 Date: Mon, 31 Aug 2026 11:52:50 +0800 Subject: [PATCH] docs(linalg): fill in the empty Safety section on load_unaligned --- rust/lance-linalg/src/simd.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rust/lance-linalg/src/simd.rs b/rust/lance-linalg/src/simd.rs index 23298694f75..7b4e2c72e7f 100644 --- a/rust/lance-linalg/src/simd.rs +++ b/rust/lance-linalg/src/simd.rs @@ -58,6 +58,20 @@ pub trait SIMD: /// Load unaligned data from memory. /// /// # Safety + /// + /// `ptr` must be valid for reads of `N` elements of `T`. + /// + /// Most implementations also require a target feature that the build's + /// baseline may not provide, and none of them check for it at runtime: + /// + /// - `f32x8`, `f32x16`, `f64x4`, `f64x8` and `i32x8` need AVX on x86_64 and + /// LASX on loongarch64; + /// - `u8x16` needs nothing beyond the baseline on any target. + /// + /// Calling one without its feature is undefined behaviour rather than a + /// wrong answer, so either build with the feature enabled, as + /// `.cargo/config.toml` does for `x86_64-unknown-linux-gnu`, or check with + /// `is_x86_feature_detected!` first. See #8872. unsafe fn load_unaligned(ptr: *const T) -> Self; /// Store the values to aligned memory.