Skip to content

Commit 59e56ce

Browse files
committed
fix(ci): allow dead_code on Tier enums for non-x86_64 cross-builds
i686-unknown-linux-gnu cross-tests (which run under -D warnings) failed: error: variants `Avx512` and `Avx2` are never constructed --> src/backend/native.rs:17:5 = note: `-D dead-code` implied by `-D warnings` Two `enum Tier { Avx512, Avx2, ..., Scalar }` definitions exist, one in `src/backend/native.rs` and one in `src/simd.rs`. Both `detect_tier()` blocks gate the AVX-detection paths behind `#[cfg(target_arch = "x86_64")]`; the NEON-detection (simd.rs only) is gated behind `#[cfg(target_arch = "aarch64")]`. On i686 / wasm32 / etc., none of those gates match → only `Scalar` is ever constructed → dead-code lint fires on the other variants. Fix: `#[allow(dead_code)]` on both Tier enums. The variants ARE needed on x86_64 and aarch64 builds (the cfg blocks produce them via runtime feature detection); they just don't reach instantiation under the i686 target_arch. The src/simd.rs fix is preemptive — only src/backend/native.rs was flagged in the CI error, but src/simd.rs has 4 non-Scalar variants (Avx512, Avx2, NeonDotProd, Neon) that would trigger the same lint under -D warnings on i686. Both fixed in one commit. Verification: - `cargo clippy --no-deps` (default x86_64) → clean (the variants ARE constructed via `is_x86_feature_detected!("avx512f")`) - `RUSTFLAGS="-D dead_code" cargo check --lib --features ...` → clean
1 parent 6245c00 commit 59e56ce

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/backend/native.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ use std::sync::LazyLock;
1212

1313
// ─── Tier detection: happens ONCE, at first access ─────────────────
1414

15+
// On non-x86_64 targets (e.g. i686 / aarch64 / s390x cross-tests) only the
16+
// `Scalar` variant is ever constructed — the AVX detection block below is
17+
// gated `#[cfg(target_arch = "x86_64")]`. Without `dead_code` allowance the
18+
// `-D warnings` build fails on i686 with `variants Avx512 and Avx2 are
19+
// never constructed`.
20+
#[allow(dead_code)]
1521
#[derive(Clone, Copy, PartialEq)]
1622
enum Tier {
1723
Avx512,

src/simd.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#[cfg(feature = "std")]
99
use std::sync::LazyLock;
1010

11+
// On i686 / wasm32 / etc. only the `Scalar` variant is constructed —
12+
// `detect_tier()`'s feature-detection blocks are `target_arch = "x86_64"`
13+
// or `"aarch64"` gated, both false on i686. Without `dead_code` allowance
14+
// the `-D warnings` build fails with `variants ... are never constructed`.
15+
#[allow(dead_code)]
1116
#[derive(Clone, Copy, PartialEq, Debug)]
1217
#[repr(u8)]
1318
enum Tier {

0 commit comments

Comments
 (0)