Repository: sharksforarms/deku
Pull request #575 (2025-07-16 02:16:26)

Warnings and clippy fixes
On the path of other efforts I came across a bunch of warnings/clippys. Here are some patches that tidy them up.

sharksforarms: Nice! Is there something we should change in the CI to catch these? additional flags, targets, etc?
amboar: So my process wasn't super rigorous, lots of these came about via LSP in my editor. But perhaps we can add something in the vein of `RUSTFLAGS="-D warnings" cargo check --all-targets` to hit most of them (and more). Give me a moment.

Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a6a3e0e..f881c9b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -51,7 +51,7 @@ jobs:
         with:
           toolchain: stable
 
-      - run: cargo clippy -- -D warnings
+      - run: cargo clippy --all-targets -- -D warnings
       - run: cargo fmt --all -- --check
 
   ensure_no_std:
diff --git a/Cargo.toml b/Cargo.toml
index 0adc906..72f7a00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -44,6 +44,7 @@ trybuild = "1.0.99"
 rustc-hash = "=2.1.0"
 env_logger = "0.11.5"
 assert_hex = "0.4.1"
+log = { version = "0.4.22" }
 
 [[bench]]
 name = "deku"
diff --git a/benches/deku.rs b/benches/deku.rs
index 80dd55a..671e10b 100644
--- a/benches/deku.rs
+++ b/benches/deku.rs
@@ -1,6 +1,6 @@
 use std::io::{Cursor, Read, Seek};
 
-use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
+use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
 use deku::prelude::*;
 
 #[cfg(feature = "bits")]
@@ -55,7 +55,7 @@ fn criterion_benchmark(c: &mut Criterion) {
     });
     c.bench_function("deku_write_byte", |b| {
         b.iter(|| {
-            deku_write(black_box(&DekuBytes {
+            deku_write(std::hint::black_box(&DekuBytes {
                 data_00: 0x00,
                 data_01: 0x02,
                 data_02: 0x03,
@@ -74,7 +74,7 @@ fn criterion_benchmark(c: &mut Criterion) {
     #[cfg(feature = "bits")]
     c.bench_function("deku_write_bits", |b| {
         b.iter(|| {
-            deku_write(black_box(&DekuBits {
+            deku_write(std::hint::black_box(&DekuBits {
                 data_01: 0x01,
                 data_02: 0x03,
                 data_03: 0x06,
@@ -91,7 +91,7 @@ fn criterion_benchmark(c: &mut Criterion) {
         )
     });
     c.bench_function("deku_write_enum", |b| {
-        b.iter(|| deku_write(black_box(&DekuEnum::VariantA(0x02))))
+        b.iter(|| deku_write(std::hint::black_box(&DekuEnum::VariantA(0x02))))
     });
 
     let deku_write_vec_input = DekuVec {
@@ -107,7 +107,7 @@ fn criterion_benchmark(c: &mut Criterion) {
         )
     });
     c.bench_function("deku_write_vec", |b| {
-        b.iter(|| deku_write(black_box(&deku_write_vec_input)))
+        b.iter(|| deku_write(std::hint::black_box(&deku_write_vec_input)))
     });
 }
 
@@ -138,14 +138,14 @@ pub fn read_all_vs_count_vs_read_exact(c: &mut Criterion) {
     }
 
     c.bench_function("read_all_bytes", |b| {
-        b.iter(|| AllWrapper::from_bytes(black_box((&[1; 1500], 0))))
+        b.iter(|| AllWrapper::from_bytes(std::hint::black_box((&[1; 1500], 0))))
     });
 
     c.bench_function("read_all", |b| {
         b.iter(|| {
             let mut cursor = Cursor::new([1u8; 1500].as_ref());
             let mut reader = Reader::new(&mut cursor);
-            AllWrapper::from_reader_with_ctx(black_box(&mut reader), ())
+            AllWrapper::from_reader_with_ctx(std::hint::black_box(&mut reader), ())
         })
     });
 
@@ -153,7 +153,7 @@ pub fn read_all_vs_count_vs_read_exact(c: &mut Criterion) {
         b.iter(|| {
             let mut cursor = Cursor::new([1u8; 1500].as_ref());
             let mut reader = Reader::new(&mut cursor);
-            CountWrapper::from_reader_with_ctx(black_box(&mut reader), ())
+            CountWrapper::from_reader_with_ctx(std::hint::black_box(&mut reader), ())
         })
     });
 
@@ -161,7 +161,7 @@ pub fn read_all_vs_count_vs_read_exact(c: &mut Criterion) {
         b.iter(|| {
             let mut cursor = Cursor::new([1u8; 1500].as_ref());
             let mut reader = Reader::new(&mut cursor);
-            CountWrapper::from_reader_with_ctx(black_box(&mut reader), ())
+            CountWrapper::from_reader_with_ctx(std::hint::black_box(&mut reader), ())
         })
     });
 
@@ -169,7 +169,7 @@ pub fn read_all_vs_count_vs_read_exact(c: &mut Criterion) {
         b.iter(|| {
             let mut cursor = Cursor::new([1u8; 1500].as_ref());
             let mut reader = Reader::new(&mut cursor);
-            CountNonSpecialize::from_reader_with_ctx(black_box(&mut reader), ())
+            CountNonSpecialize::from_reader_with_ctx(std::hint::black_box(&mut reader), ())
         })
     });
 }
diff --git a/examples/custom_reader_and_writer.rs b/examples/custom_reader_and_writer.rs
index d3903af..84fdf8b 100644
--- a/examples/custom_reader_and_writer.rs
+++ b/examples/custom_reader_and_writer.rs
@@ -11,10 +11,10 @@ fn bit_flipper_read<R: std::io::Read + std::io::Seek>(
     bit_size: BitSize,
 ) -> Result<u8, DekuError> {
     // Access to previously read fields
-    println!("field_a = 0x{:X}", field_a);
+    println!("field_a = 0x{field_a:X}");
 
     // Size of the current field
-    println!("bit_size: {:?}", bit_size);
+    println!("bit_size: {bit_size:?}");
 
     // read field_b, calling original func
     let value = u8::from_reader_with_ctx(reader, bit_size)?;
@@ -32,13 +32,13 @@ fn bit_flipper_write<W: Write + Seek>(
     bit_size: BitSize,
 ) -> Result<(), DekuError> {
     // Access to previously written fields
-    println!("field_a = 0x{:X}", field_a);
+    println!("field_a = 0x{field_a:X}");
 
     // value of field_b
-    println!("field_b = 0x{:X}", field_b);
+    println!("field_b = 0x{field_b:X}");
 
     // Size of the current field
-    println!("bit_size: {:?}", bit_size);
+    println!("bit_size: {bit_size:?}");
 
     // flip the bits on value if field_a is 0x01
     let value = if field_a == 0x01 { !field_b } else { field_b };
diff --git a/examples/many.rs b/examples/many.rs
index d0b62e0..29895f4 100644
--- a/examples/many.rs
+++ b/examples/many.rs
@@ -28,5 +28,5 @@ fn main() {
         Limit::new_count(10_0000),
     );
 
-    println!("{:?}", ret);
+    println!("{ret:?}");
 }
diff --git a/src/attributes.rs b/src/attributes.rs
index bb5ee0c..9f6d2c9 100644
--- a/src/attributes.rs
+++ b/src/attributes.rs
@@ -448,7 +448,7 @@ let _ = value.to_writer(&mut writer, ()).unwrap();
 assert_eq!(buf, data);
 ```
 
-Top-Leve Example:
+Top-Level Example:
 
 ```rust
 # use deku::prelude::*;
diff --git a/src/impls/arc.rs b/src/impls/arc.rs
index d00af34..7ae6c23 100644
--- a/src/impls/arc.rs
+++ b/src/impls/arc.rs
@@ -73,6 +73,7 @@ where
 }
 
 #[cfg(test)]
+#[allow(clippy::too_many_arguments)]
 mod tests {
     use no_std_io::io::Cursor;
     use rstest::rstest;
diff --git a/src/impls/boxed.rs b/src/impls/boxed.rs
index af3af82..0aded53 100644
--- a/src/impls/boxed.rs
+++ b/src/impls/boxed.rs
@@ -73,6 +73,7 @@ where
 }
 
 #[cfg(test)]
+#[allow(clippy::too_many_arguments)]
 mod tests {
     use no_std_io::io::Cursor;
     use rstest::rstest;
diff --git a/src/impls/cstring.rs b/src/impls/cstring.rs
index 0a3292d..57eae99 100644
--- a/src/impls/cstring.rs
+++ b/src/impls/cstring.rs
@@ -66,43 +66,43 @@ mod tests {
 
     #[rstest(input, len, expected, expected_rest,
         case(
-            &[b't', b'e', b's', b't', b'\0'],
+            b"test\0",
             Some(5),
             CString::new("test").unwrap(),
             &[],
         ),
         case(
-            &[b't', b'e', b's', b't', b'\0'],
+            b"test\0",
             None,
             CString::new("test").unwrap(),
             &[],
         ),
         case(
-            &[b't', b'e', b's', b't', b'\0', b'a'],
+            b"test\0a",
             Some(5),
             CString::new("test").unwrap(),
-            &[b'a'],
+            b"a",
         ),
         case(
-            &[b't', b'e', b's', b't', b'\0', b'a'],
+            b"test\0a",
             None,
             CString::new("test").unwrap(),
-            &[b'a'],
+            b"a",
         ),
 
         #[should_panic(expected = "Parse(\"Failed to convert Vec to CString: data provided is not nul terminated\")")]
         case(
-            &[b't', b'e', b's', b't'],
+            b"test",
             Some(4),
             CString::new("test").unwrap(),
-            &[b'a'],
+            b"a",
         ),
 
         #[should_panic(expected = "Incomplete(NeedSize { bits: 8 })")]
-        case(&[b't', b'e', b's', b't'], Some(5), CString::new("test").unwrap(), &[]),
+        case(b"test", Some(5), CString::new("test").unwrap(), &[]),
 
         #[should_panic(expected = "Incomplete(NeedSize { bits: 8 })")]
-        case(&[b't', b'e', b's', b't'], None, CString::new("test").unwrap(), &[]),
+        case(b"test", None, CString::new("test").unwrap(), &[]),
     )]
     fn test_cstring_count(
         input: &[u8],
diff --git a/src/impls/hashset.rs b/src/impls/hashset.rs
index 053cd88..95c2920 100644
--- a/src/impls/hashset.rs
+++ b/src/impls/hashset.rs
@@ -211,6 +211,7 @@ impl<T: DekuWriter<Ctx>, S, Ctx: Copy> DekuWriter<Ctx> for HashSet<T, S> {
 }
 
 #[cfg(test)]
+#[allow(clippy::too_many_arguments)]
 mod tests {
     #[cfg(feature = "bits")]
     use crate::bitvec::{bits, BitSlice, Msb0};
diff --git a/src/impls/slice.rs b/src/impls/slice.rs
index 15b3e18..ed6facd 100644
--- a/src/impls/slice.rs
+++ b/src/impls/slice.rs
@@ -96,8 +96,6 @@ where
 #[cfg(test)]
 mod tests {
     use super::*;
-    #[cfg(feature = "bits")]
-    use bitvec::prelude::*;
     use rstest::rstest;
     use std::io::Cursor;
 
diff --git a/src/impls/unit.rs b/src/impls/unit.rs
index 919db30..469fbe6 100644
--- a/src/impls/unit.rs
+++ b/src/impls/unit.rs
@@ -37,6 +37,7 @@ mod tests {
 
         let mut cursor = Cursor::new(input);
         let mut reader = Reader::new(&mut cursor);
+        #[allow(clippy::let_unit_value)]
         let res_read = <()>::from_reader_with_ctx(&mut reader, ()).unwrap();
         assert_eq!((), res_read);
 
diff --git a/src/impls/vec.rs b/src/impls/vec.rs
index 4202065..d7bf356 100644
--- a/src/impls/vec.rs
+++ b/src/impls/vec.rs
@@ -201,6 +201,7 @@ impl<T: DekuWriter<Ctx>, Ctx: Copy> DekuWriter<Ctx> for Vec<T> {
 }
 
 #[cfg(test)]
+#[allow(clippy::too_many_arguments)]
 mod tests {
     #[cfg(feature = "bits")]
     use crate::bitvec::{bits, BitSlice, Msb0};
diff --git a/src/writer.rs b/src/writer.rs
index 1fde9bc..88fbeb2 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -300,33 +300,33 @@ mod tests {
         let mut out_buf = Cursor::new(vec![]);
         let mut writer = Writer::new(&mut out_buf);
 
-        let mut input = hex!("aa");
-        writer.write_bytes(&mut input).unwrap();
+        let input = hex!("aa");
+        writer.write_bytes(&input).unwrap();
 
-        let mut bv = BitVec::<u8, Msb0>::from_slice(&[0xbb]);
-        writer.write_bits(&mut bv).unwrap();
+        let bv = BitVec::<u8, Msb0>::from_slice(&[0xbb]);
+        writer.write_bits(&bv).unwrap();
 
-        let mut bv = bitvec![u8, Msb0; 1, 1, 1, 1];
-        writer.write_bits(&mut bv).unwrap();
-        let mut bv = bitvec![u8, Msb0; 0, 0, 0, 1];
-        writer.write_bits(&mut bv).unwrap();
+        let bv = bitvec![u8, Msb0; 1, 1, 1, 1];
+        writer.write_bits(&bv).unwrap();
+        let bv = bitvec![u8, Msb0; 0, 0, 0, 1];
+        writer.write_bits(&bv).unwrap();
 
-        let mut input = hex!("aa");
-        writer.write_bytes(&mut input).unwrap();
+        let input = hex!("aa");
+        writer.write_bytes(&input).unwrap();
 
-        let mut bv = bitvec![u8, Msb0; 0, 0, 0, 1];
-        writer.write_bits(&mut bv).unwrap();
-        let mut bv = bitvec![u8, Msb0; 1, 1, 1, 1];
-        writer.write_bits(&mut bv).unwrap();
+        let bv = bitvec![u8, Msb0; 0, 0, 0, 1];
+        writer.write_bits(&bv).unwrap();
+        let bv = bitvec![u8, Msb0; 1, 1, 1, 1];
+        writer.write_bits(&bv).unwrap();
 
-        let mut bv = bitvec![u8, Msb0; 0, 0, 0, 1];
-        writer.write_bits(&mut bv).unwrap();
+        let bv = bitvec![u8, Msb0; 0, 0, 0, 1];
+        writer.write_bits(&bv).unwrap();
 
-        let mut input = hex!("aa");
-        writer.write_bytes(&mut input).unwrap();
+        let input = hex!("aa");
+        writer.write_bytes(&input).unwrap();
 
-        let mut bv = bitvec![u8, Msb0; 1, 1, 1, 1];
-        writer.write_bits(&mut bv).unwrap();
+        let bv = bitvec![u8, Msb0; 1, 1, 1, 1];
+        writer.write_bits(&bv).unwrap();
 
         assert_eq!(
             &mut out_buf.into_inner(),
@@ -340,8 +340,8 @@ mod tests {
         let mut out_buf = Cursor::new(vec![]);
         let mut writer = Writer::new(&mut out_buf);
 
-        let mut input = hex!("aa");
-        writer.write_bytes(&mut input).unwrap();
+        let input = hex!("aa");
+        writer.write_bytes(&input).unwrap();
 
         assert_eq!(&mut out_buf.into_inner(), &mut vec![0xaa]);
     }
@@ -357,7 +357,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1], Order::Msb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b1010_0101]);
 
         let mut out_buf = Cursor::new(vec![]);
@@ -368,7 +368,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1], Order::Lsb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b0101_1010]);
 
         let mut out_buf = Cursor::new(vec![]);
@@ -379,7 +379,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1], Order::Lsb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b1010_0101]);
 
         let mut out_buf = Cursor::new(vec![]);
@@ -390,7 +390,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1, 0, 1], Order::Msb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b1010_1001, 0b0101_0000]);
 
         let mut out_buf = Cursor::new(vec![]);
@@ -401,7 +401,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1, 0, 1], Order::Lsb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b110_1010, 0b0101_0000]);
 
         let mut out_buf = Cursor::new(vec![]);
@@ -412,7 +412,7 @@ mod tests {
         writer
             .write_bits_order(&bitvec![u8, Msb0; 0, 1, 0, 1, 0, 1], Order::Msb0)
             .unwrap();
-        writer.finalize();
+        writer.finalize().unwrap();
         assert_eq!(out_buf.into_inner(), [0b0101_0110, 0b1010_0000]);
     }
 }


Test patch:
diff --git a/tests/bit_order.rs b/tests/bit_order.rs
index df521cc..25af55a 100644
--- a/tests/bit_order.rs
+++ b/tests/bit_order.rs
@@ -419,7 +419,7 @@ mod tests {
 
         let string_data = data
             .iter()
-            .map(|f| (format!("{:08b}", f).chars().rev().collect()))
+            .map(|f| (format!("{f:08b}").chars().rev().collect()))
             .collect::<Vec<String>>()
             .join("");
 
@@ -469,7 +469,9 @@ mod tests {
         let data = vec![0x13, 0x0, 0b0111_0100, 0xFF];
         let (_, dt) = DekuTest::from_bytes((&data, 0)).unwrap();
         let to_bytes = dt.to_bytes().unwrap();
-        assert_eq!(dt.flag, 0b111_01);
+        #[allow(clippy::unusual_byte_groupings)]
+        let expected = 0b111_01;
+        assert_eq!(dt.flag, expected);
         assert_eq!(to_bytes, data);
     }
 }
diff --git a/tests/test_common/mod.rs b/tests/test_common/mod.rs
index 91a44fa..b90e04b 100644
--- a/tests/test_common/mod.rs
+++ b/tests/test_common/mod.rs
@@ -2,6 +2,7 @@
 
 pub trait FromBeBytes: Sized {
     type Bytes;
+    #[allow(dead_code)]
     fn from_be_bytes(_: Self::Bytes) -> Self;
 }
 
diff --git a/tests/test_compile/mod.rs b/tests/test_compile/mod.rs
index 60425ba..a96c39e 100644
--- a/tests/test_compile/mod.rs
+++ b/tests/test_compile/mod.rs
@@ -1,6 +1,5 @@
 #[test]
 #[cfg(feature = "bits")]
-#[cfg(not(tarpaulin))]
 #[cfg_attr(miri, ignore)]
 fn test_compile() {
     let t = trybuild::TestCases::new();
diff --git a/tests/test_cstring.rs b/tests/test_cstring.rs
index ede6e62..13568d6 100644
--- a/tests/test_cstring.rs
+++ b/tests/test_cstring.rs
@@ -9,7 +9,7 @@ fn test_cstring_no_ctx() {
         s: CString,
     }
 
-    let bytes = &[b't', b'e', b's', b't', b'\0'];
+    let bytes = b"test\0";
     let (_, d) = Data::from_bytes((bytes, 0)).unwrap();
     assert_eq!(d.s, CString::new("test").unwrap());
 }
@@ -36,7 +36,7 @@ fn test_cstring_valid_bytes() {
         s: CString,
     }
 
-    let bytes = &[b't', b'e', b's', b't', b'\0'];
+    let bytes = b"test\0";
     let (_, d) = Data::from_bytes((bytes, 0)).unwrap();
     assert_eq!(d.s, CString::new("test").unwrap());
 }
@@ -52,7 +52,7 @@ fn test_cstring_trailing_nul() {
         s: CString,
     }
 
-    let bytes = &[b't', b'e', b's', b't', b'\0', b'\0'];
+    let bytes = b"test\0\0";
     let (_, d) = Data::from_bytes((bytes, 0)).unwrap();
     assert_eq!(d.s, CString::new("test").unwrap());
 }
diff --git a/tests/test_enum.rs b/tests/test_enum.rs
index ab248e3..7d43b44 100644
--- a/tests/test_enum.rs
+++ b/tests/test_enum.rs
@@ -1,3 +1,7 @@
+//! General smoke tests for enums
+
+// TODO: These should be divided into smaller tests
+
 use std::convert::{TryFrom, TryInto};
 use std::io::Cursor;
 
@@ -5,9 +9,6 @@ use deku::prelude::*;
 use hexlit::hex;
 use rstest::*;
 
-/// General smoke tests for enums
-/// TODO: These should be divided into smaller tests
-
 #[cfg(feature = "bits")]
 #[derive(PartialEq, Debug, DekuRead, DekuWrite)]
 #[deku(id_type = "u8")]
diff --git a/tests/test_from_reader.rs b/tests/test_from_reader.rs
index a366884..1114d7f 100644
--- a/tests/test_from_reader.rs
+++ b/tests/test_from_reader.rs
@@ -65,10 +65,10 @@ fn test_from_reader_enum() {
     assert_eq!(amt_read, 6 + first_amt_read);
     assert_eq!(TestDeku::VariantB(0b10), ret_read);
 
-    c.rewind();
+    c.rewind().unwrap();
     let inner = &c.into_inner();
     let mut s = NoSeek::new(inner.as_slice());
-    let (amt_read, ret_read) = TestDeku::from_reader((&mut s, 0)).unwrap();
+    let (_amt_read, ret_read) = TestDeku::from_reader((&mut s, 0)).unwrap();
     assert_eq!(first_amt_read, 8);
     assert_eq!(TestDeku::VariantA(0b0110), ret_read);
 }
diff --git a/tests/test_own_impl.rs b/tests/test_own_impl.rs
index e28cc22..163e7f0 100644
--- a/tests/test_own_impl.rs
+++ b/tests/test_own_impl.rs
@@ -2,10 +2,10 @@
 fn test_own_impl() {
     use deku::prelude::*;
     use std::io::{Read, Seek, SeekFrom};
-    pub trait ReadSeek: Read + Seek {}
     pub enum Data {
         /// On read: Save current stream_position() as `Offset`, seek `header.filesize`
         /// This will be used to seek this this position if we want to extract *just* this file
+        #[expect(dead_code)]
         Offset(u64),
     }
 
diff --git a/tests/test_seek.rs b/tests/test_seek.rs
index a75354d..710351c 100644
--- a/tests/test_seek.rs
+++ b/tests/test_seek.rs
@@ -57,7 +57,7 @@ fn test_seek_ctx_before(input: &[u8], ctx: usize, expected: SeekCtxBefore) {
     let mut buf = vec![];
     let mut cursor = Cursor::new(&mut buf);
     let mut writer = Writer::new(&mut cursor);
-    let _ = ret_read.to_writer(&mut writer, ctx).unwrap();
+    ret_read.to_writer(&mut writer, ctx).unwrap();
     assert_eq!(buf, input);
 }
 
@@ -84,7 +84,7 @@ fn test_seek_ctx_start(input: &[u8], expected: SeekCtxBeforeStart) {
     let mut buf = vec![];
     let mut cursor = Cursor::new(&mut buf);
     let mut writer = Writer::new(&mut cursor);
-    let _ = ret_read.to_writer(&mut writer, ()).unwrap();
+    ret_read.to_writer(&mut writer, ()).unwrap();
     assert_eq!(buf, input);
 }
 
@@ -111,7 +111,7 @@ fn test_seek_ctx_end(input: &[u8], expected: SeekCtxBeforeEnd) {
     let mut buf = vec![0, 0, 0];
     let mut cursor = Cursor::new(&mut buf);
     let mut writer = Writer::new(&mut cursor);
-    let _ = ret_read.to_writer(&mut writer, ()).unwrap();
+    ret_read.to_writer(&mut writer, ()).unwrap();
     assert_eq!(buf, input);
 }
 
@@ -138,12 +138,12 @@ fn test_seek_ctx_no_seek(input: &[u8], expected: SeekCtxNoSeek) {
     let mut buf = vec![];
     let mut cursor = Cursor::new(&mut buf);
     let mut writer = Writer::new(&mut cursor);
-    let _ = ret_read.to_writer(&mut writer, ()).unwrap();
+    ret_read.to_writer(&mut writer, ()).unwrap();
     assert_eq!(buf, input);
 
     let mut buf = vec![];
     let mut cursor = NoSeek::new(&mut buf);
     let mut writer = Writer::new(&mut cursor);
-    let _ = ret_read.to_writer(&mut writer, ()).unwrap();
+    ret_read.to_writer(&mut writer, ()).unwrap();
     assert_eq!(buf, input);
 }
diff --git a/tests/test_struct.rs b/tests/test_struct.rs
index e3d7c93..3703027 100644
--- a/tests/test_struct.rs
+++ b/tests/test_struct.rs
@@ -1,3 +1,7 @@
+//! General smoke tests for structs
+
+// TODO: These should be divided into smaller tests
+
 #![allow(clippy::unusual_byte_groupings)]
 
 use std::convert::{TryFrom, TryInto};
@@ -6,9 +10,6 @@ use deku::prelude::*;
 
 mod test_common;
 
-/// General smoke tests for structs
-/// TODO: These should be divided into smaller tests
-
 // Common struct to test nesting
 #[cfg(feature = "bits")]
 #[derive(PartialEq, Debug, DekuRead, DekuWrite)]
@@ -34,6 +35,7 @@ pub struct NestedDeku {
 fn test_read_too_much_data() {
     #[derive(DekuRead)]
     pub struct TestStruct {
+        #[expect(dead_code)]
         #[deku(bits = 6)]
         pub field_a: u8,
     }
@@ -244,7 +246,7 @@ fn test_zst_vec_1() {
     }
 
     let bytes = vec![];
-    let (y, x) = ListOfThings::from_bytes((&bytes, 0)).unwrap();
+    let (_y, x) = ListOfThings::from_bytes((&bytes, 0)).unwrap();
     assert_eq!(x.things.len(), 0);
 }
 /// Issue 513
@@ -260,6 +262,6 @@ fn test_zst_vec_2() {
     }
 
     let bytes = vec![];
-    let (y, x) = ListOfThings::from_bytes((&bytes, 0)).unwrap();
+    let (_y, x) = ListOfThings::from_bytes((&bytes, 0)).unwrap();
     assert_eq!(x.things.len(), 0);
 }