From 79e197b0eeb4baed2c6bb7245d9b8beed3c19e65 Mon Sep 17 00:00:00 2001 From: Benjamin Demaille Date: Mon, 24 Aug 2026 00:18:48 +0200 Subject: [PATCH] chore(lint): fix clippy 1.98 pedantic lints on the CI toolchain Stable clippy 1.98 adds chunks_exact_to_as_chunks and manual_midpoint, both pedantic, both firing on existing code. CI runs clippy with -D warnings, so every PR opened today fails on unrelated files. - simd_scan::find_stop: as_chunks::<16>() instead of chunks_exact(16) plus try_into().unwrap(); the remainder now comes from the same destructuring. - bam_dedup: as_chunks::<2>() for the (mate1, mate2) pairing. - quant: usize::midpoint for the segment-tree split point. Behaviour is unchanged: as_chunks yields the same chunks and remainder as chunks_exact, and midpoint equals (a + b) >> 1 for the non-overflowing indices here. MSRV 1.89 covers as_chunks (1.88) and usize::midpoint (1.85). Co-Authored-By: Claude Opus 5 (1M context) --- src/align/simd_scan.rs | 10 +++------- src/bam_dedup.rs | 7 ++++++- src/quant/mod.rs | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/align/simd_scan.rs b/src/align/simd_scan.rs index 3bf4833e..2511570e 100644 --- a/src/align/simd_scan.rs +++ b/src/align/simd_scan.rs @@ -28,11 +28,9 @@ pub fn find_stop(read: &[u8], genome: &[u8]) -> Option { debug_assert_eq!(read.len(), genome.len()); let mut base = 0usize; - let mut r_chunks = read.chunks_exact(16); - let mut g_chunks = genome.chunks_exact(16); - while let (Some(rc), Some(gc)) = (r_chunks.next(), g_chunks.next()) { - let rc: &[u8; 16] = rc.try_into().unwrap(); - let gc: &[u8; 16] = gc.try_into().unwrap(); + let (r_chunks, r_rem) = read.as_chunks::<16>(); + let (g_chunks, g_rem) = genome.as_chunks::<16>(); + for (rc, gc) in r_chunks.iter().zip(g_chunks) { if !chunk_all_match(rc, gc) { for k in 0..16 { if gc[k] >= 5 || rc[k] != gc[k] { @@ -45,8 +43,6 @@ pub fn find_stop(read: &[u8], genome: &[u8]) -> Option { } // Tail shorter than 16 bytes: plain scalar scan. - let r_rem = r_chunks.remainder(); - let g_rem = g_chunks.remainder(); for (k, (&r, &g)) in r_rem.iter().zip(g_rem.iter()).enumerate() { if g >= 5 || r != g { return Some(base + k); diff --git a/src/bam_dedup.rs b/src/bam_dedup.rs index 07658c90..57170391 100644 --- a/src/bam_dedup.rs +++ b/src/bam_dedup.rs @@ -314,7 +314,12 @@ fn collapse_group(recs: &mut [DedupRec], group: &[usize], mate2_bases_n: u32) -> .then_with(|| (ra.flag & 0x80).cmp(&(rb.flag & 0x80))) }); // Pairs of adjacent (mate1, mate2) indices. - let mut pairs: Vec<(usize, usize)> = sorted.chunks_exact(2).map(|c| (c[0], c[1])).collect(); + let mut pairs: Vec<(usize, usize)> = sorted + .as_chunks::<2>() + .0 + .iter() + .map(|&[m1, m2]| (m1, m2)) + .collect(); // Sort pairs by the coordinate/flag/CIGAR key. pairs.sort_by(|&(a1, a2), &(b1, b2)| { cmp_pair(&recs[a1], &recs[a2], &recs[b1], &recs[b2], mate2_bases_n) diff --git a/src/quant/mod.rs b/src/quant/mod.rs index 7df5ddc5..efd0694f 100644 --- a/src/quant/mod.rs +++ b/src/quant/mod.rs @@ -320,7 +320,7 @@ impl GeneAnnotation { out.push(chr[nlo].2); continue; } - let mid = (nlo + nhi) >> 1; + let mid = usize::midpoint(nlo, nhi); stack[sp] = (2 * node, nlo, mid); sp += 1; stack[sp] = (2 * node + 1, mid, nhi);