From ab441e9425da0b1befd3a5cbfdf88431df8f5b1c Mon Sep 17 00:00:00 2001 From: Riley Williams Date: Tue, 15 Jul 2025 10:02:51 -0400 Subject: [PATCH 1/2] Apply clippy fixes --- src/history_buf.rs | 2 +- src/index_map.rs | 4 ++-- src/spsc.rs | 2 +- src/string/mod.rs | 4 ++-- src/vec/mod.rs | 7 ++----- tests/tsan.rs | 8 ++++---- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/history_buf.rs b/src/history_buf.rs index f1a30d573d..b06e4648b9 100644 --- a/src/history_buf.rs +++ b/src/history_buf.rs @@ -880,7 +880,7 @@ mod tests { let a_item = a.next(); let b_item = b.next(); - assert_eq!(a_item, b_item, "{}", i); + assert_eq!(a_item, b_item, "{i}"); i += 1; diff --git a/src/index_map.rs b/src/index_map.rs index b89dcee927..c5fc76129d 100644 --- a/src/index_map.rs +++ b/src/index_map.rs @@ -1871,14 +1871,14 @@ mod tests { assert_eq!(all.len(), MAP_SLOTS - 1); let mut even = almost_filled_map(); - even.retain(|_, &mut v| v % 2 == 0); + even.retain(|_, &mut v| v.is_multiple_of(2)); assert_eq!(even.len(), (MAP_SLOTS - 1) / 2); for &v in even.values() { assert_eq!(v % 2, 0); } let mut odd = almost_filled_map(); - odd.retain(|_, &mut v| v % 2 != 0); + odd.retain(|_, &mut v| !v.is_multiple_of(2)); assert_eq!(odd.len(), MAP_SLOTS / 2); for &v in odd.values() { assert_ne!(v % 2, 0); diff --git a/src/spsc.rs b/src/spsc.rs index eb206456a8..cc541fcbae 100644 --- a/src/spsc.rs +++ b/src/spsc.rs @@ -922,7 +922,7 @@ mod tests { for _ in 0..1_000_000 { let v = rb.dequeue().unwrap(); - println!("{}", v); + println!("{v}"); rb.enqueue(v).unwrap(); assert_eq!(rb.len(), 2); } diff --git a/src/string/mod.rs b/src/string/mod.rs index 668dc95407..8ad8cc0bed 100644 --- a/src/string/mod.rs +++ b/src/string/mod.rs @@ -1016,7 +1016,7 @@ mod tests { let s: String<8> = String::try_from("abcd").unwrap(); let mut std_s = std::string::String::new(); - write!(std_s, "{:?}", s).unwrap(); + write!(std_s, "{s:?}").unwrap(); assert_eq!("\"abcd\"", std_s); } @@ -1026,7 +1026,7 @@ mod tests { let s: String<8> = String::try_from("abcd").unwrap(); let mut std_s = std::string::String::new(); - write!(std_s, "{}", s).unwrap(); + write!(std_s, "{s}").unwrap(); assert_eq!("abcd", std_s); } diff --git a/src/vec/mod.rs b/src/vec/mod.rs index 9eccbfab62..5a417964df 100644 --- a/src/vec/mod.rs +++ b/src/vec/mod.rs @@ -1014,10 +1014,7 @@ impl + ?Sized> VecInner { pub fn insert(&mut self, index: usize, element: T) -> Result<(), T> { let len = self.len(); if index > len { - panic!( - "insertion index (is {}) should be <= len (is {})", - index, len - ); + panic!("insertion index (is {index}) should be <= len (is {len})"); } // check there's space for the new element @@ -1071,7 +1068,7 @@ impl + ?Sized> VecInner { pub fn remove(&mut self, index: usize) -> T { let len = self.len(); if index >= len { - panic!("removal index (is {}) should be < len (is {})", index, len); + panic!("removal index (is {index}) should be < len (is {len})"); } unsafe { // infallible diff --git a/tests/tsan.rs b/tests/tsan.rs index b7543da27e..14391e2435 100644 --- a/tests/tsan.rs +++ b/tests/tsan.rs @@ -90,7 +90,7 @@ fn contention() { while p.enqueue(i as u8).is_err() {} } - println!("producer: {}", sum); + println!("producer: {sum}"); }); scope.spawn(move || { @@ -105,7 +105,7 @@ fn contention() { } } - println!("consumer: {}", sum); + println!("consumer: {sum}"); }); }); } @@ -132,7 +132,7 @@ fn mpmc_contention() { for i in 0..(16 * N) { sum = sum.wrapping_add(i); - println!("enqueue {}", i); + println!("enqueue {i}"); while Q.enqueue(i).is_err() {} } @@ -147,7 +147,7 @@ fn mpmc_contention() { loop { if let Some(v) = Q.dequeue() { sum = sum.wrapping_add(v); - println!("dequeue {}", v); + println!("dequeue {v}"); break; } } From 090f7cad3cdc04a47d34f1ec82f4e65e6efbe649 Mon Sep 17 00:00:00 2001 From: Riley Williams Date: Tue, 15 Jul 2025 10:08:06 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c42dd51ec..3ba060d326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - CI now uses flags specified in `Cargo.toml` for `rustdoc` tests. +- Fixed clippy lints. ### Removed