From 499886116baefbdb3729855acc1697ef9e4c5e35 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 20 Jul 2026 15:39:22 +0200 Subject: [PATCH] fix(fileio): avoid indirect test-state assignment warning The callback unit test switched its fake codec result by mutating the state used for the successful invocation. Clippy cannot see the later read through the extern function pointer and reported the assignment as unused under `-D warnings`. Use a separate fake state for the error invocation. The two scenarios remain independent and still exercise both the success and error result paths without suppressing a lint or changing production code. Test Plan: - `cargo +nightly fmt --manifest-path rust/Cargo.toml --all` -- passed - `CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings` under `ulimit -v 41943040` -- passed - `git diff --check` and `git diff --cached --check` -- passed --- rust/src/fileio_asyncio.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rust/src/fileio_asyncio.rs b/rust/src/fileio_asyncio.rs index d4affddf7..b9a060670 100644 --- a/rust/src/fileio_asyncio.rs +++ b/rust/src/fileio_asyncio.rs @@ -6980,11 +6980,18 @@ mod tests { assert_eq!(to_flush_now, 19); assert_eq!(zstd_result, 0); - state.codec_result = usize::MAX; + let mut error_state = ZstdCodecCallbackTestState { + pending_flush: 19, + codec_result: usize::MAX, + observed_input: None, + observed_output: None, + observed_directive: -1, + }; + let error_cctx = (&mut error_state as *mut ZstdCodecCallbackTestState).cast::(); assert_eq!( unsafe { fio_zstd_compress_stream_with( - cctx, + error_cctx, 0, input.as_ptr(), input.len(),