From bc555f4293fb98390b47676f8e6467c5bac52098 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Thu, 2 Jan 2025 22:35:24 +0900 Subject: [PATCH] fix: clippy --- .../src/irep/goto_binary_serde.rs | 22 +++++++++---------- cprover_bindings/src/utils.rs | 1 + kani_metadata/src/artifact.rs | 4 ++-- library/kani/src/models/mod.rs | 5 ++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cprover_bindings/src/irep/goto_binary_serde.rs b/cprover_bindings/src/irep/goto_binary_serde.rs index c1b901ddd5c8..15cc0afa8902 100644 --- a/cprover_bindings/src/irep/goto_binary_serde.rs +++ b/cprover_bindings/src/irep/goto_binary_serde.rs @@ -936,9 +936,9 @@ where } } -//////////////////////////////////////// -//// Dynamic memory usage computation -//////////////////////////////////////// +// ================================== +// Dynamic memory usage computation +// ================================== #[cfg(test)] mod sharing_stats { @@ -1032,7 +1032,7 @@ mod sharing_stats { } } - impl<'a, W> DynamicUsage for GotoBinarySerializer<'a, W> + impl DynamicUsage for GotoBinarySerializer<'_, W> where W: Write, { @@ -1127,9 +1127,9 @@ mod sharing_stats { max_count = *count; max_id = Some(id); }; - nof_unique = nof_unique + 1; + nof_unique += 1; let incr = (*count as f64 - avg_count) / (nof_unique as f64); - avg_count = avg_count + incr; + avg_count += incr; } SharingStats { _nof_unique: nof_unique, @@ -1156,7 +1156,7 @@ mod sharing_stats { } impl GotoBinarySharingStats { - fn from_serializer<'a, W: Write>(s: &GotoBinarySerializer<'a, W>) -> Self { + fn from_serializer(s: &GotoBinarySerializer<'_, W>) -> Self { GotoBinarySharingStats { _allocated_bytes: s.dynamic_usage(), _string_stats: SharingStats::new(&s.string_count), @@ -1173,7 +1173,7 @@ mod sharing_stats { } } - impl<'a, W> GotoBinarySerializer<'a, W> + impl GotoBinarySerializer<'_, W> where W: Write, { @@ -1277,13 +1277,13 @@ mod tests { let mut writer = BufWriter::new(&mut vec); let mut serializer = GotoBinarySerializer::new(&mut writer); - for u in std::u8::MIN..std::u8::MAX { + for u in u8::MIN..u8::MAX { serializer.write_u8(u); } } // read back from byte stream - for u in std::u8::MIN..std::u8::MAX { + for u in u8::MIN..u8::MAX { assert_eq!(vec[u as usize], u); } } @@ -1352,7 +1352,7 @@ mod tests { let foo = String::from("foo").intern(); let bar = String::from("bar").intern(); let baz = String::from("baz").intern(); - let strings = vec![foo, bar, foo, bar, foo, baz, baz, bar, foo]; + let strings = [foo, bar, foo, bar, foo, baz, baz, bar, foo]; let mut vec: Vec = Vec::new(); diff --git a/cprover_bindings/src/utils.rs b/cprover_bindings/src/utils.rs index 4a323277ec9e..e161fb886a22 100644 --- a/cprover_bindings/src/utils.rs +++ b/cprover_bindings/src/utils.rs @@ -106,6 +106,7 @@ mod tests { use num::BigInt; #[test] + #[allow(clippy::bool_assert_comparison)] fn test_fits_in_bits() { assert_eq!(BigInt::from(10).fits_in_bits(3, false), false); assert_eq!(BigInt::from(10).fits_in_bits(4, false), true); diff --git a/kani_metadata/src/artifact.rs b/kani_metadata/src/artifact.rs index 12f8f9a49566..dbb41a213bc8 100644 --- a/kani_metadata/src/artifact.rs +++ b/kani_metadata/src/artifact.rs @@ -99,7 +99,7 @@ mod test { #[test] fn test_convert_ok() { - let path = PathBuf::from("/tmp/my_file.rs").with_extension(&SymTabGoto); + let path = PathBuf::from("/tmp/my_file.rs").with_extension(SymTabGoto); let goto = convert_type(&path, SymTabGoto, Goto); assert_eq!(goto.as_os_str(), "/tmp/my_file.out"); @@ -109,7 +109,7 @@ mod test { #[test] fn test_set_extension_ok() { - let path = PathBuf::from("/tmp/my_file.rs").with_extension(&SymTabGoto); + let path = PathBuf::from("/tmp/my_file.rs").with_extension(SymTabGoto); assert_eq!(path.as_os_str(), "/tmp/my_file.symtab.out"); } } diff --git a/library/kani/src/models/mod.rs b/library/kani/src/models/mod.rs index 2081ddf639df..af5ac336e09e 100644 --- a/library/kani/src/models/mod.rs +++ b/library/kani/src/models/mod.rs @@ -191,7 +191,7 @@ mod test { u64: From, { assert_eq!( - unsafe { u64::from(kani_intrinsic::simd_bitmask::<_, M, E, LANES>(mask.clone())) }, + unsafe { u64::from(kani_intrinsic::simd_bitmask::<_, M, E, LANES>(mask)) }, mask.to_bitmask() ); } @@ -220,8 +220,7 @@ mod test { let bitmask = mask.to_bitmask(); assert_eq!(bitmask, 0b1010); - let kani_mask = - unsafe { u64::from(kani_intrinsic::simd_bitmask::<_, u8, u32, 4>(mask.clone())) }; + let kani_mask = unsafe { u64::from(kani_intrinsic::simd_bitmask::<_, u8, u32, 4>(mask)) }; assert_eq!(kani_mask, bitmask); } }