Merge pull request #585 from riley-williams/clippy-fix

Apply clippy fixes
This commit is contained in:
Alex Martens 2025-07-15 14:30:20 +00:00 committed by GitHub
commit 2db884445a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 13 additions and 15 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed ### Fixed
- CI now uses flags specified in `Cargo.toml` for `rustdoc` tests. - CI now uses flags specified in `Cargo.toml` for `rustdoc` tests.
- Fixed clippy lints.
### Removed ### Removed

View File

@ -880,7 +880,7 @@ mod tests {
let a_item = a.next(); let a_item = a.next();
let b_item = b.next(); let b_item = b.next();
assert_eq!(a_item, b_item, "{}", i); assert_eq!(a_item, b_item, "{i}");
i += 1; i += 1;

View File

@ -1871,14 +1871,14 @@ mod tests {
assert_eq!(all.len(), MAP_SLOTS - 1); assert_eq!(all.len(), MAP_SLOTS - 1);
let mut even = almost_filled_map(); 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); assert_eq!(even.len(), (MAP_SLOTS - 1) / 2);
for &v in even.values() { for &v in even.values() {
assert_eq!(v % 2, 0); assert_eq!(v % 2, 0);
} }
let mut odd = almost_filled_map(); 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); assert_eq!(odd.len(), MAP_SLOTS / 2);
for &v in odd.values() { for &v in odd.values() {
assert_ne!(v % 2, 0); assert_ne!(v % 2, 0);

View File

@ -922,7 +922,7 @@ mod tests {
for _ in 0..1_000_000 { for _ in 0..1_000_000 {
let v = rb.dequeue().unwrap(); let v = rb.dequeue().unwrap();
println!("{}", v); println!("{v}");
rb.enqueue(v).unwrap(); rb.enqueue(v).unwrap();
assert_eq!(rb.len(), 2); assert_eq!(rb.len(), 2);
} }

View File

@ -1016,7 +1016,7 @@ mod tests {
let s: String<8> = String::try_from("abcd").unwrap(); let s: String<8> = String::try_from("abcd").unwrap();
let mut std_s = std::string::String::new(); let mut std_s = std::string::String::new();
write!(std_s, "{:?}", s).unwrap(); write!(std_s, "{s:?}").unwrap();
assert_eq!("\"abcd\"", std_s); assert_eq!("\"abcd\"", std_s);
} }
@ -1026,7 +1026,7 @@ mod tests {
let s: String<8> = String::try_from("abcd").unwrap(); let s: String<8> = String::try_from("abcd").unwrap();
let mut std_s = std::string::String::new(); let mut std_s = std::string::String::new();
write!(std_s, "{}", s).unwrap(); write!(std_s, "{s}").unwrap();
assert_eq!("abcd", std_s); assert_eq!("abcd", std_s);
} }

View File

@ -1014,10 +1014,7 @@ impl<T, LenT: LenType, S: VecStorage<T> + ?Sized> VecInner<T, LenT, S> {
pub fn insert(&mut self, index: usize, element: T) -> Result<(), T> { pub fn insert(&mut self, index: usize, element: T) -> Result<(), T> {
let len = self.len(); let len = self.len();
if index > len { if index > len {
panic!( panic!("insertion index (is {index}) should be <= len (is {len})");
"insertion index (is {}) should be <= len (is {})",
index, len
);
} }
// check there's space for the new element // check there's space for the new element
@ -1071,7 +1068,7 @@ impl<T, LenT: LenType, S: VecStorage<T> + ?Sized> VecInner<T, LenT, S> {
pub fn remove(&mut self, index: usize) -> T { pub fn remove(&mut self, index: usize) -> T {
let len = self.len(); let len = self.len();
if index >= 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 { unsafe {
// infallible // infallible

View File

@ -90,7 +90,7 @@ fn contention() {
while p.enqueue(i as u8).is_err() {} while p.enqueue(i as u8).is_err() {}
} }
println!("producer: {}", sum); println!("producer: {sum}");
}); });
scope.spawn(move || { 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) { for i in 0..(16 * N) {
sum = sum.wrapping_add(i); sum = sum.wrapping_add(i);
println!("enqueue {}", i); println!("enqueue {i}");
while Q.enqueue(i).is_err() {} while Q.enqueue(i).is_err() {}
} }
@ -147,7 +147,7 @@ fn mpmc_contention() {
loop { loop {
if let Some(v) = Q.dequeue() { if let Some(v) = Q.dequeue() {
sum = sum.wrapping_add(v); sum = sum.wrapping_add(v);
println!("dequeue {}", v); println!("dequeue {v}");
break; break;
} }
} }