From 1b1b540e1f279add020c67704f602a93587371d6 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 20 Jul 2026 16:27:57 +0200 Subject: [PATCH] fix(tests): satisfy post-batch clippy checks Use usize::BITS for the static-CDict ABI offset that Clippy identifies as a bit-width expression. Replace the two MT flush cleanup test closures that independently borrow one vector with Rc probes, preserving the explicit wait-before-release assertions while making the test harness compile. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - git diff --cached --check --- rust/src/zstd_compress_dictionary.rs | 2 +- rust/src/zstdmt_compress.rs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rust/src/zstd_compress_dictionary.rs b/rust/src/zstd_compress_dictionary.rs index a31efc197..27a1153f8 100644 --- a/rust/src/zstd_compress_dictionary.rs +++ b/rust/src/zstd_compress_dictionary.rs @@ -1115,7 +1115,7 @@ const _: () = { assert!(offset_of!(ZSTD_rust_initStaticCDictState, c_params) == 5 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, sizing) == 6 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, create_workspace) == 7 * size_of::()); - assert!(offset_of!(ZSTD_rust_initStaticCDictState, reserve_object) == 8 * size_of::()); + assert!(offset_of!(ZSTD_rust_initStaticCDictState, reserve_object) == usize::BITS as usize); assert!(offset_of!(ZSTD_rust_initStaticCDictState, move_workspace) == 9 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, initialize) == 10 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, init) == 11 * size_of::()); diff --git a/rust/src/zstdmt_compress.rs b/rust/src/zstdmt_compress.rs index 6354ceeef..64de5cd6d 100644 --- a/rust/src/zstdmt_compress.rs +++ b/rust/src/zstdmt_compress.rs @@ -6821,7 +6821,9 @@ mod tests { jobIDMask: 0, ..ZSTDMT_flushContextProjection::default() }; - let mut error_cleanup = Vec::new(); + let error_cleanup = Rc::new(RefCell::new(Vec::new())); + let wait_cleanup = Rc::clone(&error_cleanup); + let release_cleanup = Rc::clone(&error_cleanup); let result = unsafe { flush_produced_with( context, @@ -6834,13 +6836,13 @@ mod tests { |_job_id, _projection| panic!("unexpected checksum callback"), |_job_id, _dst_flushed| panic!("unexpected update callback"), |_job_id, _src_size, _c_size| panic!("unexpected completion callback"), - || error_cleanup.push("wait"), - || error_cleanup.push("release"), + move || wait_cleanup.borrow_mut().push("wait"), + move || release_cleanup.borrow_mut().push("release"), ) }; assert_eq!(result.result, ERROR(ZstdErrorCode::Generic)); assert_eq!(result.outputPos, 0); - assert_eq!(error_cleanup, ["wait", "release"]); + assert_eq!(&*error_cleanup.borrow(), &["wait", "release"]); let job = [0x80u8, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86]; let mut output = [0xa5u8; 8]; @@ -6899,7 +6901,9 @@ mod tests { frameChecksumNeeded: 1, ..ZSTDMT_flushJobProjection::default() }; - let mut error_cleanup = Vec::new(); + let error_cleanup = Rc::new(RefCell::new(Vec::new())); + let wait_cleanup = Rc::clone(&error_cleanup); + let release_cleanup = Rc::clone(&error_cleanup); let mut completed = false; let result = unsafe { @@ -6921,14 +6925,14 @@ mod tests { }, |_job_id, _dst_flushed| panic!("unexpected update callback"), |_job_id, _src_size, _c_size| completed = true, - || error_cleanup.push("wait"), - || error_cleanup.push("release"), + move || wait_cleanup.borrow_mut().push("wait"), + move || release_cleanup.borrow_mut().push("release"), ) }; assert_eq!(result.result, ERROR(ZstdErrorCode::DstSizeTooSmall)); assert_eq!(result.outputPos, 0); - assert_eq!(error_cleanup, ["wait", "release"]); + assert_eq!(&*error_cleanup.borrow(), &["wait", "release"]); assert!(!completed); assert_eq!(output, [0xa5; 8]); }