Skip to content

Commit 9b5b00e

Browse files
committed
Apply a variety of clippy feedeback items
1 parent 2c27d33 commit 9b5b00e

File tree

17 files changed

+69
-65
lines changed

17 files changed

+69
-65
lines changed

src/cache_padded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::{Deref, DerefMut};
2121
not(any(target_arch = "x86_64", target_arch = "aarch64")),
2222
repr(align(64))
2323
)]
24-
#[derive(Default, PartialEq)]
24+
#[derive(Default, PartialEq, Eq)]
2525
pub struct CachePadded<T> {
2626
value: T,
2727
}

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Db {
143143

144144
let mut tenants = self.tenants.write();
145145

146-
let tree = if let Some(tree) = tenants.remove(&*name_ref) {
146+
let tree = if let Some(tree) = tenants.remove(name_ref) {
147147
tree
148148
} else {
149149
return Ok(false);

src/ebr/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl CompareAndSetOrdering for (Ordering, Ordering) {
9090

9191
/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`.
9292
#[inline]
93-
fn low_bits<T: ?Sized + Pointable>() -> usize {
93+
const fn low_bits<T: ?Sized + Pointable>() -> usize {
9494
(1 << T::ALIGN.trailing_zeros()) - 1
9595
}
9696

src/ebr/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct Iter<'g, T, C: IsElement<T>> {
8383
}
8484

8585
/// An error that occurs during iteration over the list.
86-
#[derive(Debug, Clone, Copy, PartialEq)]
86+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8787
pub enum IterError {
8888
/// A concurrent thread modified the state of the list at the same place that this iterator
8989
/// was inspecting. Subsequent iteration will restart from the beginning of the list.

src/histogram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn multithreaded() {
255255
}));
256256
}
257257

258-
for t in threads.into_iter() {
258+
for t in threads {
259259
t.join().unwrap();
260260
}
261261

src/ivec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ mod qc {
327327
fn ivec_as_mut_identity() {
328328
let initial = &[1];
329329
let mut iv = IVec::from(initial);
330-
assert_eq!(&*initial, &*iv);
331-
assert_eq!(&*initial, &mut *iv);
332-
assert_eq!(&*initial, iv.as_mut());
330+
assert_eq!(initial, &*iv);
331+
assert_eq!(initial, &mut *iv);
332+
assert_eq!(initial, iv.as_mut());
333333
}
334334

335335
fn prop_identity(ivec: &IVec) -> bool {

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ mod compile_time_assertions {
498498
use crate::*;
499499

500500
#[allow(unreachable_code)]
501-
fn _assert_public_types_send_sync() {
501+
const fn _assert_public_types_send_sync() {
502502
_assert_send::<Subscriber>();
503503

504504
_assert_send_sync::<Iter>();
@@ -513,9 +513,9 @@ mod compile_time_assertions {
513513
_assert_send_sync::<Mode>();
514514
}
515515

516-
fn _assert_send<S: Send>() {}
516+
const fn _assert_send<S: Send>() {}
517517

518-
fn _assert_send_sync<S: Send + Sync>() {}
518+
const fn _assert_send_sync<S: Send + Sync>() {}
519519
}
520520

521521
#[cfg(all(unix, not(miri)))]

src/node.rs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,10 @@ impl<'a> Iterator for Iter<'a> {
412412
(Some((_, Some(_))), None) => {
413413
log::trace!("src/node.rs:114");
414414
log::trace!("iterator returning {:?}", self.next_a);
415-
return self.next_a.take().map(|(k, v)| {
416-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
417-
});
415+
return self
416+
.next_a
417+
.take()
418+
.map(|(k, v)| (KeyRef::Slice(k), v.unwrap().as_ref()));
418419
}
419420
(Some((k_a, v_a_opt)), Some((k_b, _))) => {
420421
let cmp = KeyRef::Slice(k_a).cmp(&k_b);
@@ -425,7 +426,7 @@ impl<'a> Iterator for Iter<'a> {
425426
log::trace!("src/node.rs:133");
426427
log::trace!("iterator returning {:?}", self.next_a);
427428
return self.next_a.take().map(|(k, v)| {
428-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
429+
(KeyRef::Slice(k), v.unwrap().as_ref())
429430
});
430431
}
431432
(Equal, None) => {
@@ -437,7 +438,7 @@ impl<'a> Iterator for Iter<'a> {
437438
(Less, Some(_)) => {
438439
log::trace!("iterator returning {:?}", self.next_a);
439440
return self.next_a.take().map(|(k, v)| {
440-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
441+
(KeyRef::Slice(k), v.unwrap().as_ref())
441442
});
442443
}
443444
(Less, None) => {
@@ -511,9 +512,10 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
511512
(Some((_, Some(_))), None) => {
512513
log::trace!("src/node.rs:483");
513514
log::trace!("iterator returning {:?}", self.next_back_a);
514-
return self.next_back_a.take().map(|(k, v)| {
515-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
516-
});
515+
return self
516+
.next_back_a
517+
.take()
518+
.map(|(k, v)| (KeyRef::Slice(k), v.unwrap().as_ref()));
517519
}
518520
(Some((k_a, Some(_))), Some((k_b, _))) if k_b > *k_a => {
519521
log::trace!("src/node.rs:508");
@@ -522,18 +524,20 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
522524
}
523525
(Some((k_a, Some(_))), Some((k_b, _))) if k_b < *k_a => {
524526
log::trace!("iterator returning {:?}", self.next_back_a);
525-
return self.next_back_a.take().map(|(k, v)| {
526-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
527-
});
527+
return self
528+
.next_back_a
529+
.take()
530+
.map(|(k, v)| (KeyRef::Slice(k), v.unwrap().as_ref()));
528531
}
529532
(Some((k_a, Some(_))), Some((k_b, _))) if k_b == *k_a => {
530533
// prefer overlay, discard node value
531534
self.next_back_b.take();
532535
log::trace!("src/node.rs:520");
533536
log::trace!("iterator returning {:?}", self.next_back_a);
534-
return self.next_back_a.take().map(|(k, v)| {
535-
(KeyRef::Slice(&*k), v.unwrap().as_ref())
536-
});
537+
return self
538+
.next_back_a
539+
.take()
540+
.map(|(k, v)| (KeyRef::Slice(k), v.unwrap().as_ref()));
537541
}
538542
_ => unreachable!(
539543
"did not expect combination a: {:?} b: {:?}",
@@ -713,10 +717,10 @@ impl Node {
713717
for (k, v) in &self.overlay {
714718
length_and_stride_matches &=
715719
v.is_some() && v.as_ref().unwrap().is_empty();
716-
length_and_stride_matches &= KeyRef::Slice(&*k) > prev
717-
&& is_linear(&prev, &KeyRef::Slice(&*k), stride);
720+
length_and_stride_matches &= KeyRef::Slice(k) > prev
721+
&& is_linear(&prev, &KeyRef::Slice(k), stride);
718722

719-
prev = KeyRef::Slice(&*k);
723+
prev = KeyRef::Slice(k);
720724

721725
if !length_and_stride_matches {
722726
break;
@@ -2398,8 +2402,8 @@ impl Inner {
23982402
pub(crate) fn contains_upper_bound(&self, bound: &Bound<IVec>) -> bool {
23992403
if let Some(hi) = self.hi() {
24002404
match bound {
2401-
Bound::Excluded(b) if hi >= &*b => true,
2402-
Bound::Included(b) if hi > &*b => true,
2405+
Bound::Excluded(b) if hi >= b => true,
2406+
Bound::Included(b) if hi > b => true,
24032407
_ => false,
24042408
}
24052409
} else {
@@ -2414,8 +2418,8 @@ impl Inner {
24142418
) -> bool {
24152419
let lo = self.lo();
24162420
match bound {
2417-
Bound::Excluded(b) if lo < &*b || (is_forward && *b == lo) => true,
2418-
Bound::Included(b) if lo <= &*b => true,
2421+
Bound::Excluded(b) if lo < b || (is_forward && *b == lo) => true,
2422+
Bound::Included(b) if lo <= b => true,
24192423
Bound::Unbounded if !is_forward => self.hi().is_none(),
24202424
_ => lo.is_empty(),
24212425
}
@@ -2629,8 +2633,8 @@ mod test {
26292633
}
26302634

26312635
let key_ref = KeyRef::Computed { base: &[2, 253], distance: 8 };
2632-
let mut buf = &mut [0, 0][..];
2633-
key_ref.write_into(&mut buf);
2636+
let buf = &mut [0, 0][..];
2637+
key_ref.write_into(buf);
26342638
assert_eq!(buf, &[3, 5]);
26352639
}
26362640

@@ -2730,7 +2734,7 @@ mod test {
27302734
.collect();
27312735

27322736
let mut ret =
2733-
Inner::new(&lo, hi.map(|h| &*h), 0, false, None, &children_ref);
2737+
Inner::new(&lo, hi.map(|h| h), 0, false, None, &children_ref);
27342738

27352739
ret.activity_sketch = g.gen();
27362740

src/pagecache/disk_pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{HeapId, LogOffset};
44
use crate::*;
55

66
/// A pointer to a location on disk or an off-log heap item.
7-
#[derive(Debug, Clone, Copy, PartialEq)]
7+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
88
pub enum DiskPtr {
99
/// Points to a value stored in the single-file log.
1010
Inline(LogOffset),

src/pagecache/logger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl Drop for Log {
502502
}
503503

504504
/// All log messages are prepended with this header
505-
#[derive(Debug, Copy, Clone, PartialEq)]
505+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
506506
pub struct MessageHeader {
507507
pub crc32: u32,
508508
pub kind: MessageKind,
@@ -512,7 +512,7 @@ pub struct MessageHeader {
512512
}
513513

514514
/// A number representing a segment number.
515-
#[derive(Copy, Clone, PartialEq, Debug)]
515+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
516516
#[repr(transparent)]
517517
pub struct SegmentNumber(pub u64);
518518

0 commit comments

Comments
 (0)