Skip to content

Commit 3506103

Browse files
committed
Clippy feedback, more restrictive imports in pagecache
1 parent 17bf21f commit 3506103

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

src/debug_delay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ pub fn debug_delay() {
4545

4646
let global_delays = GLOBAL_DELAYS.fetch_add(1, Relaxed);
4747
let local_delays = LOCAL_DELAYS.with(|ld| {
48-
let mut ld = ld.borrow_mut();
49-
let old = *ld;
50-
*ld = std::cmp::max(global_delays + 1, *ld + 1);
48+
let old = *ld.borrow();
49+
let new = (global_delays + 1).max(old + 1);
50+
*ld.borrow_mut() = new;
5151
old
5252
});
5353

src/ebr/internal.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Bag {
102102

103103
/// Seals the bag with the given epoch.
104104
fn seal(self, epoch: Epoch) -> SealedBag {
105-
SealedBag { epoch, bag: self }
105+
SealedBag { epoch, _bag: self }
106106
}
107107
}
108108

@@ -217,7 +217,8 @@ const fn no_op_func() {}
217217
#[derive(Debug)]
218218
struct SealedBag {
219219
epoch: Epoch,
220-
bag: Bag,
220+
// exists solely to be dropped
221+
_bag: Bag,
221222
}
222223

223224
/// It is safe to share `SealedBag` because `is_expired` only inspects the epoch.

src/pagecache/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub enum MessageKind {
123123
}
124124

125125
impl MessageKind {
126-
pub(crate) const fn into(self) -> u8 {
126+
pub(in crate::pagecache) const fn into(self) -> u8 {
127127
self as u8
128128
}
129129
}
@@ -225,16 +225,16 @@ fn bump_atomic_lsn(atomic_lsn: &AtomicLsn, to: Lsn) {
225225

226226
use std::convert::{TryFrom, TryInto};
227227

228-
pub(crate) const fn lsn_to_arr(number: Lsn) -> [u8; 8] {
228+
pub(in crate::pagecache) const fn lsn_to_arr(number: Lsn) -> [u8; 8] {
229229
number.to_le_bytes()
230230
}
231231

232232
#[inline]
233-
pub(crate) fn arr_to_lsn(arr: &[u8]) -> Lsn {
233+
pub(in crate::pagecache) fn arr_to_lsn(arr: &[u8]) -> Lsn {
234234
Lsn::from_le_bytes(arr.try_into().unwrap())
235235
}
236236

237-
pub(crate) const fn u64_to_arr(number: u64) -> [u8; 8] {
237+
pub(in crate::pagecache) const fn u64_to_arr(number: u64) -> [u8; 8] {
238238
number.to_le_bytes()
239239
}
240240

@@ -249,7 +249,7 @@ pub(crate) const fn u32_to_arr(number: u32) -> [u8; 4] {
249249

250250
#[allow(clippy::needless_pass_by_value)]
251251
#[allow(clippy::needless_return)]
252-
pub(crate) fn decompress(in_buf: Vec<u8>) -> Vec<u8> {
252+
pub(in crate::pagecache) fn decompress(in_buf: Vec<u8>) -> Vec<u8> {
253253
#[cfg(feature = "compression")]
254254
{
255255
use zstd::stream::decode_all;
@@ -295,8 +295,8 @@ impl<'g> Deref for MetaView<'g> {
295295

296296
#[derive(Debug, Clone, Copy)]
297297
pub struct PageView<'g> {
298-
pub(crate) read: Shared<'g, Page>,
299-
pub(crate) entry: &'g Atomic<Page>,
298+
pub(in crate::pagecache) read: Shared<'g, Page>,
299+
pub(in crate::pagecache) entry: &'g Atomic<Page>,
300300
}
301301

302302
impl<'g> Deref for PageView<'g> {
@@ -327,7 +327,7 @@ impl quickcheck::Arbitrary for CacheInfo {
327327
/// of which a page consists.
328328
#[derive(Clone, Debug)]
329329
#[cfg_attr(feature = "testing", derive(PartialEq))]
330-
pub(crate) enum Update {
330+
pub(in crate::pagecache) enum Update {
331331
Link(Link),
332332
Node(Node),
333333
Free,
@@ -410,7 +410,7 @@ pub struct Page {
410410
}
411411

412412
impl Page {
413-
pub(crate) fn rss(&self) -> Option<u64> {
413+
pub(in crate::pagecache) fn rss(&self) -> Option<u64> {
414414
match &self.update {
415415
Some(Update::Node(ref node)) => Some(node.rss()),
416416
_ => None,
@@ -1670,7 +1670,7 @@ impl PageCacheInner {
16701670
}
16711671

16721672
/// Retrieve the current persisted IDGEN value
1673-
pub(crate) fn get_idgen<'g>(
1673+
pub(in crate::pagecache) fn get_idgen<'g>(
16741674
&self,
16751675
guard: &'g Guard,
16761676
) -> (PageView<'g>, u64) {

src/pagecache/snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ fn advance_snapshot(
477477
pub fn read_snapshot_or_default(config: &RunningConfig) -> Result<Snapshot> {
478478
// NB we want to error out if the read snapshot was corrupted.
479479
// We only use a default Snapshot when there is no snapshot found.
480-
let last_snap = read_snapshot(config)?.unwrap_or_else(Snapshot::default);
480+
let last_snap = read_snapshot(config)?.unwrap_or_default();
481481

482482
let log_iter =
483483
raw_segment_iter_from(last_snap.stable_lsn.unwrap_or(0), config)?;

src/serialization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ fn shift_i64_opt(value_opt: &Option<i64>) -> i64 {
433433

434434
const fn unshift_i64_opt(value: i64) -> Option<i64> {
435435
if value == 0 {
436-
return None
436+
return None;
437437
}
438438
let subtract = value > 0;
439439
Some(value - subtract as i64)
@@ -686,7 +686,7 @@ where
686686
if self.bound == 0 || self.buf.is_empty() {
687687
return None;
688688
}
689-
let item_res = T::deserialize(&mut self.buf);
689+
let item_res = T::deserialize(self.buf);
690690
self.bound -= 1;
691691
if item_res.is_err() {
692692
self.bound = 0;

src/transaction.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,7 @@ impl<E> Transactional<E> for [Tree] {
550550
}
551551

552552
Ok(TransactionalTrees {
553-
inner: self
554-
.iter()
555-
.map(|t| TransactionalTree::from_tree(t))
556-
.collect(),
553+
inner: self.iter().map(TransactionalTree::from_tree).collect(),
557554
})
558555
}
559556

0 commit comments

Comments
 (0)