From 6ca34905c0c9f8400b10750a4e8a94ccfa4dec28 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Thu, 22 Jan 2026 16:01:47 -0800 Subject: [PATCH] fix: allow unused_unsafe for __cpuid to support both stable and nightly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Rust nightly, __cpuid was changed to be a safe function, making the unsafe block unnecessary. This causes a warning that fails CI when RUSTFLAGS includes -D warnings. Adding #[allow(unused_unsafe)] allows the code to compile without warnings on both stable (where unsafe is required) and nightly (where it's no longer needed). Also add RUSTFLAGS="-D warnings" to the linux-build CI job to catch such issues early. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .github/workflows/rust.yml | 2 ++ rust/lance-core/src/utils/cpu.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 94605239897..01a9b8363e2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -85,6 +85,8 @@ jobs: # Need up-to-date compilers for kernels CC: clang CXX: clang++ + # Treat warnings as errors to catch issues early + RUSTFLAGS: "-D warnings" steps: - uses: actions/checkout@v4 # pin the toolchain version to avoid surprises diff --git a/rust/lance-core/src/utils/cpu.rs b/rust/lance-core/src/utils/cpu.rs index 9d65650e729..4e7ab01871d 100644 --- a/rust/lance-core/src/utils/cpu.rs +++ b/rust/lance-core/src/utils/cpu.rs @@ -78,6 +78,8 @@ mod x86 { // EAX=7, ECX=0: Extended Features (includes AVX512) // More info on calling CPUID can be found here (section 1.4) // https://www.intel.com/content/dam/develop/external/us/en/documents/architecture-instruction-set-extensions-programming-reference.pdf + // __cpuid is safe in nightly but unsafe in stable, allow both + #[allow(unused_unsafe)] let ext_cpuid_result = unsafe { __cpuid(7) }; check_flag(ext_cpuid_result.edx as usize, 23) }