From 896397f729a016c060f2a4f44188fb945f2eee01 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Sat, 18 Jul 2026 21:46:36 +0200 Subject: [PATCH] fix(rust): satisfy current clippy lints The current toolchain promoted two test-only patterns to hard errors under `-D warnings`: integer-to-pointer casts used as non-null dictionary-handle sentinels, and a repeat/take construction that Clippy now replaces with `repeat_n`. The casts never represented addresses and were only placeholders for ownership fields that the cleanup functions must clear. Use the standard dangling-pointer constructor for those sentinels and the equivalent concise iterator for the generated test input. Runtime behavior and the ABI are unchanged, while the repository's Rust lint gate is warning-free again. Test Plan: - `cargo clippy --manifest-path rust/Cargo.toml -- -D warnings` -- passed - `cargo clippy --manifest-path rust/Cargo.toml --benches -- -D warnings` -- passed - `cargo clippy --manifest-path rust/Cargo.toml --tests -- -D warnings` -- passed - `cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings` -- passed - `cargo +nightly fmt --manifest-path rust/Cargo.toml` -- passed - `cargo +nightly fmt --manifest-path rust/cli/Cargo.toml` -- passed --- rust/src/fileio_backend.rs | 4 ++-- rust/src/zstd_compress.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/src/fileio_backend.rs b/rust/src/fileio_backend.rs index 3f8058138..4bb84943c 100644 --- a/rust/src/fileio_backend.rs +++ b/rust/src/fileio_backend.rs @@ -1049,7 +1049,7 @@ mod tests { let mapped = unsafe { std::slice::from_raw_parts(buffer.cast::(), mapped_size) }; assert_eq!(mapped, payload); - let mut dict_handle = 1usize as *mut c_void; + let mut dict_handle = ptr::dangling_mut::(); unsafe { FIO_rust_freeDict( FIO_MMAP_DICT, @@ -1074,7 +1074,7 @@ mod tests { assert!(!allocation.is_null()); let mut buffer = allocation; let mut buffer_size = 16; - let mut dict_handle = 1usize as *mut c_void; + let mut dict_handle = ptr::dangling_mut::(); unsafe { FIO_rust_freeDict( diff --git a/rust/src/zstd_compress.rs b/rust/src/zstd_compress.rs index e679a3475..db57ae118 100644 --- a/rust/src/zstd_compress.rs +++ b/rust/src/zstd_compress.rs @@ -4573,7 +4573,7 @@ mod tests { #[test] fn one_shot_promotes_nonfirst_rle_blocks() { let mut input = vec![b'B'; 256 * 1024 - 2]; - input.extend(std::iter::repeat(b'A').take(100 * 1024)); + input.extend(std::iter::repeat_n(b'A', 100 * 1024)); let compressed = compress_input(&input, 1); assert!(compressed.len() <= 46);