Skip to content

Commit d0fd301

Browse files
chore(clippy): adopt as_chunks, unbreaking CI on the current toolchain
CI runs 'cargo clippy --all-targets -- -D warnings' on the latest stable. A newer clippy added chunks_exact_to_as_chunks, so master and every PR opened against it now fail the Check job on code nobody touched. Master last went green on 2026-08-11. Five sites, all with a CONSTANT chunk size: sparse_reader (8 and 4), redis_utils ft_info_num_docs / ft_info_index_memory_bytes (2), and the kividb integration helper (2). The sparse_reader change is a small real improvement rather than lint appeasement: as_chunks::<N>() yields &[u8; N] directly, so the fallible try_into().unwrap() that chunks_exact forced is gone -- the length is proven by the type instead of re-checked at runtime. Verified with beta clippy (0.1.98, matching what CI resolves) clean at -D warnings, and built + unit-tested on stable 0.1.97 so this does not require a toolchain bump. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 0295901 commit d0fd301

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/bin/vector_db_benchmark/engine/redis_utils.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ pub fn ft_info_num_docs(v: &redis::Value) -> Option<u64> {
393393
let pairs: Vec<(String, &redis::Value)> = match v {
394394
redis::Value::Map(m) => m.iter().map(|(k, val)| (value_to_string(k), val)).collect(),
395395
redis::Value::Array(items) => items
396-
.chunks_exact(2)
396+
.as_chunks::<2>()
397+
.0
398+
.iter()
397399
.map(|c| (value_to_string(&c[0]), &c[1]))
398400
.collect(),
399401
_ => return None,
@@ -455,7 +457,9 @@ pub fn ft_info_index_memory_bytes(v: &redis::Value) -> Option<i64> {
455457
let pairs: Vec<(String, &redis::Value)> = match v {
456458
redis::Value::Map(m) => m.iter().map(|(k, val)| (value_to_string(k), val)).collect(),
457459
redis::Value::Array(items) => items
458-
.chunks_exact(2)
460+
.as_chunks::<2>()
461+
.0
462+
.iter()
459463
.map(|c| (value_to_string(&c[0]), &c[1]))
460464
.collect(),
461465
_ => return None,

src/readers/sparse_reader.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ fn read_i64_le(r: &mut impl Read, n: usize, max_bytes: u64) -> Result<Vec<i64>,
4040
}
4141
let mut buf = vec![0u8; byte_len];
4242
r.read_exact(&mut buf).map_err(|e| e.to_string())?;
43+
// `as_chunks::<8>()` yields `&[u8; 8]` directly, so the fallible
44+
// `try_into().unwrap()` that `chunks_exact` forced is gone: the length is
45+
// now proven by the type rather than re-checked at runtime.
4346
Ok(buf
44-
.chunks_exact(8)
45-
.map(|c| i64::from_le_bytes(c.try_into().unwrap()))
47+
.as_chunks::<8>()
48+
.0
49+
.iter()
50+
.map(|c| i64::from_le_bytes(*c))
4651
.collect())
4752
}
4853

@@ -66,10 +71,7 @@ fn read_u32_array<T>(
6671
}
6772
let mut buf = vec![0u8; byte_len];
6873
r.read_exact(&mut buf).map_err(|e| e.to_string())?;
69-
Ok(buf
70-
.chunks_exact(4)
71-
.map(|c| f(c.try_into().unwrap()))
72-
.collect())
74+
Ok(buf.as_chunks::<4>().0.iter().map(|c| f(*c)).collect())
7375
}
7476

7577
/// Number of rows a CSR file declares, read from its 24-byte header WITHOUT

tests/integration_kividb.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,12 @@ fn ft_info_field_names(v: &redis::Value) -> Vec<String> {
12261226
}
12271227
match v {
12281228
redis::Value::Map(m) => m.iter().map(|(k, _)| as_str(k)).collect(),
1229-
redis::Value::Array(items) => items.chunks_exact(2).map(|c| as_str(&c[0])).collect(),
1229+
redis::Value::Array(items) => items
1230+
.as_chunks::<2>()
1231+
.0
1232+
.iter()
1233+
.map(|c| as_str(&c[0]))
1234+
.collect(),
12301235
_ => Vec::new(),
12311236
}
12321237
}

0 commit comments

Comments
 (0)